/* KAFU Hub: an operating hub. Light, dense, quiet; colour only where it means something (status). System fonts only (no external requests). */
:root {
  --bg: #f6f9fc; --surface: #ffffff; --ink: #0a2540; --muted: #425466; --faint: #697386; --line: #e3e8ee; --line-strong: #cfd7df;
  --brand: #635bff; --brand-ink: #4b45c6; --brand-soft: #efeeff;
  --live: #0a7c50; --live-bg: #dff7ea; --partial: #8a5a00; --partial-bg: #fff1cf; --none: #4f5b6b; --none-bg: #eceff3; --infra: #1d5fb8; --infra-bg: #e1edff;
  --danger: #b3261e; --danger-bg: #fde4e2; --warn: #8a5a00; --warn-bg: #fff1cf; --ok: #0a7c50; --ok-bg: #dff7ea; --info: #1d5fb8; --info-bg: #e1edff;
  --radius: 8px; --sidebar: 248px; --topbar: 56px; --shadow: 0 1px 2px rgba(10, 37, 64, .06), 0 1px 1px rgba(10, 37, 64, .04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-ink); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 28px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; line-height: 20px; margin: 0; font-weight: 650; }
h3 { font-size: 13px; margin: 0; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.noscript { padding: 24px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; grid-template-rows: var(--topbar) 1fr; min-height: 100vh; }
.topbar { grid-column: 2; grid-row: 1; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.sidebar { grid-row: 1 / span 2; grid-column: 1; position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px 24px; }
.main { grid-column: 2; grid-row: 2; padding: 24px; min-width: 0; }
.page { width: 100%; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 14px; font-weight: 700; letter-spacing: -.01em; font-size: 16px; }
.brand .mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #635bff, #00d4ff); display: inline-block; }
.nav-group { margin-top: 14px; } .nav-group h3 { padding: 0 10px 6px; font-size: 11px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav-item:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--none); }
.dot.live { background: #1fb76b; } .dot.partial { background: #e0a100; } .dot.not_connected { background: #b6bfca; } .dot.requires_infrastructure { background: #3b82f6; }
.menu-button { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; height: 34px; padding: 0 12px 0 34px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); font: inherit; color: var(--ink); }
.search input:focus { background: #fff; outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.search .icon { position: absolute; left: 11px; top: 8px; width: 16px; height: 16px; color: var(--faint); }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(10, 37, 64, .14); max-height: 380px; overflow-y: auto; padding: 6px; z-index: 30; }
.search-results a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); } .search-results a:hover { background: var(--bg); text-decoration: none; }
.search-results .sub { color: var(--faint); font-size: 12px; }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.env { background: var(--none-bg); color: var(--none); } .pill.env.production { background: var(--danger-bg); color: var(--danger); }
.select, .button, .input { height: 32px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; padding: 0 10px; font: inherit; color: var(--ink); }
.button { white-space: nowrap; cursor: pointer; font-weight: 600; box-shadow: var(--shadow); } .button:hover { border-color: var(--faint); }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .button.primary:hover { background: var(--brand-ink); }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.user { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; }

/* banners and states */
.banner { display: flex; gap: 10px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid; font-size: 13px; }
.banner.demo { background: var(--warn-bg); border-color: #f0cf83; color: #5c3d00; }
.banner.info { background: var(--info-bg); border-color: #b7d3f7; color: #133f7a; }
.banner.legal { background: #f3f0ff; border-color: #d7d2fb; color: #322c8a; }
.banner strong { font-weight: 700; }
.state { padding: 36px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: #fff; color: var(--muted); }
.state h2 { color: var(--ink); margin-bottom: 6px; } .state p { max-width: 640px; margin: 0 auto; }
.state.error { border-color: #f1b7b2; background: #fff8f7; } .state.denied { border-color: #f0cf83; background: #fffbef; }
.skeleton { height: 14px; border-radius: 4px; background: linear-gradient(90deg, #eef1f5 25%, #f7f9fb 37%, #eef1f5 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* header, cards, tables */
.page-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.page-head .lead { color: var(--muted); max-width: 760px; margin-top: 4px; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--none-bg); color: var(--none); }
.badge.connected, .badge.idle, .badge.live, .badge.ok, .badge.active, .badge.confirmed, .badge.awarded, .badge.delivered, .badge.completed, .badge.qualified, .badge.open, .badge.ready { background: var(--live-bg); color: var(--live); }
.badge.unknown, .badge.suspended, .badge.offline, .badge.syncing, .badge.locked, .badge.provisioning, .badge.stale, .badge.standalone, .badge.staged, .badge.partial, .badge.warn, .badge.medium, .badge.pending, .badge.held, .badge.placed, .badge.in_transit, .badge.submitted, .badge.pending_decision, .badge.collecting { background: var(--partial-bg); color: var(--partial); }
.badge.wiped, .badge.decommissioned, .badge.rollback_suspected, .badge.trust_regain_refused, .badge.critical, .badge.high, .badge.failed, .badge.cancelled, .badge.revoked, .badge.denied, .badge.expired { background: var(--danger-bg); color: var(--danger); }
.badge.requires_infrastructure, .badge.info, .badge.shipped, .badge.low { background: var(--infra-bg); color: var(--infra); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 32px; }
.card .label { color: var(--muted); font-weight: 500; }
.card .foot { color: var(--faint); font-size: 12px; }
a.card { color: inherit; } a.card:hover { border-color: var(--line-strong); text-decoration: none; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel > .body { padding: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .input { min-width: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tab { padding: 10px 12px; border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--brand-ink); border-bottom-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(--faint); padding: 8px 16px; border-bottom: 1px solid var(--line); background: #fbfcfe; white-space: nowrap; }
th button { all: unset; cursor: pointer; } th button:hover { color: var(--ink); }
td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; } tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: #fafbfd; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; }
.kv > div { padding: 9px 16px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; } .kv > .k { color: var(--muted); font-weight: 500; background: #fbfcfe; }
.chain { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chain .step { display: flex; flex-direction: column; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 130px; }
.chain .step.missing { border-style: dashed; color: var(--faint); background: transparent; }
.chain .arrow { color: var(--faint); }
.muted { color: var(--muted); } .faint { color: var(--faint); font-size: 12px; }
.list { list-style: none; margin: 0; padding: 0; } .list li { display: flex; gap: 10px; align-items: baseline; padding: 9px 16px; border-bottom: 1px solid var(--line); } .list li:last-child { border-bottom: 0; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.login form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.login .input { height: 38px; }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { grid-column: 1; padding: 0 14px; } .main { grid-column: 1; padding: 16px 14px; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(84vw, 300px); transform: translateX(-102%); transition: transform .18s ease; box-shadow: 0 0 40px rgba(10, 37, 64, .25); }
  .sidebar.open { transform: none; }
  .menu-button { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; }
  .user .name, .pill.env { display: none; }
  .topbar { gap: 8px; } .topbar .select { max-width: 116px; } .search { min-width: 0; } .search input { min-width: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; } .kv > .k { border-bottom: 0; padding-bottom: 0; background: none; }
  th, td { padding: 9px 12px; }
}

/* Edge fleet: a table with an obvious sideways scroll on wide screens, cards on phones. Both are built from ONE field list (pages.js), so every field is in both. */
.fleet-scroll { overflow-x: scroll; scrollbar-gutter: stable; scrollbar-width: auto; scrollbar-color: var(--line-strong) #eef2f7; }
.fleet-scroll::-webkit-scrollbar { height: 12px; } .fleet-scroll::-webkit-scrollbar-track { background: #eef2f7; } .fleet-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }
.fleet-scroll:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.fleet-table { min-width: 1280px; }
.fleet-table th:first-child, .fleet-table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.fleet-table th:first-child { background: #fbfcfe; }
.fleet-table td { white-space: nowrap; } .fleet-table td.wrap { white-space: normal; min-width: 280px; max-width: 340px; } .fleet-table td .badge { margin-right: 4px; }
.fleet-cards { display: none; }
.fleet-card { gap: 10px; } .fleet-card-head { display: flex; align-items: baseline; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); } .fleet-card-head .mono { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.fleet-card dl { margin: 0; display: grid; gap: 8px; } .fleet-row { display: grid; grid-template-columns: 8.5rem 1fr; gap: 8px; align-items: start; } .fleet-row dt { color: var(--muted); font-weight: 500; } .fleet-row dd { margin: 0; overflow-wrap: anywhere; }
.fleet-row .badge { height: auto; min-height: 22px; padding: 2px 8px; white-space: normal; margin: 0 4px 4px 0; }
.provenance-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.fleet-hint { margin: 4px 0 8px; }
@media (max-width: 720px) { .fleet-scroll { display: none; } .fleet-cards { display: grid; gap: 12px; } .fleet-row { grid-template-columns: 7rem 1fr; } }

/* utility classes (the Content-Security-Policy forbids inline styles) */
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mt4 { margin-top: 4px; } .mt6 { margin-top: 6px; } .mt12 { margin-top: 12px; } .pad { padding: 10px 16px; } .pad10 { padding: 10px; }
.row { display: flex; gap: 10px; align-items: center; } .row.wrap { flex-wrap: wrap; } .row.tight { gap: 8px; } .flush { padding: 0; }
.legend { padding: 0 10px; display: grid; gap: 4px; } .banner.wide { max-width: 1240px; margin: 0 auto 16px; }
.skeleton { margin: 12px 0; } .skeleton.w50 { width: 50%; } .skeleton.w65 { width: 65%; } .skeleton.w80 { width: 80%; } .skeleton.w90 { width: 90%; }
a.tab, a.step, a.tab:hover, a.step:hover { text-decoration: none; } a.step { color: inherit; }
.panel.toolbar { padding: 12px 16px; border-bottom: 1px solid var(--line); }
