:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --hair: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #256abf;
  --accent-ink: #ffffff;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --good: #0ca30c; --good-ink: #006300;
  --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --info: #2a78d6;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 5%), 0 1px 1px rgb(0 0 0 / 3%);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
/* Dark: follows the device unless the viewer picks Light or Dark (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #9a988f;
    --hair: #2c2c2a; --axis: #383835;
    --accent: #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --good-ink: #0ca30c;
  }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #9a988f;
    --hair: #2c2c2a; --axis: #383835;
    --accent: #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --good-ink: #0ca30c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--plane); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--hair);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  background-image: linear-gradient(135deg, transparent 45%, rgb(255 255 255 / 35%) 45% 55%, transparent 55%); }
.brand-sub { color: var(--ink-2); font-weight: 400; }
.user { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--ink-2); font-size: 14px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.live.paused .live-dot { background: var(--axis); }
@media (max-width: 720px) {
  .topbar { gap: 8px 12px; padding: 10px 14px; }
  .live, .theme-label { display: none; }
  .user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---- layout ---- */
.app { max-width: 1240px; margin: 0 auto; padding: 24px; }
@media (max-width: 720px) { .app { padding: 14px; } }
.center-msg { padding: 80px 0; text-align: center; color: var(--ink-2); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.01em; }
.page-head p { margin: 0; color: var(--ink-2); max-width: 70ch; }
h2 { font-size: 15px; margin: 28px 0 10px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px 18px; }

/* ---- agent cards ---- */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.agent-card { display: block; color: var(--ink); padding: 18px; transition: border-color .15s; }
.agent-card:hover { text-decoration: none; border-color: var(--axis); }
.agent-card h3 { margin: 0; font-size: 16px; }
.agent-card .desc { margin: 4px 0 14px; color: var(--ink-2); font-size: 14px; }
.agent-card .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 12px 0 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.add-card { display: flex; flex-direction: column; justify-content: center; padding: 18px; border-style: dashed; box-shadow: none; color: var(--ink-2); font-size: 14px; }
.add-card strong { color: var(--ink); }

/* ---- status badge: icon + label, never color alone ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.badge svg { width: 13px; height: 13px; flex: none; }
.st-healthy svg, .st-ok svg { color: var(--good); }
.st-running svg, .st-idle svg { color: var(--info); }
.st-warning svg, .st-stale svg { color: var(--serious); }
.st-failing svg, .st-error svg, .st-blocked svg { color: var(--critical); }
.st-unknown svg { color: var(--muted); }
.st-running svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- activity feed ---- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 118px 1fr auto; gap: 12px; align-items: baseline; padding: 10px 16px; border-top: 1px solid var(--hair); font-size: 14px; }
.feed li:first-child { border-top: 0; }
.feed .when { color: var(--muted); font-size: 13px; }
.feed .what { color: var(--ink); overflow-wrap: anywhere; }
.feed .what .agent { color: var(--ink-2); font-weight: 600; margin-right: 6px; }
.feed .dur { color: var(--muted); font-size: 12.5px; }
@media (max-width: 720px) { .feed li { grid-template-columns: 1fr auto; } .feed .when { grid-column: 1 / -1; } }

/* ---- tabs ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--hair); margin: 6px 0 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- KPI tiles ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--ink-2); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---- charts ---- */
.chart-card { padding: 16px 18px 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.chart-head h3 { margin: 0; font-size: 14.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { position: relative; margin-top: 10px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--hair); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + g .seg, .chart .col:hover .seg { opacity: .85; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--hair); box-shadow: 0 4px 16px rgb(0 0 0 / 12%);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--ink); white-space: nowrap; z-index: 5; }
.tip b { display: block; margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 16px; }
.tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 12px; border-top: 1px solid var(--hair); vertical-align: top; }
thead th { border-top: 0; color: var(--ink-2); font-weight: 600; font-size: 12.5px; white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th .arrow { color: var(--accent); margin-left: 4px; }
td.num, th.num { text-align: right; }
tbody tr.item { cursor: pointer; }
tbody tr.item:hover td { background: var(--surface-2); }
tr.detail td { background: var(--surface-2); padding: 14px 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 20px; font-size: 13.5px; }
.detail-grid div span { display: block; color: var(--muted); font-size: 12px; }
.detail-actions { margin-top: 12px; display: flex; gap: 10px; }
.nowrap { white-space: nowrap; }

/* ---- search ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.search-box { flex: 1 1 320px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--axis); border-radius: 9px; padding: 0 12px; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search-box input { flex: 1; border: 0; outline: 0; background: transparent; padding: 10px 0; min-width: 0; }
.search-box svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
select, input[type=date] { background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; padding: 7px 10px; }
.filters { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-bottom: 12px; font-size: 13.5px; }
.filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter > label, .filter > .flabel { color: var(--ink-2); font-weight: 600; font-size: 12.5px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--axis); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .sw { width: 8px; height: 8px; border-radius: 2px; }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--hair); font-size: 13.5px; color: var(--ink-2); }
.pager { display: flex; align-items: center; gap: 8px; }
.btn { border: 1px solid var(--axis); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13.5px; }
.btn:hover:not(:disabled) { border-color: var(--ink-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); }
.progress { height: 3px; background: var(--hair); border-radius: 2px; overflow: hidden; margin: 6px 0 12px; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
mark { background: color-mix(in srgb, var(--warning) 45%, transparent); color: inherit; border-radius: 2px; }
.pill { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--hair); }
.pill.fast { border-color: var(--accent); color: var(--accent); }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-2); }
.signin { max-width: 420px; margin: 80px auto; text-align: center; padding: 32px; }
.signin h1 { font-size: 20px; margin: 0 0 8px; }
.signin p { color: var(--ink-2); margin: 0 0 20px; }
.error-box { border-left: 3px solid var(--critical); padding: 10px 14px; background: var(--surface); margin-bottom: 16px; font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.theme-btn { display: inline-flex; align-items: center; gap: 6px; }
.theme-btn svg { width: 16px; height: 16px; }

/* ---- profile dialog ---- */
dialog.profile { border: 1px solid var(--hair); border-radius: 12px; padding: 22px; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 12px 40px rgb(0 0 0 / 25%); }
dialog.profile::backdrop { background: rgb(0 0 0 / 35%); }
dialog.profile h2 { margin: 0 0 4px; font-size: 17px; }
dialog.profile p { margin: 0 0 14px; color: var(--ink-2); font-size: 14px; }
dialog.profile label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
dialog.profile input { width: 100%; border: 1px solid var(--axis); border-radius: 8px; padding: 9px 11px; background: var(--surface); }
dialog.profile input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
dialog.profile .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog.profile .msg { min-height: 18px; font-size: 13px; margin-top: 8px; color: var(--ink-2); }
dialog.profile .msg.err { color: var(--critical); }

/* ---- shell + sidebar ---- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 53px); }
.shell.no-side { display: block; }
.sidebar { position: sticky; top: 53px; height: calc(100vh - 53px); overflow-y: auto; display: flex; flex-direction: column;
  border-right: 1px solid var(--hair); background: var(--surface); padding: 14px 10px; }
.sidebar nav { flex: 1; }
.side-section { margin: 18px 10px 6px; font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.side-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); font-size: 14px; }
.side-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.side-link.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.side-link svg { width: 16px; height: 16px; flex: none; }
.side-link .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-sub { display: block; padding: 5px 10px 5px 36px; border-radius: 8px; color: var(--ink-2); font-size: 13.5px; }
.side-sub:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.side-sub.active { color: var(--accent); font-weight: 600; }
.side-dot svg { width: 14px; height: 14px; }
.side-foot { border-top: 1px solid var(--hair); padding-top: 10px; display: grid; gap: 2px; }
.side-btn { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); font-size: 14px; cursor: pointer; text-align: left; }
.side-btn:hover { background: var(--surface-2); color: var(--ink); }
.side-btn svg { width: 16px; height: 16px; }
.menu-btn { padding: 6px 8px; }
.menu-btn svg { width: 18px; height: 18px; display: block; }
.scrim { display: none; }
@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 20; top: 53px; left: 0; width: 260px; transform: translateX(-102%); transition: transform .18s ease; box-shadow: 0 8px 30px rgb(0 0 0 / 18%); }
  .sidebar.open { transform: none; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 53px 0 0 0; background: rgb(0 0 0 / 30%); z-index: 15; }
}
@media (min-width: 901px) { .menu-btn { display: none; } }

/* ---- landing (signed out) ---- */
.landing { max-width: 1080px; margin: 0 auto; padding: 56px 24px 40px; }
.hero { position: relative; padding: 56px 48px; border-radius: 18px; overflow: hidden; border: 1px solid var(--hair);
  background: radial-gradient(1200px 400px at 85% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
              radial-gradient(700px 300px at -10% 120%, color-mix(in srgb, var(--s3) 14%, transparent), transparent 60%), var(--surface); }
.hero .eyebrow { margin: 0 0 14px; font-size: 13px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.hero h1 { margin: 0; font-size: clamp(28px, 4.4vw, 46px); line-height: 1.08; letter-spacing: -0.025em; max-width: 18ch; }
.hero .lede { margin: 18px 0 0; font-size: 17px; color: var(--ink-2); max-width: 60ch; }
.hero .cta { margin-top: 28px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.btn-lg { padding: 11px 22px; font-size: 15px; font-weight: 600; border-radius: 10px; }
.hero-art { position: absolute; right: 36px; top: 50%; transform: translateY(-50%); width: 300px; opacity: .9; }
@media (max-width: 980px) { .hero-art { display: none; } }
@media (max-width: 720px) { .landing { padding: 20px 14px; } .hero { padding: 32px 22px; } }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 18px; }
.feature { padding: 20px; }
.feature .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); margin-bottom: 12px; }
.feature .ic svg { width: 18px; height: 18px; }
.feature h3 { margin: 0 0 6px; font-size: 15.5px; }
.feature p { margin: 0; color: var(--ink-2); font-size: 14px; }
.landing-foot { margin-top: 28px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---- browse views ---- */
.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 8px 14px; font-size: 13.5px; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--axis); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); font-weight: 600; }
.range { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.range .btn { padding: 6px 10px; }
.top-signin { margin-left: auto; }
