@import url("https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@700;800;900&family=IBM+Plex+Mono:wght@400;500;600&family=Public+Sans:wght@400;500;600;700&display=swap");

:root {
  --signal: #FF6700; --blueprint: #1F4B8C; --charcoal: #2B2A28; --on-dark: #FFFFFF;
  --paper: #F0F1F3; --paper-2: #E6E8EB; --white: #FFFFFF; --ink: #1C1B1A;
  --steel: #585C63; --line: #D3D6DB;
  --success: #1F7A52; --warning: #A66A00; --danger: #B8352A;
  --success-t: #1F7A52; --warning-t: #8A5800; --danger-t: #B8352A; --link: #1F4B8C;
  --r-sm: 2px; --r-md: 4px;
  --f-head: "Big Shoulders Display", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ink:#EDEBE7; --paper:#171615; --paper-2:#1E1C1A; --white:#211F1D; --line:#3A3733; --steel:#ACA8A1; --success-t:#5CC790; --warning-t:#E3A33A; --danger-t:#EB6F63; --link:#8DB4F0; color-scheme: dark; }
}
:root[data-theme="dark"] { --ink:#EDEBE7; --paper:#171615; --paper-2:#1E1C1A; --white:#211F1D; --line:#3A3733; --steel:#ACA8A1; --success-t:#5CC790; --warning-t:#E3A33A; --danger-t:#EB6F63; --link:#8DB4F0; color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--f-body); min-height: 100vh; overflow-x: hidden; }
h1, h2, h3 { font-family: var(--f-head); text-transform: uppercase; font-weight: 800; line-height: 1.05; margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(32px, 6vw, 56px); } h2 { font-size: clamp(24px, 4vw, 40px); } h3 { font-size: 24px; }
p { margin: 0; }
a { color: var(--link); }
.mono { font-family: var(--f-mono); }
.eyebrow { font: 500 12px/1.4 var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--steel); }
.muted { color: var(--steel); }
.small { font-size: 14px; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--blueprint); outline-offset: 2px; }
:root[data-theme="dark"] :focus-visible { outline-color: #8DB4F0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :focus-visible { outline-color: #8DB4F0; } }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.s16 { width: 16px; height: 16px; } .icon.s24 { width: 24px; height: 24px; }

/* topbar */
.topbar { background: var(--charcoal); color: var(--on-dark); display: flex; align-items: center; gap: 16px; padding: 0 16px; min-height: 56px; position: sticky; top: 0; z-index: 20; }
.topbar .brand { font-family: var(--f-head); font-weight: 900; font-size: 24px; text-transform: uppercase; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.topbar .brand b { color: var(--signal); }
.topbar .brand span { font: 500 12px var(--f-mono); opacity: .8; text-transform: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar .who { font: 400 14px var(--f-mono); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
@media (max-width: 600px) { .topbar .who { display: none; } }
.topbar .btn-icon { color: var(--on-dark); border-color: #5a5753; background: transparent; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; justify-content: space-between; margin-bottom: 24px; }
.page-head .grow { flex: 1 1 280px; min-width: 0; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 24px; }
.panel + .panel { margin-top: 24px; }
.panel > h3 { margin-bottom: 16px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 24px; border: 1px solid transparent; border-radius: var(--r-md); font: 600 14px/1.2 var(--f-body); cursor: pointer; text-decoration: none; background: transparent; color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--signal); color: #1C1B1A; }
.btn-primary:hover:not(:disabled) { background: #E55C00; }
.btn-secondary { background: var(--ink); color: var(--white); }
.btn-secondary:hover:not(:disabled) { opacity: .88; }
.btn-ghost { border-color: var(--line); background: var(--white); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); }
.btn-danger { border-color: var(--danger); color: var(--danger-t); background: transparent; }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-icon { width: 40px; height: 40px; min-height: 40px; padding: 0; border: 1px solid var(--line); background: var(--white); color: var(--ink); border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-block { width: 100%; }
.btn-lg { min-height: 64px; font-size: 17px; padding: 16px 32px; }
.btn-sm { min-height: 36px; padding: 4px 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; min-width: 0; }
.field label, .field .lbl { font: 600 14px var(--f-body); }
.field .hint { font-size: 14px; color: var(--steel); }
input, select, textarea { font: 400 17px var(--f-body); color: var(--ink); background: var(--white); border: 1px solid var(--steel); border-radius: var(--r-md); min-height: 48px; padding: 8px 16px; width: 100%; min-width: 0; }
input::placeholder { color: var(--steel); opacity: .8; }
input[type=radio], input[type=checkbox] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--ink); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--steel); border-radius: var(--r-md); overflow: hidden; background: var(--white); }
.seg label { margin: 0; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 4px 8px; font: 600 14px var(--f-body); text-align: center; }
.seg input:checked + span { background: var(--ink); color: var(--white); }
.seg input:focus-visible + span { outline: 3px solid var(--blueprint); outline-offset: -3px; }
.seg label + label { border-left: 1px solid var(--steel); }
.alert { display: flex; gap: 16px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; background: var(--white); margin-bottom: 16px; }
.alert .ic { width: 32px; height: 32px; border: 2px solid currentColor; border-radius: 50%; display: grid; place-items: center; flex: none; }
.alert.danger { color: var(--danger-t); } .alert.success { color: var(--success-t); } .alert.warning { color: var(--warning-t); }
.alert > div { color: var(--ink); font-size: 15px; min-width: 0; }
.err { color: var(--danger-t); font-size: 14px; font-weight: 600; }

/* tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 16px; min-height: 48px; font: 600 14px var(--f-body); color: var(--steel); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--ink); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 8px; font: 500 12px/1 var(--f-mono); text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-radius: var(--r-sm); border: 1px solid currentColor; background: var(--white); white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--success-t); background: color-mix(in srgb, var(--success) 14%, var(--white)); }
.badge.warn { color: var(--warning-t); background: color-mix(in srgb, var(--warning) 14%, var(--white)); }
.badge.bad { color: var(--danger-t); background: color-mix(in srgb, var(--danger) 14%, var(--white)); }
.badge.off { color: var(--steel); background: var(--paper-2); }

/* tables */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font: 500 12px var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--steel); background: var(--paper-2); white-space: nowrap; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--paper-2) 50%, var(--white)); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--f-mono); }
tr.click { cursor: pointer; } tr.click:hover { background: var(--paper-2); }
td .name { font-weight: 600; }
.empty { padding: 32px 16px; text-align: center; color: var(--steel); }
@media (max-width: 720px) {
  .stack-sm thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .stack-sm, .stack-sm tbody, .stack-sm tr, .stack-sm td { display: block; width: 100%; }
  .stack-sm tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .stack-sm td { border: 0; padding: 4px 16px; display: flex; justify-content: space-between; gap: 16px; text-align: right; }
  .stack-sm td::before { content: attr(data-l); font: 500 12px var(--f-mono); text-transform: uppercase; color: var(--steel); text-align: left; }
  .stack-sm td.num { text-align: right; }
}

/* metrics */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.metric .v { font: 800 clamp(32px, 5vw, 56px)/1 var(--f-head); }
.metric .l { font: 500 12px var(--f-mono); text-transform: uppercase; color: var(--steel); letter-spacing: .06em; margin-top: 8px; }

/* toast */
.toasts { position: fixed; bottom: 16px; left: 16px; right: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 16px; background: var(--charcoal); color: var(--on-dark); padding: 12px 16px; border-radius: var(--r-md); max-width: 560px; box-shadow: 0 2px 8px rgba(0,0,0,.3); font-size: 15px; }
.toast .ic { width: 24px; height: 24px; border: 2px solid currentColor; border-radius: 50%; display: grid; place-items: center; flex: none; }
.toast.success .ic { color: #5CC790; } .toast.danger .ic { color: #EB6F63; } .toast.info .ic { color: #8DB4F0; }

/* modal */
dialog { border: 1px solid var(--line); border-radius: var(--r-md); padding: 0; background: var(--white); color: var(--ink); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(20,19,18,.7); }
dialog.wide { width: min(880px, calc(100vw - 32px)); }
dialog form, dialog .dlg { padding: 24px; }
dialog h3 { margin-bottom: 16px; }

/* secret box */
.secret { border: 2px dashed var(--signal); border-radius: var(--r-md); padding: 16px; background: var(--white); margin-bottom: 16px; }
.secret code { display: block; font: 600 20px/1.4 var(--f-mono); word-break: break-all; margin: 8px 0 16px; padding: 12px; background: var(--paper-2); border-radius: var(--r-sm); }

/* big code */
.code-big { font: 600 clamp(48px, 16vw, 112px)/1 var(--f-mono); letter-spacing: .04em; max-width: 100%; overflow: hidden; text-align: center; padding: 16px 0; font-variant-numeric: tabular-nums; }
.qr { display: block; margin: 0 auto; width: min(240px, 100%); height: auto; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); image-rendering: pixelated; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(440px, 100%); }
.demo { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.demo summary { cursor: pointer; font: 500 12px var(--f-mono); text-transform: uppercase; color: var(--steel); min-height: 32px; display: flex; align-items: center; }
.demo button { display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 0; min-height: 44px; cursor: pointer; font: 400 14px var(--f-mono); color: var(--ink); }
.demo button span:last-child { color: var(--steel); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (prefers-reduced-motion: no-preference) { .toast { animation: tin .18s ease-out; } @keyframes tin { from { transform: translateY(8px); opacity: 0; } } }
