@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;450;500;600;700&display=swap');

/* Tokens ---------------------------------------------------------------- */
:root {
  --ink:        #102a4c;   /* navy blue, the brand base */
  --ink-deep:   #081a30;
  --ink-soft:   #1f4d80;
  --paper:      #eef2f8;
  --surface:    #ffffff;
  --line:       #d7e1ec;
  --line-soft:  #e8eef6;
  --muted:      #5c7290;
  --jade:       #2563eb;   /* primary action, delivered */
  --jade-deep:  #1d4ed8;
  --jade-wash:  #e3ecfd;
  --ochre:      #b8760f;   /* queued, scheduled, pending */
  --ochre-wash: #fbf0dc;
  --clay:       #a3342a;   /* failed, destructive */
  --clay-wash:  #f8e6e3;

  --sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --r-control: 8px;
  --r-panel: 14px;
  --r-card: 16px;
  --shell: 1160px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 8px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 12px 20px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.09), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

/* Reset ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.018em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.05rem); }
h3 { font-size: 1.12rem; letter-spacing: -0.01em; }

p { text-wrap: pretty; }
a { color: var(--jade-deep); text-decoration-thickness: 1px; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--jade);
  outline-offset: 2px;
  border-radius: 2px;
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  background: var(--jade);
  color: #fff;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 100ms ease, box-shadow 120ms ease;
}
.btn:hover:not(:disabled) { background: var(--jade-deep); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--jade-wash); }

.btn-line {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-line:hover:not(:disabled) { background: var(--surface); border-color: var(--muted); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.88rem;
}
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--line-soft); }

.btn-danger { background: var(--clay); }
.btn-danger:hover:not(:disabled) { background: #8b2b22; }

.btn-sm { padding: 6px 12px; font-size: 0.86rem; }
.btn-block { width: 100%; }

/* Forms ----------------------------------------------------------------- */
.field { display: block; margin-bottom: 16px; }
.field[hidden] { display: none; }
.field > span {
  display: block;
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field .hint { font-weight: 400; color: var(--muted); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--jade);
  box-shadow: 0 0 0 3px var(--jade-wash);
}
.textarea { resize: vertical; min-height: 120px; font-family: var(--mono); font-size: 0.94rem; line-height: 1.55; }
.input:disabled, .select:disabled { background: var(--line-soft); color: var(--muted); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }

/* Status pills ---------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}
.pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill-ok      { background: var(--jade-wash);  color: var(--jade-deep); }
.pill-wait    { background: var(--ochre-wash); color: var(--ochre); }
.pill-bad     { background: var(--clay-wash);  color: var(--clay); }
.pill-neutral { background: var(--line-soft);  color: var(--muted); }

/* Tables ---------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0 14px 8px;
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Toast ----------------------------------------------------------------- */
#toast {
  position: fixed;
  inset: auto 20px 20px auto;
  z-index: 80;
  display: grid;
  gap: 8px;
  justify-items: end;
}
.toast {
  max-width: 360px;
  padding: 11px 16px;
  border-radius: var(--r-control);
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(10, 32, 41, 0.22);
  animation: toast-in 160ms ease-out;
}
.toast-ok  { background: var(--jade-deep); }
.toast-bad { background: var(--clay); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Empty states ---------------------------------------------------------- */
.empty {
  padding: 42px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--muted);
}
.empty-icon { width: 84px; height: 84px; margin-bottom: 14px; }
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.empty span { font-size: 0.92rem; }

/* Segment meter --------------------------------------------------------- */
.meter {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--r-control) var(--r-control);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meter b { color: var(--ink); font-weight: 500; }
.meter .over { color: var(--clay); }
.composer-body { border-radius: var(--r-control) var(--r-control) 0 0; }
