/* =========================================================================
   Iron Horse · CEO Operating System
   Dark, moody, luxe. Black / gold / silver. Cinzel · DM Sans · Space Mono.
   ========================================================================= */

:root {
  /* Surfaces — near-black up through raised inputs */
  --bg-0: #0a0a0b;
  --bg-1: #101116;
  --bg-2: #16181d;
  --bg-3: #1d2026;
  --bg-4: #24272e;

  /* Brand */
  --gold: #c9a24b;
  --gold-bright: #e7cf8a;
  --gold-dim: rgba(201, 162, 75, 0.55);
  --silver: #c8cdd4;

  /* Ink */
  --text: #ece8e0;
  --muted: #8c919b;
  --faint: #5f636c;

  /* Lines */
  --line: rgba(201, 162, 75, 0.16);
  --line-soft: rgba(200, 205, 212, 0.09);
  --line-hard: rgba(200, 205, 212, 0.14);

  /* States */
  --ok: #79c598;
  --warn: #d9a441;

  /* Type */
  --display: "Cinzel", "Times New Roman", serif;
  --body: "DM Sans", system-ui, -apple-system, sans-serif;
  --mono: "Space Mono", ui-monospace, "SFMono-Regular", monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px -28px rgba(0, 0, 0, 0.9);
  --maxw: 940px;
  --nav-h: 64px;
  --save-h: 64px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--body);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  background:
    radial-gradient(1200px 680px at 78% -8%, rgba(201, 162, 75, 0.10), transparent 60%),
    radial-gradient(900px 600px at 0% 0%, rgba(200, 205, 212, 0.04), transparent 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--save-h) + env(safe-area-inset-bottom));
}

::selection { background: rgba(201, 162, 75, 0.28); color: #fff; }

/* ----------------------------------------------------------------- Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, rgba(10, 10, 11, 0.92), rgba(10, 10, 11, 0.74));
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}
.brand-logo {
  height: 30px;
  width: auto;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}
.brand-words { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.brand-sub {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
  position: relative;
  transition: color 0.18s ease, background 0.18s ease;
}
.nav-tab .icon { color: var(--faint); transition: color 0.18s ease; display: inline-flex; }
.nav-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.nav-tab:hover .icon { color: var(--silver); }
.nav-tab.active { color: var(--gold); }
.nav-tab.active .icon { color: var(--gold); }
.nav-tab.active::after {
  content: "";
  position: absolute;
  left: 13px; right: 13px; bottom: 2px;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* -------------------------------------------------------------------- View */
.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 30px 20px 40px;
}
.view-inner { display: flex; flex-direction: column; gap: 22px; }

.fade-in { animation: fade 0.4s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Page header (each tab starts with one) */
.page-head { margin-bottom: 2px; }
.page-kicker {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}
.page-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(30px, 5vw, 44px);
  letter-spacing: 1px;
  line-height: 1.04;
  margin: 0;
  text-transform: uppercase;
}
.page-lede {
  color: var(--muted);
  max-width: 60ch;
  margin: 12px 0 0;
  font-size: 15px;
}

/* ------------------------------------------------------------------- Cards */
.card {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 18px; }

.sec-head { margin-bottom: 18px; }
.eyebrow, .page-kicker {
  font-family: var(--mono);
  text-transform: uppercase;
}
.eyebrow {
  font-size: 10.5px;
  letter-spacing: 2.6px;
  color: var(--gold);
  margin-bottom: 8px;
}
.sec-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.6px;
  margin: 0;
  text-transform: uppercase;
}
.sec-sub { color: var(--muted); margin: 8px 0 0; font-size: 14px; }

.hairline { height: 1px; background: var(--line); border: 0; margin: 20px 0; }

/* ------------------------------------------------------------------ Fields */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
}
.field-help { font-size: 12px; color: var(--faint); }

.inp {
  width: 100%;
  font-family: var(--body);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  appearance: none;
}
.inp::placeholder { color: var(--faint); }
.inp:focus {
  outline: none;
  border-color: var(--gold-dim);
  background: var(--bg-4);
  box-shadow: 0 0 0 3px rgba(201, 162, 75, 0.14);
}
.inp.ta { resize: none; line-height: 1.5; min-height: 56px; }
select.inp {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
  cursor: pointer;
}

.inp-prefix { display: flex; align-items: stretch; }
.inp-prefix .pfx {
  display: grid; place-items: center;
  padding: 0 12px;
  font-family: var(--mono);
  color: var(--gold);
  background: var(--bg-4);
  border: 1px solid var(--line-hard);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.inp-prefix .inp { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* checkbox rows */
.chk-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.chk-row:last-child { border-bottom: 0; }
.chk {
  appearance: none;
  width: 19px; height: 19px;
  margin-top: 1px;
  border: 1px solid var(--line-hard);
  border-radius: 5px;
  background: var(--bg-3);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chk:checked { background: var(--gold); border-color: var(--gold); }
.chk:checked::after {
  content: "";
  position: absolute; left: 6px; top: 2.5px;
  width: 4px; height: 9px;
  border: solid #14110a; border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.chk-label { font-size: 15px; transition: color 0.15s ease; }
.chk-row.done .chk-label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--gold-dim); }

/* ---------------------------------------------------------------- Repeater */
.repeater { display: flex; flex-direction: column; gap: 12px; }
.rep-empty {
  color: var(--faint);
  font-size: 14px;
  padding: 14px;
  border: 1px dashed var(--line-hard);
  border-radius: var(--radius-sm);
  text-align: center;
}
.rep-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px;
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.rep-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 12px;
}
.rep-grid .field { margin-bottom: 0; }
.rep-del {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  color: var(--faint);
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.rep-del:hover { color: #e98b7a; border-color: rgba(233, 139, 122, 0.4); background: rgba(233, 139, 122, 0.07); }

/* ----------------------------------------------------------------- Buttons */
.btn {
  font-family: var(--body);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.btn:active { transform: translateY(1px); }
.btn.solid {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1408;
  border-color: var(--gold);
}
.btn.solid:hover { filter: brightness(1.06); }
.btn.ghost {
  background: transparent;
  color: var(--silver);
  border-color: var(--line-hard);
}
.btn.ghost:hover { color: var(--text); border-color: var(--gold-dim); }

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  background: transparent;
  border: 1px dashed var(--gold-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.btn-add:hover { background: rgba(201, 162, 75, 0.08); color: var(--gold-bright); }
.btn-add .icon { display: inline-flex; }

.icon svg { display: block; }

/* ------------------------------------------------------------------- Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.stat {
  background: var(--bg-2);
  padding: 20px 18px;
}
.stat.accent { background: linear-gradient(180deg, rgba(201,162,75,0.10), var(--bg-2)); }
.stat-val {
  font-family: var(--display);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: 0.5px;
  color: var(--text);
  line-height: 1;
}
.stat.accent .stat-val { color: var(--gold); }
.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 9px;
}

/* ---------------------------------------------------------------- Progress */
.bar {
  height: 6px;
  border-radius: 99px;
  background: var(--bg-3);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.metric-row {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 9px; gap: 12px;
}
.metric-row .label { font-family: var(--mono); font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.metric-row .val { font-family: var(--mono); font-size: 13px; color: var(--silver); }
.metric-row .val b { color: var(--gold); font-weight: 700; }

/* ---------------------------------------------------- Dashboard signature */
.odometer {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: center;
  padding: 30px 28px;
  background:
    radial-gradient(120% 160% at 85% 0%, rgba(201,162,75,0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ring { width: 132px; height: 132px; flex-shrink: 0; }
.ring-track { fill: none; stroke: var(--bg-4); stroke-width: 7; }
.ring-fill {
  fill: none; stroke: url(#goldgrad); stroke-width: 7;
  stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 0 6px rgba(201,162,75,0.35));
}
.ring-center { text-anchor: middle; }
.ring-num { font-family: var(--display); font-weight: 700; font-size: 30px; fill: var(--text); }
.ring-cap { font-family: var(--mono); font-size: 7.5px; letter-spacing: 2px; fill: var(--muted); text-transform: uppercase; }

.odo-copy .odo-kicker {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 2.6px;
  text-transform: uppercase; color: var(--gold); margin-bottom: 10px;
}
.odo-copy .odo-line {
  font-family: var(--display); font-weight: 500;
  font-size: clamp(20px, 3.4vw, 27px); letter-spacing: 0.4px;
  line-height: 1.2; margin: 0; text-transform: uppercase;
}
.odo-copy .odo-meta { color: var(--muted); font-size: 13.5px; margin-top: 12px; }
.odo-copy .odo-meta b { color: var(--silver); font-weight: 600; }
.odo-edit { margin-top: 16px; max-width: 220px; }
.odo-edit .field { margin-bottom: 0; }

/* tag pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase;
  padding: 4px 9px; border-radius: 99px;
  border: 1px solid var(--line-hard); color: var(--muted);
}
.pill.gold { color: var(--gold); border-color: var(--gold-dim); background: rgba(201,162,75,0.07); }

.lede-block { color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.lede-block b { color: var(--text); font-weight: 600; }

/* two-column helper for wider cards */
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.cols-2 .field { margin-bottom: 0; }

/* saved review entries */
.log-item {
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
}
.log-date { font-family: var(--mono); font-size: 11px; letter-spacing: 1.4px; color: var(--gold); text-transform: uppercase; }
.log-body { margin-top: 8px; font-size: 14px; color: var(--silver); white-space: pre-wrap; }

/* -------------------------------------------------------------- Save bar */
.savebar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: linear-gradient(0deg, rgba(10,10,11,0.96), rgba(10,10,11,0.8));
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.savebar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: var(--save-h);
  padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.save-status { display: flex; align-items: center; gap: 10px; min-width: 0; }
.save-dot {
  width: 7px; height: 7px; border-radius: 99px; background: var(--ok);
  box-shadow: 0 0 10px rgba(121, 197, 152, 0.7); flex-shrink: 0;
}
.saved-tag { font-family: var(--mono); font-size: 12px; letter-spacing: 1px; color: var(--silver); white-space: nowrap; }
.saved-tag.flash { animation: tagflash 0.5s ease; }
@keyframes tagflash { 0% { color: var(--gold-bright); } 100% { color: var(--silver); } }
.save-note { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* -------------------------------------------------------------- Responsive */
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: 0; padding: 0 14px; }
  .brand { padding: 11px 0; }
  .nav-tabs {
    order: 3; width: calc(100% + 28px); margin: 0 -14px;
    padding: 6px 14px; border-top: 1px solid var(--line-soft);
  }
  .nav-tab .nav-label { display: none; }
  .nav-tab { padding: 9px 12px; }
  .view { padding: 22px 14px 34px; }
  .card { padding: 18px; }
  .odometer { grid-template-columns: 1fr; text-align: center; justify-items: center; gap: 18px; padding: 24px 20px; }
  .odo-edit { margin-left: auto; margin-right: auto; }
  .rep-grid { grid-template-columns: 1fr 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
  .save-note { display: none; }
}
@media (max-width: 420px) {
  .rep-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------- A11y / motion */
a:focus-visible, button:focus-visible, .inp:focus-visible, .chk:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* --------------------------------------------------- Exit phase strip */
.phase-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.phase { background: var(--bg-2); padding: 20px 18px; }
.phase-n {
  font-family: var(--mono); font-size: 12px; letter-spacing: 2px;
  color: var(--gold-dim);
}
.phase-title {
  font-family: var(--display); font-weight: 600; font-size: 17px;
  letter-spacing: 0.5px; text-transform: uppercase; margin-top: 8px;
}
.phase-date {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--gold); margin-top: 4px;
}
.phase-body { color: var(--muted); font-size: 13px; margin: 10px 0 0; line-height: 1.5; }
@media (max-width: 720px) { .phase-grid { grid-template-columns: 1fr; } }

/* ------------------------------------------------------- Vision creed */
.creed {
  text-align: center;
  background:
    radial-gradient(130% 130% at 50% 0%, rgba(201,162,75,0.10), transparent 62%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-color: var(--line);
  padding: 36px 24px;
}
.creed .eyebrow { color: var(--gold); }
.creed-line {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(26px, 5vw, 40px);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold-bright);
  margin: 10px 0 0;
  text-shadow: 0 0 30px rgba(201,162,75,0.25);
}
.creed-rule {
  width: 70px; height: 2px; margin: 18px auto 14px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.creed-sub { color: var(--muted); font-size: 14px; margin: 0; }

/* ── Auth screen ─────────────────────────────────────────────────────────── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 24px;
}
.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.auth-logo { margin-bottom: 16px; }
.auth-logo img { border-radius: 12px; }
.auth-title {
  font-family: 'Cinzel', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold-bright);
  margin: 0 0 4px;
  letter-spacing: 1px;
}
.auth-sub { color: var(--muted); font-size: 13px; margin: 0 0 28px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .inp { text-align: left; }
.auth-form .btn { margin-top: 4px; }
.auth-error {
  color: #e07070;
  font-size: 13px;
  text-align: left;
  padding: 8px 12px;
  background: rgba(224, 112, 112, 0.1);
  border-radius: 6px;
}

/* ── Sync status tag ────────────────────────────────────────────────────── */
.sync-tag {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-left: 8px;
  transition: color 0.3s;
}
.sync-tag.syncing { color: var(--gold); }
.sync-tag.offline { color: var(--warn, #d4844a); }
.sync-tag.error   { color: #e07070; }

/* ── Sign-out button (small, in save bar) ───────────────────────────────── */
.sign-out-btn {
  font-size: 11px;
  padding: 4px 10px;
  opacity: 0.6;
}
.sign-out-btn:hover { opacity: 1; }
