/* JAT Cipherline 2300 console. No external fonts or libraries; light and dark themes. */
:root {
  color-scheme: light;
  --bg: #f4f6f8; --panel: #ffffff; --panel-2: #f8fafb; --line: #e3e8ee; --line-2: #d3dae3;
  --ink: #0e1a28; --ink-2: #4b5b6d; --ink-3: #6d7c8d;
  --brand: #0b6e78; --brand-2: #0f8a96; --brand-ink: #ffffff; --brand-soft: #e3f3f4;
  --side: #0c1724; --side-ink: #c9d6e3; --side-ink-2: #8295a8; --side-active: #16283b;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --grid: #e9edf2; --axis: #9aa7b5;
  --radius: 10px; --shadow: 0 1px 2px rgba(14, 26, 40, .06), 0 1px 1px rgba(14, 26, 40, .04);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0a121c; --panel: #111c29; --panel-2: #0e1823; --line: #1f2d3e; --line-2: #2a3b50;
    --ink: #e7eef6; --ink-2: #a9b8c8; --ink-3: #8798aa;
    --brand: #2bb3bf; --brand-2: #45c6d1; --brand-ink: #04232a; --brand-soft: #0f2c33;
    --side: #070e16; --side-active: #13243a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --grid: #1b2838; --axis: #5d6f83;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }


/* ---------- shell */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side, .content, .main { min-width: 0; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-weight: 700; letter-spacing: .01em; color: #fff; font-size: 14.5px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--side-ink-2); line-height: 1.3; }
.nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-weight: 520; white-space: nowrap; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--side-active); color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand-2); }
.nav .count { margin-left: auto; background: var(--crit); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 7px; }
.side-foot { padding: 12px 16px 16px; border-top: 1px solid #172638; font-size: 12.5px; color: var(--side-ink-2); }
.side-foot b { color: #fff; font-weight: 600; }
.side-foot .link { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; text-decoration: underline; }
.content { min-width: 0; }
.main { padding: 26px 30px 48px; max-width: 1240px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { height: auto; position: sticky; z-index: 5; }
  .brand { padding: 12px 14px 6px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 4px 8px 10px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 7px 11px; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--brand-2); }
  .side-foot { display: none; }
  .main { padding: 18px 14px 40px; }
  .mobile-only { display: inline-flex !important; }
}
.mobile-only { display: none !important; }

/* ---------- page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); max-width: 70ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards and grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid > .card + .card, .dev-grid > .card + .card { margin-top: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 14px; }
@media (max-width: 980px) { .g2, .g3 { grid-template-columns: 1fr; } }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--ink-2); font-weight: 560; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 680; letter-spacing: -.015em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 13px; font-weight: 560; color: var(--ink-2); margin-left: 3px; }
.kpi .sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.section-title { margin: 22px 0 10px; }

/* ---------- status */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.status.good::before { background: var(--good); }
.status.warn::before { background: var(--warn); }
.status.serious::before { background: var(--serious); }
.status.crit::before { background: var(--crit); }
.status.idle { color: var(--ink-2); font-weight: 520; }
.banner { display: flex; align-items: center; gap: 12px; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--panel); }
.banner .icon { width: 22px; height: 22px; flex: none; }
.banner.good { border-left: 4px solid var(--good); }
.banner.crit { border-left: 4px solid var(--crit); }
.banner.warn { border-left: 4px solid var(--warn); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 620; padding: 1px 8px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.brand { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.pill.crit { color: var(--crit); border-color: currentColor; background: transparent; }
.pill.warn { color: #9a6700; border-color: var(--warn); background: transparent; }
@media (prefers-color-scheme: dark) { .pill.warn { color: var(--warn); } }

/* ---------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 2px; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.empty { color: var(--ink-2); padding: 18px 4px; text-align: center; }

/* ---------- tables (become cards on phones) */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl .name { font-weight: 600; }
.tbl .row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 720px) {
  .tbl.responsive thead { display: none; }
  .tbl.responsive, .tbl.responsive tbody { display: block; }
  .tbl.responsive tr { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; background: var(--panel); }
  .tbl.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 0; text-align: right; }
  .tbl.responsive td::before { content: attr(data-label); color: var(--ink-2); font-size: 12px; text-align: left; }
  .tbl.responsive td.first { font-size: 15px; }
  .tbl.responsive td.first::before { content: none; }
  .tbl.responsive .row-actions { justify-content: flex-start; width: 100%; }
}

/* ---------- buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); padding: 7px 13px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); line-height: 1.3; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--crit); }
.btn.danger.solid { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--brand-soft); color: var(--brand); }
.form { display: grid; gap: 12px; }
.field label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); outline: none;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav a:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); outline: none; }
textarea.config { font-family: var(--mono); font-size: 12px; min-height: 180px; resize: vertical; white-space: pre; background: var(--panel-2); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 520; }
.check input { margin-top: 3px; }
.choice { display: grid; gap: 8px; }
.choice label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice b { display: block; }
.error { color: var(--crit); font-weight: 560; min-height: 1.2em; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 260px; }
.toolbar select { width: auto; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { padding: 0 0 16px; }
.login-card .brand-name { color: var(--ink); }
.login-card .brand-sub { color: var(--ink-2); }
.login-note { font-size: 12px; color: var(--ink-2); margin-top: 14px; text-align: center; }

/* ---------- charts */
.chart-card { position: relative; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
svg.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
svg.chart text { font: 11px var(--sans); fill: var(--ink-3); }
svg.chart .grid line { stroke: var(--grid); }
svg.chart .base { stroke: var(--axis); }
svg.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .direct { font-weight: 600; fill: var(--ink-2); }
svg.chart .cross { stroke: var(--axis); stroke-dasharray: 3 3; }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12); white-space: nowrap; z-index: 3; font-variant-numeric: tabular-nums; }
.tip .t { color: var(--ink-2); margin-bottom: 2px; }
.tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
details.data { margin-top: 6px; font-size: 12px; }
details.data summary { cursor: pointer; color: var(--ink-2); }
details.data table { margin-top: 6px; }
.chart-empty { height: 150px; display: grid; place-items: center; color: var(--ink-3); font-size: 13px; }

/* ---------- device cards (user portal) */
.dev-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.dev { display: flex; flex-direction: column; gap: 8px; }
.dev .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.dev .title { font-weight: 650; font-size: 15px; }
.dev .stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dev .btns { display: flex; gap: 8px; margin-top: auto; }

/* ---------- modal and toast */
dialog.modal { border: 1px solid var(--line-2); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.28); }
dialog.modal::backdrop { background: rgba(6, 12, 20, .5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; overflow-y: auto; max-height: calc(100vh - 170px); }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); padding: 2px 6px; }
.qr { display: block; width: 240px; max-width: 100%; margin: 0 auto 12px; background: #fff; border-radius: 10px; padding: 8px; }
.qr-missing { width: 240px; max-width: 100%; aspect-ratio: 1; margin: 0 auto 12px; display: grid; place-items: center; text-align: center; padding: 18px; border: 1px dashed var(--line-2); border-radius: 10px; color: var(--ink-3); font-size: 12.5px; }
.secret { font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: .02em; padding: 12px; background: var(--panel-2); border: 1px dashed var(--line-2); border-radius: 8px; text-align: center; user-select: all; word-break: break-all; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-weight: 560; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 360px; }
.toast.bad { background: var(--crit); color: #fff; }
dl.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 8px 16px; margin: 0; }
dl.kv dt { color: var(--ink-2); }
dl.kv dd { margin: 0; font-family: var(--mono); font-size: 13px; word-break: break-word; }
@media (max-width: 600px) { dl.kv { grid-template-columns: 1fr; gap: 2px; } dl.kv dd { margin-bottom: 8px; } }
ol.steps { margin: 0; padding-left: 20px; }
ol.steps li { margin-bottom: 6px; }
.skeleton { height: 90px; border-radius: var(--radius); background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: sk 1.2s infinite linear; border: 1px solid var(--line); }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.link-item { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.link-item .card-head { margin-bottom: 6px; }
.link-item input { font-family: var(--mono); font-size: 12px; background: var(--panel-2); }
.qr.small { width: 180px; }


/* ---------- device setup page and people */
.proto-row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 640px) { .proto-row { grid-template-columns: minmax(0, 1fr); } }
.proto-row .qr { margin: 0; width: 220px; }
@media (max-width: 640px) { .proto-row .qr { margin: 0 auto; } }
.link-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); margin-top: 14px; }
.link-grid > .card + .card { margin-top: 0; }
.link-card { display: flex; flex-direction: column; gap: 8px; }
.link-card .qr { width: 200px; margin: 4px auto; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; background: var(--panel-2); }
textarea.sub { font-family: var(--mono); font-size: 12px; min-height: 92px; resize: vertical; word-break: break-all; background: var(--panel-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--line-2); border-radius: 20px; font-size: 12.5px; color: var(--ink); text-decoration: none; background: var(--panel); }
.chip:hover { border-color: var(--brand); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.chip .dot.on { background: var(--good); }
.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; margin-bottom: 10px; }
.back svg { width: 16px; height: 16px; }
.preview { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.card > h2 { margin-bottom: 8px; }
.dev .btns { flex-wrap: wrap; }
.dev .btns .btn { white-space: nowrap; }
