:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --ink: #1a2142;
  --muted: #5d6585;
  --line: #dfe2ee;
  --accent: #c81e6a;
  --accent-ink: #ffffff;
  --info: #0a7ea4;
  --ok: #17803d;
  --ok-bg: #e5f5ea;
  --warn: #8a5a00;
  --warn-bg: #fff2d6;
  --bad: #b3261e;
  --bad-bg: #fdeaea;
  --focus: #0a7ea4;
  --radius: 10px;
  font-family: "Segoe UI", "Noto Sans Hebrew", Arial, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12152b; --surface: #1b2040; --ink: #eceffb; --muted: #a2a9c9; --line: #323a63;
    --accent: #ff5c9c; --accent-ink: #1a1030; --info: #5cc8ea; --ok: #62d68b; --ok-bg: #173824;
    --warn: #f2c260; --warn-bg: #3d3010; --bad: #ff8f86; --bad-bg: #40191a; --focus: #5cc8ea;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--info); }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.wrap.wide { max-width: 1240px; }

.brand { display: flex; align-items: center; gap: 14px; padding: 14px 0 6px; }
.brand img { height: 54px; width: auto; border-radius: 6px; background: #fff; }
.brand h1 { font-size: 1.15rem; margin: 0; line-height: 1.25; }
.brand small { color: var(--muted); display: block; font-weight: 400; }
.brand .grow { flex: 1; }
.who { color: var(--muted); font-size: .88rem; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 14px 0; }
.card h2 { margin: 0 0 4px; font-size: 1.1rem; }
.card .sub { color: var(--muted); margin: 0 0 14px; font-size: .92rem; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--info); padding: 6px 8px; min-height: 32px; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; min-height: 32px; font-size: .9rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); min-width: 0; }
label.f > span.hint { font-size: .78rem; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px; padding: 8px 10px; min-height: 40px;
}
input.num { text-align: center; direction: ltr; }
input:disabled, select:disabled, textarea:disabled { opacity: .75; cursor: not-allowed; }
input.bad, select.bad { border-color: var(--bad); background: var(--bad-bg); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.status { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.status.draft { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.status.submitted { color: var(--info); border-color: var(--info); }
.status.approved { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.status.returned { color: var(--bad); background: var(--bad-bg); border-color: transparent; }

.years { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.year { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.year .y { font-size: 2rem; font-weight: 700; letter-spacing: 1px; }
.year .nums { color: var(--muted); font-size: .9rem; min-height: 1.4em; }

.banner { border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; border: 1px solid var(--line); background: var(--surface); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.banner.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.banner.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.banner b { font-weight: 700; }

.topbar { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .in { max-width: 980px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.topbar.wide .in { max-width: 1240px; }
.kpis { display: flex; gap: 16px; flex-wrap: wrap; align-items: baseline; }
.kpi { display: flex; flex-direction: column; line-height: 1.15; }
.kpi b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .72rem; color: var(--muted); }
.kpi.big b { color: var(--accent); font-size: 1.6rem; }
.savestate { font-size: .8rem; color: var(--muted); min-width: 9em; }
.savestate.err { color: var(--bad); }
.tierhint { font-size: .82rem; color: var(--muted); flex-basis: 100%; }

.work { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 10px 0; background: var(--surface); }
.work.hasErr { border-color: var(--bad); }
.work-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.idx { background: var(--ink); color: var(--surface); border-radius: 999px; width: 28px; height: 28px; display: grid; place-items: center; font-size: .85rem; font-weight: 700; flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--bg); padding: 6px 12px; cursor: pointer; font-size: .9rem; }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--surface); font-weight: 600; }
.seg button[disabled] { cursor: not-allowed; }
.chip { font-size: .82rem; background: var(--bg); border-radius: 999px; padding: 2px 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip b { color: var(--ink); }
.cos { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.cos h4 { margin: 0 0 6px; font-size: .88rem; color: var(--muted); font-weight: 600; }
.co { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; margin-bottom: 8px; align-items: end; }
.issues { margin: 8px 0 0; padding: 0; list-style: none; font-size: .86rem; }
.issues li { padding: 2px 0; }
.issues .ERROR { color: var(--bad); }
.issues .WARN { color: var(--warn); }
.issues li::before { content: "● "; font-size: .7em; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.decl { font-size: .93rem; background: var(--bg); border-radius: 8px; padding: 12px 14px; border: 1px solid var(--line); }
.decl ol { margin: 6px 0 0; padding-inline-start: 22px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 3px; flex: none; }

.overlay { position: fixed; inset: 0; background: rgba(10, 12, 30, .55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; padding: 20px; max-width: 620px; width: 100%; max-height: 88vh; overflow: auto; }
.modal h3 { margin: 0 0 10px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 14px; flex-wrap: wrap; }
.modal textarea { min-height: 150px; direction: rtl; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.modal ul { padding-inline-start: 20px; }

.tablewrap { overflow-x: auto; }
table.t { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 8px 8px; text-align: right; vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--bg); }
table.t td.n { font-variant-numeric: tabular-nums; text-align: center; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.chips button[aria-pressed=true] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.err { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.steps { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; background: var(--bg); border-radius: 8px; padding: 10px 12px 10px 12px; font-size: .92rem; }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .78rem; font-weight: 700; margin-inline-end: 8px; }

/* print document */
.doc { background: #fff; color: #000; padding: 22px; max-width: 900px; margin: 0 auto; font-size: 13px; line-height: 1.45; }
.doc h1 { font-size: 20px; margin: 0 0 4px; }
.doc h2 { font-size: 15px; margin: 16px 0 6px; border-bottom: 1px solid #000; padding-bottom: 2px; }
.doc table { border-collapse: collapse; width: 100%; }
.doc th, .doc td { border: 1px solid #555; padding: 3px 6px; text-align: right; vertical-align: top; }
.doc th { background: #eee; }
.doc .kv { display: grid; grid-template-columns: 140px 1fr 140px 1fr; gap: 0; border: 1px solid #555; }
.doc .kv > div { padding: 3px 6px; border-bottom: 1px solid #ccc; }
.doc .kv > .k { background: #eee; font-weight: 700; }
.doc .sig { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-top: 26px; }
.doc .sig div { border-top: 1px solid #000; padding-top: 3px; text-align: center; }
.doc ol { margin: 4px 0; padding-inline-start: 22px; }
.doc .num { text-align: center; direction: ltr; }
.noprint { }
@media print {
  body { background: #fff; }
  .noprint, .topbar { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .doc { padding: 0; max-width: none; }
  tr { break-inside: avoid; }
  .sigblock { break-inside: avoid; }
}
@media (max-width: 560px) {
  .tierhint { display: none; }
  .kpis { gap: 10px; }
  .kpi b { font-size: 1.05rem; }
  .topbar .in { gap: 8px; padding: 8px 12px; }
  .co { grid-template-columns: 1fr 90px auto; }
  .brand h1 { font-size: 1rem; }
  .doc .kv { grid-template-columns: 110px 1fr; }
}
.decl .esign { margin: 10px 0 0; font-weight: 600; }
.esigned { border: 1px solid #000; padding: 8px 12px; margin-top: 12px; }
