/* GulzMD Dashboard.
   Quiet when healthy: colour appears only where something needs you. The theme lives between
   THEME START and THEME END; everything else uses its tokens.
   Fonts are served from this folder (SIL Open Font License); the page makes no outside requests. */

/* THEME START */
@font-face { font-family: "UI"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/ui-400.woff2") format("woff2"); }
@font-face { font-family: "UI"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/ui-500.woff2") format("woff2"); }
@font-face { font-family: "UI"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/ui-600.woff2") format("woff2"); }
@font-face { font-family: "Code"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/mono-400.woff2") format("woff2"); }
:root {
  color-scheme: dark;
  --canvas: #0e0f11;
  --surface: #15171a;
  --raised: #1c1f23;
  --line: #25282d;
  --line-strong: #33373d;
  --track: #24272c;
  --text: #f2f3f5;
  --text-2: #a4a9b1;
  --text-3: #70757d;
  --fill: #e4e6ea;
  --accent: #79aafc;
  --accent-strong: #2d68e6;
  --accent-strong-hover: #3a75f0;
  --on-accent: #ffffff;
  --primary: #2d68e6;
  --primary-hover: #3a75f0;
  --on-primary: #ffffff;
  --ok: #4fbf8f;
  --attention: #e5bb4e;
  --fault: #f06b6b;
  --mark-tile: #2d68e6;
  --mark-glyph: #ffffff;
  --font-ui: "UI", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font-ui);
  --font-mono: "Code", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: -0.025em;
}
/* THEME END */

:root {
  --r-panel: 14px;
  --r-control: 10px;
  --tabbar: 62px;
  --side: 240px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--canvas); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text-2); }
button, input, select { font: inherit; color: inherit; }
a, button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.9em; letter-spacing: 0; }
.noscript { padding: 40px; color: var(--text-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --- frame ---------------------------------------------------------------------------- */

.main {
  max-width: 1040px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 28px) max(20px, env(safe-area-inset-right, 0px))
           calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 40px) max(20px, env(safe-area-inset-left, 0px));
}
.sidebar { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
  padding: 0 max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--canvas) 96%, transparent);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 11px; font-weight: 500; text-decoration: none; letter-spacing: 0.01em;
}
.tab[aria-current="page"] { color: var(--accent); }

@media (min-width: 960px) {
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0; width: var(--side);
    padding: 30px 16px 24px;
    border-right: 1px solid var(--line);
  }
  .main { margin-left: var(--side); padding: 56px 64px 96px; max-width: calc(1040px + var(--side)); }
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 30px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.mark-tile { fill: var(--mark-tile); }
.mark-glyph { fill: none; stroke: var(--mark-glyph); stroke-width: 2.4; }
.mark-dot { fill: var(--mark-glyph); stroke: var(--mark-tile); stroke-width: 1.6; }
.live { display: inline-flex; align-items: center; gap: 7px; }
.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.live.lost::before { background: var(--attention); }
.figure-value.fault { color: var(--fault); }
.brand-name { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: 18px; line-height: 1; }
.brand-sub { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; letter-spacing: 0.01em; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px;
  border-radius: 9px; color: var(--text-2); text-decoration: none; font-weight: 500;
}
.side-link:hover { background: var(--surface); color: var(--text); }
.side-link[aria-current="page"] { background: var(--surface); color: var(--text); }
.side-link[aria-current="page"] .icon { color: var(--accent); }
.side-foot { margin-top: auto; padding: 0 12px; font-size: 13px; color: var(--text-3); }
.side-foot button { background: none; border: 0; padding: 0; color: var(--text-2); cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

/* --- page header ---------------------------------------------------------------------- */

.page-head { margin-bottom: 36px; }
.page-title {
  font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking);
  font-size: 32px; line-height: 1.1; margin: 0;
  display: flex; align-items: center; gap: 14px;
}
.page-title .tone { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 4px; }
.tone.calm { background: var(--ok); }
.tone.attention { background: var(--attention); }
.tone.fault { background: var(--fault); }
.page-sub { margin: 12px 0 0; color: var(--text-2); max-width: 62ch; }
.page-meta { margin: 6px 0 0; color: var(--text-3); font-size: 13px; }
@media (min-width: 960px) { .page-title { font-size: 40px; } }

/* --- sections ------------------------------------------------------------------------- */

.section { margin-top: 44px; }
.page-head + .section { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.005em; }
.section-note { font-size: 13px; color: var(--text-3); text-align: right; }
.section-note a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.lede { color: var(--text-2); margin: -4px 0 16px; font-size: 14px; max-width: 62ch; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 56px; align-items: start; }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --- vitals ----------------------------------------------------------------------------- */

.vitals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 24px; }
@media (min-width: 720px) { .vitals { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 30px 40px; } }
.vital-label { font-size: 13px; color: var(--text-2); }
.vital-value { font-size: 28px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; margin-top: 4px; white-space: nowrap; }
.vital-unit { font-size: 15px; font-weight: 400; color: var(--text-2); margin-left: 3px; letter-spacing: 0; }
.vital-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vital-sub.hover { color: var(--text-2); }
.spark { display: block; width: 100%; height: 38px; margin-top: 12px; overflow: visible; touch-action: pan-y; cursor: crosshair; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark path.area { fill: var(--accent); fill-opacity: 0.10; stroke: none; }
.spark line.cursor { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark-dot { position: absolute; }

/* --- panels and rows ---------------------------------------------------------------------- */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; min-height: 56px; position: relative; }
.row + .row, .row + .detail, .detail + .row { border-top: 1px solid var(--line); }
button.row { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; }
button.row:hover { background: var(--raised); }
button.row:focus-visible { outline-offset: -2px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title.muted { color: var(--text-2); font-weight: 400; }
label.row .row-title { white-space: normal; }
.row-sub { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.row-end { text-align: right; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-end .quiet { display: block; color: var(--text-3); }
.row .chev { color: var(--text-3); width: 18px; height: 18px; transition: transform 0.15s ease; }
.row[aria-expanded="true"] .chev { transform: rotate(90deg); }
.detail { padding: 4px 16px 18px; background: var(--surface); }
.facts { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 7px 18px; margin: 10px 0 0; font-size: 13px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.facts dd .quiet { color: var(--text-3); }
.split { display: grid; gap: 12px; }
@media (min-width: 720px) { .split.two { grid-template-columns: 1fr 1fr; } }

/* --- state markers ------------------------------------------------------------------------ */

.state { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.state.ok::before { background: var(--ok); }
.state.attention::before { background: var(--attention); }
.state.fault::before { background: var(--fault); }
.state.fault { color: var(--text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); } .dot.attention { background: var(--attention); } .dot.fault { background: var(--fault); }

/* --- meters --------------------------------------------------------------------------------- */

.meters { display: flex; flex-direction: column; }
.meter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 16px; padding: 14px 0; }
.meter-row + .meter-row { border-top: 1px solid var(--line); }
.meter-row.child { padding: 9px 0 9px 18px; border-top: 0; }
.meter-row.child .meter-name { color: var(--text-2); font-size: 14px; }
.meter-name { font-weight: 500; }
.meter-figure { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter-figure b { color: var(--text); font-weight: 500; }
.meter { grid-column: 1 / -1; position: relative; height: 6px; margin-top: 8px; border-radius: 3px; background: var(--track); }
.meter.thin { height: 3px; margin-top: 6px; }
.meter > i { position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); border-radius: inherit; background: var(--accent); }
.meter.thin > i { background: color-mix(in srgb, var(--accent) 50%, var(--track)); }
.meter.muted > i { background: var(--text-3); }
.meter.attention > i { background: var(--attention); }
.meter.fault > i { background: var(--fault); }
.meter > b { position: absolute; top: -4px; bottom: -4px; left: var(--at, 20%); width: 1px; background: var(--text-2); }
.meter-note { grid-column: 1 / -1; font-size: 12px; color: var(--text-3); margin-top: 6px; }

.after-figures { margin-top: 24px; }
.detail-head { margin: 22px 0 10px; }
.offer-note { text-align: center; margin: 12px 0 22px; }
.sheet .qr { margin-top: 8px; }

/* --- figures in a row ------------------------------------------------------------------------ */

.figures { display: flex; flex-wrap: wrap; gap: 18px 36px; }
.figure-value { font-size: 22px; font-weight: 500; letter-spacing: -0.015em; }
.figure-label { font-size: 13px; color: var(--text-3); }

/* --- controls ------------------------------------------------------------------------------------ */

.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-control);
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  font: 500 14px/1 var(--font-ui); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--raised); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.quiet { border-color: transparent; color: var(--text-2); padding: 0 10px; }
.btn.quiet:hover { color: var(--text); background: var(--raised); }
.btn.danger { color: var(--fault); }
.btn.block { width: 100%; height: 46px; font-size: 15px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.field-hint { display: block; font-size: 12px; color: var(--text-3); margin-top: 6px; }
.input, .select {
  width: 100%; height: 46px; padding: 0 14px;
  background: var(--canvas); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  font: 400 16px var(--font-ui);
}
.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.input.code { font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.32em; text-align: center; padding-left: 0.32em; }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 19px) 20px, calc(100% - 14px) 20px; background-size: 5px 5px; background-repeat: no-repeat; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .select { width: auto; min-width: 200px; flex: 1 1 220px; height: 40px; font-size: 15px; }
.toolbar .input { height: 40px; font-size: 15px; flex: 1 1 180px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control); }
.seg button { height: 32px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--text-2); font: 500 13px var(--font-ui); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); }

.switch {
  appearance: none; position: relative; flex: none; width: 44px; height: 26px; margin: 0;
  border-radius: 13px; background: var(--track); border: 1px solid var(--line-strong); cursor: pointer;
  transition: background-color 0.15s ease;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform 0.15s ease, background-color 0.15s ease; }
.switch:checked { background: var(--primary); border-color: var(--primary); }
.switch:checked::after { transform: translateX(18px); background: #ffffff; }

/* --- logs ------------------------------------------------------------------------------------------ */

.log {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: 10px 0; font: 12.5px/1.6 var(--font-mono); max-height: calc(100dvh - 300px); min-height: 280px; overflow: auto;
  overscroll-behavior: contain;
}
.log-line { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 1px 16px; }
.log-line:hover { background: var(--raised); }
.log-time { color: var(--text-3); white-space: nowrap; }
.log-msg { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.log-line.warn .log-msg { color: var(--attention); }
.log-line.err .log-msg { color: var(--fault); }
.log-empty { padding: 28px 16px; color: var(--text-3); font-family: var(--font-ui); font-size: 14px; }
@media (max-width: 600px) { .log-line { grid-template-columns: 1fr; gap: 0; padding: 4px 14px; } .log-time { font-size: 11px; } }

/* --- notes ------------------------------------------------------------------------------------------ */

.note { color: var(--text-3); font-size: 13px; margin: 10px 0 0; }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-panel); color: var(--text-2); font-size: 14px; }
.callout .dot { margin-top: 7px; }
.empty { padding: 26px 16px; color: var(--text-3); font-size: 14px; }

/* --- sheets and toasts ---------------------------------------------------------------------------- */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(7, 9, 12, 0.66);
  animation: fade 0.16s ease;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 90dvh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  animation: rise 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (min-width: 720px) { .scrim { align-items: center; } .sheet { border-radius: 16px; border-bottom: 1px solid var(--line); padding: 28px; } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sheet-title { margin: 0; font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: 24px; line-height: 1.2; }
.sheet-text { color: var(--text-2); margin: 0 0 20px; font-size: 14px; }
.icon-btn { flex: none; width: 36px; height: 36px; display: grid; place-items: center; margin: -4px -8px 0 0; border: 0; border-radius: 50%; background: none; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.toast {
  position: fixed; left: 50%; z-index: 50; transform: translateX(-50%);
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 18px);
  max-width: calc(100vw - 40px);
  padding: 11px 16px; border-radius: 10px;
  background: var(--raised); border: 1px solid var(--line-strong); color: var(--text); font-size: 14px;
  animation: rise 0.2s ease;
}
@media (min-width: 960px) { .toast { bottom: 28px; left: calc(50% + var(--side) / 2); } }
.form-error { color: var(--fault); font-size: 14px; margin: 0 0 14px; min-height: 0; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast { animation-name: toast-rise; }
@keyframes toast-rise { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* --- sign-in ------------------------------------------------------------------------------------------- */

.auth {
  min-height: 100dvh; display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 32px) 24px calc(env(safe-area-inset-bottom, 0px) + 32px);
}
.auth-card { width: 100%; max-width: 360px; }
.auth-mark { width: 44px; height: 44px; display: block; }
.auth-title { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: 30px; line-height: 1.1; margin: 22px 0 6px; }
.auth-text { color: var(--text-2); margin: 0 0 30px; }
.qr { display: block; width: 216px; height: 216px; margin: 0 auto 18px; border-radius: 12px; }
.secret { display: block; text-align: center; font: 15px/1.6 var(--font-mono); letter-spacing: 0.06em; color: var(--text); margin: 0 0 6px; user-select: all; overflow-wrap: anywhere; }
.auth-foot { margin-top: 26px; font-size: 13px; color: var(--text-3); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .dot, .state::before, .tone { forced-color-adjust: none; border: 1px solid CanvasText; }
  .meter > i { background: Highlight; }
}
