/* Santanaride branding — palette and typeface taken from santanaride.com */

@font-face {
  font-family: 'Space Grotesk';
  src: url('/brand/space-grotesk.woff2') format('woff2-variations'),
       url('/brand/space-grotesk.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  /* brand constants — identical in both themes */
  --navy: #0a2b52;
  --blue: #2f9df5;
  --mint: #7ae7c7;
  --gold: #f5c34d;

  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: #e4e8f0;
  --text: #0f172a;
  --muted: #5b6b7a;
  --brand: var(--blue);
  --brand-ink: #ffffff;
  --topbar: var(--navy);
  --topbar-ink: #ffffff;
  --ok: #0f8a5f;
  --ok-bg: #e2f6ee;
  --warn: #8a6100;
  --warn-bg: #fdf4e0;
  --bad: #c2283a;
  --bad-bg: #fdeaec;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(10, 43, 82, .12);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* dark surfaces tinted toward the brand navy rather than neutral grey */
    --bg: #071a31;
    --surface: #0d2744;
    --surface-2: #123153;
    --border: #1c4269;
    --text: #eaf2fb;
    --muted: #93aac2;
    --brand: var(--blue);
    --topbar: #061627;
    --ok: #4ad295;
    --ok-bg: #0c3b2a;
    --warn: var(--gold);
    --warn-bg: #3a2e0d;
    --bad: #ff8593;
    --bad-bg: #431821;
    --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 'Space Grotesk', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); font-size: 14px; margin: 8px 0 0; }

/* ── Login ───────────────────────────────────────────── */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  /* the wordmark is white artwork, so it sits on the brand navy */
  background: linear-gradient(160deg, var(--navy) 0%, #061a33 100%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-mark {
  background: var(--navy);
  border-radius: 12px;
  padding: 18px 20px;
  margin: -4px 0 18px;
}
.login-mark img { width: 100%; max-width: 190px; height: auto; display: block; margin: 0 auto; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.login-card p { margin: 0 0 20px; font-size: 14px; }
.login-card input {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  margin-bottom: 12px;
}

/* ── Chrome ──────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  /* matches the santanaride.com header */
  background: var(--topbar);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  color: var(--topbar-ink);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* logo-wordmark.png is cropped to the artwork, so height maps straight to legibility */
.brand img { height: 30px; width: auto; display: block; flex: 0 0 auto; }
.brand-sub {
  font-size: 13px; font-weight: 500;
  color: rgba(255, 255, 255, .72);
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, .22);
  white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.clock {
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .7);
  font-size: 13px;
}
.topbar .btn.ghost {
  border-color: rgba(255, 255, 255, .28);
  color: var(--topbar-ink);
  background: transparent;
}
@media (max-width: 420px) {
  .brand-sub { display: none; }
}

.tabs {
  position: sticky; top: 49px; z-index: 19;
  display: flex; gap: 4px;
  padding: 8px 12px;
  background: var(--bg);
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.tab.active { background: var(--brand); color: var(--brand-ink); font-weight: 600; }

main { padding: 12px 12px 48px; max-width: 760px; margin: 0 auto; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 650; }

.banner {
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.banner.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.banner.bad  { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad); }
.banner .banner-sub { display: block; font-weight: 400; font-size: 13px; margin-top: 4px; opacity: .9; }

.countdown {
  font-size: 34px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.pill {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  white-space: nowrap;
}
.pill.ok   { background: var(--ok-bg);   color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad  { background: var(--bad-bg);  color: var(--bad); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 7px 12px; font-size: 13px; flex-direction: row; align-items: center; }
.btn.block { display: flex; width: 100%; align-items: center; justify-content: center; }
.actions { display: grid; gap: 10px; }

/* ── Lists ───────────────────────────────────────────── */
.row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row-main { min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 13px; margin-top: 2px; word-break: break-word; }
.row-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.driver-line {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 6px 0; font-size: 14px;
}

/* ── Forms ───────────────────────────────────────────── */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, select {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px; /* 16px stops iOS zooming on focus */
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
}
.inline-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 140px; width: auto; }

.driver-edit {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--surface-2);
}
.driver-edit .times { display: flex; gap: 8px; }
.driver-edit .times input, .driver-edit .times select { flex: 1; }
.driver-edit-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.driver-edit-head strong { font-size: 14px; }

/* ── Sheets ──────────────────────────────────────────── */
.sheet {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
  overflow-y: auto;
}
.sheet-card {
  background: var(--surface);
  width: 100%; max-width: 640px;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
}
@media (min-width: 640px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: var(--radius); }
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.sheet-actions .btn { flex-direction: row; }

/* ── Logs & run detail ───────────────────────────────── */
.logbox {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font: 12px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow-y: auto;
  margin: 12px 0 0;
}

.step {
  display: flex; gap: 10px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.step:last-child { border-bottom: 0; }
.step-dot { flex: 0 0 auto; }
.step-name { font-weight: 600; }
.step-detail { color: var(--muted); word-break: break-word; }
.step-ms { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }

.shot { width: 100%; border-radius: 10px; border: 1px solid var(--border); margin-top: 10px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin-bottom: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
