:root {
  --navy: #1f3864; --navy-2: #2c4a7e; --ink: #1b1f24; --muted: #5b6573; --line: #dde3ec; --bg: #f5f7fb; --card: #ffffff;
  --accent: #2a78d6; --accent-soft: #d9e7fb; --grey: #c3cad5; --ok: #2f7d4f; --warn-bg: #fdecea; --warn: #9c0006;
  --setup: #1f3864; --monthly: #7fa7dd; --perf: #f0a43a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; }
h1 { font-size: 22px; margin: 0 0 6px; } h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: var(--navy); color: #fff; }
.brand { font-weight: 700; letter-spacing: .3px; }
.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; }
.link.dark { color: var(--muted); font-size: 12px; margin-top: 4px; }
.who { color: #cdd8ec; font-size: 12px; margin-right: 10px; }
#step-1, #step-2, #step-3 { display: grid; gap: 10px; }
input[type=email], input[type=text], input[inputmode=numeric] { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
input[inputmode=numeric] { font-size: 22px; letter-spacing: 6px; text-align: center; }
main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 48px; }
.title-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.status { font-size: 12px; color: var(--muted); white-space: nowrap; padding-top: 6px; }
.banner { background: #fff4ce; border: 1px solid #f0d58a; padding: 8px 12px; border-radius: 6px; }
.caveat { background: #fff4ce; border: 1px solid #f0d58a; border-left: 6px solid #e0a800; padding: 10px 14px; border-radius: 6px; margin: 12px 0; color: #5a4300; }
.caveat.small { font-size: 12px; margin: 12px 0 0; }

.gate { display: grid; place-items: center; min-height: calc(100vh - 48px); padding: 16px; }
.gate-card { background: var(--card); padding: 28px; border-radius: 10px; width: min(380px, 100%); box-shadow: 0 6px 24px rgba(20,40,80,.08); display: grid; gap: 10px; }
.gate-card h1 { font-size: 20px; }
input[type=password], select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.primary { background: var(--navy); color: #fff; border: 0; border-radius: 6px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.primary:disabled { opacity: .6; }
.error { color: var(--warn); margin: 0; }
.alert { background: #fde7e9; border: 1px solid #f1a7ae; border-left: 6px solid #c42b1c; color: #7a1a10; padding: 10px 14px; border-radius: 6px; margin: 10px 0; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.kpi { background: var(--card); border-radius: 10px; padding: 14px 16px; border: 1px solid var(--line); }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.main { background: var(--navy); color: #fff; border-color: var(--navy); }
.kpi.main .label, .kpi.main .sub { color: #cdd8ec; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #f8fafd; border-radius: 999px; padding: 5px 11px; cursor: pointer; font: inherit; font-size: 12px; color: var(--navy); }
.chip:hover { background: var(--accent-soft); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.grid th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); padding: 8px 10px; vertical-align: bottom; }
.grid td { border-bottom: 1px solid var(--line); padding: 7px 10px; vertical-align: middle; }
.grid tfoot td, .grid tr.total td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.grid.compact td, .grid.compact th { padding: 6px 8px; }
.num { text-align: right; white-space: nowrap; } .center { text-align: center; }
.country { font-weight: 600; white-space: nowrap; }
.country small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; white-space: normal; max-width: 220px; }
.full.over { color: var(--warn); font-style: italic; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fffbea; }
.step { width: 34px; height: 32px; border: 0; background: #fff3c4; font-size: 18px; font-weight: 700; color: var(--navy); cursor: pointer; }
.step:hover:not(:disabled) { background: #ffe58a; }
.step:disabled { color: #b8bfca; cursor: not-allowed; background: #f3f4f6; }
.stepper output { min-width: 78px; text-align: center; font-weight: 700; font-size: 15px; color: #0b4fb3; }

.bar { position: relative; height: 12px; background: #eef1f6; border-radius: 6px; min-width: 140px; }
.bar-max { position: absolute; left: 0; top: 0; bottom: 0; background: var(--grey); border-radius: 6px; }
.bar-target { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 6px; transition: width .2s; }
.bar-label { font-size: 12px; color: var(--muted); }
.legend { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.sw { display: inline-block; width: 12px; height: 10px; border-radius: 3px; margin: 0 4px 0 10px; vertical-align: middle; }
.sw-target { background: var(--accent); } .sw-max { background: var(--grey); } .sw-setup { background: var(--setup); } .sw-monthly { background: var(--monthly); } .sw-perf { background: var(--perf); }
.red-note { color: var(--warn); font-style: italic; margin-left: 10px; }

.pay-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.pay-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin: 4px 0 14px; }
.pay-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin: 0; }
.pay-controls small { font-size: 11px; }
.pay-controls .pct-in { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; color: var(--ink, inherit); font-weight: 600; }
.pay-controls input, .pay-controls select { width: 76px; padding: 6px 8px; font-size: 15px; font-weight: 600; margin: 0; }
.pay-controls select { width: auto; }
.pay-controls output { min-width: 40px; display: inline-block; padding: 6px 0; }
.pay-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; border-left: 5px solid var(--setup); }
.pay-card.monthly { border-left-color: var(--monthly); } .pay-card.perf { border-left-color: var(--perf); }
.pay-card .t { font-size: 12px; color: var(--muted); } .pay-card .v { font-size: 20px; font-weight: 700; margin: 2px 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); }

#scenarios th.use, #scenarios td.use-cell { text-align: right; }
.scen-btn { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; }
#scenarios .yours { background: #f2f7ff; }
#scenarios tr.sub td { color: var(--muted); }
.notes ul { margin: 0; padding-left: 18px; color: var(--muted); }
.notes li { margin: 4px 0; }

/* admin */
.admin-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0 16px; }
details.mkt { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; }
details.mkt > summary { cursor: pointer; padding: 10px 12px; font-weight: 600; }
details.mkt .table-wrap { padding: 0 8px 8px; }
.src { color: var(--muted); font-size: 12px; }
.diff-bad { background: #fff2cc; }
code { font-size: 12px; background: #f1f3f7; padding: 1px 4px; border-radius: 4px; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two, .pay-cards { grid-template-columns: 1fr; }
}
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } main { padding: 12px; } }

/* admin page: visibly different from the client calculator */
body.admin { --admin: #b42318; }
body.admin .top { background: #23272e; border-bottom: 3px solid var(--admin); }
body.admin .gate { background: #2f343c; }
body.admin .gate-card { border-top: 6px solid var(--admin); }
body.admin .gate-card .primary { background: var(--admin); border-color: var(--admin); }
.admin-pill { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: #b42318; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; vertical-align: 1px; }
.admin-tag { margin: 0; color: #b42318; font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; }
#pay-chart { max-width: 880px; }

/* loading screen while a sign-in link or saved session opens the page (avoids flashing the sign-in form) */
.boot { display: none; place-items: center; align-content: center; gap: 14px; min-height: calc(100vh - 48px); color: var(--muted); }
html.booting .boot { display: grid; }
html.booting #gate, html.booting #app { display: none !important; }
body.admin .boot { background: #2f343c; color: #d6dbe3; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
body.admin .spinner { border-color: #4a515c; border-top-color: #b42318; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
