:root {
  --bg: #101418;
  --ink: #1a1d21;
  --paper: #fbfaf7;
  --accent: #0b6e4f;
  --warn: #a4243b;
  --muted: #6b7280;        /* on paper/light backgrounds */
  --muted-dark: #9aa4b1;   /* on dark backgrounds — AA contrast */
}

* { box-sizing: border-box; }

/* accessibility utilities */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
button:focus-visible, input:focus-visible, select:focus-visible,
a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: #e8eaed;
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
  line-height: 1.55;
}

main { max-width: 720px; margin: 0 auto; padding: 32px 20px 64px; }

.hero h1 { font-size: 44px; margin: 0 0 8px; letter-spacing: -1px; }
.hero .sub { font-size: 20px; margin: 0 0 4px; color: #c9ced6; }
.hero .sub2 { color: var(--muted-dark); margin: 0 0 24px; }

.input-row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
  background: #181d23; border: 1px solid #2a313a; border-radius: 12px; padding: 16px;
}
.input-row > label { flex-basis: 100%; color: #c9ced6; font-size: 14px; }
.presets {
  flex-basis: 100%;
  border-top: 1px solid #2a313a; margin-top: 12px; padding-top: 12px;
}
.presets-label { display: block; color: var(--muted-dark); font-size: 13px; margin-bottom: 8px; }
.personas { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.chip {
  font-size: 13.5px; padding: 8px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid #3a4350; background: #0d1116; color: #c9ced6;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
}
.chip b { color: #fff; font-size: 15px; }
.chip:hover { border-color: var(--accent); color: #fff; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.active b { color: #fff; }
.preset-selects { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.loc-select {
  flex: 1; min-width: 240px; appearance: auto;
  display: block; flex-direction: unset; text-align: right; padding: 8px 10px;
}
.loc-select:has(option:checked:not([value=""])) { background: var(--accent); border-color: var(--accent); color: #fff; }
.input-row input {
  flex: 1; min-width: 160px; font-size: 22px; padding: 10px 12px;
  border-radius: 8px; border: 1px solid #3a4350; background: #0d1116; color: #fff;
}
.input-row button {
  font-size: 18px; font-weight: 700; padding: 12px 22px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.input-row button:hover { filter: brightness(1.1); }
.extras {
  flex-basis: 100%;
  border-top: 1px solid #2a313a; margin-top: 12px; padding-top: 12px;
}
.extras .presets-label { margin-bottom: 10px; }
.opt-row {
  display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap;
  color: #c9ced6; font-size: 14px; padding: 9px 0;
}
.opt-row + .opt-row { border-top: 1px dashed #232a33; }
.opt-toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-weight: 600; white-space: nowrap; min-width: 170px;
}
.opt-toggle input { accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }
.opt-field { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.opt-field-label { color: #9aa3ae; white-space: nowrap; }
.opt-field input { width: 100px; font-size: 15px; padding: 5px 8px; border-radius: 6px; border: 1px solid #3a4350; background: #0d1116; color: #fff; }
.opt-field .hint { flex-basis: 100%; color: var(--muted-dark); font-size: 12px; }
.opt-field.hidden { visibility: hidden; }

.hidden { display: none; }

.receipt { margin-top: 28px; }
.paper {
  background: var(--paper); color: var(--ink);
  border-radius: 6px; padding: 26px 24px 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  font-variant-numeric: tabular-nums;
}
.paper-head { text-align: center; border-bottom: 2px dashed #c9c4b8; padding-bottom: 12px; }
.brand { font-weight: 800; }
.year { color: var(--muted); font-size: 14px; }
.persona-tag {
  display: inline-block; margin-top: 8px; padding: 3px 12px; border-radius: 999px;
  background: #e7f2ee; color: var(--accent); font-size: 13.5px; font-weight: 700;
}
.persona-tag.hidden { display: none; }
.years-row { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.ybtn {
  font-size: 12.5px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  border: 1px solid #d8d3c8; background: transparent; color: var(--muted); cursor: pointer;
}
.ybtn.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.y-custom { font-size: 12.5px; color: var(--muted); }
.y-custom input { width: 52px; font-size: 13px; padding: 2px 6px; border-radius: 6px; border: 1px solid #d8d3c8; background: #fff; color: var(--ink); text-align: center; }
.y-custom.hidden { display: none; }
.search-status { color: var(--warn); font-size: 12.5px; min-height: 16px; margin-bottom: 4px; }
.years-teaser {
  display: block; width: 100%; margin-top: 12px; padding: 10px 14px;
  background: #efece4; border: 1px dashed #b6b0a2; border-radius: 10px;
  font-size: 14.5px; color: var(--ink); cursor: pointer; text-align: center;
  font-family: inherit;
}
.years-teaser b { color: var(--warn); font-size: 16px; }
.years-teaser:hover { background: #e7e2d4; border-color: var(--warn); }

.totals { padding: 14px 0 6px; }
.total-line { display: flex; justify-content: space-between; padding: 3px 0; }
.total-line.grand { font-weight: 800; font-size: 20px; border-top: 1px solid #d8d3c8; margin-top: 8px; padding-top: 10px; }
.eff { text-align: center; color: var(--warn); font-weight: 700; margin-top: 6px; }
.eff .paren { color: #7c2d3f; font-weight: 600; }
.eff-sub { color: var(--muted); font-weight: 400; font-size: 13px; }
.paren { color: var(--muted); font-weight: 500; font-size: 0.92em; }
.paren.tip { border-bottom: 1px dotted #b6b0a2; cursor: help; }
/* amount tooltips sit at the left edge in RTL — open them toward the center */
.amt .tip:hover::after { right: auto; left: 0; }
.amt .tip:hover::before { right: auto; left: 14px; }
.total-line.grand .paren { font-size: 15px; }
.employer-note { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 4px; }
.employer-note b { color: var(--ink); }
.has-tip { text-decoration: underline dotted #b6b0a2; text-underline-offset: 3px; cursor: help; }

/* custom informative tooltips */
.tip { position: relative; }
.tip:hover::after, .tip:focus::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); right: 0;
  background: #1a1d21; color: #fbfaf7;
  padding: 10px 13px; border-radius: 10px;
  font-size: 12.5px; font-weight: 400; line-height: 1.55; text-align: right;
  width: max-content; max-width: min(320px, 78vw); white-space: normal;
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
  z-index: 30; pointer-events: none;
}
.tip:hover::before {
  content: ""; position: absolute; bottom: calc(100% + 2px); right: 14px;
  border: 6px solid transparent; border-top-color: #1a1d21; z-index: 30;
}
.freedom-day { text-align: center; color: var(--muted); font-size: 13px; margin-top: 6px; }
.freedom-day b { color: var(--warn); }
.balance-line { text-align: center; font-size: 14px; margin-top: 8px; color: var(--ink); }
.balance-line .pos { color: var(--accent); }
.balance-line .neg { color: var(--warn); }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; color: #7c5c10;
  background: #f5e9c9; border-radius: 999px; padding: 1px 8px; vertical-align: 1px;
}
.search-scope { display: flex; gap: 6px; margin: 2px 0 6px; }
.scope-btn {
  font-size: 12.5px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  border: 1px solid #d8d3c8; background: transparent; color: var(--muted); cursor: pointer;
}
.scope-btn.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.alloc li > span > a { color: var(--ink); text-decoration: underline dotted #b6b0a2; text-underline-offset: 3px; }
.alloc li > span > a:hover { color: var(--accent); }

#livebar {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: var(--paper); color: var(--ink); font-size: 15px;
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 24px rgba(0,0,0,.55); border: 1px solid #d8d3c8;
  transition: opacity .2s, transform .2s; z-index: 50; white-space: nowrap;
}
#livebar b { color: var(--warn); }
#livebar .livebar-hint { color: var(--muted); font-size: 12.5px; margin-inline-start: 10px; }
#livebar.hidden { display: none; }
#livebar.offscreen { opacity: 0; transform: translateX(-50%) translateY(60px); pointer-events: none; }

.divider { text-align: center; color: #b6b0a2; margin: 10px 0; overflow: hidden; white-space: nowrap; }

.paper h2 { font-size: 17px; margin: 8px 0 6px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reroll {
  font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid #c9c4b8; background: transparent; color: var(--ink);
}
.reroll:hover { background: #efece4; }
.small { font-size: 13px; color: var(--muted); margin: 0 0 8px; }

.alloc { list-style: none; margin: 0; padding: 0; }
.alloc li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 15px; }
.alloc li .amt { white-space: nowrap; font-weight: 600; }
.alloc li .pct { color: var(--muted); font-size: 12.5px; }
.highlights li a { color: var(--ink); text-decoration: underline dotted; }
.highlights li .amt { color: var(--warn); }

.hl-more {
  display: block; margin: 8px auto 0; padding: 5px 18px;
  font-size: 13px; font-weight: 600; border-radius: 999px; cursor: pointer;
  border: 1px solid #c9c4b8; background: transparent; color: var(--muted);
  font-family: inherit;
}
.hl-more:hover { background: #efece4; color: var(--ink); }
.hl-more.hidden { display: none; }

.paper-foot { text-align: center; color: var(--muted); font-size: 12px; border-top: 2px dashed #c9c4b8; margin-top: 14px; padding-top: 10px; }

.hl-search {
  width: 100%; box-sizing: border-box; font-size: 14px; padding: 7px 10px;
  border-radius: 8px; border: 1px solid #d8d3c8; background: #fff; color: var(--ink);
  margin: 2px 0 8px;
}
.hl-search:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.headline-card {
  margin-top: 20px; background: #181d23; border: 1px solid #2a313a;
  border-radius: 12px; padding: 16px;
}
.headline-card h3 { margin: 0 0 4px; font-size: 17px; }
.headline-card .small { color: var(--muted-dark); margin: 0 0 10px; }
.headline-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.headline-row input {
  width: 110px; font-size: 18px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid #3a4350; background: #0d1116; color: #fff;
}
.headline-row select {
  font-size: 15px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid #3a4350; background: #0d1116; color: #c9ced6;
}
.headline-result { font-size: 17px; color: #e8eaed; }
.headline-result b { color: #ff8fa3; font-size: 20px; }

.actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.actions button {
  font-size: 16px; font-weight: 700; padding: 12px 26px; border: 0; border-radius: 8px;
  background: #e8eaed; color: #101418; cursor: pointer;
}
.actions button.secondary {
  background: transparent; color: #c9ced6; border: 1px solid #3a4350; font-weight: 600;
}
.actions button.secondary:hover { border-color: #e8eaed; color: #fff; }

.method { margin-top: 28px; color: #c9ced6; font-size: 14px; }
.method summary { cursor: pointer; font-weight: 700; }
.method a { color: #7fd1b9; }

.site-foot { margin-top: 40px; text-align: center; color: var(--muted-dark); font-size: 13px; }
