/* ==========================================================================
   NCRDA PWA — stylesheet
   Tokens carried over from the ncrda.org site so the app and the website
   read as one thing. Layout is rebuilt for a phone held in one hand.
   ========================================================================== */

:root{
  /* Brand — identical to the website */
  --navy-900:#0A1A2A;
  --navy-800:#0F2338;
  --navy-700:#14304D;
  --navy-600:#1D3E5E;
  --navy-500:#2C5480;
  --navy-300:#7C97B5;
  --gold:#C9A142;
  --gold-light:#E7CD82;
  --orange:#FF5A36;
  --orange-dark:#D63F1E;
  --cream:#F6F2E9;
  --white:#FFFFFF;
  --ink:#152A42;
  --gray:#5C6673;
  --line:rgba(20,48,77,0.12);

  /* App surfaces */
  --bg:var(--cream);
  --surface:var(--white);
  --surface-sunk:#EFEAE0;
  --text:var(--ink);
  --text-dim:var(--gray);
  --border:var(--line);
  --chrome:var(--navy-900);
  --chrome-text:#E8EEF4;
  --shadow:0 1px 2px rgba(10,26,42,.06), 0 8px 24px -16px rgba(10,26,42,.5);

  --tap:48px;                 /* minimum touch target */
  --pad:20px;
  --radius:14px;
  --radius-sm:9px;
}

[data-theme="dark"]{
  --bg:#08141F;
  --surface:#0F2338;
  --surface-sunk:#0A1A2A;
  --text:#E8EEF4;
  --text-dim:#93A7BC;
  --border:rgba(232,238,244,.14);
  --chrome:#050E17;
  --chrome-text:#E8EEF4;
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 8px 24px -16px rgba(0,0,0,.9);
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}

html{
  scroll-behavior:smooth;
  /* Stops iOS zooming the whole app when a driver double-taps a field */
  -webkit-text-size-adjust:100%;
}

body{
  margin:0;
  font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.55;
  -webkit-font-smoothing:antialiased;
  overscroll-behavior-y:none;
}

h1,h2,h3,h4{
  font-family:'Oswald',sans-serif;
  font-weight:600;
  letter-spacing:.005em;
  line-height:1.1;
  margin:0;
}
h1{font-size:1.55rem;}
h2{font-size:1.2rem;}
h3{font-size:1.02rem;}

p{margin:0 0 .9em;}
p:last-child{margin-bottom:0;}
a{color:inherit;}
button{font-family:inherit;}

.num{
  font-family:'IBM Plex Mono',ui-monospace,monospace;
  font-variant-numeric:tabular-nums;
  letter-spacing:-.01em;
}

:focus-visible{
  outline:3px solid var(--orange);
  outline-offset:2px;
  border-radius:4px;
}

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

/* --------------------------------------------------------------------------
   APP FRAME
   -------------------------------------------------------------------------- */
.app{
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  max-width:640px;
  margin:0 auto;
  background:var(--bg);
}

/* --- top bar --- */
.topbar{
  position:sticky;
  top:0;
  z-index:60;
  background:var(--chrome);
  color:var(--chrome-text);
  padding:calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display:flex;
  align-items:center;
  gap:12px;
  min-height:56px;
  border-bottom:1px solid rgba(255,255,255,.07);
}
.topbar__mark{
  width:32px;height:32px;flex:0 0 32px;
  border-radius:6px;
  object-fit:contain;
}
.topbar__title{
  font-family:'Oswald',sans-serif;
  font-size:.98rem;
  font-weight:600;
  letter-spacing:.02em;
  line-height:1.15;
  flex:1;
  min-width:0;
}
.topbar__title span{
  display:block;
  font-family:'IBM Plex Mono',monospace;
  font-size:.6rem;
  letter-spacing:.14em;
  color:var(--gold);
  font-weight:500;
  margin-top:2px;
}
.iconbtn{
  width:var(--tap);height:var(--tap);
  flex:0 0 var(--tap);
  display:grid;place-items:center;
  background:transparent;
  border:none;
  color:inherit;
  cursor:pointer;
  border-radius:10px;
  margin:-8px -10px -8px 0;
}
.iconbtn:active{background:rgba(255,255,255,.1);}
.iconbtn svg{width:22px;height:22px;}

/* --- scrolling view area --- */
.view{
  flex:1;
  padding:var(--pad) 16px calc(96px + env(safe-area-inset-bottom));
}
.view[hidden]{display:none;}

/* --- bottom tabs --- */
.tabs{
  position:fixed;
  bottom:0;left:0;right:0;
  z-index:70;
  max-width:640px;
  margin:0 auto;
  display:grid;
  grid-template-columns:repeat(5,1fr);
  background:var(--chrome);
  padding-bottom:env(safe-area-inset-bottom);
  border-top:1px solid rgba(255,255,255,.07);
}
.tab{
  appearance:none;
  background:none;
  border:none;
  color:rgba(232,238,244,.62);
  padding:9px 2px 10px;
  min-height:var(--tap);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:3px;
  cursor:pointer;
  font-size:.63rem;
  font-weight:600;
  letter-spacing:.02em;
  position:relative;
}
.tab svg{width:21px;height:21px;stroke-width:1.7;}
.tab[aria-selected="true"]{color:var(--gold-light);}
.tab[aria-selected="true"]::before{
  content:"";
  position:absolute;
  top:0;left:50%;
  transform:translateX(-50%);
  width:26px;height:2px;
  background:var(--gold);
}
.tab__dot{
  position:absolute;
  top:6px;
  right:calc(50% - 18px);
  width:8px;height:8px;
  border-radius:50%;
  background:var(--orange);
  border:2px solid var(--chrome);
}

/* --------------------------------------------------------------------------
   BUILDING BLOCKS
   -------------------------------------------------------------------------- */
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:18px;
  box-shadow:var(--shadow);
  margin-bottom:14px;
}
.card--flat{box-shadow:none;background:var(--surface-sunk);}

.section-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  margin:26px 0 12px;
}
.section-head:first-child{margin-top:0;}
.section-head h2{flex:1;}
.section-head a,.section-head button.link{
  font-size:.78rem;
  font-weight:600;
  color:var(--orange-dark);
  background:none;border:none;padding:0;cursor:pointer;
}
[data-theme="dark"] .section-head a,
[data-theme="dark"] .section-head button.link{color:var(--gold-light);}

.lede{
  color:var(--text-dim);
  font-size:.93rem;
  margin-bottom:18px;
}

.btn{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  width:100%;
  min-height:var(--tap);
  padding:13px 18px;
  border-radius:var(--radius-sm);
  border:1px solid transparent;
  font-size:.94rem;
  font-weight:650;
  letter-spacing:.01em;
  cursor:pointer;
  text-align:center;
  transition:transform .08s ease, background .15s ease;
}
.btn:active{transform:scale(.985);}
.btn svg{width:18px;height:18px;flex:0 0 18px;}
.btn--primary{background:var(--orange);color:#fff;}
.btn--primary:active{background:var(--orange-dark);}
.btn--navy{background:var(--navy-700);color:#fff;}
[data-theme="dark"] .btn--navy{background:var(--navy-600);}
.btn--ghost{
  background:transparent;
  color:var(--text);
  border-color:var(--border);
}
.btn--danger{background:transparent;color:var(--orange-dark);border-color:var(--border);}
[data-theme="dark"] .btn--danger{color:#FF8567;}
.btn + .btn{margin-top:10px;}
.btn[disabled]{opacity:.45;pointer-events:none;}

.btn-row{display:flex;gap:10px;}
.btn-row .btn{margin-top:0;}

/* --------------------------------------------------------------------------
   HOME
   -------------------------------------------------------------------------- */
.hero{
  background:linear-gradient(160deg,var(--navy-800),var(--navy-900));
  color:#fff;
  border-radius:var(--radius);
  padding:24px 20px;
  margin-bottom:16px;
  position:relative;
  overflow:hidden;
}
.hero::after{
  content:"";
  position:absolute;
  right:-40px;bottom:-60px;
  width:180px;height:180px;
  border-radius:50%;
  background:radial-gradient(circle,rgba(201,161,66,.22),transparent 70%);
  pointer-events:none;
}
.hero h1{font-size:1.5rem;margin-bottom:10px;position:relative;}
.hero p{color:#B9C9D8;font-size:.92rem;position:relative;}
.hero .btn{margin-top:16px;position:relative;}

.quickgrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin-bottom:6px;
}
.quick{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px 14px;
  text-align:left;
  cursor:pointer;
  min-height:104px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  gap:10px;
  color:var(--text);
  box-shadow:var(--shadow);
}
.quick:active{background:var(--surface-sunk);}
.quick svg{width:24px;height:24px;color:var(--orange);stroke-width:1.7;}
.quick strong{
  font-family:'Oswald',sans-serif;
  font-weight:600;
  font-size:.95rem;
  line-height:1.15;
  display:block;
}
.quick small{color:var(--text-dim);font-size:.74rem;line-height:1.35;display:block;margin-top:3px;}

/* --------------------------------------------------------------------------
   FORMS
   -------------------------------------------------------------------------- */
.field{margin-bottom:16px;}
.field:last-child{margin-bottom:0;}
.field > label,
.fieldset > legend{
  display:block;
  font-size:.86rem;
  font-weight:650;
  margin-bottom:6px;
  color:var(--text);
  padding:0;
}
.hint{
  display:block;
  font-size:.76rem;
  color:var(--text-dim);
  margin-bottom:7px;
  line-height:1.4;
}
p.hint{margin-bottom:0;}

input[type="text"],input[type="email"],input[type="number"],
input[type="date"],input[type="tel"],select,textarea{
  width:100%;
  min-height:var(--tap);
  padding:12px 14px;
  font-family:inherit;
  /* 16px stops iOS Safari zooming in when the field is focused */
  font-size:16px;
  color:var(--text);
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  appearance:none;
}
textarea{min-height:120px;resize:vertical;line-height:1.5;}
select{
  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 d='M1 1l5 5 5-5' stroke='%235C6673' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 15px center;
  padding-right:38px;
}
input:focus,select:focus,textarea:focus{
  outline:none;
  border-color:var(--orange);
  box-shadow:0 0 0 3px rgba(255,90,54,.16);
}
input.money{padding-left:30px;}
.money-wrap{position:relative;}
.money-wrap::before{
  content:"$";
  position:absolute;
  left:14px;top:50%;
  transform:translateY(-50%);
  color:var(--text-dim);
  font-family:'IBM Plex Mono',monospace;
  pointer-events:none;
}

.fieldset{border:none;padding:0;margin:0 0 16px;}
.choices{display:flex;flex-wrap:wrap;gap:8px;}
.choice{position:relative;}
.choice input{
  position:absolute;opacity:0;width:100%;height:100%;
  top:0;left:0;margin:0;cursor:pointer;
}
.choice span{
  display:flex;
  align-items:center;
  padding:10px 15px;
  min-height:44px;
  border:1.5px solid var(--border);
  border-radius:22px;
  font-size:.87rem;
  font-weight:600;
  background:var(--surface-sunk);
  color:var(--text-dim);
  cursor:pointer;
  transition:background .12s ease, color .12s ease, border-color .12s ease;
}

/* Selected: a hard swap of background and text, not a tint.
   Light mode goes to deep navy; dark mode goes to gold, because navy on a
   navy surface was nearly impossible to read. */
.choice input:checked + span{
  background:var(--navy-900);
  border-color:var(--navy-900);
  color:#fff;
  font-weight:700;
}
[data-theme="dark"] .choice input:checked + span{
  background:var(--gold);
  border-color:var(--gold-light);
  color:var(--navy-900);
}

/* A checkmark so selection never depends on color alone. */
.choice input:checked + span::before{
  content:"";
  width:6px;
  height:11px;
  border:solid currentColor;
  border-width:0 2.5px 2.5px 0;
  transform:rotate(43deg);
  margin:-3px 10px 0 1px;
  flex:0 0 auto;
}

.choice input:focus-visible + span{outline:3px solid var(--orange);outline-offset:2px;}

.check{
  display:flex;
  gap:12px;
  align-items:flex-start;
  padding:12px 0;
  cursor:pointer;
  min-height:var(--tap);
}
.check input{
  width:22px;height:22px;flex:0 0 22px;
  margin:2px 0 0;
  accent-color:var(--orange);
}
.check span{font-size:.87rem;line-height:1.45;}

.split{display:grid;grid-template-columns:1fr 1fr;gap:12px;}
@media (max-width:359px){.split{grid-template-columns:1fr;}}

/* --------------------------------------------------------------------------
   CALCULATOR RESULT — the signature block
   -------------------------------------------------------------------------- */
.result{
  background:linear-gradient(165deg,var(--navy-800),var(--navy-900));
  color:#fff;
  border-radius:var(--radius);
  padding:22px 20px;
  margin-bottom:16px;
}
.result__label{
  font-family:'IBM Plex Mono',monospace;
  font-size:.72rem;
  letter-spacing:.03em;
  color:var(--gold);
  margin-bottom:4px;
}
.result__big{
  font-family:'Oswald',sans-serif;
  font-size:3.4rem;
  font-weight:600;
  line-height:1;
  letter-spacing:-.01em;
  display:flex;
  align-items:baseline;
  gap:8px;
}
.result__big small{
  font-family:'Inter',sans-serif;
  font-size:.86rem;
  font-weight:600;
  color:#B9C9D8;
  letter-spacing:0;
}
.result__note{
  color:#B9C9D8;
  font-size:.83rem;
  margin-top:10px;
  line-height:1.45;
}

/* gross → net gap bar */
.gap{margin:20px 0 4px;}
.gap__track{
  height:34px;
  border-radius:6px;
  overflow:hidden;
  display:flex;
  background:rgba(255,255,255,.09);
}
.gap__net{background:var(--gold);}
.gap__cost{background:var(--orange);}
.gap__key{
  display:flex;
  justify-content:space-between;
  gap:14px;
  margin-top:9px;
  font-size:.76rem;
  color:#B9C9D8;
}
.gap__key b{
  display:block;
  font-family:'IBM Plex Mono',monospace;
  font-size:.95rem;
  color:#fff;
  font-weight:600;
}
.gap__key i{
  display:inline-block;
  width:9px;height:9px;
  border-radius:2px;
  margin-right:5px;
}

.breakdown{list-style:none;margin:0;padding:0;}
.breakdown li{
  display:flex;
  justify-content:space-between;
  gap:16px;
  padding:11px 0;
  border-bottom:1px solid var(--border);
  font-size:.89rem;
}
.breakdown li:last-child{border-bottom:none;}
.breakdown li.total{
  font-weight:700;
  border-top:2px solid var(--text);
  border-bottom:none;
  margin-top:4px;
  padding-top:12px;
}
.breakdown li span:first-child{color:var(--text-dim);}
.breakdown li.total span:first-child{color:var(--text);}
.breakdown li span:last-child{
  font-family:'IBM Plex Mono',monospace;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

.accordion{
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--surface);
  margin-bottom:12px;
  overflow:hidden;
}
.accordion > summary{
  padding:15px 18px;
  min-height:var(--tap);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  cursor:pointer;
  font-family:'Oswald',sans-serif;
  font-weight:600;
  font-size:1rem;
  list-style:none;
}
.accordion > summary::-webkit-details-marker{display:none;}
.accordion > summary::after{
  content:"";
  width:9px;height:9px;
  border-right:2px solid var(--text-dim);
  border-bottom:2px solid var(--text-dim);
  transform:rotate(45deg);
  transition:transform .18s ease;
  flex:0 0 auto;
  margin-top:-4px;
}
.accordion[open] > summary::after{transform:rotate(-135deg);margin-top:3px;}
.accordion__body{padding:2px 18px 18px;}

/* --------------------------------------------------------------------------
   ALERTS
   -------------------------------------------------------------------------- */
.alert{
  background:var(--surface);
  border:1px solid var(--border);
  border-left:4px solid var(--navy-500);
  border-radius:var(--radius);
  padding:16px 18px;
  margin-bottom:12px;
  box-shadow:var(--shadow);
}
.alert--urgent{border-left-color:var(--orange);}
.alert--win{border-left-color:var(--gold);}
.alert__meta{
  display:flex;
  align-items:center;
  gap:9px;
  margin-bottom:7px;
  font-family:'IBM Plex Mono',monospace;
  font-size:.66rem;
  letter-spacing:.1em;
  color:var(--text-dim);
}
.pill{
  padding:3px 8px;
  border-radius:4px;
  background:var(--surface-sunk);
  color:var(--text-dim);
  font-weight:600;
}
.pill--urgent{background:var(--orange);color:#fff;}
.pill--win{background:var(--gold);color:var(--navy-900);}
.alert h3{margin-bottom:7px;}
.alert__body{font-size:.9rem;color:var(--text-dim);white-space:pre-line;}
.alert .btn{margin-top:14px;}
.alert__unread{
  width:8px;height:8px;border-radius:50%;
  background:var(--orange);
  margin-left:auto;
}

/* --------------------------------------------------------------------------
   SAVED ITEMS / LISTS
   -------------------------------------------------------------------------- */
.item{
  display:flex;
  align-items:center;
  gap:14px;
  width:100%;
  text-align:left;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px 16px;
  margin-bottom:10px;
  cursor:pointer;
  color:var(--text);
  min-height:var(--tap);
}
.item:active{background:var(--surface-sunk);}
.item__main{flex:1;min-width:0;}
.item__main strong{display:block;font-size:.92rem;font-weight:650;}
.item__main small{
  display:block;
  color:var(--text-dim);
  font-size:.76rem;
  font-family:'IBM Plex Mono',monospace;
  margin-top:2px;
}
.item__badge{
  font-size:.68rem;
  font-weight:700;
  padding:4px 9px;
  border-radius:20px;
  background:var(--surface-sunk);
  color:var(--text-dim);
  white-space:nowrap;
}
.item__badge--sent{background:rgba(201,161,66,.2);color:#8A6D1E;}
[data-theme="dark"] .item__badge--sent{background:rgba(201,161,66,.22);color:var(--gold-light);}

.empty{
  text-align:center;
  padding:34px 20px;
  color:var(--text-dim);
}
.empty svg{width:34px;height:34px;margin-bottom:12px;color:var(--navy-300);stroke-width:1.5;}
.empty p{font-size:.88rem;margin-bottom:16px;}

/* --------------------------------------------------------------------------
   NOTICES
   -------------------------------------------------------------------------- */
.notice{
  border-radius:var(--radius-sm);
  padding:14px 16px;
  font-size:.83rem;
  line-height:1.5;
  margin-bottom:14px;
  border:1px solid;
}
.notice strong{display:block;margin-bottom:3px;font-weight:700;}
.notice--privacy{
  background:rgba(44,84,128,.09);
  border-color:rgba(44,84,128,.28);
  color:var(--text);
}
.notice--legal{
  background:rgba(201,161,66,.12);
  border-color:rgba(201,161,66,.4);
  color:var(--text);
}
.notice--warn{
  background:rgba(255,90,54,.09);
  border-color:rgba(255,90,54,.35);
  color:var(--text);
}

/* Placeholder marker — same orange dashed convention as the website */
.placeholder{
  display:inline-block;
  border:1px dashed var(--orange);
  color:var(--orange-dark);
  background:rgba(255,90,54,.07);
  padding:1px 6px;
  border-radius:4px;
  font-family:'IBM Plex Mono',monospace;
  font-size:.85em;
  font-weight:600;
}
[data-theme="dark"] .placeholder{color:#FF8567;}

/* --------------------------------------------------------------------------
   SHEETS / TOAST / MISC
   -------------------------------------------------------------------------- */
.sheet-backdrop{
  position:fixed;inset:0;z-index:90;
  background:rgba(6,16,26,.55);
  display:flex;align-items:flex-end;justify-content:center;
  padding:0;
}
.sheet-backdrop[hidden]{display:none;}
.sheet{
  background:var(--surface);
  width:100%;max-width:640px;
  border-radius:18px 18px 0 0;
  padding:22px 20px calc(22px + env(safe-area-inset-bottom));
  max-height:86dvh;
  overflow-y:auto;
  animation:rise .2s ease;
}
@keyframes rise{from{transform:translateY(18px);opacity:.6;}to{transform:none;opacity:1;}}
.sheet h2{margin-bottom:10px;}
.sheet p{font-size:.89rem;color:var(--text-dim);}

.toast{
  position:fixed;
  left:50%;
  bottom:calc(84px + env(safe-area-inset-bottom));
  transform:translate(-50%,14px);
  z-index:120;
  background:var(--navy-900);
  color:#fff;
  padding:12px 20px;
  border-radius:24px;
  font-size:.86rem;
  font-weight:600;
  box-shadow:0 10px 30px -8px rgba(0,0,0,.6);
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease,transform .2s ease;
  max-width:min(92vw,420px);
  text-align:center;
}
.toast.show{opacity:1;transform:translate(-50%,0);}

.backlink{
  display:inline-flex;
  align-items:center;
  gap:7px;
  background:none;border:none;
  color:var(--text-dim);
  font-size:.85rem;
  font-weight:600;
  padding:8px 10px 8px 0;
  margin:-8px 0 8px -2px;
  cursor:pointer;
  min-height:44px;
}
.backlink svg{width:16px;height:16px;}

.foot{
  text-align:center;
  color:var(--text-dim);
  font-size:.74rem;
  line-height:1.6;
  padding:26px 6px 6px;
}
.foot strong{
  display:block;
  font-family:'Oswald',sans-serif;
  letter-spacing:.03em;
  color:var(--text);
  margin-bottom:4px;
  font-weight:600;
}

.offline-flag{
  background:var(--navy-700);
  color:#fff;
  text-align:center;
  font-size:.76rem;
  font-weight:600;
  padding:7px 12px;
}
.offline-flag[hidden]{display:none;}
