/* TraceIT portal. One light theme, system sans, hairline chrome; the data is the only loud thing. */
:root {
  color-scheme: light;
  --page: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef1f5;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #8a94a6;
  --line: #e3e7ee;
  --line-2: #cfd6e1;
  --brand: #1d4ed8;
  --brand-2: #1e40af;
  --brand-wash: #eaf0fe;
  --nav: #0f1b33;
  --nav-ink: #c9d3e6;
  --nav-active: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-1-wash: rgba(42, 120, 214, 0.10);
  --series-2-wash: rgba(235, 104, 52, 0.10);
  --grid: #e8ebf0;
  --axis: #c3c9d4;
  --good: #0ca30c;
  --good-ink: #067a06;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --low: #64748b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.16);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 6px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { height: 12px; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center; font-weight: 750; font-size: 15px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.brand-org { font-size: 11px; color: #8ea0c2; }
.nav-group { padding: 10px 10px 4px; }
.nav-group-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6f7f9f; padding: 6px 10px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--nav-ink);
  font-size: 13.5px; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(59,130,246,.22); color: var(--nav-active); }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav .badge { margin-left: auto; background: var(--critical); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px;
  line-height: 18px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 11.5px; color: #6f7f9f; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  background: rgba(245,246,248,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; max-width: 520px; }
.search input[type=search] { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.search svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--ink-3); }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 70vh; overflow: auto; padding: 6px; }
.search-results .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 8px 10px 4px; }
.search-results a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--ink); }
.search-results a:hover { background: var(--surface-3); text-decoration: none; }
.user-menu { position: relative; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center;
  font-weight: 600; cursor: pointer; border: 0; }
.menu { position: absolute; right: 0; top: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; z-index: 30; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; background: none;
  border: 0; color: var(--ink); cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-3); text-decoration: none; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.content { padding: 22px 24px 48px; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-2); margin-top: 3px; font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 12.5px; color: var(--ink-3); margin-bottom: 4px; }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--surface); cursor: pointer; font-weight: 550; font-size: 13px; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: var(--axis); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--critical); border-color: #f1c4c4; }
.btn.danger:hover { background: #fdf2f2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url],
select, textarea { padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); min-width: 0; }
textarea { width: 100%; min-height: 84px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid rgba(29,78,216,.35); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 550; }
label.field .help { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.check input { margin-top: 3px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow-x: auto; overflow-y: hidden;
  background: var(--surface); max-width: 100%; scrollbar-width: none; }
.seg button { border: 0; background: none; padding: 6px 11px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; flex: none; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand-wash); color: var(--brand-2); font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { width: 240px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 20px; background: var(--surface-3);
  font-size: 12px; color: var(--ink-2); }
.chip button { border: 0; background: none; cursor: pointer; padding: 0; color: var(--ink-3); }

/* ---------- cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.card-head .hint { color: var(--ink-3); font-size: 12px; }
.card-head .tools { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 8px 16px 16px; }
.card.pad { padding: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 236px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .label { font-size: 12.5px; color: var(--ink-2); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.tile .foot { font-size: 12px; color: var(--ink-3); }
a.tile { color: inherit; }
a.tile:hover { border-color: var(--axis); text-decoration: none; }
.hero .value { font-size: 44px; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; user-select: none; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--ink); }
table.data td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; max-width: 420px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.wrap { white-space: normal; word-break: break-word; }
table.data tr.clickable { cursor: pointer; }
table.data tbody tr:hover { background: #f7f9fc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
.table-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: var(--ink-3); font-size: 12.5px; border-top: 1px solid var(--line); }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 4px; }

/* ---------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--ink-2); white-space: nowrap; line-height: 19px; }
.sev { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.sev i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.sev.critical i { background: var(--critical); } .sev.high i { background: var(--serious); }
.sev.medium i { background: var(--warning); } .sev.low i { background: var(--low); }
.sev .glyph { font-size: 11px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--axis); flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(12,163,12,.14); }
.dot.off { background: var(--critical); }
.dot.warn { background: var(--warning); }
.pill-ok { background: #e7f6e7; color: var(--good-ink); }
.pill-warn { background: #fff4dc; color: #8a5a00; }
.pill-bad { background: #fdecec; color: #a12424; }
.pill-info { background: var(--brand-wash); color: var(--brand-2); }
.cat { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.cat i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }
.os { display: inline-flex; align-items: center; gap: 6px; }
.os svg { width: 15px; height: 15px; color: var(--ink-2); }

/* ---------- charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis text, .chart text.tick { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin: 2px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; border-radius: 8px; padding: 8px 10px; font-size: 12px;
  box-shadow: var(--shadow-lg); z-index: 5; min-width: 140px; white-space: nowrap; }
.tooltip .t { color: #aab4c7; margin-bottom: 4px; }
.tooltip .r { display: flex; align-items: center; gap: 8px; }
.tooltip .r i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tooltip .r b { margin-left: auto; font-variant-numeric: tabular-nums; padding-left: 12px; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.bar-row .track { height: 10px; position: relative; }
.bar-row .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .val { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; min-width: 64px; text-align: right; }
.bar-row a.name { color: var(--ink); }
.severity-strip { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface); margin: 8px 0 10px; }
.severity-strip span { display: block; height: 100%; }
.sev-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; }
.sev-legend a { color: var(--ink); display: inline-flex; gap: 6px; align-items: center; }

/* ---------- lists, detail */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin; }
.tabs a { padding: 9px 13px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 550; font-size: 13px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--brand-2); border-bottom-color: var(--brand); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 80px 26px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: start; }
.timeline .when { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.timeline .ico { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.timeline .ico svg { width: 14px; height: 14px; }
.timeline .what { min-width: 0; }
.timeline .what .t { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline .what .d { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline .day { grid-template-columns: 1fr; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--ink-2); padding: 6px 8px; }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.notes .by { color: var(--ink-3); font-size: 12px; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; overflow: auto; font-size: 12px; margin: 0; white-space: pre-wrap; word-break: break-all; }
.callout { border: 1px solid #c7d7fd; background: #f3f6ff; border-radius: 10px; padding: 12px 14px; font-size: 13px; color: #1e3a8a; }
.callout.warn { border-color: #f7d48a; background: #fffaeb; color: #6b4a00; }
.callout.bad { border-color: #f3c0c0; background: #fff5f5; color: #8a1f1f; }
.callout.ok { border-color: #bfe5bf; background: #f3fbf3; color: #135c13; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin: 6px 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
@media (max-width: 860px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }
.section-title { font-size: 14px; font-weight: 650; margin: 4px 0 2px; }

/* ---------- modal, toast */
.backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal.wide { width: min(900px, 100%); }
.modal-head { padding: 16px 18px 8px; display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 8px 18px 16px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); box-shadow: var(--shadow-lg);
  z-index: 45; overflow-y: auto; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: 420px; }
.toast.bad { background: #8a1f1f; }
.toast.ok { background: #135c13; }

/* ---------- sign-in */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-art { background: radial-gradient(1200px 600px at 10% 10%, #1e3a8a 0%, #0f1b33 55%, #0a1224 100%); color: #dbe5ff; padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h2 { font-size: 30px; line-height: 1.2; color: #fff; margin: 0 0 14px; font-weight: 700; letter-spacing: -0.02em; }
.auth-art p { color: #a9b8da; max-width: 460px; }
.auth-art ul { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.auth-art li { display: flex; gap: 10px; align-items: center; color: #cdd8f3; }
.auth-art li svg { width: 18px; height: 18px; color: #7aa2ff; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-box { width: min(380px, 100%); }
.auth-box h1 { font-size: 24px; margin-bottom: 4px; }
.auth-box .stack { gap: 14px; }
.auth-box .btn { justify-content: center; padding: 10px 14px; font-size: 14px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.qr { background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 10px; display: inline-block; }
.qr svg { width: 196px; height: 196px; display: block; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-family: var(--mono); font-size: 14px; background: var(--surface-2);
  padding: 12px; border-radius: 8px; border: 1px solid var(--line); }
.error { color: var(--critical); font-size: 13px; }
@media (max-width: 900px) { .auth-page { grid-template-columns: 1fr; } .auth-art { display: none; } }

.loading { opacity: .55; transition: opacity .15s; pointer-events: none; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media print { .sidebar, .topbar, .page-head .actions, .filters { display: none !important; } .shell { display: block; } .card { break-inside: avoid; } }
