/* ottos dashboard — styling reproduced from the design handoff prototype.
   The handoff's <style> block is the source of truth; tokens are authored in
   oklch and switched via [data-theme]. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg, #0e0f1a); }

.o-root {
  /* Defaults the prototype set inline; the tweaks panel is dropped in prod. */
  --font-ui: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --accent: #5b62d6;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px;
  --row-pad: 10px;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* ── Theme tokens ─────────────────────────────────────────────── */
.o-root[data-theme="light"] {
  --bg: oklch(0.984 0.004 258);
  --bg-grad: oklch(0.965 0.008 262);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.974 0.005 258);
  --surface-3: oklch(0.955 0.006 258);
  --border: oklch(0.915 0.006 260);
  --border-2: oklch(0.865 0.008 260);
  --text: oklch(0.27 0.022 264);
  --muted: oklch(0.505 0.02 264);
  --faint: oklch(0.63 0.016 264);
  --shadow: 0 1px 2px rgba(22,24,44,.05), 0 10px 28px -14px rgba(22,24,44,.18);
  --shadow-pop: 0 4px 12px rgba(22,24,44,.1), 0 18px 40px -16px rgba(22,24,44,.3);
  --accent-ink: var(--accent);
  --accent-soft: color-mix(in oklab, var(--accent) 11%, transparent);
  --accent-line: color-mix(in oklab, var(--accent) 32%, transparent);
  --ok: oklch(0.62 0.13 152); --ok-soft: color-mix(in oklab, var(--ok) 13%, transparent); --ok-ink: oklch(0.46 0.11 152);
  --warn: oklch(0.74 0.13 75); --warn-soft: color-mix(in oklab, var(--warn) 16%, transparent); --warn-ink: oklch(0.5 0.11 62);
  --crit: oklch(0.58 0.2 27); --crit-soft: color-mix(in oklab, var(--crit) 12%, transparent); --crit-ink: oklch(0.5 0.19 27);
  --never: oklch(0.56 0.06 292); --never-soft: color-mix(in oklab, var(--never) 13%, transparent); --never-ink: oklch(0.46 0.06 292);
  color-scheme: light;
}
.o-root[data-theme="dark"] {
  --bg: oklch(0.18 0.012 262);
  --bg-grad: oklch(0.215 0.018 268);
  --surface: oklch(0.224 0.013 262);
  --surface-2: oklch(0.255 0.014 262);
  --surface-3: oklch(0.295 0.015 262);
  --border: oklch(0.33 0.014 262);
  --border-2: oklch(0.41 0.016 262);
  --text: oklch(0.95 0.006 264);
  --muted: oklch(0.72 0.014 264);
  --faint: oklch(0.585 0.014 264);
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 14px 34px -16px rgba(0,0,0,.7);
  --shadow-pop: 0 6px 16px rgba(0,0,0,.4), 0 22px 48px -18px rgba(0,0,0,.8);
  --accent-ink: color-mix(in oklab, var(--accent) 72%, white 28%);
  --accent-soft: color-mix(in oklab, var(--accent) 26%, transparent);
  --accent-line: color-mix(in oklab, var(--accent) 50%, transparent);
  --ok: oklch(0.74 0.14 155); --ok-soft: color-mix(in oklab, var(--ok) 18%, transparent); --ok-ink: oklch(0.82 0.13 155);
  --warn: oklch(0.79 0.13 78); --warn-soft: color-mix(in oklab, var(--warn) 18%, transparent); --warn-ink: oklch(0.85 0.12 80);
  --crit: oklch(0.68 0.18 26); --crit-soft: color-mix(in oklab, var(--crit) 22%, transparent); --crit-ink: oklch(0.8 0.15 28);
  --never: oklch(0.72 0.06 292); --never-soft: color-mix(in oklab, var(--never) 20%, transparent); --never-ink: oklch(0.82 0.06 292);
  color-scheme: dark;
}

.o-mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

/* ══ LOGIN ════════════════════════════════════════════════════ */
.o-login {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 24px;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--bg-grad), transparent 60%),
    radial-gradient(60% 50% at 85% 110%, var(--accent-soft), transparent 70%),
    var(--bg);
  color: var(--text);
}
.o-login__card {
  width: 100%; max-width: 384px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 36px 34px 28px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.o-brandmark {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(150deg, color-mix(in oklab, var(--accent) 88%, white 12%), var(--accent));
  box-shadow: 0 2px 8px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,.3);
}
.o-brandmark--lg { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 18px; }
.o-login__title { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.o-login__sub { font-size: 13px; color: var(--muted); margin: 6px 0 26px; }
.o-field { width: 100%; text-align: left; display: block; }
.o-field__lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.o-field__wrap {
  display: flex; align-items: center; gap: 9px; padding: 0 12px;
  height: 46px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); transition: border-color .15s, box-shadow .15s;
}
.o-field__wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.o-field__wrap input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 15px; color: var(--text); letter-spacing: 0.04em;
}
.o-field__toggle { border: 0; background: transparent; color: var(--faint); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px; }
.o-field__toggle:hover { color: var(--text); }
.o-login__err { width: 100%; text-align: left; color: var(--crit-ink); font-size: 12.5px; margin: 9px 0 0; }
.o-login__foot { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); margin: 16px 0 0; line-height: 1.4; }
.o-login__ver { font-size: 11px; color: var(--faint); font-family: var(--font-mono); }

/* ══ APP SHELL ════════════════════════════════════════════════ */
.o-app { min-height: 100vh; background: var(--bg); color: var(--text); display: flex; flex-direction: column; }

.o-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 22px; background: color-mix(in oklab, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.o-top__brand { display: flex; align-items: center; gap: 12px; }
.o-top__names { display: flex; flex-direction: column; line-height: 1.15; }
.o-top__title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.o-top__sub { font-size: 11.5px; color: var(--faint); font-weight: 500; }
.o-top__right { display: flex; align-items: center; gap: 10px; }

.o-conn { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; padding: 5px 11px 5px 10px; border-radius: 999px; }
.o-conn__dot { width: 7px; height: 7px; border-radius: 50%; }
.o-conn--ok { color: var(--ok-ink); background: var(--ok-soft); }
.o-conn--ok .o-conn__dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: opulse 2.4s ease-in-out infinite; }
.o-conn--bad { color: var(--crit-ink); background: var(--crit-soft); }
.o-conn--bad .o-conn__dot { background: var(--crit); }
@keyframes opulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.o-refresh { display: flex; align-items: center; gap: 6px; padding-left: 6px; border-left: 1px solid var(--border); }
.o-refresh__meta { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.o-refresh__lbl { font-size: 10px; color: var(--faint); font-weight: 500; }
.o-refresh__time { font-size: 12px; font-weight: 600; font-family: var(--font-mono); }

.o-iconbtn {
  width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 9px; transition: background .14s, color .14s, border-color .14s;
}
.o-iconbtn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }
.o-iconbtn:disabled { opacity: 0.5; cursor: default; }
.o-iconbtn--text { color: var(--faint); }
.o-spin { display: grid; place-items: center; animation: ospin .85s linear infinite; }
@keyframes ospin { to { transform: rotate(360deg); } }

.o-main { width: 100%; max-width: 1300px; margin: 0 auto; padding: 22px 22px 60px; display: flex; flex-direction: column; gap: 16px; }

/* ── Error banner ───────────────────────────────────────────── */
.o-banner {
  display: flex; align-items: center; gap: 13px; padding: 13px 16px;
  background: var(--crit-soft); border: 1px solid color-mix(in oklab, var(--crit) 30%, transparent);
  border-radius: var(--r-md); color: var(--crit-ink);
}
.o-banner__body { flex: 1; font-size: 13px; line-height: 1.45; }
.o-banner__body strong { font-weight: 700; }
.o-banner code { font-family: var(--font-mono); font-size: 11.5px; background: color-mix(in oklab, var(--crit) 14%, transparent); padding: 1px 6px; border-radius: 5px; }

/* ── Summary cards ──────────────────────────────────────────── */
.o-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.o-card {
  position: relative; overflow: hidden; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; padding: 16px 17px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow); font: inherit; color: var(--text);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.o-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.o-card.is-active { border-color: var(--card-c, var(--accent)); box-shadow: 0 0 0 1px var(--card-c, var(--accent)), var(--shadow); }
.o-card__label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.o-card__value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.o-card__sub { font-size: 11.5px; color: var(--faint); font-weight: 500; }
.o-card__accent { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--card-c, transparent); }
.o-card--ok { --card-c: var(--ok); }
.o-card--crit { --card-c: var(--crit); }
.o-card--never { --card-c: var(--never); }
.o-card--crit .o-card__value { color: var(--crit-ink); }
.o-card--neutral .o-card__accent { background: var(--border-2); }

/* ── Controls ───────────────────────────────────────────────── */
.o-controls { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.o-spacer { flex: 1; }
.o-thresh { display: flex; align-items: center; gap: 10px; }
.o-thresh__lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.o-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.o-seg__b {
  border: 0; background: transparent; font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--muted); padding: 5px 11px; border-radius: 7px; cursor: pointer;
  font-variant-numeric: tabular-nums; transition: color .12s, background .12s;
}
.o-seg__b:hover { color: var(--text); }
.o-seg__b.is-on { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow); }

.o-select { position: relative; display: inline-flex; align-items: center; }
.o-select select {
  appearance: none; font: inherit; font-size: 13px; font-weight: 500; color: var(--text);
  padding: 9px 32px 9px 13px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; outline: none;
}
.o-select select:hover { border-color: var(--border-2); }
.o-select > svg { position: absolute; right: 11px; pointer-events: none; color: var(--faint); }

.o-search { display: inline-flex; align-items: center; gap: 8px; padding: 0 11px; height: 38px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; min-width: 250px; color: var(--faint); transition: border-color .15s, box-shadow .15s; }
.o-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--muted); }
.o-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font: inherit; font-size: 13.5px; color: var(--text); }
.o-search__x { border: 0; background: transparent; color: var(--faint); cursor: pointer; display: grid; place-items: center; padding: 2px; }
.o-search__x:hover { color: var(--text); }

.o-export { position: relative; }
.o-export__veil { position: fixed; inset: 0; z-index: 30; }
.o-export__menu {
  position: absolute; right: 0; top: calc(100% + 7px); z-index: 31; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 5px; overflow: hidden;
}
.o-export__hd { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); padding: 7px 9px 5px; }
.o-export__menu button { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; background: transparent; font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text); padding: 9px 9px; border-radius: 8px; cursor: pointer; }
.o-export__menu button:hover { background: var(--surface-2); }
.o-export__menu em { font-style: normal; font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); }

/* ── Buttons ────────────────────────────────────────────────── */
.o-btn { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 13.5px; font-weight: 600; padding: 9px 15px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; transition: background .14s, border-color .14s, transform .1s; }
.o-btn:active { transform: translateY(1px); }
.o-btn--primary { background: var(--accent); color: #fff; box-shadow: 0 2px 6px var(--accent-soft); }
.o-btn--primary:hover { background: color-mix(in oklab, var(--accent) 88%, black 12%); }
.o-btn--ghost { background: transparent; border-color: currentColor; color: var(--muted); }
.o-btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.o-btn--block { width: 100%; justify-content: center; height: 46px; font-size: 14.5px; margin-top: 22px; }
.o-btn--sm { padding: 6px 11px; font-size: 12.5px; }

/* ── Table ──────────────────────────────────────────────────── */
.o-tablewrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.o-tablehd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.o-tablehd__count { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.o-tablehd__count strong { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.o-chip { display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 11.5px; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); border: 0; border-radius: 999px; padding: 3px 5px 3px 10px; cursor: pointer; }
.o-chip:hover { background: color-mix(in oklab, var(--accent) 18%, transparent); }
.o-tablehd__sev { display: flex; align-items: center; gap: 9px; font-size: 11px; color: var(--faint); font-weight: 500; }
.o-key { display: inline-flex; align-items: center; gap: 5px; font-style: normal; }
.o-key::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.o-key--ok::before { background: var(--ok); }
.o-key--warn::before { background: var(--warn); }
.o-key--crit::before { background: var(--crit); }
.o-key--never::before { background: var(--never); }

.o-tablescroll { overflow-x: auto; }
.o-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.o-table thead th { position: sticky; top: 0; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); padding: 10px 16px; background: var(--surface-2); cursor: pointer; user-select: none; white-space: nowrap; border-bottom: 1px solid var(--border); }
.o-table thead th.is-sorted { color: var(--text); }
.o-th { display: inline-flex; align-items: center; gap: 4px; }
.o-th__arr { opacity: 0; transition: opacity .12s; display: inline-flex; }
.o-table thead th:hover .o-th__arr { opacity: 0.5; }
.o-th__arr.is-on { opacity: 1; color: var(--accent-ink); }

.o-table tbody td { padding: var(--row-pad, 11px) 16px; vertical-align: middle; }
.o-row { transition: background .1s; }
.o-row:hover td { background: var(--surface-2); }
.o-table--lined tbody tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.o-table--zebra tbody tr:nth-child(even) td { background: color-mix(in oklab, var(--surface-2) 60%, transparent); }
.o-table--zebra tbody tr:hover td { background: var(--surface-2); }
.o-row--never td:first-child { box-shadow: inset 3px 0 0 var(--never); }
.o-row--crit td:first-child { box-shadow: inset 3px 0 0 var(--crit); }

.o-unit { display: flex; flex-direction: column; line-height: 1.25; }
.o-unit__name { font-weight: 600; color: var(--text); }
.o-unit__model { font-size: 11.5px; color: var(--faint); }
.o-imei { font-size: 12.5px; color: var(--muted); letter-spacing: 0.01em; }
.o-group { font-size: 12.5px; color: var(--muted); }

.o-seen { display: flex; flex-direction: column; gap: 1px; }
.o-seen__row { display: flex; align-items: baseline; gap: 7px; font-size: 12.5px; color: var(--text); }
.o-seen__row em { font-style: normal; font-size: 9.5px; font-weight: 600; letter-spacing: 0.05em; color: var(--faint); }
.o-seen__row--utc { color: var(--faint); }
.o-seen__row--utc .o-mono { color: var(--faint); }
.o-seen--never { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--never-ink); font-style: italic; }

/* ── Severity displays ──────────────────────────────────────── */
.o-days { font-variant-numeric: tabular-nums; font-size: 13px; }
.o-days--ok { display: inline-flex; align-items: center; gap: 6px; color: var(--ok-ink); font-weight: 500; }
.o-onlinedot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.o-days--never { color: var(--never-ink); font-weight: 500; }

.o-pill { display: inline-flex; align-items: center; font-weight: 600; padding: 4px 11px; border-radius: 999px; }
.o-pill--warn { background: var(--warn-soft); color: var(--warn-ink); }
.o-pill--crit { background: var(--crit-soft); color: var(--crit-ink); }

.o-dot { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.o-dotmark { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.o-dot--warn .o-dotmark { background: var(--warn); }
.o-dot--crit .o-dotmark { background: var(--crit); }

.o-bar { display: inline-flex; align-items: center; gap: 10px; }
.o-bar__track { width: 84px; height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.o-bar__fill { display: block; height: 100%; border-radius: 999px; }
.o-bar--warn .o-bar__fill { background: var(--warn); }
.o-bar--crit .o-bar__fill { background: var(--crit); }
.o-bar__num { font-size: 12.5px; font-weight: 600; color: var(--text); }

/* ── Status badge ───────────────────────────────────────────── */
.o-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: 999px; white-space: nowrap; }
.o-badge__dot { width: 6px; height: 6px; border-radius: 50%; }
.o-badge--ok { color: var(--ok-ink); background: var(--ok-soft); }
.o-badge--ok .o-badge__dot { background: var(--ok); }
.o-badge--warn { color: var(--warn-ink); background: var(--warn-soft); }
.o-badge--warn .o-badge__dot { background: var(--warn); }
.o-badge--crit { color: var(--crit-ink); background: var(--crit-soft); }
.o-badge--crit .o-badge__dot { background: var(--crit); }
.o-badge--never { color: var(--never-ink); background: var(--never-soft); }
.o-badge--never .o-badge__dot { background: var(--never); }

/* ── Skeleton + empty ───────────────────────────────────────── */
.o-skrow td { padding: var(--row-pad, 11px) 16px; }
.o-sk { display: block; height: 13px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: oshimmer 1.3s linear infinite; }
@keyframes oshimmer { to { background-position: -200% 0; } }
.o-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px 64px; gap: 5px; }
.o-empty__mark { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); margin-bottom: 12px; }
.o-empty__t { font-size: 16px; font-weight: 700; margin: 0; }
.o-empty__s { font-size: 13px; color: var(--muted); margin: 0 0 12px; max-width: 360px; }

/* ── Toast ──────────────────────────────────────────────────── */
.o-toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 9px; padding: 11px 16px; border-radius: 11px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-pop); animation: otoast .25s cubic-bezier(.3,.8,.3,1); }
.o-toast--info, .o-toast--ok { background: var(--text); color: var(--bg); }
.o-toast--warn { background: var(--crit); color: #fff; }
@keyframes otoast { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 860px) {
  .o-cards { grid-template-columns: repeat(2, 1fr); }
  .o-controls { gap: 9px; }
  .o-search { min-width: 160px; flex: 1; }
  .o-refresh__meta { display: none; }
}
