/* Octane — Swiss / enterprise minimalism: slate sidebar, one brand accent (LIT gold), green for the primary action.
   Light by default, dark with the OS. Mobile: the sidebar becomes a bottom bar and "New client" a floating button. */
:root {
  --brand: #8a7744; --brand-soft: #f5f0e3;
  --side: #1e293b; --side-text: #cbd5e1; --side-muted: #94a3b8; --side-hover: #273449; --side-active: #334155;
  --bg: #f6f7f9; --panel: #ffffff; --field: #ffffff; --line: #e2e8f0; --line-strong: #cbd5e1;
  --text: #0f172a; --muted: #64748b;
  --ok: #15803d; --ok-bg: #dcfce7; --bad: #b91c1c; --bad-bg: #fee2e2; --warn: #b45309; --warn-bg: #fef3c7;
  --primary: #16a34a; --primary-hover: #15803d; --on-primary: #ffffff;
  --ring: #2563eb; --radius: 12px; --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 1px 3px rgb(15 23 42 / .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #c9b47a; --brand-soft: #2a2516;
    --side: #0b1220; --side-hover: #162033; --side-active: #1e293b;
    --bg: #0f172a; --panel: #1b2336; --field: #111a2b; --line: #2a3650; --line-strong: #3b4a66;
    --text: #f1f5f9; --muted: #94a3b8;
    --ok: #4ade80; --ok-bg: #0f2a1a; --bad: #f87171; --bad-bg: #2f1214; --warn: #fbbf24; --warn-bg: #2d2109;
    --primary: #22c55e; --primary-hover: #16a34a; --on-primary: #052e16; --ring: #60a5fa;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 Inter, -apple-system, "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 13px; margin: 0; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.mono, code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.err { color: var(--bad); font-weight: 600; font-size: 13px; min-height: 18px; }
.err:empty { min-height: 0; }
.warn { background: var(--warn-bg); border-left: 3px solid var(--warn); padding: 10px 12px; border-radius: 8px; font-size: 14px; }

/* controls */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--field); color: var(--text); font-size: 15px; font-weight: 400; }
input:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent); }
.with-btn { display: flex; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background-color .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: var(--bad-bg); border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.icon { padding: 0; width: 40px; min-height: 40px; border-color: transparent; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 13px; flex-shrink: 0; }
.avatar.big { width: 48px; height: 48px; font-size: 16px; border-radius: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--brand) 18%, var(--bg)), var(--bg) 60%); }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgb(15 23 42 / .12); padding: 32px 28px; display: flex; flex-direction: column; gap: 16px; }
.login-logo { height: 64px; align-self: center; }
.login-card h1 { margin-bottom: 4px; }

/* shell */
.shell { display: grid; grid-template-columns: 240px 1fr; height: 100%; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; color: #fff; text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 8px; background: #fff; padding: 3px; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand small { color: var(--side-muted); font-size: 12px; }
.nav { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--side-text); text-decoration: none; font-weight: 600; border: 0; background: none; cursor: pointer; position: relative; text-align: left; }
.nav:hover { background: var(--side-hover); color: #fff; }
.nav[aria-current="page"] { background: var(--side-active); color: #fff; }
.nav[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.who { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: var(--side-muted); font-size: 13px; border-top: 1px solid #ffffff14; margin-top: 8px; }
.main { overflow: auto; height: 100vh; }
.page { max-width: 1040px; margin: 0 auto; padding: 32px 28px 48px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }

/* clients */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.stat span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat b { font-size: 26px; font-variant-numeric: tabular-nums; }
.search { flex-direction: row; align-items: center; gap: 0; position: relative; }
.search svg { position: absolute; left: 14px; color: var(--muted); }
.search input { padding-left: 42px; }
.list { overflow: hidden; }
.list-head, .row { display: grid; grid-template-columns: minmax(0, 2.2fr) 1fr 1fr 1fr; gap: 16px; align-items: center; padding: 0 20px; }
.list-head { min-height: 42px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 60%, var(--panel)); }
.row { min-height: 68px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background-color .12s; }
.row:last-child { border-bottom: 0; }
.row:hover, .row.sel { background: color-mix(in srgb, var(--brand) 7%, var(--panel)); }
.who-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who-cell > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.who-cell b, .who-cell small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-cell small { color: var(--muted); font-size: 12px; }
.meter { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-variant-numeric: tabular-nums; max-width: 120px; }
.meter i { height: 6px; border-radius: 99px; background: var(--line); position: relative; overflow: hidden; }
.meter i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--brand); border-radius: 99px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 56px 20px; text-align: center; }
.empty > svg { width: 40px; height: 40px; color: var(--brand); }

/* settings */
.section { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.section-title { display: flex; gap: 14px; align-items: flex-start; }
.section-title > svg { width: 22px; height: 22px; color: var(--brand); margin-top: 2px; }
.section-title p { font-size: 14px; }
.row-form { display: flex; align-items: flex-end; gap: 10px; }
.row-form label { max-width: 220px; }
.downloads { display: flex; flex-direction: column; gap: 10px; }
a.dl { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
a.dl:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, var(--panel)); }
a.dl > svg { color: var(--brand); }
a.dl .grow { display: flex; flex-direction: column; }
a.dl small { font-size: 12px; }

/* side panel */
.scrim { position: fixed; inset: 0; background: rgb(15 23 42 / .35); z-index: 9; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -16px 0 40px rgb(15 23 42 / .18); z-index: 10; display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; gap: 14px; padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 19px; }
.panel-body { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.panel-foot { display: flex; gap: 10px; padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.panel-foot .btn { flex: 1; }
.block-title { display: flex; justify-content: space-between; align-items: baseline; }
.devices { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; }
.devices li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.devices li:last-child { border-bottom: 0; }
.devices li > svg { color: var(--muted); }
.devices .grow { display: flex; flex-direction: column; }
.devices small { font-size: 12px; }
.devices .none { justify-content: center; padding: 18px; }

/* dialogs */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 24px; width: min(460px, calc(100% - 32px)); box-shadow: 0 20px 60px rgb(15 23 42 / .3); }
dialog::backdrop { background: rgb(15 23 42 / .5); }
dialog[open], dialog form { display: flex; flex-direction: column; gap: 14px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.cred { display: flex; align-items: center; gap: 8px; }
.cred code { flex: 1; font-size: 19px; font-weight: 700; background: var(--bg); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 10px 12px; user-select: all; overflow-wrap: anywhere; }

.fab { display: none; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 20; box-shadow: var(--shadow); }

/* tablet / phone */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .main { height: auto; overflow: visible; }
  .page { padding: 20px 16px 110px; }
  .side { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; justify-content: space-around; gap: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 8; border-top: 1px solid #ffffff14; }
  .brand, .who, .side .grow { display: none; }
  .nav { flex-direction: column; gap: 2px; font-size: 11px; min-height: 52px; padding: 4px 16px; flex: 1; align-items: center; }
  .nav[aria-current="page"]::before { left: 30%; right: 30%; top: -6px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .new-btn { display: none; }
  .fab { display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 16px; border: 0; background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 24px rgb(22 163 74 / .4); z-index: 8; cursor: pointer; }
  .fab svg { width: 24px; height: 24px; }
  .list-head { display: none; }
  .row { grid-template-columns: 1fr auto; grid-template-areas: "who status" "meter seen"; gap: 10px; padding: 14px 16px; }
  .row > :nth-child(1) { grid-area: who; } .row > :nth-child(2) { grid-area: status; justify-self: end; }
  .row > :nth-child(3) { grid-area: meter; } .row > :nth-child(4) { grid-area: seen; justify-self: end; font-size: 13px; }
  .row-form { flex-wrap: wrap; }
  .panel { width: 100%; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
