/* Runway. Tokens first; light and dark are each chosen, not flipped.
   Logical properties throughout, so Hebrew (dir=rtl) mirrors for free. */
:root {
  color-scheme: light;
  --surface-0: #f6f6f4;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --grid: #e8e7e2;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --critical-ink: #b42c2c;
  --warning-bg: #fff6e0;
  --critical-bg: #fdecec;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Hebrew", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --border: #33332f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #94938a;
    --accent: #5598e7;
    --accent-ink: #0b0b0b;
    --grid: #2c2c29;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --good-ink: #5fd35f;
    --critical-ink: #f08a8a;
    --warning-bg: #3a2f12;
    --critical-bg: #3a1c1c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242422;
  --border: #33332f;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #94938a;
  --accent: #5598e7;
  --accent-ink: #0b0b0b;
  --grid: #2c2c29;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --good-ink: #5fd35f;
  --critical-ink: #f08a8a;
  --warning-bg: #3a2f12;
  --critical-bg: #3a1c1c;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--surface-0);
  color: var(--text-primary);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 16px; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 13px; margin: 16px 0 8px; font-weight: 650; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .03em; }
.boot, .muted { color: var(--text-muted); }
.boot { padding: 48px 16px; text-align: center; }
.num { font-variant-numeric: tabular-nums; text-align: end; white-space: nowrap; }
.neg { color: var(--critical-ink); }
.pos { color: var(--good-ink); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Shell */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface-1); border-block-end: 1px solid var(--border);
  position: sticky; inset-block-start: 0; z-index: 5;
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; color: var(--text-primary); }
.brand img { inline-size: 22px; block-size: 22px; }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
nav.tabs a { padding: 6px 10px; border-radius: 8px; color: var(--text-secondary); }
nav.tabs a.on { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
nav.tabs a:hover { text-decoration: none; background: var(--surface-2); }
.who { margin-inline-start: auto; color: var(--text-muted); font-size: 12px; }
main { padding: 20px; max-inline-size: 1280px; margin: 0 auto; }

/* Surfaces */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-block-end: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-block-end: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--text-secondary); font-size: 12px; }
.tile .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin-block: 2px; }
.tile .sub { color: var(--text-muted); font-size: 12px; }

/* Notices */
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; margin-block-end: 8px; background: var(--warning-bg); }
.notice.error { background: var(--critical-bg); }
.notice .icon { font-weight: 700; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--text-secondary); white-space: nowrap; }
.badge.good { color: var(--good-ink); }
.badge.bad { color: var(--critical-ink); }
.badge.work::before { content: ""; display: inline-block; inline-size: 8px; block-size: 8px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent; margin-inline-end: 6px; animation: spin 1s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; inline-size: 100%; }
th, td { padding: 7px 8px; border-block-end: 1px solid var(--border); text-align: start; vertical-align: top; }
th { font-weight: 600; color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tfoot td, tr.total td { font-weight: 650; }
td .sub { display: block; color: var(--text-muted); font-size: 12px; }

/* Forms */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row.spread { justify-content: space-between; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); min-inline-size: 140px; flex: 1 1 160px; }
.row > label.field { max-inline-size: 320px; }
label.check { display: flex; gap: 6px; align-items: center; font-size: 13px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; min-inline-size: 0;
}
textarea { min-block-size: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
button:hover { filter: brightness(0.97); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--critical-ink); }
button.link { background: none; border: none; padding: 2px 4px; color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-block-start: 12px; }
.error-text { color: var(--critical-ink); font-size: 13px; }

dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-1); color: var(--text-primary); padding: 20px; inline-size: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .35); }

details > summary { cursor: pointer; color: var(--text-secondary); margin-block: 6px; }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; inline-size: 100%; block-size: auto; overflow: visible; }
.chart .axis { fill: var(--text-muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--text-muted); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .dot.neg { fill: var(--critical); }
.chart .marker { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .marker-label { fill: var(--critical-ink); font-size: 11px; font-weight: 600; }
.chart .hit { fill: transparent; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; }
.chart .s-salary { fill: var(--series-1); }
.chart .s-rent { fill: var(--series-2); }
.chart .s-tech { fill: var(--series-3); }
.chart .s-other { fill: var(--series-4); }
.chart .seg { stroke: var(--surface-1); stroke-width: 2; }
.chart .seg.dim { opacity: .45; }
.tip {
  position: absolute; pointer-events: none; z-index: 3; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgb(0 0 0 / .12); min-inline-size: 160px;
}
.tip .t { font-weight: 650; margin-block-end: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 12px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-block: 4px 8px; }
.legend .sw { display: inline-block; inline-size: 10px; block-size: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.sw.s-salary { background: var(--series-1); }
.sw.s-rent { background: var(--series-2); }
.sw.s-tech { background: var(--series-3); }
.sw.s-other { background: var(--series-4); }

@media (max-width: 640px) {
  main { padding: 16px; }
  .top { padding: 8px 16px; }
  .who { display: none; }
  .tile .value { font-size: 22px; }
}

/* Payslip */
.payslip { border-block-start: 1px solid var(--border); padding-block-start: 8px; }
.payslip .annual { margin-block-end: 6px; }
.breakdown { margin-block-start: 12px; background: var(--surface-2); border-radius: 8px; padding: 12px; }
.breakdown table td { border-block-end-color: var(--border); }

/* Lock */
.lock { max-inline-size: 560px; padding-block-start: 48px; }
pre.recovery { font: 600 15px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border-radius: 8px; padding: 12px; white-space: pre-wrap; word-break: break-all; user-select: all; }
button.chip { padding: 4px 10px; border-radius: 999px; font-size: 12px; }
button.chip.on { background: var(--warning-bg); border-color: var(--warning); }
