:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #17201d;
  --muted: #5f6b67;
  --line: #dde3e1;
  --brand: #165a4a;
  --brand-ink: #ffffff;
  --ok-bg: #e3f3ec; --ok: #11603f;
  --warn-bg: #fff4dc; --warn: #7a4d00;
  --bad-bg: #fde8e7; --bad: #9b1c14;
  --info-bg: #e6eefb; --info: #1d4b8f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: "Segoe UI", "Noto Sans Hebrew", "Arial Hebrew", Arial, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513; --card: #18201d; --ink: #e8eeeb; --muted: #9aa8a3; --line: #2a3531;
    --brand: #3fa486; --brand-ink: #06110d;
    --ok-bg: #133126; --ok: #8fe0bd; --warn-bg: #3a2e10; --warn: #f2cf7c;
    --bad-bg: #3d1614; --bad: #f4a29b; --info-bg: #142640; --info: #a9c6f5;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: 0 0 .7rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
small { display: block; color: var(--muted); margin-top: .2rem; font-weight: 400; }

.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand-mark { background: var(--brand); color: var(--brand-ink); width: 28px; height: 28px; border-radius: 7px; display: inline-grid; place-items: center; font-size: .95rem; }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav a, .linkbtn { color: var(--ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; font: inherit; }
.nav a.on { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.linkbtn { background: none; border: 0; cursor: pointer; color: var(--muted); }
.inline { display: inline; }

main.wrap { padding-top: 18px; padding-bottom: 24px; }
.foot { color: var(--muted); font-size: .8rem; padding-bottom: 28px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.narrow { max-width: 440px; margin-inline: auto; margin-top: 6vh; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; }
.flash ul { margin: .3rem 0 0; padding-inline-start: 1.2rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.info { background: var(--info-bg); color: var(--info); }

.chip { display: inline-block; font-size: .78rem; padding: 2px 9px; border-radius: 999px; white-space: nowrap; vertical-align: middle; font-weight: 600; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.big { width: 100%; min-height: 50px; font-size: 1.05rem; margin-top: 8px; }
.btn[disabled] { opacity: .6; cursor: wait; }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; min-width: 0; }
input, select, textarea { font: inherit; width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: 20px; height: 20px; min-height: 0; flex: none; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.grid-status { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.grid-status .wide { grid-column: 1 / -1; }

.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-value { font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-value.neg { color: var(--bad); }
.stat-sub { color: var(--muted); font-size: .85rem; }

.next { display: flex; gap: 16px; align-items: center; justify-content: space-between; border-inline-start: 4px solid var(--brand); }
.next h2 { margin: .1rem 0 .2rem; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); font-weight: 700; }

.years { display: grid; gap: 8px; }
.year-row { display: grid; grid-template-columns: 64px minmax(0,1fr) auto minmax(0,150px); gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; }
.year-row:hover { border-color: var(--brand); }
.yr { font-weight: 700; font-size: 1.1rem; }
.amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.amt.neg { color: var(--bad); }
.dl { font-size: .85rem; text-align: end; }
.miss { grid-column: 1 / -1; font-size: .82rem; color: var(--warn); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; overflow-wrap: anywhere; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: start; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.tbl th { font-size: .82rem; color: var(--muted); font-weight: 600; }
.tbl.calc td:first-child { color: var(--muted); width: 40%; }
.tbl.calc tr.sep td { border-top: 2px solid var(--line); }
.tbl.calc tr.total td { font-weight: 700; font-size: 1.1rem; }
.tbl.sheet .fld { font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; }
.tbl.sheet .val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: end; }
.copy { font: inherit; font-size: .8rem; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px; padding: 4px 8px; cursor: pointer; min-height: 32px; }
.copy.done { background: var(--ok-bg); color: var(--ok); }

.drop { display: grid; gap: 12px; }
.drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-label { display: grid; gap: 4px; place-items: center; text-align: center; border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 12px; cursor: pointer; font-weight: 400; }
.drop.over .drop-label, .drop-label:hover { border-color: var(--brand); background: var(--ok-bg); }
.drop-label .files { font-size: .85rem; color: var(--ink); }

.doc-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.doc-head h1 { overflow-wrap: anywhere; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.review { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
.review-form { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
.hint { background: var(--info-bg); color: var(--info); padding: 8px 10px; border-radius: 8px; font-size: .85rem; margin: 0; }
.section { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0 0 12px; min-width: 0; }
.section legend { padding: 0 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-weight: 700; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.field span { font-weight: 400; font-size: .8rem; color: var(--muted); }
.field input { min-height: 40px; padding: 8px 10px; }
.field.active input { outline: 3px solid var(--brand); }
.check-fail { color: var(--bad); margin: .4rem 0 0; }
.remove { color: var(--muted); font-size: .85rem; }
.add-section { display: flex; gap: 8px; }
.add-section select { flex: 1; }
.viewer { padding: 10px; min-height: 300px; overflow: auto; }
.page-wrap { position: relative; margin: 0 auto 12px; box-shadow: 0 0 0 1px var(--line); background: #fff; max-width: 100%; }
.page-wrap canvas { display: block; width: 100%; height: auto; }
.hl { position: absolute; border: 2px solid #1d8f6b; background: rgba(29,143,107,.12); border-radius: 3px; pointer-events: none; }
.hl.sel { border-color: #c47a00; background: rgba(196,122,0,.18); }
.tx { position: absolute; cursor: pointer; border-radius: 2px; background: transparent; border: 0; padding: 0; margin: 0; min-height: 0; appearance: none; }
.tx:hover { background: rgba(29,143,107,.22); outline: 1px solid #1d8f6b; }

@media (max-width: 860px) {
  .review { grid-template-columns: minmax(0, 1fr); }
  .review-form { position: static; max-height: none; }
  .viewer { order: -1; max-height: 70vh; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.3rem; }
  .card { padding: 14px; }
  .stat-value { font-size: 1.7rem; }
  .next { flex-direction: column; align-items: stretch; }
  .year-row { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 6px; }
  .year-row .yr { min-width: 48px; }
  .year-row .amt { flex: 1 0 calc(100% - 70px); }
  .year-row .dl { margin-inline-start: auto; text-align: end; }
  .year-row .miss { flex-basis: 100%; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .tbl td { border: 0; padding: 3px 0; }
  .tbl td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .8rem; }
  .tbl.calc td:first-child { width: 100%; font-size: .85rem; }
  .tbl.sheet .val, .tbl.sheet td:last-child { display: inline-block; width: auto; text-align: start; margin-inline-end: 10px; }
  .nav a, .linkbtn { padding: 6px 8px; }
}

/* Settings → intake status */
details { margin: 6px 0; }
details summary { cursor: pointer; }
pre.log { overflow-x: auto; max-width: 100%; white-space: pre; direction: ltr; text-align: left; font-size: 12px; line-height: 1.5; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0 0; }

/* Login → Turnstile status under the check */
.ts-status { margin: 4px 0 0; min-height: 1.4em; }
.ts-status.warn { color: var(--warn); }
.ts-status.bad { color: var(--bad); }
#turnstile:empty { display: none; }
