/* ==========================================================================
   Nusan design system
   Deep ink navy + signal amber. Built for clarity on dense data screens.
   ========================================================================== */

:root {
  /* Brand */
  --ink:        #0A1020;
  --ink-2:      #131C33;
  --ink-3:      #1E2A47;
  --ink-soft:   #2C3A5C;

  --amber:      #F0A32B;
  --amber-dim:  #C8811A;
  --amber-soft: #FDF3E2;

  --teal:       #10796B;
  --teal-soft:  #E4F3F0;
  --red:        #C4372B;
  --red-soft:   #FBECEA;
  --violet:     #5B4BC4;
  --violet-soft:#EEEBFB;

  /* Neutrals */
  --paper:      #FBFAF7;
  --white:      #FFFFFF;
  --line:       #E6E3DC;
  --line-2:     #D5D1C7;
  --muted:      #6B6659;
  --muted-2:    #918B7C;
  --text:       #1A1814;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Space + shape */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(10,16,32,.06), 0 1px 3px rgba(10,16,32,.04);
  --shadow:    0 2px 4px rgba(10,16,32,.04), 0 8px 24px rgba(10,16,32,.07);
  --shadow-lg: 0 4px 8px rgba(10,16,32,.05), 0 24px 56px rgba(10,16,32,.12);

  --maxw: 1180px;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
h1,h2,h3,h4,h5 { margin: 0 0 .5em; line-height: 1.2; font-weight: 660; letter-spacing: -.02em; color: var(--ink); }
h1 { font-size: clamp(2rem, 4.4vw, 3.3rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.5rem, 2.8vw, 2.15rem); letter-spacing: -.028em; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }
p  { margin: 0 0 1em; }
a  { color: var(--ink); text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--amber); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
small { font-size: .8125rem; }
code, pre, .mono { font-family: var(--font-mono); font-size: .875em; }
::selection { background: var(--amber); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 24px; }
.wrap-sm { max-width: 760px; }
.wrap-xs { max-width: 480px; }
.section { padding-block: clamp(48px, 7vw, 96px); }
.section-tight { padding-block: clamp(32px, 4vw, 56px); }

.row { display: flex; gap: 16px; align-items: center; }
.row-between { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.spacer { flex: 1; }

.center { text-align: center; }
.muted { color: var(--muted); }
.tiny  { font-size: .78rem; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: var(--stack, 16px); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--ink);
  --btn-fg: var(--white);
  --btn-bd: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  font: inherit; font-weight: 560; font-size: .94rem; line-height: 1;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-bd); border-radius: var(--r);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, opacity .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-primary { --btn-bg: var(--amber); --btn-fg: var(--ink); --btn-bd: var(--amber); font-weight: 640; }
.btn-primary:hover { --btn-bg: #F7AE3C; }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--ink); --btn-bd: var(--line-2); }
.btn-ghost:hover { --btn-bg: var(--white); }
.btn-quiet { --btn-bg: transparent; --btn-fg: var(--muted); --btn-bd: transparent; padding-inline: 10px; }
.btn-quiet:hover { --btn-fg: var(--ink); --btn-bg: rgba(10,16,32,.04); box-shadow: none; transform: none; }
.btn-danger { --btn-bg: var(--red); --btn-fg: #fff; --btn-bd: var(--red); }
.btn-sm { padding: 7px 13px; font-size: .84rem; border-radius: var(--r-sm); }
.btn-lg { padding: 15px 28px; font-size: 1.02rem; }
.btn-block { display: flex; width: 100%; }

/* --------------------------------------------------------------------------
   Cards + surfaces
   -------------------------------------------------------------------------- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-hd {
  padding: 18px 24px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-hd h3, .card-hd h2 { margin: 0; font-size: 1.02rem; }
.card-bd { padding: 24px; }
.card-ft { padding: 16px 24px; border-top: 1px solid var(--line); background: var(--paper); }
.card-hover { transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.card-hover:hover { border-color: var(--line-2); box-shadow: var(--shadow); transform: translateY(-2px); }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.panel-amber { background: var(--amber-soft); border-color: #F0DDB8; }
.panel-teal  { background: var(--teal-soft);  border-color: #C4E4DE; }
.panel-red   { background: var(--red-soft);   border-color: #F1CFCB; }

/* --------------------------------------------------------------------------
   Badges + pills
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; letter-spacing: .01em;
  background: rgba(10,16,32,.06); color: var(--ink); border: 1px solid transparent;
  white-space: nowrap;
}
.badge-amber { background: var(--amber-soft); color: #8A5A05; border-color: #F0DDB8; }
.badge-teal  { background: var(--teal-soft);  color: #0A5449; border-color: #C4E4DE; }
.badge-red   { background: var(--red-soft);   color: #8E2419; border-color: #F1CFCB; }
.badge-violet{ background: var(--violet-soft);color: #3B2E93; border-color: #D9D3F6; }
.badge-ink   { background: var(--ink); color: #fff; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.eyebrow {
  display: inline-block;
  font-size: .74rem; font-weight: 660; letter-spacing: .13em; text-transform: uppercase;
  color: var(--amber-dim); margin-bottom: 14px;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { margin-bottom: 18px; }
.field > label, .label {
  display: block; margin-bottom: 6px;
  font-size: .84rem; font-weight: 600; color: var(--ink);
}
.input, .select, .textarea {
  width: 100%; padding: 11px 13px;
  font: inherit; font-size: .94rem; color: var(--text);
  background: var(--white);
  border: 1px solid var(--line-2); border-radius: var(--r);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(240,163,43,.18);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B6659' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 10px;
}
.hint { margin-top: 5px; font-size: .79rem; color: var(--muted); line-height: 1.45; }
.field-error .input, .field-error .select, .field-error .textarea { border-color: var(--red); }
.error-text { margin-top: 5px; font-size: .79rem; color: var(--red); font-weight: 520; }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input[type="checkbox"] { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--amber); flex-shrink: 0; }
.check span { font-size: .9rem; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form .input { flex: 1 1 240px; width: auto; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th {
  text-align: left; padding: 11px 14px;
  font-size: .74rem; font-weight: 640; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap;
  background: var(--paper);
}
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: rgba(240,163,43,.05); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Stats
   -------------------------------------------------------------------------- */
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.stat-label { font-size: .76rem; font-weight: 620; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 2.1rem; font-weight: 680; letter-spacing: -.03em; color: var(--ink); line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.delta { font-size: .82rem; font-weight: 620; }
.delta-up   { color: var(--teal); }
.delta-down { color: var(--red); }

/* Score ring */
.ring { --size: 132px; --val: 0; --ring-col: var(--amber);
  width: var(--size); height: var(--size); border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--ring-col) calc(var(--val) * 1%), var(--line) 0);
}
.ring::after { content: ""; position: absolute; inset: 11px; background: var(--white); border-radius: 50%; }
.ring > * { position: relative; z-index: 1; text-align: center; }
.ring-val { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.ring-cap { font-size: .68rem; font-weight: 620; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

/* Horizontal bar */
.bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--amber); transition: width .5s ease; }
.bar-teal > i { background: var(--teal); }
.bar-red  > i { background: var(--red); }

/* --------------------------------------------------------------------------
   Alerts / flash
   -------------------------------------------------------------------------- */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 16px; border-radius: var(--r); margin-bottom: 20px;
  font-size: .9rem; border: 1px solid;
  background: var(--panel-bg, var(--paper)); border-color: var(--line);
}
.alert-ok    { background: var(--teal-soft);  border-color: #C4E4DE; color: #0A5449; }
.alert-error { background: var(--red-soft);   border-color: #F1CFCB; color: #8E2419; }
.alert-warn  { background: var(--amber-soft); border-color: #F0DDB8; color: #8A5A05; }
.alert-info  { background: #EAF1FB; border-color: #CBDCF3; color: #1B4A85; }
.alert b { font-weight: 640; }

/* --------------------------------------------------------------------------
   Marketing: nav + hero
   -------------------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251,250,247,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 28px; height: 66px; }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a { font-size: .92rem; font-weight: 520; color: var(--muted); text-decoration: none; }
.nav-links a:hover { color: var(--ink); }

.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 700; font-size: 1.16rem; letter-spacing: -.03em; color: var(--ink); }
.logo:hover { text-decoration: none; }
.logo-mark { width: 26px; height: 26px; flex-shrink: 0; }

.hero { background: var(--ink); color: #EAE7E0; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(760px 380px at 78% -8%, rgba(240,163,43,.20), transparent 62%),
    radial-gradient(560px 320px at 8% 108%, rgba(91,75,196,.20), transparent 60%);
  pointer-events: none;
}
.hero .wrap { position: relative; z-index: 1; }
.hero h1 { color: #fff; }
.hero p.lede { font-size: clamp(1.03rem, 1.7vw, 1.22rem); color: #B9B4A9; max-width: 620px; }
.hero .eyebrow { color: var(--amber); }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; padding-block: clamp(56px, 8vw, 104px); }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; gap: 40px; } }

.dark-card {
  background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.11);
  border-radius: var(--r-lg); padding: 22px; backdrop-filter: blur(8px);
}
.dark-card .stat-label { color: #8F897C; }
.dark-card .stat-value { color: #fff; }

.logos { display: flex; flex-wrap: wrap; gap: 10px 26px; align-items: center; opacity: .75; }
.logos span { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #8F897C; }

/* Feature list */
.feat { display: flex; gap: 14px; align-items: flex-start; }
.feat-ico {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--amber-soft); color: var(--amber-dim);
  border: 1px solid #F0DDB8;
}
.feat h3 { font-size: 1.02rem; margin-bottom: 4px; }
.feat p { font-size: .92rem; color: var(--muted); margin: 0; }

/* Steps */
.steps { counter-reset: step; }
.step { display: flex; gap: 18px; padding-block: 22px; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step::before {
  counter-increment: step; content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono); font-size: .82rem; font-weight: 600;
  color: var(--amber-dim); padding-top: 3px; flex-shrink: 0;
}

/* Pricing */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(258px, 1fr)); gap: 20px; align-items: start; }
.price {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 26px; position: relative;
  display: flex; flex-direction: column; height: 100%;
}
.price-featured { border-color: var(--ink); border-width: 2px; box-shadow: var(--shadow-lg); }
.price-flag {
  position: absolute; top: -11px; left: 26px;
  background: var(--ink); color: #fff;
  font-size: .69rem; font-weight: 660; letter-spacing: .09em; text-transform: uppercase;
  padding: 4px 11px; border-radius: 999px;
}
.price-name { font-size: .78rem; font-weight: 660; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.price-amt { font-size: 2.7rem; font-weight: 700; letter-spacing: -.04em; color: var(--ink); line-height: 1; margin: 12px 0 2px; }
.price-amt sup { font-size: 1.15rem; font-weight: 600; vertical-align: super; margin-right: 1px; }
.price-per { font-size: .85rem; color: var(--muted); }
.price-desc { font-size: .89rem; color: var(--muted); margin: 12px 0 18px; min-height: 42px; }
.price ul { list-style: none; padding: 0; margin: 0 0 22px; font-size: .9rem; }
.price li { padding: 7px 0 7px 25px; position: relative; }
.price li::before {
  content: ""; position: absolute; left: 0; top: 13px;
  width: 13px; height: 7px; border-left: 2px solid var(--teal); border-bottom: 2px solid var(--teal);
  transform: rotate(-45deg);
}
.price li.off { color: var(--muted-2); }
.price li.off::before { border-color: var(--line-2); }
.price .btn { margin-top: auto; }

/* FAQ */
details.faq { border-bottom: 1px solid var(--line); padding: 4px 0; }
details.faq summary {
  cursor: pointer; padding: 16px 0; font-weight: 600; font-size: 1rem;
  list-style: none; display: flex; justify-content: space-between; gap: 16px; align-items: center;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; font-size: 1.3rem; font-weight: 400; color: var(--amber-dim); flex-shrink: 0; line-height: 1; }
details.faq[open] summary::after { content: "\2212"; }
details.faq p { color: var(--muted); font-size: .94rem; padding-bottom: 16px; margin: 0; max-width: 68ch; }

/* Footer */
.footer { background: var(--ink); color: #8F897C; padding-block: 56px 32px; font-size: .88rem; }
.footer a { color: #B9B4A9; text-decoration: none; }
.footer a:hover { color: var(--amber); }
.footer h4 { color: #fff; font-size: .77rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 12px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 36px; }
@media (max-width: 780px) { .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; } }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); margin-top: 40px; padding-top: 22px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer ul { list-style: none; padding: 0; margin: 0; }
.footer li { padding: 4px 0; }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--ink); color: #B9B4A9; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .logo { color: #fff; padding: 4px 10px 20px; }
.side-sec { font-size: .68rem; font-weight: 660; letter-spacing: .12em; text-transform: uppercase; color: #6A6459; padding: 16px 10px 6px; }
.side a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: #B9B4A9; text-decoration: none; font-size: .9rem; font-weight: 520;
  transition: background .12s ease, color .12s ease;
}
.side a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side a.on { background: var(--amber); color: var(--ink); font-weight: 620; }
.side a.on svg { color: var(--ink); }
.side svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; border-bottom: 1px solid var(--line); background: var(--white);
  display: flex; align-items: center; gap: 16px; padding-inline: 26px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.1rem; margin: 0; letter-spacing: -.02em; }
.content { padding: 26px; flex: 1; }
.content > .page-hd { margin-bottom: 24px; }
.page-hd h2 { margin-bottom: 4px; }
.page-hd p { color: var(--muted); margin: 0; font-size: .94rem; }

/* --------------------------------------------------------------------------
   Mobile navigation

   Both shells use a hidden checkbox as the toggle rather than JavaScript, so
   the menu works before app.js loads and under script-src 'self'. The checkbox
   resets on navigation, which closes the menu for free.
   -------------------------------------------------------------------------- */

.nav-toggle, .side-toggle { position: absolute; opacity: 0; pointer-events: none; }

/* Hamburger — three bars drawn from one element via ::before/::after. */
.burger {
  display: none;
  width: 42px; height: 42px; flex-shrink: 0;
  align-items: center; justify-content: center;
  border-radius: var(--r-sm); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.burger:hover { background: rgba(10,16,32,.06); }
.burger-bars, .burger-bars::before, .burger-bars::after {
  display: block; width: 20px; height: 2px; border-radius: 2px;
  background: var(--ink); transition: transform .2s ease, opacity .2s ease;
}
.burger-bars { position: relative; }
.burger-bars::before, .burger-bars::after { content: ""; position: absolute; left: 0; }
.burger-bars::before { top: -6px; }
.burger-bars::after  { top: 6px; }
.burger-dark .burger-bars,
.burger-dark .burger-bars::before,
.burger-dark .burger-bars::after { background: var(--ink); }

/* Bars morph into a cross while open. */
.nav-toggle:checked ~ .burger .burger-bars { background: transparent; }
.nav-toggle:checked ~ .burger .burger-bars::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle:checked ~ .burger .burger-bars::after  { transform: translateY(-6px) rotate(-45deg); }

.nav-toggle:focus-visible ~ .burger,
.side-toggle:focus-visible ~ .main .burger { outline: 2px solid var(--amber); outline-offset: 2px; }

.nav-links { margin-left: auto; }

/* ---- Marketing nav ------------------------------------------------------ */
@media (max-width: 820px) {
  .nav-inner { gap: 12px; }
  .burger { display: inline-flex; margin-left: auto; }

  .nav-links {
    position: absolute; left: 0; right: 0; top: 100%;
    display: none; flex-direction: column; align-items: stretch; gap: 0;
    margin: 0; padding: 8px 16px 16px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    max-height: calc(100vh - 66px);
    overflow-y: auto;
  }
  .nav-toggle:checked ~ .nav-links { display: flex; }

  /* Generous tap targets — 44px minimum. */
  .nav-links > a {
    padding: 13px 8px;
    font-size: 1rem; font-weight: 540; color: var(--ink);
    border-bottom: 1px solid var(--line);
  }
  .nav-links > a:last-child { border-bottom: 0; }
  .nav-links > a.btn {
    margin-top: 12px; padding: 14px 20px;
    justify-content: center; border-bottom: 0; font-size: 1rem;
  }
}

/* ---- App shell ---------------------------------------------------------- */
.side-top { display: flex; align-items: center; justify-content: space-between; }
.side-close { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }

  .topbar { padding-inline: 12px; gap: 8px; }
  .topbar .burger { display: inline-flex; }
  .topbar h1 { font-size: 1rem; }

  /* Off-canvas drawer rather than a wrapped row of links. */
  .side {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    width: min(280px, 84vw); height: 100dvh;
    padding: 16px 14px;
    transform: translateX(-100%);
    transition: transform .24s ease;
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(10,16,32,.28);
  }
  .side-toggle:checked ~ .side { transform: translateX(0); }

  .side-scrim {
    display: none; position: fixed; inset: 0; z-index: 55;
    background: rgba(10,16,32,.5);
    -webkit-tap-highlight-color: transparent;
  }
  .side-toggle:checked ~ .side-scrim { display: block; }

  .side-close {
    display: grid; place-items: center;
    width: 38px; height: 38px; flex-shrink: 0;
    font-size: 1.6rem; line-height: 1; color: #B9B4A9;
    border-radius: var(--r-sm); cursor: pointer;
  }
  .side-close:hover { background: rgba(255,255,255,.08); color: #fff; }

  /* Section labels stay — they are what makes a 9-item list navigable. */
  .side-sec { display: block; }
  .side a, .side-signout { padding: 11px 12px; font-size: .95rem; }

  .content { padding: 16px; }

  /* Stop the drawer scrolling the page behind it. */
  .side-toggle:checked ~ .main { overflow: hidden; }
}

/* Dense data screens need horizontal room on a phone. */
@media (max-width: 640px) {
  .page-hd h2 { font-size: 1.5rem; }
  .grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.7rem; }
  .card, .card-bd { padding: 18px; }
  .card-hd { padding: 14px 18px; }
  .ring { --size: 104px; }
  .row-between { gap: 12px; }
  .price-grid { grid-template-columns: 1fr; }
  .btn-lg { padding: 14px 22px; font-size: .98rem; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .input, .inline-form .select { flex: 1 1 auto; width: 100%; }
  .hero-grid { padding-block: 40px; }
  .tbl th, .tbl td { padding: 10px 12px; }
}

/* --------------------------------------------------------------------------
   Answer / result rendering
   -------------------------------------------------------------------------- */
.answer {
  font-size: .91rem; line-height: 1.65; color: var(--text);
  background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--amber);
  border-radius: var(--r); padding: 15px 17px; white-space: pre-wrap; word-break: break-word;
  max-height: 330px; overflow-y: auto;
}
.answer mark { background: var(--amber); color: var(--ink); padding: 1px 3px; border-radius: 3px; font-weight: 620; }
.answer mark.rival { background: var(--violet-soft); color: #3B2E93; box-shadow: inset 0 0 0 1px #D9D3F6; }

.engine-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; }
.engine-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-openai     { background: #10A37F; }
.dot-anthropic  { background: #D97757; }
.dot-google     { background: #4285F4; }
.dot-perplexity { background: #20808D; }

.cite-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 5px; }
.cite-list a { font-size: .82rem; color: var(--muted); text-decoration: none; display: inline-flex; gap: 6px; align-items: baseline; }
.cite-list a:hover { color: var(--ink); text-decoration: underline; }
.cite-list .n { font-family: var(--font-mono); font-size: .72rem; color: var(--amber-dim); flex-shrink: 0; }

/* Empty state */
.empty { text-align: center; padding: 52px 24px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 42ch; margin-inline: auto; font-size: .93rem; }

/* Loading */
.spinner {
  width: 17px; height: 17px; border: 2px solid rgba(10,16,32,.18);
  border-top-color: var(--ink); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; flex-shrink: 0;
}
.btn-primary .spinner { border-color: rgba(10,16,32,.25); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

.progress { height: 5px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--amber); transition: width .4s ease; border-radius: 999px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* Print */
@media print {
  .side, .topbar, .nav, .footer, .btn, .no-print { display: none !important; }
  .app { grid-template-columns: 1fr; }
  body { background: #fff; }
  .card { border-color: #ccc; break-inside: avoid; }
}

/* Sign-out is a POST form button styled to match the sidebar links. */
.side-signout {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: #B9B4A9;
  font: inherit; font-size: .9rem; font-weight: 520; text-align: left;
  cursor: pointer; transition: background .12s ease, color .12s ease;
}
.side-signout:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-signout svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }
