/* The Race — visual identity */
:root {
  --bg:        #060E1A;
  --bg-2:      #0A1729;
  --panel:     #0E1D33;
  --panel-2:   #12243F;
  --line:      #22344F;
  --line-2:    #2C425F;
  --line-soft: #1B2C47;
  --text:      #E7EEF8;
  --muted:     #8FA6C4;
  --muted-2:   #5C7496;
  --gold:      #F5A623;
  --gold-2:    #FFD35C;
  --green:     #22C58B;
  --red:       #F0616D;
  --blue:      #4C8DFF;
  --purple:    #A78BFA;
  --radius:    16px;
  --shadow:    0 18px 40px rgba(0,0,0,.35);
  --font:      'Segoe UI', system-ui, -apple-system, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 82% -8%, rgba(245,166,35,.10), transparent 60%),
    radial-gradient(900px 520px at 5% 4%, rgba(76,141,255,.10), transparent 55%),
    var(--bg);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

/* ---- Header ---- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 34px;
  position: sticky; top: 0; z-index: 30;
  background: rgba(6,14,26,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand img { display: block; }
.top-nav { display: flex; align-items: center; gap: 26px; font-weight: 600; font-size: 14.5px; }
.top-nav a { color: var(--muted); transition: color .15s; }
.top-nav a:hover { color: var(--text); }
.top-nav .pill {
  color: var(--bg); background: linear-gradient(135deg, var(--gold-2), var(--gold));
  padding: 8px 16px; border-radius: 999px; font-weight: 700;
}

/* ---- Hero ---- */
.hero {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center;
  max-width: 1240px; margin: 0 auto; padding: 64px 34px 40px;
}
.eyebrow { letter-spacing: 3px; font-size: 12px; font-weight: 700; color: var(--gold); margin-bottom: 16px; }
.hero h1 { font-size: 52px; line-height: 1.05; margin: 0 0 18px; letter-spacing: -1px; font-weight: 800; }
.hero h1 span { color: var(--gold); font-style: italic; }
.lede { font-size: 17.5px; color: var(--muted); max-width: 560px; margin: 0 0 26px; }
.chips { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 28px; }
.chip {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; min-width: 108px;
}
.chip-k { font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted-2); }
.chip-v { font-size: 20px; font-weight: 800; color: var(--text); }
.cta {
  display: inline-block; background: linear-gradient(135deg, var(--gold-2), var(--gold));
  color: var(--bg); font-weight: 800; padding: 13px 24px; border-radius: 12px;
  box-shadow: var(--shadow); transition: transform .12s;
}
.cta:hover { transform: translateY(-2px); }
.hero-art {
  background: linear-gradient(160deg, var(--panel-2), var(--bg-2));
  border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow);
}
.hero-art svg { width: 100%; height: auto; display: block; }

/* ---- Layout ---- */
.layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 26px; align-items: start;
  max-width: 1240px; margin: 20px auto 60px; padding: 0 34px;
}

/* ---- Inputs ---- */
.inputs {
  position: sticky; top: 88px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}
.inputs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.inputs-head h2 { font-size: 18px; margin: 0; }
.btn-row { display: flex; gap: 8px; }
.btn {
  font-family: var(--font); font-weight: 700; font-size: 12.5px; cursor: pointer;
  border: none; border-radius: 9px; padding: 8px 12px;
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: var(--bg);
}
.btn.ghost { background: transparent; border: 1px solid var(--line-2, #2C425F); color: var(--muted); }
.btn.gold { background: transparent; border: 1px solid rgba(245,166,35,.55); color: var(--gold); }
.btn:hover { filter: brightness(1.05); }
.mode-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 12px 0 2px; padding: 10px 12px;
  background: rgba(245,166,35,.07); border: 1px solid rgba(245,166,35,.35); border-radius: 10px;
  font-size: 12px; letter-spacing: .8px; text-transform: uppercase; font-weight: 800; color: var(--gold);
}
#scenarioMode {
  font-family: var(--font); font-weight: 700; font-size: 13px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  text-transform: none; letter-spacing: 0; min-width: 150px;
}
#scenarioMode:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,166,35,.15); }

fieldset { border: 1px solid var(--line-soft); border-radius: 12px; margin: 14px 0 0; padding: 12px 14px 14px; }
legend { font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); font-weight: 700; padding: 0 6px; }
label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--muted); margin-top: 10px; }
label input {
  width: 118px; text-align: right; font-family: var(--font); font-weight: 700; font-size: 14px;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
label input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,166,35,.15); }
.disclaimer { font-size: 11px; color: var(--muted-2); margin: 16px 2px 0; line-height: 1.5; }

/* ---- Results ---- */
.results { display: flex; flex-direction: column; gap: 22px; }
.group { margin-bottom: 4px; }
.group-head h3 { margin: 4px 0 2px; font-size: 19px; }
.group-head p { margin: 0 0 14px; color: var(--muted); font-size: 14px; max-width: 780px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-left: 4px solid var(--muted-2);
  border-radius: 14px; padding: 16px 18px;
}
.card.up { border-left-color: var(--green); }
.card.down { border-left-color: var(--red); }
.card-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.card-value { font-size: 27px; font-weight: 800; margin: 6px 0 4px; letter-spacing: -.5px; }
.card-delta { font-size: 13.5px; font-weight: 700; }
.card-delta.g { color: var(--green); }
.card-delta.r { color: var(--red); }
.card-note { font-size: 12.5px; color: var(--muted-2); margin-top: 8px; line-height: 1.45; }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.panel.signature { border-color: rgba(245,166,35,.32); }
.panel-head h3 { margin: 0 0 4px; font-size: 18px; }
.panel-head p { margin: 0 0 16px; color: var(--muted); font-size: 14px; max-width: 820px; }
.chart { width: 100%; }
.chart-svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; justify-content: center; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.legend-item i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }

/* ---- Cascade ---- */
.panel.cascade { border-color: rgba(240,97,109,.32); }
.pill-tag {
  font-size: 11.5px; font-weight: 800; letter-spacing: .5px; padding: 3px 10px;
  border-radius: 999px; vertical-align: middle; margin-left: 8px;
}
.pill-tag.safe { background: rgba(34,197,139,.16); color: var(--green); }
.pill-tag.warn { background: rgba(245,166,35,.18); color: var(--gold); }
.pill-tag.danger { background: rgba(240,97,109,.18); color: var(--red); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px;
}
.stat .k { font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted-2); }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 4px; }
.stat.good .v { color: var(--green); }
.stat.bad .v { color: var(--red); }

.insights { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; }
.insights li { color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.insights strong { color: var(--text); font-weight: 700; }

/* ---- Footer ---- */
.site-footer {
  text-align: center; padding: 40px 20px 56px; border-top: 1px solid var(--line-soft);
  color: var(--muted-2); font-size: 13px;
}
.site-footer img { opacity: .85; margin-bottom: 12px; }
.site-footer .fine { font-size: 11.5px; margin-top: 4px; }
.footer-link { color: var(--gold); font-weight: 700; font-size: 13px; }
.footer-link:hover { text-decoration: underline; }

/* ---- Responsive ---- */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; }
  .hero-art { order: -1; }
  .hero h1 { font-size: 40px; }
  .layout { grid-template-columns: 1fr; }
  .inputs { position: static; }
}
@media (max-width: 560px) {
  .site-header { padding: 12px 18px; }
  .top-nav { gap: 14px; font-size: 13px; }
  .top-nav a:not(.pill) { display: none; }
  .hero, .layout { padding-left: 18px; padding-right: 18px; }
  .hero h1 { font-size: 32px; }
}

/* ---- Button sizes / variants ---- */
.btn.xs { font-size: 11.5px; padding: 6px 10px; border-radius: 8px; }
.btn.sm { font-size: 12.5px; padding: 7px 12px; }
.btn.wide { width: 100%; padding: 12px; font-size: 14px; margin-top: 6px; }
.btn.danger { background: linear-gradient(135deg, #ff8a8f, var(--red)); color: #2a0708; }
.btn.ghost.xs { padding: 5px 10px; }

/* ---- Login ---- */
.login {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: flex-start;
  padding: 24px 24px 24px clamp(24px, 8vw, 130px);
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(245,166,35,.14), transparent 60%),
    radial-gradient(700px 480px at 10% 110%, rgba(76,141,255,.12), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; text-align: left;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 20px; padding: 34px 30px; box-shadow: var(--shadow);
}
.login-card img { margin-bottom: 14px; }
.login-card h1 { margin: 6px 0 2px; font-size: 24px; }
.login-tag { margin: 0 0 22px; color: var(--muted); font-size: 13px; letter-spacing: .4px; }
.login-card form label { display: block; text-align: left; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.login-card form input {
  display: block; width: 100%; margin-top: 5px; padding: 11px 12px; box-sizing: border-box;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px; color: var(--text);
  font-family: var(--font); font-size: 14px; font-weight: 600;
}
.login-card form input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,166,35,.15); }
.login-err { color: var(--red); font-size: 12.5px; font-weight: 700; min-height: 16px; text-align: left; }
.login-note { margin: 18px 0 0; font-size: 11px; color: var(--muted-2); line-height: 1.5; }

/* ---- User bar ---- */
.userbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 34px; background: var(--bg-2); border-bottom: 1px solid var(--line-soft);
}
.ub-left, .ub-right { display: flex; align-items: center; gap: 8px; }
.ub-client { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .5px;
  text-transform: uppercase; color: var(--muted-2); font-weight: 700; }
#clientSelect {
  font-family: var(--font); font-weight: 700; font-size: 13px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  min-width: 180px; text-transform: none; letter-spacing: 0;
}
#clientSelect:focus { outline: none; border-color: var(--gold); }
.ub-user { display: flex; flex-direction: column; line-height: 1.15; text-align: right; margin-right: 4px; }
.ub-user b { font-size: 13px; }
.ub-tenant { font-size: 11px; color: var(--muted-2); }

/* ---- Overlay / admin ---- */
.overlay {
  position: fixed; inset: 0; z-index: 90; display: none; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow: auto; background: rgba(3,8,16,.72); backdrop-filter: blur(4px);
}
.overlay-card {
  width: 100%; max-width: 960px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.overlay-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.overlay-head h2 { margin: 0; font-size: 20px; }
.overlay-actions { display: flex; gap: 8px; }
.admin-sub { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }
.admin-form {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 12px; margin-bottom: 6px;
}
.admin-form input, .admin-form select {
  font-family: var(--font); font-size: 13px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.admin-form input { width: 130px; }
.admin-form input:focus, .admin-form select:focus { outline: none; border-color: var(--gold); }
.au-active { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.au-msg { font-size: 12.5px; font-weight: 700; min-height: 16px; margin: 6px 2px; }
.au-msg.ok { color: var(--green); }
.au-msg.err { color: var(--red); }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); }
.admin-table th { color: var(--muted-2); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.admin-table td { color: var(--text); }
.role { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.role-admin { background: rgba(245,166,35,.18); color: var(--gold); }
.role-user { background: rgba(76,141,255,.16); color: var(--blue); }
.au-actions { display: flex; gap: 6px; white-space: nowrap; }

/* ---- Version history overlay ---- */
.hist-card { max-width: 520px; }
.hist-client { color: var(--gold); font-weight: 700; font-size: 13.5px; margin: 10px 0 14px; }
.hist-list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.hist-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 14px;
}
.hist-meta { display: flex; flex-direction: column; gap: 2px; }
.hist-meta b { color: var(--text); font-size: 13.5px; }
.hist-meta span { color: var(--muted-2); font-size: 11.5px; }
.hist-empty { color: var(--muted); font-size: 13.5px; }

/* ---- Custodial panel ---- */
.panel.custodial { border-color: rgba(34,197,139,.3); }
.tax-breakdown {
  display: grid; grid-template-columns: 1fr; gap: 0; margin: 6px 0 16px;
  border: 1px solid var(--line-soft); border-radius: 12px; overflow: hidden;
}
.txrow { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px;
  font-size: 13.5px; color: var(--muted); border-bottom: 1px solid var(--line-soft); }
.txrow:last-child { border-bottom: none; }
.txrow b { color: var(--text); font-weight: 700; }
.txrow.r b { color: var(--red); }
.txrow.g { background: rgba(34,197,139,.08); }
.txrow.g span, .txrow.g b { color: var(--green); font-weight: 800; }
.cust-narrative { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 4px 0 0; }
.cust-narrative strong { color: var(--text); }

/* Lump-sum pay down simulation */
.paydown-box {
  border: 1px solid rgba(245,166,35,.4); border-radius: 12px; overflow: hidden;
  margin: 0 0 16px; background: rgba(245,166,35,.05);
}
.pd-head {
  padding: 10px 14px; font-size: 13px; font-weight: 800; color: var(--gold);
  background: rgba(245,166,35,.12); border-bottom: 1px solid rgba(245,166,35,.3);
}
.paydown-box .txrow { border-bottom-color: rgba(245,166,35,.16); }
.pd-arrow { color: var(--gold); font-weight: 800; padding: 0 4px; }
.pd-val { color: var(--muted); font-weight: 600; }
.pd-val b { color: var(--gold); }
.pd-note {
  padding: 10px 14px; font-size: 12.5px; color: var(--muted); line-height: 1.5;
  border-top: 1px solid rgba(245,166,35,.3);
}
.pd-note b { color: var(--green); }

/* ---- Print ---- */
@media print {
  body { background: #fff; color: #111; }
  .userbar, .overlay, .site-header, .top-nav, .cta, .hero-art, .inputs .btn-row, .disclaimer { display: none !important; }
  .hero { padding: 10px 0; }
  .layout { grid-template-columns: 1fr; }
  .panel, .card, .inputs { box-shadow: none; border-color: #ccc; }
  .panel, .card { break-inside: avoid; }
}
