/* ==========================================================================
   MarineCalc ToolKit v2 — design system
   Light navy / white style: soft grey canvas, white cards, deep navy hero
   surfaces, light-blue tints, pill navigation.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #EEF1F6;
  --surface: #FFFFFF;
  --surface-2: #F5F7FB;
  --surface-3: #EAF0F9;
  --ink: #0F1B2D;
  --ink-2: #33415C;
  --muted: #6B778C;
  --faint: #9AA6B8;
  --line: #E3E8F0;
  --line-strong: #CFD8E6;

  --navy: #0E2240;
  --navy-2: #1A3560;
  --navy-3: #24477D;
  --on-navy: #FFFFFF;
  --on-navy-muted: rgba(255, 255, 255, .68);
  --sky: #9EC0F5;            /* accent text on navy */
  --blue: #2F63D0;           /* links / focus */
  --blue-soft: #DCE7FB;      /* icon circles */
  --tint-1: #E6EEFC;
  --tint-2: #CADBF6;

  --ok: #15803D;   --ok-bg: #DCFCE7;
  --warn: #B45309; --warn-bg: #FEF3C7;
  --bad: #B91C1C;  --bad-bg: #FEE2E2;
  --info: #1D4ED8; --info-bg: #DBEAFE;

  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 33, 64, .05);
  --shadow: 0 1px 2px rgba(16, 33, 64, .04), 0 10px 28px rgba(16, 33, 64, .07);
  --shadow-lg: 0 18px 40px rgba(14, 34, 64, .18);

  --font: 'Plus Jakarta Sans', 'Zain', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --nav-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0A1322;
  --surface: #121F35;
  --surface-2: #17263F;
  --surface-3: #1B2D4B;
  --ink: #E9EFF8;
  --ink-2: #C3CEDF;
  --muted: #93A3BD;
  --faint: #6F7F98;
  --line: #22324F;
  --line-strong: #2E4166;
  --navy: #17325C;
  --navy-2: #1F3F72;
  --navy-3: #2A5291;
  --blue: #7FA8F2;
  --blue-soft: #1F3559;
  --tint-1: #172B4A;
  --tint-2: #1E3860;
  --ok: #4ADE80;   --ok-bg: rgba(74, 222, 128, .12);
  --warn: #FBBF24; --warn-bg: rgba(251, 191, 36, .12);
  --bad: #F87171;  --bad-bg: rgba(248, 113, 113, .12);
  --info: #93C5FD; --info-bg: rgba(147, 197, 253, .12);
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 28px rgba(0, 0, 0, .25);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0A1322; --surface: #121F35; --surface-2: #17263F; --surface-3: #1B2D4B;
    --ink: #E9EFF8; --ink-2: #C3CEDF; --muted: #93A3BD; --faint: #6F7F98;
    --line: #22324F; --line-strong: #2E4166;
    --navy: #17325C; --navy-2: #1F3F72; --navy-3: #2A5291;
    --blue: #7FA8F2; --blue-soft: #1F3559; --tint-1: #172B4A; --tint-2: #1E3860;
    --ok: #4ADE80; --ok-bg: rgba(74, 222, 128, .12);
    --warn: #FBBF24; --warn-bg: rgba(251, 191, 36, .12);
    --bad: #F87171; --bad-bg: rgba(248, 113, 113, .12);
    --info: #93C5FD; --info-bg: rgba(147, 197, 253, .12);
    --shadow-sm: none; --shadow: 0 10px 28px rgba(0, 0, 0, .25); --shadow-lg: 0 18px 40px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; color: var(--ink); }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
.i { width: 20px; height: 20px; flex: none; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 26px; height: 26px; }
.i-xl { width: 34px; height: 34px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--navy); color: #fff; padding: 8px 14px; border-radius: 999px; z-index: 2000; }
.skip-link:focus { left: 12px; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 16px; }
.container.wide { max-width: 1040px; }
.page { padding: 20px 0 calc(var(--nav-h) + 48px + var(--safe-b)); }
.layout-auth .page, .layout-bare .page { padding-bottom: 40px; }

.hero-top {
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(110, 160, 240, .22) 0%, transparent 55%),
    linear-gradient(160deg, var(--navy-2) 0%, var(--navy) 62%);
  color: var(--on-navy);
  padding: calc(14px + env(safe-area-inset-top, 0px)) 0 52px;
}
.hero-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.hero-bar-end { display: flex; align-items: center; gap: 10px; }
.hero-title { color: #fff; font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.hero-title span { color: var(--sky); }
.hero-sub { color: var(--on-navy-muted); margin-top: 8px; font-size: 14px; max-width: 46ch; }
.sheet {
  position: relative;
  margin-top: -28px;
  background: var(--bg);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 18px 0 calc(var(--nav-h) + 48px + var(--safe-b));
  min-height: 60vh;
}
.brand-mark { width: 42px; height: 42px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.brand-mark img { width: 34px; height: 34px; }

.stack > * + * { margin-top: 14px; }
.stack-lg > * + * { margin-top: 22px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 380px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; } .mt-4 { margin-top: 32px; }
.mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  position: relative;
}
.card-flat { box-shadow: none; border: 1px solid var(--line); }
.card-pad-lg { padding: 22px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

.card-navy {
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(120, 165, 240, .25) 0%, transparent 60%),
    linear-gradient(150deg, var(--navy-2), var(--navy));
  color: #fff;
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.card-navy .muted, .card-navy .card-sub { color: var(--on-navy-muted); }
.card-navy h2, .card-navy h3, .card-navy .card-title { color: #fff; }
.card-navy .accent { color: var(--sky); }

.card-tint {
  background: linear-gradient(135deg, var(--tint-1) 0%, var(--tint-2) 100%);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative;
}

.watermark { position: absolute; right: -14px; bottom: -18px; width: 140px; height: 140px; opacity: .12; color: #fff; pointer-events: none; }
.watermark .i { width: 100%; height: 100%; stroke-width: 1.2; }

/* Section headings */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 26px 2px 12px; }
.section-head h2 { font-size: 16px; font-weight: 700; }
.section-head a { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.card-navy .eyebrow { color: var(--on-navy-muted); }

/* ---------- Greeting header (home) ---------- */
.greet { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 6px; }
.greet .hello { color: var(--muted); font-size: 14px; margin-top: 14px; }
.greet .name { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }

/* ---------- Avatars ---------- */
.avatar {
  width: 52px; height: 52px; border-radius: 50%; overflow: hidden; flex: none;
  background: var(--blue-soft); color: var(--navy); display: grid; place-items: center;
  font-weight: 700; font-size: 17px; box-shadow: 0 0 0 3px var(--surface), var(--shadow);
  text-decoration: none !important;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 40px; height: 40px; font-size: 14px; box-shadow: none; }
.avatar-lg { width: 96px; height: 96px; font-size: 30px; }
.avatar.on-dark { box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .14); color: #fff; }
.avatar-stack { display: flex; }
.avatar-stack > * { margin-left: -10px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack > *:first-child { margin-left: 0; }

/* ---------- Buttons ---------- */
.circle-btn {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  text-decoration: none !important; transition: transform .15s ease, background .15s ease;
}
.circle-btn:active { transform: scale(.94); }
.circle-btn.on-dark { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .16); box-shadow: none; }
.circle-btn.on-dark:hover { background: rgba(255, 255, 255, .2); }
.circle-btn.white { background: #fff; color: var(--navy); border: 0; }
.circle-btn.sm { width: 36px; height: 36px; }
.circle-btn.sm .i { width: 18px; height: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px; text-decoration: none !important; white-space: nowrap;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 8px 18px rgba(14, 34, 64, .22); }
.btn-primary:hover { background: var(--navy-2); }
.btn-soft { background: var(--blue-soft); border-color: transparent; color: var(--navy); }
:root[data-theme="dark"] .btn-soft { color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--blue); }
.btn-danger { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.btn-block { width: 100%; }
.btn-sm { height: 38px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 56px; font-size: 16px; }

/* Large navy call-to-action pill with white arrow circle (reference "Book Consultation") */
.cta {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; min-height: 68px; padding: 12px 12px 12px 22px;
  border-radius: 999px; border: 0;
  background: linear-gradient(150deg, var(--navy-2), var(--navy));
  color: #fff; text-align: left; text-decoration: none !important;
  box-shadow: var(--shadow-lg);
  transition: transform .15s ease, filter .15s ease;
}
.cta:hover { filter: brightness(1.08); }
.cta:active { transform: scale(.99); }
.cta strong { display: block; font-size: 15px; font-weight: 700; color: #fff; }
.cta small { display: block; font-size: 12.5px; color: var(--on-navy-muted); margin-top: 1px; }
.cta .circle-btn { width: 46px; height: 46px; background: #fff; color: var(--navy); border: 0; }
.cta.locked { background: var(--surface); color: var(--ink); border: 1px dashed var(--line-strong); box-shadow: none; }
.cta.locked strong { color: var(--ink); }
.cta.locked small { color: var(--muted); }
.cta.locked .circle-btn { background: var(--blue-soft); color: var(--navy); }
.cta[disabled] { opacity: .6; pointer-events: none; }

/* ---------- Forms ---------- */
.field { display: block; }
.field + .field { margin-top: 14px; }
.grid-2 > .field + .field, .grid-3 > .field + .field { margin-top: 0; }
.field-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.input-wrap {
  min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input-wrap:focus-within { border-color: var(--blue); background: var(--surface); box-shadow: 0 0 0 4px rgba(47, 99, 208, .12); }
.input-wrap input, .input-wrap select {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  font-size: 16px; font-weight: 600; color: var(--ink);
}
.input-wrap input::placeholder, .input, textarea::placeholder { color: var(--faint); font-weight: 500; }
.input-wrap .unit { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.input-wrap .i { color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 52px; padding: 13px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 15px; color: var(--ink); outline: 0;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--blue); background: var(--surface); box-shadow: 0 0 0 4px rgba(47, 99, 208, .12); }
select.input, .input-wrap select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B778C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="date"], input[type="datetime-local"] { min-height: 50px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); margin: 1px 0 0; flex: none; }
input[type="range"] { width: 100%; accent-color: var(--navy); }

/* Segmented control (mode toggles) */
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-sm); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button, .segmented a {
  flex: 1; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent;
  font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; text-decoration: none !important;
  display: inline-flex; align-items: center; justify-content: center;
}
.segmented .active, .segmented [aria-pressed="true"], .segmented [aria-selected="true"] { background: var(--navy); color: #fff; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none !important;
}
.chip.active, .chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }

/* Search pill (hero) */
.search-row { display: flex; gap: 10px; margin-top: 20px; }
.search-pill {
  flex: 1; display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 18px;
  background: #fff; border-radius: 999px; color: #0F1B2D;
}
.search-pill .i { color: #6B778C; }
.search-pill input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; color: #0F1B2D; }
.search-pill input::placeholder { color: #9AA6B8; }
.circle-btn.white.lg { width: 50px; height: 50px; }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge .i { width: 14px; height: 14px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--surface-3); color: var(--ink-2); }
.card-navy .badge-neutral { background: rgba(255, 255, 255, .14); color: #fff; }
.card-navy .badge-ok { background: rgba(74, 222, 128, .18); color: #86EFAC; }
.card-navy .badge-warn { background: rgba(251, 191, 36, .18); color: #FCD34D; }
.card-navy .badge-bad { background: rgba(248, 113, 113, .2); color: #FCA5A5; }
.card-navy .badge-info { background: rgba(147, 197, 253, .18); color: #BFDBFE; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 13px 15px; border-radius: var(--r-md); font-size: 14px; font-weight: 500; margin-bottom: 14px; }
.alert .i { margin-top: 1px; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-info { background: var(--info-bg); color: var(--info); }

.usage-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); box-shadow: var(--shadow-sm);
}
.usage-pill .i { width: 16px; height: 16px; color: var(--blue); }
.usage-pill.pro .i { color: #C58B16; }
.usage-pill a { font-weight: 700; }

/* ---------- Stats (Health Overview style) ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); }
.stat-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.stat-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stat { padding: 2px 12px; min-width: 0; }
.stat:first-child { padding-left: 0; }
.stat + .stat { border-left: 1px solid rgba(14, 34, 64, .1); }
:root[data-theme="dark"] .stat + .stat { border-left-color: rgba(255, 255, 255, .08); }
.card-navy .stat + .stat { border-left-color: rgba(255, 255, 255, .14); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.card-navy .stat-label { color: var(--on-navy-muted); }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card-navy .stat-value { color: #fff; }
.stat-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.stat-foot .i { width: 16px; height: 16px; color: var(--blue); }
@media (max-width: 560px) {
  .stat-row.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; }
  .stat-row.cols-4 .stat:nth-child(3) { border-left: 0; padding-left: 0; }
}

/* Result hero (big number on navy) */
.result-hero .label { font-size: 13px; font-weight: 600; color: var(--on-navy-muted); }
.result-hero .value { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; font-size: 46px; font-weight: 700; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; color: #fff; }
.result-hero .value small { font-size: 18px; font-weight: 600; color: var(--sky); letter-spacing: 0; }
.result-hero .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* Key-value list */
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv li:last-child { border-bottom: 0; padding-bottom: 0; }
.kv li:first-child { padding-top: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.kv .v.total { font-size: 17px; }

/* ---------- Quick access (circle icon grid) ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-item { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--ink); text-decoration: none !important; line-height: 1.25; }
.quick-ico { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--navy); transition: transform .15s ease; }
:root[data-theme="dark"] .quick-ico { color: var(--ink); }
.quick-item:first-child .quick-ico, .quick-ico.featured { background: var(--blue-soft); border-color: transparent; }
.quick-item:active .quick-ico { transform: scale(.94); }

/* Feature icons row (detail screen) */
.feature-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.feature-row div { font-size: 11.5px; font-weight: 600; color: var(--ink-2); line-height: 1.3; }
.feature-row .i { display: block; margin: 0 auto 8px; color: var(--navy); width: 24px; height: 24px; }
:root[data-theme="dark"] .feature-row .i { color: var(--blue); }

/* ---------- Tiles (image-card style) ---------- */
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 150px; padding: 16px; border-radius: var(--r-lg); overflow: hidden;
  background:
    radial-gradient(120% 100% at 90% 0%, rgba(160, 196, 248, .55) 0%, transparent 55%),
    linear-gradient(155deg, #5B84C8 0%, #2C4F8A 55%, #1B3561 100%);
  color: #fff; text-decoration: none !important; box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.tile:active { transform: scale(.985); }
.tile.dark { background: radial-gradient(120% 100% at 90% 0%, rgba(120, 165, 240, .3) 0%, transparent 55%), linear-gradient(155deg, var(--navy-3), var(--navy)); }
.tile.light { background: radial-gradient(120% 100% at 90% 0%, rgba(255, 255, 255, .7) 0%, transparent 55%), linear-gradient(155deg, #A9C3EC, #6F95D1); }
.tile.big { min-height: 196px; }
.tile .tile-ico { position: absolute; top: 14px; left: 16px; width: 44px; height: 44px; border-radius: 14px; background: rgba(255, 255, 255, .18); display: grid; place-items: center; backdrop-filter: blur(4px); }
.tile .tile-art { position: absolute; right: -10px; top: -6px; width: 128px; height: 128px; color: rgba(255, 255, 255, .16); }
.tile.big .tile-art { width: 170px; height: 170px; right: -14px; top: -14px; }
.tile .tile-art .i { width: 100%; height: 100%; stroke-width: 1.1; }
.tile-title { font-size: 15px; font-weight: 700; position: relative; padding-right: 48px; line-height: 1.25; }
.tile-sub { font-size: 12.5px; color: rgba(255, 255, 255, .78); position: relative; padding-right: 48px; margin-top: 2px; }
.tile .circle-btn { position: absolute; right: 14px; bottom: 14px; width: 38px; height: 38px; background: #fff; color: var(--navy); border: 0; }

/* Banner (talk to a specialist) */
.banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--tint-1), var(--tint-2)); text-decoration: none !important; color: var(--ink);
}
.banner .title { font-size: 14px; font-weight: 700; color: var(--blue); }
:root[data-theme="dark"] .banner .title { color: var(--sky); }
.banner .sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.banner .circle-btn { width: 38px; height: 38px; background: var(--surface); border: 0; color: var(--navy); }
:root[data-theme="dark"] .banner .circle-btn { color: var(--ink); }

/* ---------- Tools grid ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .container.wide .tool-grid { grid-template-columns: repeat(4, 1fr); } }
.tool-card {
  display: flex; flex-direction: column; gap: 12px; padding: 16px; min-height: 148px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
  color: var(--ink); text-decoration: none !important; transition: transform .15s ease, box-shadow .15s ease;
}
.tool-card:hover { box-shadow: var(--shadow-lg); }
.tool-card:active { transform: scale(.98); }
.tool-card .ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-soft); color: var(--navy); }
:root[data-theme="dark"] .tool-card .ico { color: var(--ink); }
.tool-card .name { font-size: 14.5px; font-weight: 700; line-height: 1.25; }
.tool-card .desc { font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.tool-card .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.tool-card .foot .i { width: 16px; height: 16px; color: var(--blue); }

/* ---------- List rows ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--shadow); color: var(--ink); text-decoration: none !important; position: relative;
}
.list-item .ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-soft); color: var(--navy); flex: none; }
:root[data-theme="dark"] .list-item .ico { color: var(--ink); }
.list-item .title { font-size: 14.5px; font-weight: 700; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.list-item .meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.list-item .desc { font-size: 13px; color: var(--ink-2); margin-top: 4px; overflow-wrap: anywhere; }
.list-item .end { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }

/* Settings-style menu list */
.menu-list { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.menu-list a, .menu-list button, .menu-list .menu-row {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; background: transparent; border: 0;
  border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none !important; font-size: 14.5px; font-weight: 600; text-align: left;
}
.menu-list > *:last-child { border-bottom: 0; }
.menu-list .ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--navy); flex: none; }
:root[data-theme="dark"] .menu-list .ico { color: var(--ink); }
.menu-list .chev { margin-left: auto; color: var(--faint); }
.menu-list .danger { color: var(--bad); }
.menu-list .danger .ico { background: var(--bad-bg); color: var(--bad); }

/* Dropdown menu */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 6px; display: none;
}
.dropdown.open .dropdown-menu { display: block; }
/* The card holding an open menu is lifted above the cards after it. */
.menu-host { z-index: 60 !important; }
.list-item:has(.dropdown.open), .card:has(.dropdown.open), .post:has(.dropdown.open), .reply:has(.dropdown.open) { z-index: 60; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: transparent;
  border-radius: 10px; color: var(--ink); font-size: 14px; font-weight: 600; text-align: left; text-decoration: none !important;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); }
.dropdown-menu .danger { color: var(--bad); }
.dropdown-menu form { margin: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-md); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Lock / empty states ---------- */
.lock-card { text-align: center; padding: 30px 22px; }
.lock-card .lock-ico { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center; background: var(--blue-soft); color: var(--navy); }
:root[data-theme="dark"] .lock-card .lock-ico { color: var(--ink); }
.lock-card h2 { font-size: 20px; }
.lock-card p { color: var(--muted); margin: 8px auto 20px; max-width: 34ch; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .i { width: 40px; height: 40px; color: var(--faint); margin: 0 auto 10px; }

/* ---------- Bottom navigation (floating pill) ---------- */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + var(--safe-b)); z-index: 100;
  width: calc(100% - 32px); max-width: 420px; height: 64px; padding: 7px;
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  background: var(--surface); border-radius: 999px; box-shadow: 0 10px 30px rgba(14, 34, 64, .16); border: 1px solid var(--line);
}
.nav-item {
  height: 50px; min-width: 50px; padding: 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); text-decoration: none !important; font-size: 13.5px; font-weight: 700;
  transition: background .2s ease, color .2s ease, flex .2s ease;
}
.nav-item span { display: none; }
.nav-item.active { background: var(--navy); color: #fff; padding: 0 18px; }
:root[data-theme="dark"] .nav-item.active { background: var(--navy-3); }
.nav-item.active span { display: inline; }
.nav-item:not(.active):hover { color: var(--ink); background: var(--surface-2); }

/* ---------- Toast & offline bar ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 24px + var(--safe-b));
  z-index: 300; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 999px;
  background: var(--navy); color: #fff; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px; animation: toast-in .25s ease;
}
.toast.error { background: var(--bad); }
.toast.success { background: #166534; }
.layout-auth .toast { bottom: 24px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.offline-bar { position: sticky; top: 0; z-index: 500; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; background: var(--warn-bg); color: var(--warn); font-size: 12.5px; font-weight: 600; text-align: center; }
.offline-bar .i { width: 16px; height: 16px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 900; display: grid; place-items: end center; background: rgba(8, 18, 34, .55); backdrop-filter: blur(3px); padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { width: 100%; max-width: 460px; background: var(--surface); border-radius: var(--r-xl); padding: 22px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; }
@media (min-width: 600px) { .modal { place-items: center; } }

/* ---------- Auth ---------- */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; }
.auth-top {
  background: radial-gradient(120% 90% at 100% 0%, rgba(110, 160, 240, .22) 0%, transparent 55%), linear-gradient(160deg, var(--navy-2), var(--navy));
  color: #fff; padding: calc(36px + env(safe-area-inset-top, 0px)) 16px 64px; text-align: center;
}
.auth-top .brand-mark { width: 76px; height: 76px; margin: 0 auto 16px; }
.auth-top .brand-mark img { width: 62px; height: 62px; }
.auth-top h1 { color: #fff; font-size: 26px; font-weight: 700; }
.auth-top h1 span { color: var(--sky); }
.auth-top p { color: var(--on-navy-muted); margin-top: 6px; font-size: 14px; }
.auth-body { flex: 1; margin-top: -32px; padding: 0 16px 40px; }
.auth-card { max-width: 440px; margin: 0 auto; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Progress & steps ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--navy); transition: width .3s ease; }
.progress.ok > span { background: var(--ok); } .progress.warn > span { background: var(--warn); } .progress.bad > span { background: var(--bad); }
.steps { display: flex; gap: 6px; }
.steps span { flex: 1; height: 5px; border-radius: 999px; background: var(--line-strong); transition: background .2s ease; }
.steps span.done { background: var(--navy); }
:root[data-theme="dark"] .steps span.done { background: var(--blue); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 86%; padding: 12px 15px; border-radius: 20px; font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.bubble.ai { background: var(--surface); box-shadow: var(--shadow); border-bottom-left-radius: 6px; align-self: flex-start; }
.bubble.me { background: var(--navy); color: #fff; border-bottom-right-radius: 6px; align-self: flex-end; }
.bubble.err { background: var(--bad-bg); color: var(--bad); align-self: flex-start; }
.bubble ul, .bubble ol { margin: 6px 0; padding-left: 20px; }
.bubble p + p { margin-top: 8px; }
.bubble code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.composer { position: sticky; bottom: calc(var(--nav-h) + 24px + var(--safe-b)); display: flex; gap: 10px; align-items: flex-end; padding: 8px; background: var(--surface); border-radius: 28px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); margin-top: 16px; }
.composer textarea { flex: 1; border: 0; outline: 0; background: transparent; resize: none; min-height: 44px; max-height: 140px; padding: 11px 10px; font-size: 15px; }

/* ---------- Quiz ---------- */
.option {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; margin-top: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 14.5px; font-weight: 600; text-align: left; color: var(--ink); transition: border-color .15s, background .15s;
}
.option:hover:not(:disabled) { border-color: var(--blue); }
.option .key { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 13px; flex: none; }
.option.correct { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.option:disabled { cursor: default; }

/* ---------- Map ---------- */
.map-box { position: relative; height: 340px; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); background: var(--surface-3); }
#map { width: 100%; height: 100%; z-index: 1; }
.map-tools { position: absolute; right: 10px; top: 10px; z-index: 5; display: flex; flex-direction: column; gap: 8px; }
.leaflet-container { font-family: var(--font); }

/* ---------- Forum ---------- */
.post { position: relative; background: var(--surface); …rest unchanged…
.reply { position: relative; background: var(--surface); …rest unchanged…
.post-head { display: flex; align-items: center; gap: 10px; }
.post-title { font-size: 16px; font-weight: 700; margin-top: 12px; overflow-wrap: anywhere; }
.post-body { font-size: 14px; color: var(--ink-2); margin-top: 6px; white-space: pre-line; overflow-wrap: anywhere; }
.post-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }

/* ---------- Pricing ---------- */
.price { display: flex; align-items: baseline; gap: 4px; }
.price strong { font-size: 52px; font-weight: 800; letter-spacing: -.04em; line-height: 1; color: #fff; }
.price span { color: var(--on-navy-muted); font-weight: 600; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: 14.5px; }
.check-list .i { color: var(--ok); margin-top: 1px; }
.card-navy .check-list .i { color: #86EFAC; }

/* ---------- Ads ---------- */
.ad-slot { border-radius: var(--r-lg); overflow: hidden; background: var(--surface); border: 1px dashed var(--line-strong); padding: 8px; min-height: 60px; }

/* ---------- Helpers for status colouring from JS ---------- */
.tone-ok { color: var(--ok) !important; }
.tone-warn { color: var(--warn) !important; }
.tone-bad { color: var(--bad) !important; }
.tone-info { color: var(--info) !important; }

/* ---------- Animations ---------- */
@media (prefers-reduced-motion: no-preference) {
  .fade-in { animation: fade-up .35s ease backwards; }
  .fade-in:nth-child(2) { animation-delay: .04s; } .fade-in:nth-child(3) { animation-delay: .08s; }
  .fade-in:nth-child(4) { animation-delay: .12s; } .fade-in:nth-child(5) { animation-delay: .16s; }
}
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  .hero-title { font-size: 34px; }
  .hero-top { padding-bottom: 60px; }
  .tool-grid.lg-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .bottom-nav, .toast, .offline-bar, .no-print, .hero-bar, .skip-link { display: none !important; }
  .hero-top { background: #fff !important; color: var(--ink); padding: 0 0 12px; }
  .hero-title, .hero-title span { color: var(--ink) !important; }
  .hero-sub { color: var(--muted); }
  .sheet { margin: 0; padding: 0; }
  .card, .list-item { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
}
