@import url("fonts.css");

/* כיוון ב׳: תיק משפטי. נייר, אותיות מודפסות וחותמות. */
:root {
  --paper: #F3EEE3;
  --sheet: #FBF8F1;
  --ink: #2B2522;
  --ink2: #4A423B;
  --muted: #6B6259;
  --line: #DDD3C2;
  --rule: #CFC3AE;
  --field: #EAE3D4;
  --red: #A63A2B;
  --red-soft: #F4DDD6;
  --blue: #24477A;
  --blue-soft: #DFE6F0;
  --green: #2F6B4A;
  --memo: #FFF9E8;
  --memo-line: #EADFC6;
  --hl: #F5D77A;
  --serif: "Frank Ruhl Libre", "Times New Roman", serif;
  --sans: "Assistant", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --tabs-h: 56px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1A1613;
    --sheet: #231E1A;
    --ink: #EFE7D8;
    --ink2: #D6CCBB;
    --muted: #A89C8C;
    --line: #3A322B;
    --rule: #4A4037;
    --field: #2E2722;
    --red: #E58A78;
    --red-soft: #3E211B;
    --blue: #9DB8E4;
    --blue-soft: #1E2A3D;
    --green: #8FCCA8;
    --memo: #2A241E;
    --memo-line: #3A3229;
    --hl: #6A5414;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.modal-open { overflow: hidden; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 22px) 22px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 34px);
  outline: none;
}
a { color: var(--blue); }
b, strong { font-weight: 700; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.noscript { padding: 24px; text-align: center; }

/* ---------- כותרת ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 3px double var(--rule); }
.overline { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; color: var(--red); }
.overline.plain { color: var(--muted); }
.top h1, .page-title { margin: 2px 0 0; font-family: var(--serif); font-size: 34px; line-height: 1.1; font-weight: 900; }
.page-title { margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 6px; }

/* ---------- כפתורים ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 6px; border: 1.5px solid transparent;
  font: inherit; font-weight: 700; font-size: 16px; line-height: 1.2; cursor: pointer;
  color: var(--ink); background: transparent; text-decoration: none;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.ink { background: var(--ink); color: var(--paper); }
.btn.outline { border-color: var(--ink); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--red); padding: 0 4px; }
.btn.plain { color: var(--blue); padding: 0 4px; }
.btn[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.link { background: none; border: 0; color: var(--blue); font: inherit; font-weight: 700; padding: 8px 0; cursor: pointer; text-decoration: none; }
.link.red { color: var(--red); }
.link.small { font-size: 14px; padding: 4px 0; }

/* ---------- חותמות ---------- */
.stamp {
  display: inline-block; padding: 1px 8px; border: 1.5px solid currentColor; border-radius: 4px;
  transform: rotate(-3deg); color: var(--blue); font-size: 12.5px; font-weight: 700; line-height: 1.5; white-space: nowrap;
}
.stamp.red { color: var(--red); }
.stamp.green { color: var(--green); }
.stamp.muted { color: var(--muted); }
.stamp.tilt { transform: rotate(2deg); }

/* ---------- הודעות ---------- */
.notice { margin: 16px 0 0; padding: 12px 14px; border-radius: 6px; background: var(--blue-soft); font-size: 14.5px; }
.notice.red { background: var(--red-soft); }
.notice p { margin: 0; }
.notice .link { padding: 4px 0 0; font-size: 14.5px; }

/* ---------- רשימה ---------- */
.sec { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 22px 0 6px; }
.sec h2 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 700; }
.sec.red h2 { color: var(--red); }
.sec .count { color: var(--muted); font-size: 14px; font-weight: 700; }
.rows { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.row:active { background: color-mix(in srgb, var(--line) 45%, transparent); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-family: var(--serif); font-size: 19px; font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 14px; color: var(--ink2); }
.row-num { flex: none; width: 64px; text-align: center; line-height: 1; }
.row-num b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 900; }
.row-num small { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); line-height: 1.2; }
.row.hot .row-num b { font-size: 38px; color: var(--red); }
.row.hot .row-name { font-size: 20px; }
.row-num.dim b { color: var(--muted); font-size: 24px; }
details.done > summary { list-style: none; cursor: pointer; }
details.done > summary::-webkit-details-marker { display: none; }
.search { width: 100%; margin: 16px 0 0; padding: 11px 14px; border: 0; border-radius: 6px; background: var(--field); color: var(--ink); font: inherit; font-size: 16px; -webkit-appearance: none; appearance: none; }

.empty { text-align: center; padding: 44px 12px 24px; }
.empty .stamp { font-family: var(--serif); font-size: 20px; padding: 4px 14px; font-weight: 900; }
.empty h2 { font-family: var(--serif); font-size: 24px; margin: 22px 0 6px; }
.empty p { color: var(--muted); margin: 0 auto 20px; max-width: 300px; }
.empty .small { margin-top: 20px; font-size: 14px; }

/* ---------- תיק של שוטר ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); font-weight: 700; text-decoration: none; padding: 6px 0; margin: -6px 0 8px; }
.back svg { width: 20px; height: 20px; }
.file-head { padding-bottom: 12px; border-bottom: 3px double var(--rule); }
.file-head h1 { margin: 2px 0 0; font-family: var(--serif); font-size: 32px; font-weight: 900; line-height: 1.12; }
.file-head .sub { color: var(--muted); font-size: 15px; }
.big { margin-top: 16px; display: flex; align-items: flex-end; gap: 12px; }
.big b { font-family: var(--serif); font-size: 76px; line-height: .85; font-weight: 900; font-variant-numeric: tabular-nums; }
.big b.red { color: var(--red); }
.big .t { font-family: var(--serif); font-size: 21px; font-weight: 700; }
.big .s { font-size: 15px; color: var(--ink2); }
.big-msg { margin: 16px 0 0; font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.3; }
.big-msg.red { color: var(--red); }
.todo { margin-top: 14px; padding: 10px 14px; border-inline-start: 3px solid var(--red); background: var(--red-soft); color: var(--ink); font-size: 15px; }
.todo.blue { border-color: var(--blue); background: var(--blue-soft); }
.actions { display: grid; gap: 8px; margin: 18px 0 4px; }
.actions .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .pair .btn { min-height: 44px; padding: 0 10px; font-size: 15px; }
.mini-actions { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 4px; }
.mini-actions .link { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.mini-actions svg { width: 17px; height: 17px; }

.h-sec { display: flex; justify-content: space-between; align-items: baseline; margin: 24px 0 8px; }
.h-sec h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.h-sec .link { font-size: 15px; padding: 2px 0; }
.stamps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; padding: 16px 4px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stamps > div { text-align: center; }
.stamps .stamp { font-family: var(--serif); font-size: 15px; font-weight: 900; line-height: 1.12; padding: 6px 8px; border-width: 2px; border-radius: 6px; white-space: normal; }
.stamps .when { margin-top: 8px; font-size: 13px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.stamps .who { font-size: 12px; color: var(--muted); }
.stamps .now .when { color: var(--red); font-weight: 700; }
.stamps .del { margin-top: 2px; }

.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); flex: none; max-width: 50%; }
.kv dd { margin: 0; font-weight: 700; text-align: left; }
.kv dd small { display: block; font-weight: 400; color: var(--muted); font-size: 13.5px; }
.mark { background: linear-gradient(transparent 58%, var(--hl) 58%); padding: 0 2px; }

.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list .t { font-weight: 700; }
.list .s { color: var(--muted); font-size: 14px; }
.list .e { text-align: left; flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.list .e .link { display: block; margin-inline-start: auto; }
.list .none { color: var(--muted); font-size: 14.5px; }
.notes { white-space: pre-wrap; margin: 0; padding: 11px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--ink2); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 30px; padding-top: 10px; border-top: 3px double var(--rule); }

/* ---------- חלונית טופס ---------- */
dialog { color: var(--ink); }
dialog#sheet {
  padding: 0; border: 0; margin: 0; max-width: none; max-height: none;
  inset: auto 0 0 0; width: 100%;
  height: calc(100% - env(safe-area-inset-top) - 14px);
  height: calc(100dvh - env(safe-area-inset-top) - 14px);
  border-radius: 16px 16px 0 0;
  background: var(--sheet);
  overflow: hidden;
}
@media (min-width: 700px) {
  dialog#sheet { inset: 0; margin: auto; width: 600px; height: min(86vh, 820px); border-radius: 16px; }
}
dialog::backdrop { background: rgba(43, 37, 34, .45); }
dialog#sheet[open] { animation: sheet-in .22s ease-out; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-form { display: flex; flex-direction: column; height: 100%; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 12px; border-bottom: 3px double var(--rule); }
.sheet-head .overline { color: var(--muted); }
.sheet-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 900; line-height: 1.15; outline: none; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 20px 20px; }
.sheet-foot { padding: 12px 20px calc(env(safe-area-inset-bottom) + 14px); border-top: 1px solid var(--line); background: var(--sheet); }
.sheet-sec { margin: 22px 0 2px; font-family: var(--serif); font-size: 17px; font-weight: 700; }

.fields { margin-top: 6px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.field > span:first-child, .field > label:first-child { flex: none; color: var(--ink2); font-weight: 700; font-size: 15.5px; }
.field.stack { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 0; }
.field input, .field select, .field textarea {
  min-width: 0; flex: 1 1 auto; max-width: 64%;
  font: inherit; font-size: 16px; color: var(--ink);
  border: 0; border-radius: 6px; background: var(--field);
  padding: 9px 12px; text-align: left;
  -webkit-appearance: none; appearance: none;
}
.field.stack textarea, .field.stack select { max-width: none; text-align: right; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.field input[type="date"] { flex: 0 0 158px; width: 158px; max-width: 158px; min-height: 40px; text-align: center; }
.field input[type="date"]::-webkit-date-and-time-value { text-align: center; }
.field input[type="number"] { flex: 0 0 76px; width: 76px; text-align: center; -moz-appearance: textfield; }
.field input[type="number"]::-webkit-inner-spin-button, .field input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.field select { padding-left: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6259' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 9px center; background-size: 16px; direction: rtl; text-align: right; }
.unitwrap { display: inline-flex; align-items: center; gap: 8px; }
.unitwrap em { font-style: normal; color: var(--muted); font-size: 14.5px; }
.hint { margin: 8px 0 0; font-size: 13.5px; color: var(--muted); }
.hint.warn { color: var(--red); font-weight: 700; }
.err { margin: 10px 0 0; color: var(--red); font-weight: 700; font-size: 14.5px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span { display: block; padding: 7px 14px; border-radius: 6px; border: 1.5px solid var(--rule); font-weight: 700; font-size: 15px; cursor: pointer; }
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.seg input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

.result { margin-top: 18px; border-top: 1px solid var(--line); }
.fields + [data-preview] .result, .fields + [data-out] .result, .chips + [data-out] .result { margin-top: 0; border-top: 0; }
.result > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.result dt { color: var(--muted); }
.result dd { margin: 0; font-weight: 700; text-align: left; }
.result dd small { display: block; font-weight: 400; color: var(--muted); font-size: 13.5px; }

/* ---------- פתק התזכורת ---------- */
dialog#memo {
  padding: 34px 24px 22px; border: 0; width: min(346px, calc(100% - 44px)); max-height: calc(100dvh - 60px); overflow: visible;
  border-radius: 3px; transform: rotate(-1.2deg);
  background-color: var(--memo);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--memo-line) 31px, var(--memo-line) 32px);
  box-shadow: 0 2px 0 var(--memo-line), 0 22px 50px rgba(30, 20, 10, .35);
}
dialog#memo[open] { animation: memo-in .3s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes memo-in { from { transform: translateY(40px) rotate(-4deg); opacity: 0; } to { transform: rotate(-1.2deg); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog#sheet[open], dialog#memo[open] { animation: none; } }
.memo-clip { position: absolute; top: -22px; left: 40px; width: 34px; height: 62px; color: #7D8794; stroke-width: 3; }
.memo-stamp { position: absolute; top: 30px; left: 20px; padding: 3px 10px; border: 2px solid var(--red); border-radius: 4px; transform: rotate(-12deg); color: var(--red); font-family: var(--serif); font-size: 18px; font-weight: 900; opacity: .85; }
#memo h2 { margin: 2px 0 10px; font-family: var(--serif); font-size: 27px; font-weight: 900; line-height: 1.15; outline: none; }
.memo-list { max-height: calc(100dvh - 320px); min-height: 120px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px; }
.memo-list.more { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 44px), transparent); }
.memo-row { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; }
.memo-row input { flex: none; width: 26px; height: 26px; margin: 3px 0 0; border: 1.5px solid var(--ink); border-radius: 4px; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; display: grid; place-content: center; }
.memo-row input:checked { background: var(--ink); }
.memo-row input:checked::after { content: ""; width: 12px; height: 7px; border: solid var(--memo); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); }
.memo-row input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.memo-row .who { flex: 1; min-width: 0; }
.memo-row .name { font-family: var(--serif); font-size: 20px; font-weight: 700; color: inherit; text-decoration: none; }
.memo-row .what { font-size: 15px; color: var(--ink2); }
.memo-row .what.red { color: var(--red); font-weight: 700; }
.memo-row.done .name, .memo-row.done .what { text-decoration: line-through; color: var(--muted); }
.memo-hint { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.memo-actions { margin-top: 16px; }

/* ---------- מחשבון והגדרות ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.chips button { border: 1.5px solid var(--rule); font: inherit; font-weight: 700; font-size: 15px; padding: 6px 14px; border-radius: 6px; background: transparent; color: var(--ink); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.offlist { margin: 6px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--muted); font-weight: 400; }
.offlist li { padding: 2px 0; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 40px; height: 40px; border: 1.5px solid var(--rule); border-radius: 6px; background: transparent; color: var(--ink); font: inherit; font-size: 22px; font-weight: 700; line-height: 1; cursor: pointer; }
.stepper output { min-width: 34px; text-align: center; font-family: var(--serif); font-size: 22px; font-weight: 900; }
.switch { position: relative; flex: none; width: 51px; height: 31px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--rule); transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; right: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + i { background: var(--ink); }
.switch input:checked + i::after { transform: translateX(-20px); }
.switch input:focus-visible + i { outline: 2px solid var(--blue); outline-offset: 2px; }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 14px; min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.setrow .t { font-weight: 700; }
.setrow .s { display: block; color: var(--muted); font-size: 13.5px; font-weight: 400; }
.setlist { border-top: 1px solid var(--line); }
.about { color: var(--ink2); font-size: 14.5px; }
.about p { margin: 10px 0; }
.year-title { margin: 16px 0 4px; font-family: var(--serif); font-size: 17px; font-weight: 700; }

/* ---------- ניווט תחתון ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-around;
  background: var(--paper);
  border-top: 3px double var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { flex: 1; max-width: 160px; display: flex; align-items: center; justify-content: center; height: var(--tabs-h); color: var(--muted); text-decoration: none; font-size: 16px; font-weight: 700; }
.tabs a span { padding: 2px 2px 3px; border-bottom: 2px solid transparent; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] span { border-bottom-color: var(--red); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px); z-index: 20;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 6px;
  font-weight: 700; font-size: 15px; white-space: nowrap; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
