/* Shared tokens, top bar, sign in screens and admin. Brand: Altitude Select indigo and orange. */
:root {
  --indigo: #2f2b60;
  --indigo-deep: #1f1c45;
  --orange: #da532c;
  --orange-ink: #b8401d;
  --bg: #f4f4f8;
  --surface: #ffffff;
  --fg: #1c1a33;
  --muted: #5d5b75;
  --line: #dddce8;
  --chip: #ebeaf4;
  --on-band: #ffffff;
  --band-muted: #c9c7e6;
  --ok-bg: #e4f4ea; --ok-fg: #17603a;
  --warn-bg: #fff1dc; --warn-fg: #8a4b00;
  --err-bg: #fde8e4; --err-fg: #a12a12;
  --font-display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --font-body: "Barlow", "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121124; --surface: #1c1a36; --fg: #ecebf7; --muted: #a6a4c2;
    --line: #2f2c52; --chip: #262347; --indigo-deep: #0d0c1c; --orange-ink: #f07a52;
    --ok-bg: #133524; --ok-fg: #8fdcb0;
    --warn-bg: #3a2a10; --warn-fg: #f5c27a;
    --err-bg: #3d1a14; --err-fg: #f5a08c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 16px/1.6 var(--font-body); }
img { max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.05; text-wrap: balance; margin: 0; letter-spacing: .01em; }
.label { font: 500 12px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 700 20px/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; color: var(--on-band); }
.brand-mark { width: 28px; height: 28px; flex: none; }
.wave { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 120px; pointer-events: none; }
.wave path { fill: none; stroke-width: 2; }

/* ---------- Buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; font: 600 16px/1 var(--font-body); border-radius: 10px; padding: 14px 20px; border: 0; cursor: pointer; transition: background .15s ease, transform .15s ease; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: #c4471f; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--fg); }
.btn-ghost:hover { border-color: var(--orange); color: var(--orange-ink); }

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 15px; }
.field .hint { font-size: 13px; color: var(--muted); }
.field input { width: 100%; font: 400 16px/1.4 var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; transition: border-color .15s ease, box-shadow .15s ease; }
.field input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(218,83,44,.2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: var(--chip); border: 0; border-radius: 7px; padding: 6px 10px; font: 600 13px/1 var(--font-body); color: var(--muted); cursor: pointer; }

.alert { border-radius: 10px; padding: 12px 14px; font-size: 15px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert-warn { background: var(--warn-bg); color: var(--warn-fg); }
.alert-error { background: var(--err-bg); color: var(--err-fg); }

/* ---------- Sign in screens ---------- */
body.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.auth-side { position: relative; overflow: hidden; background: var(--indigo); color: var(--on-band); }
.auth-side-inner { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; gap: 40px; padding: 40px max(32px, env(safe-area-inset-left, 0px)) 160px 48px; }
.auth-pitch { display: grid; gap: 16px; margin-top: auto; }
.auth-pitch .label { color: #f6a07f; }
.auth-pitch h1 { font-size: clamp(48px, 6vw, 80px); text-transform: uppercase; }
.auth-pitch p { margin: 0; color: var(--band-muted); font-size: 18px; max-width: 40ch; }
.auth-list { list-style: none; margin: 0 0 auto; padding: 0; display: grid; gap: 10px; color: var(--band-muted); }
.auth-list li { display: flex; gap: 12px; align-items: baseline; }
.auth-list li::before { content: ""; width: 14px; height: 2px; background: var(--orange); flex: none; transform: translateY(-4px); }

.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding-block: 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth-card { width: 100%; max-width: 440px; display: grid; gap: 18px; }
.auth-card h2 { font-size: 40px; text-transform: uppercase; }
.auth-intro { margin: 0; color: var(--muted); }
.auth-card form { display: grid; gap: 16px; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 15px; }
.auth-links a, .auth-alt a { color: var(--orange-ink); font-weight: 600; text-decoration: none; }
.auth-links a:hover, .auth-alt a:hover { text-decoration: underline; }
.auth-alt { margin: 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; }
.auth-foot { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.auth-foot a { color: inherit; }

@media (max-width: 860px) {
  body.auth { grid-template-columns: 1fr; }
  .auth-side-inner { padding: 24px 20px 72px; gap: 20px; }
  .auth-pitch { margin-top: 8px; gap: 8px; }
  .auth-pitch h1 { font-size: 44px; }
  .auth-pitch p { font-size: 16px; }
  .auth-list { display: none; }
  .auth-side .wave { height: 64px; }
  .auth-main { justify-content: flex-start; padding-block: 28px 40px; }
}

/* ---------- Signed in top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--indigo-deep); color: var(--on-band); }
.topbar .wrap { display: flex; align-items: center; gap: 20px; min-height: 60px; }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { text-decoration: none; font-weight: 500; font-size: 15px; padding: 8px 12px; border-radius: 6px; color: var(--band-muted); white-space: nowrap; }
.nav a:hover { color: var(--on-band); background: rgba(255,255,255,.08); }
.userbox { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.nav + .userbox { margin-left: 8px; padding-left: 16px; border-left: 1px solid rgba(255,255,255,.15); }
.who { color: var(--band-muted); font-size: 14px; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-link { text-decoration: none; font: 500 12px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; padding: 7px 10px; border-radius: 6px; background: var(--orange); color: #fff; }
.logout { background: transparent; border: 1px solid rgba(255,255,255,.25); color: var(--on-band); font: 600 14px/1 var(--font-body); padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.logout:hover { border-color: var(--orange); }
@media (max-width: 860px) { .nav { display: none; } .nav + .userbox { margin-left: auto; padding-left: 0; border: 0; } }
@media (max-width: 480px) { .who { display: none; } }

/* ---------- Admin ---------- */
.admin { padding-block: 40px 80px; display: grid; gap: 28px; }
.admin-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; }
.admin-head h1 { font-size: clamp(36px, 5vw, 52px); text-transform: uppercase; }
.admin-head .label { color: var(--orange-ink); display: block; margin-bottom: 10px; }
.counts { display: flex; flex-wrap: wrap; gap: 8px; }
.count { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.count b { font-family: var(--font-mono); font-weight: 500; font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--chip); }
.count.is-on { border-color: var(--indigo); background: var(--indigo); color: #fff; }
.count.is-on b { background: rgba(255,255,255,.18); }
.count.has-pending b { background: var(--orange); color: #fff; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar form { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.toolbar input[type=search] { flex: 1; min-width: 0; font: 400 15px/1.4 var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.toolbar .btn { padding: 11px 16px; font-size: 15px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table.users { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 860px; }
.users th { text-align: left; font: 500 11px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.users td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.users tr:last-child td { border-bottom: 0; }
.users .name { font-weight: 600; }
.users .sub { color: var(--muted); font-size: 13px; }
.users .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; font: 500 11px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; padding: 5px 8px; border-radius: 999px; white-space: nowrap; }
.tag-active { background: var(--ok-bg); color: var(--ok-fg); }
.tag-pending { background: var(--warn-bg); color: var(--warn-fg); }
.tag-disabled { background: var(--chip); color: var(--muted); }
.tag-admin { background: var(--indigo); color: #fff; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions form { margin: 0; }
.act { font: 600 13px/1 var(--font-body); padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; white-space: nowrap; }
.act:hover { border-color: var(--orange); color: var(--orange-ink); }
.act-go { background: var(--orange); border-color: var(--orange); color: #fff; }
.act-go:hover { background: #c4471f; color: #fff; }
.act-danger:hover { border-color: var(--err-fg); color: var(--err-fg); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.admin-note { margin: 0; color: var(--muted); font-size: 14px; max-width: 70ch; }
