/* The console shell: base type, the sticky header, shared controls and the components in
   js/ui/components.js and js/ui/charts.js. Bench and document styles are in /static/app.css. */
* { box-sizing: border-box; }
/* --top-h: the top bar's height (56 px; taller on phones), kept up to date by main.js. */
:root { --top-h: 56px; }
html { background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
body { margin: 0; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 6px; letter-spacing: -.01em; font-weight: 600; }
h3 { font-size: 12.5px; margin: 18px 0 8px; color: var(--fg-2); letter-spacing: 0; font-weight: 600; }
h3:first-child { margin-top: 0; }
h4 { font-size: 12px; margin: 0 0 6px; color: var(--muted-fg); font-weight: 500; }
.muted { color: var(--muted-fg); font-weight: 400; }
.hidden, [hidden] { display: none !important; }
.note { font-size: 12px; color: var(--muted-fg); }
[data-icon] { display: inline-flex; width: 16px; height: 16px; flex: none; }
[data-icon] svg { width: 100%; height: 100%; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::selection { background: hsl(199 89% 60% / 30%); }

/* Buttons and inputs, shadcn-style. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--card); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .15s, background .15s, color .15s; white-space: nowrap; font-weight: 500; font-size: 13px; text-decoration: none; }
.btn:hover { background: var(--muted); }
.btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: var(--muted); }
.btn.outline { background: transparent; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn [data-icon] { width: 15px; height: 15px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius); border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--muted-fg); }
.icon-btn:hover { background: var(--muted); color: var(--fg); }
.icon-btn [data-icon] { width: 17px; height: 17px; }
input[type=password], input[type=search], input[type=text], select, textarea { border: 1px solid var(--input); background: transparent; border-radius: var(--radius); padding: 6px 10px; outline: none; }
select { background: var(--card); }
select option { background: var(--popover); color: var(--fg); }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.linkish { border: none; background: none; color: var(--info-ink); cursor: pointer; padding: 0 3px; font: inherit; text-decoration: underline dotted; text-underline-offset: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Header: sticky, blurred, 56 px. */
.top { position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: var(--header); backdrop-filter: blur(10px) saturate(1.4); -webkit-backdrop-filter: blur(10px) saturate(1.4); border-bottom: 1px solid var(--border); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; color: var(--fg); text-decoration: none; white-space: nowrap; }
.wm-icon { width: 28px; height: 28px; flex: none; display: block; }
.wm-short { display: none; }
.env { margin-left: -4px; }
.navtabs { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--muted); margin-left: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.navtabs::-webkit-scrollbar { display: none; }
.navtabs a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: 13px; font-weight: 500; color: var(--muted-fg); padding: 4px 11px; border-radius: 7px; white-space: nowrap; transition: color .15s, background .15s; }
.navtabs a:hover { color: var(--fg); }
.navtabs a.on { background: var(--bg); color: var(--fg); box-shadow: var(--shadow-sm); }
[data-theme="light"] .navtabs a.on { background: #fff; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: none; }

/* Live dot: emerald with a ping = live, amber = paused, grey = offline. */
.livebox { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: var(--radius); font-size: 12.5px; color: var(--muted-fg); white-space: nowrap; }
.livebox .resume { padding: 2px 8px; }
.sdot { position: relative; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.sdot.live, .sdot.ok { background: var(--ok); }
.sdot.warn, .sdot.paused { background: var(--warn); }
.sdot.bad { background: var(--bad); }
.sdot.info { background: var(--info); }
.sdot.off { background: transparent; box-shadow: inset 0 0 0 1px var(--faint); }
.sdot.ping::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 1.6s cubic-bezier(0, 0, .2, 1) infinite; }
.sdot.pulse { animation: pulse 1s infinite; }
@keyframes ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .sdot.ping::after, .sdot.pulse { animation: none; } }

/* Key menu. */
.keymenu { position: relative; }
.keybtn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: var(--radius); border: 1px solid var(--border); background: transparent; cursor: pointer; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.keybtn:hover { background: var(--muted); }
.keybtn.missing { border-color: hsl(38 92% 50% / 45%); color: var(--warn-ink); }
.keybtn .ok { display: inline-flex; color: var(--ok); }
.keybtn [data-icon] { display: block; width: 15px; height: 15px; }
.keybtn .ok [data-icon] { width: 14px; height: 14px; }
.keybtn [data-icon] svg { display: block; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 300px; background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-l); padding: 14px; }
.menu h4 { margin-bottom: 8px; }
.menu input { width: 100%; }
.menu .row { margin-top: 10px; }
.menu .note { margin: 10px 0 0; }
/* A tick box with its label (Remember on this device). */
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--fg-2); cursor: pointer; user-select: none; }
.check input[type=checkbox] { width: 15px; height: 15px; margin: 0; flex: none; accent-color: var(--brand); cursor: pointer; }

/* Router outlet. Views other than the bench are pages that use the full width, with the head
   (title, controls, actions) pinned under the top bar and a hairline once content scrolls under it.
   --pad is the page's side padding; the head bleeds into it so its background spans the page. */
.view { min-width: 0; }
.pagewrap { --pad: 24px; padding: 0 var(--pad) 48px; }
@media (min-width: 2200px) { .pagewrap { --pad: 36px; padding-bottom: 56px; } }
.page-head { position: sticky; top: var(--top-h); z-index: 20; display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; min-height: 64px;
  margin: 0 calc(var(--pad) * -1); padding: 12px var(--pad); background: var(--bg); border-bottom: 1px solid transparent; transition: border-color .15s; }
.page-head.stuck { border-bottom-color: var(--border); }
.page-head h1 { font-size: 20px; line-height: 1.3; white-space: nowrap; }
.head-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-intro { margin: -6px 0 16px; color: var(--muted-fg); max-width: 980px; }

/* Loading placeholders (ph() in components.js): a bar inside a real line box. */
.ph { display: inline-block; position: relative; max-width: 100%; color: transparent; vertical-align: baseline; user-select: none; }
.ph::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: max(8px, .62em); transform: translateY(-50%); border-radius: 4px;
  background: linear-gradient(90deg, var(--muted), var(--border), var(--muted)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.ph-badge { border-color: var(--border-2); }
.ph-text { color: transparent; border-radius: 4px; background: linear-gradient(90deg, var(--muted), var(--border), var(--muted)); background-size: 200% 100%; animation: shimmer 1.4s infinite;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; user-select: none; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .ph::before { animation: none; } }

/* The shared popover (data-pop), in place of native tooltips. */
.popover { position: fixed; z-index: 70; left: 0; top: 0; max-width: 340px; padding: 7px 10px; border-radius: var(--radius); background: var(--popover); color: var(--fg);
  border: 1px solid var(--border); box-shadow: var(--shadow-l); font-size: 12px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; pointer-events: none;
  opacity: 0; transform: translateY(-2px); transition: opacity .12s, transform .12s; }
.popover.on { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .popover { transition: none; } }

/* Components. */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.card-head h2 { margin: 0; font-size: 14px; flex: 1; min-width: 0; }
.card-head .sub { color: var(--muted-fg); font-size: 12px; font-weight: 400; }
.card-body { padding: 14px 16px 16px; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 1px 9px; font-size: 11.5px; font-weight: 500; border: 1px solid var(--border); color: var(--fg-2); white-space: nowrap; line-height: 1.6; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok-ink); border-color: hsl(160 84% 39% / 35%); background: var(--ok-soft); }
.badge.warn { color: var(--warn-ink); border-color: hsl(38 92% 50% / 35%); background: var(--warn-soft); }
.badge.bad { color: var(--bad-ink); border-color: hsl(350 89% 60% / 35%); background: var(--bad-soft); }
.badge.info { color: var(--info-ink); border-color: hsl(199 89% 60% / 30%); background: var(--info-soft); }
.badge.brand { color: var(--brand); border-color: hsl(0 72% 51% / 40%); background: var(--brand-soft); }
.badge.solid-brand { color: var(--on-brand); background: var(--brand); border-color: var(--brand); }

.ctabs { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--muted); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.ctabs::-webkit-scrollbar { display: none; }
.ctabs button { flex: none; border: none; background: none; padding: 4px 11px; border-radius: 7px; cursor: pointer; color: var(--muted-fg); font-weight: 500; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ctabs button:hover { color: var(--fg); }
.ctabs button.on { background: var(--bg); color: var(--fg); box-shadow: var(--shadow-sm); }
[data-theme="light"] .ctabs button.on { background: #fff; }
.count { font-size: 11px; background: var(--muted); color: var(--fg-2); border-radius: 99px; padding: 0 6px; min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.ctabs .count { background: var(--border); }

/* Stepper: Scan → Convert → Read → Rules → AI → Privacy. */
.stepper { display: flex; align-items: center; gap: 0; list-style: none; margin: 0; padding: 0; overflow-x: auto; scrollbar-width: none; }
.stepper li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted-fg); white-space: nowrap; }
.stepper li:not(:last-child)::after { content: ""; width: 22px; height: 1px; background: var(--border-strong); margin: 0 8px; }
.stepper .n { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 600; background: var(--muted); color: var(--muted-fg); }
.stepper .n [data-icon] { width: 12px; height: 12px; }
.stepper .done { color: var(--fg-2); }
.stepper .done .n { background: var(--ok-soft); color: var(--ok-ink); }
.stepper .current { color: var(--fg); font-weight: 500; }
.stepper .current .n { background: var(--info-soft); color: var(--info-ink); box-shadow: 0 0 0 1px hsl(199 89% 60% / 45%); }
.stepper .failed { color: var(--bad-ink); }
.stepper .failed .n { background: var(--bad-soft); color: var(--bad-ink); }
.stepper .skipped { opacity: .5; }
.stepper .skipped .n { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 56px 24px; border: 1px dashed var(--border-strong); border-radius: var(--radius-l); background: radial-gradient(60% 80% at 50% 0%, var(--brand-soft), transparent 70%), var(--card); }
.empty-state .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--muted); color: var(--fg-2); margin-bottom: 8px; }
.empty-state .ic [data-icon] { width: 22px; height: 22px; }
.empty-state h2 { font-size: 17px; margin: 0; }
.empty-state p { margin: 0; color: var(--muted-fg); max-width: 520px; }
.empty-state .actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--popover); color: var(--fg); border: 1px solid var(--border); padding: 10px 16px; border-radius: var(--radius-l); z-index: 60; max-width: min(80vw, 640px); box-shadow: var(--shadow-l); font-size: 13px; }
.toast.err { background: var(--bad); border-color: var(--bad); color: #fff; }

.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Charts (js/ui/charts.js). */
.spark { display: block; overflow: visible; }
.spark .line { fill: none; stroke: var(--c, var(--info)); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { fill: var(--c, var(--info)); opacity: .14; }
.spark .cap, .chart .cap { stroke: var(--muted-fg); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; opacity: .7; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid { stroke: var(--border-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .1; }
.chart .cursor { stroke: var(--muted-fg); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .axis { position: absolute; font-size: 11px; color: var(--muted-fg); font-variant-numeric: tabular-nums; pointer-events: none; white-space: nowrap; }
.chart .cap-label { position: absolute; right: 0; font-size: 11px; color: var(--muted-fg); transform: translateY(-100%); pointer-events: none; }
.chart .ctip { position: absolute; z-index: 5; pointer-events: none; background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-l); padding: 7px 10px; font-size: 12px; min-width: 140px; }
.chart .ctip .t { color: var(--muted-fg); margin-bottom: 3px; }
.chart .ctip .r { display: flex; align-items: center; gap: 8px; }
.chart .ctip .r b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .ctip b.gap, .sx-chip b.gap { color: var(--muted-fg); font-weight: 500; font-style: italic; }
.chart .ctip.follow { display: flex; gap: 8px; min-width: 0; padding: 0 7px; height: 21px; align-items: center; font-size: 11px; white-space: nowrap; box-shadow: var(--shadow-sm); }
.chart .ctip.follow .r { gap: 4px; }
.chart .ctip.follow .r b { margin-left: 0; }
.chart .ctip.follow .n { color: var(--muted-fg); }
/* A sparkline in a synced group: the crosshair, dot and value chip are drawn over the line, so the
   card never changes size. */
.spark-wrap { position: relative; display: block; height: 100%; touch-action: pan-y; cursor: crosshair; }
.spark-wrap > svg { display: block; }
.sx-line { position: absolute; top: -2px; bottom: 0; width: 1px; margin-left: -.5px; background: var(--muted-fg); opacity: .7; pointer-events: none; }
.sx-dot { position: absolute; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--c, var(--info)); box-shadow: 0 0 0 2px var(--card); pointer-events: none; }
.sx-chip { position: absolute; top: -3px; z-index: 6; display: inline-flex; align-items: baseline; gap: 6px; height: 19px; padding: 0 6px; border-radius: 6px; background: var(--popover); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); font-size: 11px; line-height: 17px; white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums; }
.sx-chip .t { color: var(--muted-fg); }
.sx-chip b { font-weight: 600; color: var(--fg); }
.chart .ctip i, .legend i { width: 10px; height: 2px; border-radius: 1px; background: var(--c); display: inline-block; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted-fg); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Phones: wordmark and controls on the first row, the tabs scroll sideways on a second. */
@media (max-width: 860px) {
  .top { height: auto; flex-wrap: wrap; padding: 0 12px; row-gap: 0; }
  .wordmark, .top-right { height: 56px; }
  .env { margin-left: 0; }
  .wm-long { display: none; }
  .wm-short { display: inline; }
  .navtabs { order: 3; flex-basis: 100%; margin: 0 -12px; padding: 3px 12px 8px; border-radius: 0; background: transparent; }
  .navtabs a.on { background: var(--muted); box-shadow: none; }
  .livebox .label { display: none; }
  .keybtn .label { display: none; }
  .menu { position: fixed; left: 12px; right: 12px; top: 60px; width: auto; }
  .pagewrap { --pad: 14px; padding: 0 var(--pad) 40px; }
  .page-head { min-height: 52px; padding-block: 8px; }
  .page-head h1 { font-size: 18px; }
}
