:root {
  /* Desk (dark fiscal pine) */
  --bg: #0e1f1b;
  --bg-2: #0b1815;
  --panel: #163029;
  --panel-2: #1b3a32;
  --line: #294a42;
  --line-soft: #21403a;
  --ink: #e8efe9;
  --muted: #8ca79d;
  --gold: #e3b45c;
  --gold-deep: #caa049;
  --teal: #52c6a6;

  /* Payslip (light paper laid on the desk) */
  --paper: #f2efe4;
  --paper-2: #eae5d6;
  --paper-ink: #1b2a25;
  --paper-muted: #6f7b72;
  --paper-line: #d8d1bf;
  --out: #b1503a;

  /* Composition palette (meaningful: green = yours, warm = tax, cool = locked savings) */
  --c-net: #1f8f74;
  --c-tax: #b1503a;
  --c-bl: #d3963a;
  --c-health: #e0c766;
  --c-pension: #4f7bb0;
  --c-keren: #8a6bb0;

  --radius: 14px;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Assistant', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* Faint engraved guilloché arc behind the hero — a nod to security print */
.engrave {
  position: fixed;
  top: -30vh; left: 50%;
  width: 120vh; height: 120vh;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background:
    repeating-radial-gradient(circle at 50% 42%, transparent 0 15px, rgba(82, 198, 166, 0.05) 15px 16px),
    radial-gradient(circle at 50% 30%, rgba(227, 180, 92, 0.10), transparent 55%);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(var(--bg), rgba(14, 31, 27, 0.55));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--gold), var(--gold-deep));
  color: #22160a; font-weight: 800; font-size: 22px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2), 0 6px 16px -6px rgba(227,180,92,0.5);
}
.brand-text { font-family: 'Frank Ruhl Libre', serif; font-weight: 900; font-size: 24px; letter-spacing: 0.5px; }
.brand-year { color: var(--gold); margin-inline-start: 3px; }
.verified-badge {
  font-size: 13px; font-weight: 600; color: var(--teal);
  border: 1px solid var(--line); background: var(--panel);
  padding: 6px 12px; border-radius: 999px;
}

/* ---------- Layout ---------- */
.app { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 26px 22px 70px; }
.intro { margin: 14px 2px 26px; max-width: 640px; }
.eyebrow { text-transform: uppercase; letter-spacing: 3px; font-size: 12px; font-weight: 700; color: var(--gold); margin: 0 0 8px; }
.title { font-family: 'Frank Ruhl Libre', serif; font-weight: 900; font-size: clamp(34px, 6vw, 54px); line-height: 1.05; margin: 0 0 10px; }
.lede { color: var(--muted); font-size: 17px; line-height: 1.55; margin: 0; }

.layout { display: grid; gap: 22px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .layout { grid-template-columns: 0.95fr 1.05fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-title {
  font-family: 'Frank Ruhl Libre', serif; font-weight: 700; font-size: 22px;
  margin: 0; padding: 20px 22px 0;
  display: flex; align-items: baseline; gap: 8px;
}
.panel-sub { font-family: 'Assistant', sans-serif; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Inputs ---------- */
.inputs { padding-bottom: 8px; }
.field { padding: 16px 22px 4px; }
.field-head { display: flex; align-items: center; justify-content: space-between; }
.field label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; line-height: 1.4; }

.money-input, .pct-input {
  display: flex; align-items: center;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 11px; overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.money-input:focus-within, .pct-input:focus-within, .plain-input:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(227, 180, 92, 0.15);
}
.money-input .shk { padding: 0 12px; color: var(--gold); font-weight: 700; font-size: 17px; }
.money-input input, .pct-input input, .plain-input {
  flex: 1; width: 100%; min-width: 0;
  background: transparent; border: none; color: var(--ink);
  font: inherit; font-size: 18px; font-weight: 600;
  padding: 13px 4px 13px 14px;
}
.money-input input { padding-inline-start: 0; }
.money-input input:focus, .pct-input input:focus, .plain-input:focus { outline: none; }
.pct-input { padding-inline-end: 12px; }
.pct-input .pct { color: var(--muted); font-weight: 700; }
.plain-input {
  width: 100%;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 11px; color: var(--ink); font: inherit; font-size: 17px; font-weight: 600;
  padding: 13px 14px;
}
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; }
.ghost-btn {
  background: none; border: 1px solid var(--line); color: var(--gold);
  border-radius: 999px; font: inherit; font-weight: 600; font-size: 13px;
  padding: 4px 12px; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.ghost-btn:hover { border-color: var(--gold); background: rgba(227, 180, 92, 0.08); }

.settlement-note {
  margin: 8px 0 0; font-size: 13px; color: var(--teal);
  background: rgba(82, 198, 166, 0.08); border: 1px solid var(--line-soft);
  border-radius: 9px; padding: 8px 10px; line-height: 1.45;
}
.advanced { margin: 8px 22px 16px; border-top: 1px solid var(--line-soft); padding-top: 6px; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; padding: 8px 0; list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: '⌄ '; color: var(--gold); }
.advanced[open] summary::before { content: '⌃ '; }
.advanced .field { padding-inline: 0; }
.advanced .row-2 { gap: 14px; }

/* ---------- Result / payslip ---------- */
.result { background: transparent; border: none; box-shadow: none; padding: 0; }
.slip {
  position: relative;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 8px;
  padding: 26px 24px 22px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(0,0,0,0.04);
}
.slip-perf {
  position: absolute; left: 0; right: 0; height: 12px;
  background-image: radial-gradient(circle at 8px 0, transparent 0 7px, var(--paper) 7px);
  background-size: 18px 12px; background-repeat: repeat-x;
}
.slip-perf.top { top: -10px; transform: scaleY(-1); }
.slip-perf.bottom { bottom: -10px; }

.slip-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding-bottom: 14px; border-bottom: 2px solid var(--paper-ink);
  gap: 12px; flex-wrap: wrap;
}
.slip-label { font-size: 13px; font-weight: 700; letter-spacing: 1px; color: var(--paper-muted); text-transform: uppercase; }
.slip-gross { display: flex; align-items: baseline; gap: 8px; }
.slip-gross-label { font-size: 14px; color: var(--paper-muted); font-weight: 600; }
.slip-gross-val { font-family: 'Frank Ruhl Libre', serif; font-weight: 700; font-size: 26px; }

.ledger { padding: 8px 0 4px; }
.ledger-group { padding: 8px 0; }
.ledger-group-title { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--paper-muted); margin-bottom: 4px; }
.ledger-line {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 7px 2px; border-bottom: 1px dashed var(--paper-line); gap: 12px;
}
.ll-name { font-size: 15.5px; font-weight: 500; }
.ll-tag { color: var(--paper-muted); font-size: 12px; font-weight: 600; }
.ll-val { font-weight: 700; font-size: 16px; white-space: nowrap; }
.ll-val.out::before { content: '−'; margin-inline-end: 1px; color: var(--out); }
.ll-val.out { color: var(--out); }
.total-deductions { border-bottom: none; border-top: 2px solid var(--paper-ink); margin-top: 4px; padding-top: 10px; }
.total-deductions .ll-name { font-weight: 700; }
.total-deductions .ll-val { font-size: 17px; }

.net {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; padding: 16px 18px;
  background: linear-gradient(135deg, #1b2a25, #223b33);
  color: var(--paper); border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(227,180,92,0.25);
}
.net-label { font-family: 'Frank Ruhl Libre', serif; font-weight: 700; font-size: 20px; }
.net-val { font-family: 'Frank Ruhl Libre', serif; font-weight: 900; font-size: clamp(30px, 6vw, 40px); color: var(--gold); letter-spacing: 0.5px; }

/* Composition bar */
.composition { margin-top: 18px; }
.comp-bar {
  display: flex; height: 16px; border-radius: 8px; overflow: hidden;
  background: var(--paper-2); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}
.comp-seg { height: 100%; transition: width 0.35s ease; }
.comp-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--paper-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-item b { color: var(--paper-ink); font-weight: 700; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; text-align: center;
}
.stat-num { display: block; font-family: 'Frank Ruhl Libre', serif; font-weight: 700; font-size: 26px; color: var(--gold); }
.stat-cap { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* Breakdown */
.breakdown { margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.breakdown summary { cursor: pointer; padding: 14px 18px; font-weight: 600; color: var(--ink); list-style: none; }
.breakdown summary::-webkit-details-marker { display: none; }
.breakdown summary::before { content: '＋ '; color: var(--gold); font-weight: 700; }
.breakdown[open] summary::before { content: '－ '; }
.breakdown-body { padding: 0 18px 16px; }
.bd-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 14.5px; }
.bd-line:last-child { border-bottom: none; }
.bd-line .k { color: var(--muted); }
.bd-line .v { font-weight: 700; }
.bd-sub { font-size: 12.5px; color: var(--muted); padding: 6px 0 2px; }
.bd-note {
  font-size: 12px; color: var(--muted); opacity: 0.85;
  padding: 0 0 8px; margin-top: -5px; border-bottom: 1px solid var(--line-soft); line-height: 1.4;
}

/* Money values render as isolated LTR units so the sign (−/+) and ₪ sit on the
   correct (left) side regardless of the surrounding RTL text. */
.ll-val, .slip-gross-val, .net-val, .bd-line .v, .stat-num {
  direction: ltr; unicode-bidi: isolate;
}

.adv-check {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 6px 0 4px; font-size: 13px; color: var(--muted); line-height: 1.4; cursor: pointer;
}
.adv-check input { width: 18px; height: 18px; accent-color: var(--gold); flex: none; margin-top: 1px; }

/* Footer */
.app-foot { margin-top: 34px; color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 760px; }
.sources { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; }
.sources a { color: var(--teal); font-size: 12.5px; text-decoration: none; border-bottom: 1px dashed var(--line); padding-bottom: 1px; }
.sources a:hover { color: var(--gold); border-color: var(--gold); }

/* ---------- Questionnaire modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(6, 14, 12, 0.74); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; width: 100%; max-width: 620px;
  max-height: 88vh; display: flex; flex-direction: column;
  animation: sheet 0.28s ease both;
}
@keyframes sheet { from { transform: translateY(28px); opacity: 0.5; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) { .modal-backdrop { align-items: center; } .modal { border-radius: 18px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { margin: 0; font-family: 'Frank Ruhl Libre', serif; font-weight: 700; font-size: 21px; }
.icon-x { background: none; border: none; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
.icon-x:hover { color: var(--gold); }
.modal-body { padding: 6px 20px 12px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-top: 1px solid var(--line-soft); background: var(--panel-2);
  border-radius: 0 0 18px 18px;
}
.q-total { font-size: 15px; color: var(--muted); }
.q-total strong { color: var(--gold); font-size: 20px; font-family: 'Frank Ruhl Libre', serif; }

.q-field { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.q-field:last-child { border-bottom: none; }
.q-field > label { display: block; font-weight: 600; margin-bottom: 8px; }
.q-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.q-help { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { background: none; border: none; color: var(--muted); font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--gold); color: #22160a; }
.q-select, .q-num {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  font: inherit; font-weight: 600; border-radius: 9px; padding: 9px 11px;
}
.q-num { width: 74px; text-align: center; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font-size: 18px; cursor: pointer; }
.stepper button:hover { border-color: var(--gold); color: var(--gold); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.q-kids-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.q-kid { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 10px; }
.q-kid span { font-size: 13.5px; }
.q-kid .stepper button { width: 28px; height: 28px; font-size: 15px; }
.q-kid .q-num { width: 40px; }

.primary-btn {
  background: linear-gradient(145deg, var(--gold), var(--gold-deep)); color: #22160a;
  border: none; border-radius: 11px; font: inherit; font-weight: 700; font-size: 15px;
  padding: 12px 22px; cursor: pointer; transition: filter 0.15s, transform 0.12s;
}
.primary-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }

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

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
  .q-kids-grid { grid-template-columns: 1fr; }
}

/* ---------- Mid-year start: estimated annual refund ---------- */
.refund {
  margin-top: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 18px;
}
.refund-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.refund-title { display: block; font-weight: 700; color: var(--ink); }
.refund-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.refund-amount {
  font-family: 'Frank Ruhl Libre', serif; font-weight: 700; font-size: 28px; color: var(--teal);
  direction: ltr; unicode-bidi: isolate;
}
.refund-lines { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 10px; display: grid; gap: 7px; }
.rf-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink); }
.rf-line .v { font-weight: 700; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.rf-note-inline { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; }
.refund-note {
  margin: 12px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55;
  border-top: 1px solid var(--line-soft); padding-top: 10px;
}
