/* Console design system: quiet, professional, legible. Light by default; follows the OS dark mode. */
:root {
  --bg: #f7f8fa; --surface: #ffffff; --surface-2: #f2f4f7; --line: #e4e7ec; --line-strong: #d0d5dd;
  --ink: #101828; --ink-2: #344054; --muted: #667085; --faint: #98a2b3;
  --brand: #1d3a6e; --brand-ink: #ffffff; --brand-soft: #eef2f8;
  --accent: #2459c4; --accent-soft: #eaf0fb;
  --ok: #067647; --ok-soft: #ecfdf3; --warn: #b54708; --warn-soft: #fffaeb;
  --bad: #b42318; --bad-soft: #fef3f2; --ai: #5925dc; --ai-soft: #f4f3ff;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 4px 16px rgba(16, 24, 40, .08);
  --sidebar: 248px;
  font-synthesis: none;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111d; --surface: #131a2a; --surface-2: #1a2235; --line: #263045; --line-strong: #344056;
    --ink: #f2f4f7; --ink-2: #d0d5dd; --muted: #98a2b3; --faint: #667085;
    --brand: #2b4f91; --brand-soft: #1a2640; --accent: #6b9bf2; --accent-soft: #19253d;
    --ok: #47cd89; --ok-soft: #0f2a1e; --warn: #fdb022; --warn-soft: #2e2210;
    --bad: #f97066; --bad-soft: #2f1414; --ai: #a48afb; --ai-soft: #221b3d;
    --shadow: none; --shadow-lg: 0 4px 16px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); }
p { margin: 0; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---- layout ---------------------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 16px 12px; gap: 4px; }
.org { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.org .mark { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .02em; }
.org .name { font-weight: 600; font-size: 13px; line-height: 1.25; }
.org select { margin-top: 2px; font-size: 12px; padding: 2px 4px; border: 0; background: transparent; color: var(--muted); max-width: 170px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
@media (prefers-color-scheme: dark) { .nav a.on { color: var(--ink); } }
.nav .badge { margin-left: auto; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint);
  padding: 14px 10px 4px; }
.me { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); flex: none; }
.me .who { line-height: 1.25; min-width: 0; }
.me .who strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who span { font-size: 12px; color: var(--muted); }
.me form { margin-left: auto; }
main { padding: 28px 32px 48px; max-width: 1080px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--muted); margin-top: 4px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .org { border: 0; padding: 0 8px 0 0; margin: 0; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav-label, .org select { display: none; }
  .me { margin: 0 0 0 auto; border: 0; padding: 0; }
  .me .who { display: none; }
  main { padding: 20px 16px 40px; }
}

/* ---- surfaces -------------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); }
.card-head p { color: var(--muted); font-size: 13px; }
.card-body { padding: 18px; }
.section { margin-top: 28px; }
.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.section-title p { color: var(--muted); font-size: 13px; margin-left: 4px; }

/* queue / list items */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.item { padding: 16px 18px; display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; align-items: start; }
.item + .item { border-top: 1px solid var(--line); }
.item h2 a { color: var(--ink); }
.item .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item .summary { color: var(--ink-2); margin-top: 6px; }
.item .route { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.item .route .addr { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; }
.item .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.item .foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
@media (max-width: 700px) { .item { grid-template-columns: 1fr; } .item .actions { justify-content: flex-start; } }

/* ---- badges and pills ------------------------------------------------------------------------ */
.pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; line-height: 20px;
  padding: 0 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.pill.ai { background: var(--ai-soft); color: var(--ai); border-color: transparent; }
.pill.out { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 12px; font-weight: 600;
  display: inline-grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.badge.hot { background: var(--bad); color: #fff; }
.badge.brand { background: var(--brand); color: #fff; }

/* ---- buttons and inputs ---------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 14px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
form.inline { display: inline; }
.split { display: inline-flex; }
.split .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split details > summary.btn { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-color: rgba(255,255,255,.25);
  padding: 0 8px; list-style: none; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.pop { position: relative; }
.pop > div { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px; min-width: 240px; }
.pop > div label { font-weight: 500; }
.pop > div .row { display: flex; gap: 6px; margin-top: 10px; }
label.field { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 14px; }
label.field span.hint { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 7px 10px; max-width: 100%; }
label.field input, label.field textarea, label.field select { display: block; width: 100%; margin-top: 6px; font-weight: 400; }
textarea { line-height: 1.55; resize: vertical; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-weight: 400; }
.check:first-of-type { border-top: 0; }
.check input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--brand); }
.check .t { color: var(--ink); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { min-width: 240px; }
.reasons { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- tabs, tables, definition lists ---------------------------------------------------------- */
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 10px 2px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; display: inline-flex; gap: 8px; align-items: center; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-color: var(--brand); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td a { color: var(--ink); font-weight: 500; }
.muted { color: var(--muted); }
dl.facts { display: grid; grid-template-columns: 150px 1fr; gap: 10px 20px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 13px; }
dl.facts dd { margin: 0; }
@media (max-width: 600px) { dl.facts { grid-template-columns: 1fr; gap: 2px 0; } dl.facts dd { margin-bottom: 8px; } }

/* ---- content blocks -------------------------------------------------------------------------- */
.doc { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); padding: 14px 16px; }
.doc .k { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 12px; }
.doc .k:first-child { margin-top: 0; }
.doc .v { white-space: pre-wrap; margin-top: 2px; }
pre.diff { white-space: pre-wrap; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 6px 0 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.timeline li:first-child { border-top: 0; }
.timeline .when { color: var(--muted); }
@media (max-width: 600px) { .timeline li { grid-template-columns: 1fr; gap: 0; } }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty svg.i { width: 28px; height: 28px; stroke-width: 1.5; color: var(--faint); margin-bottom: 8px; }
.empty strong { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 2px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.err { background: var(--bad-soft); color: var(--bad); }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.err-line { color: var(--bad); font-size: 13px; margin-top: 6px; }

/* ---- sign-in --------------------------------------------------------------------------------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-soft), var(--bg)); }
.auth-card { width: 100%; max-width: 380px; padding: 32px 28px; }
.auth-card .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center;
  font-weight: 700; margin-bottom: 18px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card p.lead { color: var(--muted); margin-bottom: 22px; }
.auth-card .btn { width: 100%; height: 40px; margin-top: 6px; }
