:root {
  --bg: #f4f6f7; --surface: #ffffff; --surface-2: #f8fafb; --border: #e2e8eb; --border-2: #cfd8dc;
  --text: #17222b; --text-2: #4a5a66; --muted: #7b8a95;
  --primary: #0f766e; --primary-2: #0d5f59; --primary-soft: #e0f2ef; --on-primary: #fff;
  --green: #15803d; --green-soft: #dcfce7; --red: #b91c1c; --red-soft: #fee2e2; --orange: #c2410c; --orange-soft: #ffedd5;
  --blue: #1d4ed8; --blue-soft: #dbeafe; --purple: #6d28d9;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
  --radius: 12px; --radius-sm: 8px;
  --sidebar: 236px; --topbar: 60px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1417; --surface: #151d21; --surface-2: #1b252a; --border: #26333a; --border-2: #33434b;
  --text: #e6edf0; --text-2: #b0bec5; --muted: #7d8f98;
  --primary: #2dd4bf; --primary-2: #5eead4; --primary-soft: #12332f; --on-primary: #06201d;
  --green: #4ade80; --green-soft: #12301f; --red: #f87171; --red-soft: #3a1717; --orange: #fb923c; --orange-soft: #3a2412;
  --blue: #60a5fa; --blue-soft: #172a45; --purple: #a78bfa;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: "Heebo", "Assistant", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.ic { flex-shrink: 0; vertical-align: middle; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.green { color: var(--green); } .red { color: var(--red); } .orange { color: var(--orange); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ===== layout ===== */
#app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 12px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; font-weight: 700; font-size: 17px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 14.5px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav .sep { height: 1px; background: var(--border); margin: 8px 6px; }
.nav .badge { margin-inline-start: auto; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--border);
}
.search-wrap { position: relative; flex: 1; max-width: 520px; }
.search-wrap input[type=search] { width: 100%; padding-block: 9px; padding-inline: 38px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.search-wrap .ic { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-results {
  position: absolute; top: calc(100% + 6px); inset-inline: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 70vh; overflow: auto; z-index: 50; padding: 6px;
}
.search-results h6 { margin: 8px 8px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.search-results button { display: flex; width: 100%; text-align: start; gap: 8px; padding: 8px; border: 0; background: none; border-radius: 8px; cursor: pointer; align-items: center; }
.search-results button:hover, .search-results button:focus { background: var(--surface-2); outline: none; }
.top-actions { display: flex; gap: 6px; margin-inline-start: auto; align-items: center; }
#save-state { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
#save-state[data-state="saving"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
#save-state[data-state="saved"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.content { padding: 20px; max-width: 1400px; width: 100%; margin: 0 auto; flex: 1; }
.banner { padding: 8px 20px; font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.banner.warn { background: var(--orange-soft); color: var(--orange); }
.banner.info { background: var(--blue-soft); color: var(--blue); }
.banner button { margin-inline-start: auto; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; margin: 0; margin-inline-end: auto; }

/* ===== controls ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border-2);
  background: var(--surface); cursor: pointer; font-size: 14px; white-space: nowrap; min-height: 38px; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--border)); }
.btn.danger.solid { background: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.icon { padding: 7px; min-width: 38px; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font-size: 13.5px; min-height: 36px; }
.seg button + button { border-inline-start: 1px solid var(--border); }
.seg button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=password], input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-2); border-radius: 8px; background: var(--surface); min-height: 38px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.field .help { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--red); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-weight: 700; font-size: 14px; color: var(--primary); margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
button.chip { cursor: pointer; }
.multi-box { border: 1px solid var(--border-2); border-radius: 8px; padding: 6px; max-height: 180px; overflow: auto; background: var(--surface); }
.multi-box input[type=search] { margin-bottom: 6px; min-height: 32px; padding: 4px 8px; }
.multi-box label { display: flex; align-items: center; gap: 8px; padding: 3px 4px; font-size: 14px; cursor: pointer; }
.rating { display: flex; gap: 4px; }
.rating button { border: 0; background: none; cursor: pointer; color: var(--border-2); padding: 2px; }
.rating button.on { color: #eab308; }
.rating button.on svg { fill: #eab308; }

/* ===== cards & badges ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.card h3 .btn { margin-inline-start: auto; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; text-align: start; box-shadow: var(--shadow); transition: border-color .15s; }
.kpi:hover { border-color: var(--primary); }
.kpi .lbl { font-size: 13px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.kpi .val { font-size: 21px; font-weight: 700; margin-top: 4px; line-height: 1.25; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.good .val { color: var(--green); } .kpi.bad .val { color: var(--red); } .kpi.warn .val { color: var(--orange); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.green, .st-done { background: var(--green-soft); color: var(--green); }
.badge.red, .st-noshow { background: var(--red-soft); color: var(--red); }
.badge.orange, .st-cancelc { background: var(--orange-soft); color: var(--orange); }
.badge.blue, .st-planned { background: var(--blue-soft); color: var(--blue); }
.st-cancel { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.li:last-child { border-bottom: 0; }
.li.click { cursor: pointer; border-radius: 8px; }
.li.click:hover { background: var(--surface-2); }
.li .meta { font-size: 12.5px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 14px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ===== tables ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: start; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 9px 10px; font-size: 13px; white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 9px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t tfoot td { font-weight: 700; background: var(--surface-2); }
.void td { opacity: .5; text-decoration: line-through; }

/* ===== client cards view ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ccard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; text-align: start; }
.ccard:hover { border-color: var(--primary); }
.ccard .top { display: flex; gap: 10px; align-items: center; }
.ccard .name { font-weight: 700; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input[type=search] { max-width: 260px; }
.filters select { width: auto; min-width: 130px; }

/* ===== modal / drawer ===== */
.overlay { position: fixed; inset: 0; background: rgba(10,16,20,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 16px; width: min(640px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(980px, 100%); }
.modal.narrow { width: min(440px, 100%); }
/* כרטיס (למשל כרטיס מטופל): ממורכז כמו חלונית, בגובה קבוע כדי שלא יקפוץ במעבר בין לשוניות */
.modal.sheet { width: min(1100px, 100%); height: min(960px, calc(100vh - 32px)); background: var(--bg); overflow: hidden; }
.modal.sheet .modal-head { background: var(--surface); }
.modal.sheet .modal-body { flex: 1; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.drawer-ov { justify-content: flex-start; padding: 0; align-items: stretch; }
.drawer { background: var(--bg); width: min(1100px, 100%); height: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slidein .2s; }
@keyframes slidein { from { transform: translateX(40px); opacity: .4; } }
.drawer .modal-head { background: var(--surface); }
.drawer .modal-body { flex: 1; }
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); background: var(--surface); padding: 0 12px; scrollbar-width: thin; }
.tabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; white-space: nowrap; color: var(--text-2); border-bottom: 2px solid transparent; font-size: 14px; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.toast-host { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2a30; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; animation: fade .2s; max-width: 90vw; }
.toast.err { background: var(--red); } .toast.ok { background: #166534; }
.note-box { background: var(--orange-soft); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; border-inline-start: 4px solid var(--orange); }
.info-box { background: var(--blue-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; border-inline-start: 4px solid var(--blue); }
.danger-box { background: var(--red-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; border-inline-start: 4px solid var(--red); }
.confidential { border: 1px dashed var(--purple); border-radius: 10px; padding: 10px; }
.confidential-tag { color: var(--purple); font-size: 12px; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.timeline { border-inline-start: 2px solid var(--border); padding-inline-start: 14px; margin-inline-start: 6px; }
.timeline .ev { position: relative; padding: 6px 0 12px; }
.timeline .ev::before { content: ""; position: absolute; inset-inline-start: -21px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); }

/* ===== FAB & quick ===== */
.fab { position: fixed; bottom: 24px; inset-inline-end: 24px; width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: var(--on-primary); border: 0; box-shadow: var(--shadow-lg); cursor: pointer; z-index: 40; display: grid; place-items: center; }
.quick-menu { position: fixed; bottom: 90px; inset-inline-end: 24px; z-index: 41; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; }
.quick-menu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: none; cursor: pointer; border-radius: 8px; font-size: 15px; }
.quick-menu button:hover { background: var(--surface-2); }
.notif-panel { position: absolute; top: calc(var(--topbar) - 4px); inset-inline-end: 12px; width: min(380px, calc(100vw - 24px)); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 60; padding: 8px; }
.dot-count { position: absolute; top: 2px; inset-inline-end: 2px; background: var(--red); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 3px; }
.rel { position: relative; }

/* ===== bottom nav (mobile) ===== */
.bottom-nav { display: none; }
.mobile-only { display: none; }

/* ===== calendar ===== */
.cal-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.cal-title { font-weight: 700; font-size: 17px; min-width: 160px; }
.cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-head { display: grid; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-head div { padding: 6px; text-align: center; font-size: 13px; border-inline-start: 1px solid var(--border); }
.cal-head .today { color: var(--primary); font-weight: 700; }
.cal-allday { display: grid; border-bottom: 1px solid var(--border); min-height: 26px; }
.cal-allday > div { border-inline-start: 1px solid var(--border); padding: 2px; display: flex; flex-direction: column; gap: 2px; }
.cal-allday .task-pill { font-size: 11.5px; padding: 1px 6px; border-radius: 5px; background: var(--orange-soft); color: var(--orange); cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-allday .task-pill.done { text-decoration: line-through; opacity: .6; }
.cal-scroll { max-height: calc(100vh - 260px); overflow-y: auto; position: relative; }
.cal-body { display: grid; position: relative; }
.cal-times div { height: var(--hour-h); font-size: 11px; color: var(--muted); text-align: center; border-top: 1px solid var(--border); padding-top: 2px; }
.cal-col { position: relative; border-inline-start: 1px solid var(--border); }
.cal-col .slot { height: calc(var(--hour-h) / 2); border-top: 1px solid var(--border); }
.cal-col .slot:nth-child(even) { border-top-style: dotted; }
.cal-col .slot.off { background: repeating-linear-gradient(45deg, transparent, transparent 6px, color-mix(in srgb, var(--border) 50%, transparent) 6px, color-mix(in srgb, var(--border) 50%, transparent) 7px); }
.cal-col.today-col { background: color-mix(in srgb, var(--primary-soft) 40%, transparent); }
.now-line { position: absolute; inset-inline: 0; height: 2px; background: var(--red); z-index: 3; pointer-events: none; }
.ev-box {
  position: absolute; inset-inline-start: 3px; inset-inline-end: 3px; border-radius: 7px; padding: 3px 6px; font-size: 12px; overflow: hidden; cursor: grab;
  color: #fff; border-inline-start: 4px solid rgba(0,0,0,.25); z-index: 2; touch-action: none; user-select: none; line-height: 1.3;
}
.ev-box.dragging { opacity: .85; box-shadow: var(--shadow-lg); z-index: 10; cursor: grabbing; }
.ev-box.conflict { outline: 2px solid var(--red); outline-offset: 1px; }
.ev-box.cancelled { opacity: .45; text-decoration: line-through; }
.ev-box.done::after { content: "✓"; position: absolute; top: 2px; inset-inline-end: 5px; }
.ev-box .rs { position: absolute; bottom: 0; inset-inline: 0; height: 8px; cursor: ns-resize; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-grid .mcell { min-height: 108px; border-inline-start: 1px solid var(--border); border-top: 1px solid var(--border); padding: 4px; font-size: 12px; cursor: pointer; overflow: hidden; }
.month-grid .mcell.other { background: var(--surface-2); color: var(--muted); }
.month-grid .mcell.today .dn { background: var(--primary); color: var(--on-primary); border-radius: 50%; }
.month-grid .dn { display: inline-grid; place-items: center; width: 24px; height: 24px; font-weight: 600; }
.month-grid .heb { font-size: 10.5px; color: var(--muted); margin-inline-start: 4px; }
.mev { display: block; padding: 1px 5px; border-radius: 4px; color: #fff; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }

/* ===== charts ===== */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { transition: opacity .15s; }
.chart .bar:hover { opacity: .8; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart-tip { position: fixed; pointer-events: none; z-index: 400; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.hbar .track { height: 12px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; background: var(--primary); }
.legend { display: flex; gap: 12px; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; flex-wrap: wrap; }
.legend span { display: inline-flex; gap: 5px; align-items: center; }
.progress { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); }

/* ===== lock & wizard ===== */
.fullscreen { position: fixed; inset: 0; background: var(--bg); z-index: 500; display: grid; place-items: center; padding: 16px; overflow: auto; }
.lock-card, .wizard { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; width: min(420px, 100%); box-shadow: var(--shadow-lg); text-align: center; }
.wizard { width: min(760px, 100%); text-align: start; }
.wizard h1 { margin: 0 0 4px; font-size: 22px; }
.steps { display: flex; gap: 6px; margin: 12px 0 18px; }
.steps div { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.steps div.on { background: var(--primary); }
.prof-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.prof-grid button { padding: 12px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; text-align: start; }
.prof-grid button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.daypick { display: flex; gap: 6px; flex-wrap: wrap; }
.daypick button { width: 42px; height: 38px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; }
.daypick button.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.status-table td:first-child { width: 40%; }
.ok-dot { color: var(--green); font-weight: 700; } .no-dot { color: var(--red); font-weight: 700; } .part-dot { color: var(--orange); font-weight: 700; }

/* ===== print ===== */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; color: #000; background: #fff; font-size: 12pt; }
  #print-area table { width: 100%; border-collapse: collapse; }
  #print-area th, #print-area td { border-bottom: 1px solid #ccc; padding: 4pt; text-align: start; }
  @page { margin: 14mm; }
}
.doc { background: #fff; color: #111; padding: 24px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px; }
.doc h2 { margin: 0; font-size: 20px; } .doc h4 { margin: 18px 0 6px; font-size: 14px; }
.doc table { width: 100%; border-collapse: collapse; } .doc th, .doc td { border-bottom: 1px solid #ddd; padding: 5px; text-align: start; }
.doc .doc-logo { max-height: 72px; max-width: 160px; object-fit: contain; display: block; }
.doc .disc { margin-top: 18px; font-size: 12px; color: #555; border-top: 1px solid #ddd; padding-top: 8px; }
.doc .total { font-size: 17px; font-weight: 700; }

/* ===== responsive ===== */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 0 12px; }
  .content { padding: 14px 12px 96px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; z-index: 45; background: var(--surface);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: 11.5px; color: var(--text-2); text-decoration: none; border: 0; background: none; cursor: pointer; }
  .bottom-nav .active { color: var(--primary); font-weight: 600; }
  .fab { bottom: 78px; inset-inline-end: 16px; }
  .quick-menu { bottom: 142px; inset-inline-end: 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { max-height: 100%; border-radius: 14px; }
  .overlay:not(.drawer-ov) { padding: 8px; align-items: flex-end; }
  .drawer { width: 100%; }
  .overlay:has(> .modal.sheet) { padding: 0; align-items: stretch; }
  .modal.sheet { height: 100%; max-height: none; border-radius: 0; }
  .hide-m { display: none !important; }
  .mobile-only { display: initial; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .val { font-size: 17px; }
  .page-head h1 { font-size: 19px; }
  .filters input[type=search] { max-width: none; flex: 1 1 100%; }
  .month-grid .mcell { min-height: 70px; }
  .mev { font-size: 10px; }
  #save-state span { display: none; }
}
/* ===== palettes (בהיר / כהה) ===== */
:root[data-palette="blue"] { --primary: #1d4ed8; --primary-2: #1e40af; --primary-soft: #e0e9fd; }
:root[data-palette="indigo"] { --primary: #4338ca; --primary-2: #3730a3; --primary-soft: #e6e6fb; }
:root[data-palette="purple"] { --primary: #7e22ce; --primary-2: #6b21a8; --primary-soft: #f1e6fb; }
:root[data-palette="plum"] { --primary: #a21caf; --primary-2: #86198f; --primary-soft: #fae6fb; }
:root[data-palette="brown"] { --primary: #7c4a2d; --primary-2: #5f3820; --primary-soft: #f3e9e2; }
:root[data-palette="slate"] { --primary: #334155; --primary-2: #1e293b; --primary-soft: #e5e9ef; }
:root[data-theme="dark"][data-palette="blue"] { --primary: #60a5fa; --primary-2: #93c5fd; --primary-soft: #15263f; --on-primary: #0a1a33; }
:root[data-theme="dark"][data-palette="indigo"] { --primary: #818cf8; --primary-2: #a5b4fc; --primary-soft: #1e1f45; --on-primary: #10123a; }
:root[data-theme="dark"][data-palette="purple"] { --primary: #c084fc; --primary-2: #d8b4fe; --primary-soft: #2a1840; --on-primary: #1c0b2e; }
:root[data-theme="dark"][data-palette="plum"] { --primary: #e879f9; --primary-2: #f0abfc; --primary-soft: #36153a; --on-primary: #2a0830; }
:root[data-theme="dark"][data-palette="brown"] { --primary: #d6a27c; --primary-2: #e6bf9f; --primary-soft: #33241a; --on-primary: #2a1a0f; }
:root[data-theme="dark"][data-palette="slate"] { --primary: #94a3b8; --primary-2: #cbd5e1; --primary-soft: #1f2933; --on-primary: #0f172a; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border: 2px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 14px; }
.swatch span { width: 22px; height: 22px; border-radius: 50%; display: inline-block; }
.swatch.on { border-color: var(--primary); font-weight: 600; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.mod-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--surface); }
.mod-item.locked { cursor: default; color: var(--muted); background: var(--surface-2); }
.mod-item .badge { margin-inline-start: auto; }

/* ===== guide ===== */
.guide { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.guide-toc { position: sticky; top: calc(var(--topbar) + 12px); display: flex; flex-direction: column; gap: 1px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; max-height: calc(100vh - var(--topbar) - 40px); overflow-y: auto; }
.guide-toc button { display: flex; gap: 8px; align-items: center; text-align: start; border: 0; background: none; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.guide-toc button:hover { background: var(--surface-2); color: var(--text); }
.guide-toc button.dim { opacity: .35; }
.guide-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.guide-sec { scroll-margin-top: calc(var(--topbar) + 12px); line-height: 1.7; }
.guide-sec h3 { font-size: 17px; color: var(--primary); }
.guide-sec h4 { margin: 14px 0 6px; font-size: 14.5px; }
.guide-sec p { margin: 6px 0; }
.guide-sec ul, .guide-sec ol { margin: 6px 0; padding-inline-start: 22px; }
.guide-sec li { margin-bottom: 4px; }
.guide-sec li .btn { margin-inline-start: 6px; vertical-align: middle; }
.guide-sec .table-wrap, .guide-sec .info-box, .guide-sec .note-box, .guide-sec > .card { margin: 10px 0; }
.guide-sec code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; direction: ltr; unicode-bidi: isolate; }
.faq { border-bottom: 1px solid var(--border); padding: 8px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--text-2); }
@media (max-width: 900px) {
  .guide { grid-template-columns: 1fr; }
  .guide-toc { position: static; flex-direction: row; flex-wrap: wrap; max-height: none; }
  .guide-toc button { font-size: 12.5px; padding: 5px 8px; background: var(--surface-2); }
}
.more-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.more-sheet a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 12px; background: var(--surface-2); text-decoration: none; color: var(--text); font-size: 13px; text-align: center; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* בחירה עם הוספת פריט חדש, ובחירה מרובה כרשימה נפתחת עם תגיות */
.sel-add { display: flex; gap: 6px; align-items: stretch; }
.sel-add select { flex: 1; min-width: 0; }
.sel-add .btn.icon { flex: none; }
.combo .chips { margin-top: 6px; }
.combo .chips:empty { display: none; }
.chip .chip-x { border: 0; background: none; padding: 0; margin-inline-start: 2px; cursor: pointer; color: inherit; display: inline-flex; opacity: .65; }
.chip .chip-x:hover { opacity: 1; }
/* שורות חוזרות (ילדים) */
.rows-box [data-list] { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.row-item { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row-item .mini { display: flex; flex-direction: column; gap: 2px; flex: 1 1 160px; min-width: 0; }
.row-item .mini span { font-size: 12px; color: var(--muted); }
/* מסך כניסה */
.login-card { width: min(440px, 100%); }
.login-logo { background: #fff; border-radius: 14px; padding: 10px 12px; margin: -6px 0 10px; }
.login-logo img { display: block; width: 100%; height: auto; }
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-inline-end: 42px; }
.pw-wrap .btn.icon { position: absolute; inset-inline-end: 3px; top: 50%; transform: translateY(-50%); }
/* בחירה עם הקלדה וחיפוש */
.ta { position: relative; flex: 1; min-width: 0; }
.ta-in { width: 100%; }
.ta-list { position: absolute; inset-inline: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 260px; overflow: auto; z-index: 60; padding: 4px; }
.ta-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.ta-item.on, .ta-item:hover { background: var(--primary-soft); }
.ta-new { color: var(--primary); font-weight: 600; border-top: 1px solid var(--border); margin-top: 2px; }
.ta-empty { padding: 8px 10px; }

.pw-hint { min-height: 18px; margin-top: -4px; }

/* תחתית תפריט הצד: הלוגו המלא מימין, הגרסה משמאל */
.side-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 14px 6px 4px; border-top: 1px solid var(--border); }
.side-foot .sf-logo { display: block; width: 140px; max-width: calc(100% - 72px); height: auto; }
.side-foot .tiny { white-space: nowrap; padding-bottom: 2px; }
.sf-dark { display: none !important; }
:root[data-theme="dark"] .sf-light { display: none !important; }
:root[data-theme="dark"] .sf-dark { display: block !important; }

/* שאלונים */
.as-items { display: flex; flex-direction: column; gap: 10px; }
.as-item { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.as-q { margin-bottom: 8px; font-weight: 500; }
.as-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.as-opts button { flex: 1 1 110px; min-height: 36px; }
.as-sum { padding: 10px 12px; }
/* גרף התקדמות: קו דק, נקודות, קווי סף עמומים */
.trend { width: 100%; height: auto; max-height: 200px; display: block; margin: 4px 0 10px; }
.trend .tr-axis { stroke: var(--border); stroke-width: 1; }
.trend .tr-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.trend .tr-lbl { fill: var(--muted); font-size: 11px; }
.trend .tr-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend .tr-dot { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.trend .tr-dot.flag { fill: var(--red); }
.trend .tr-pt { cursor: pointer; outline: none; }
.trend .tr-pt:hover .tr-dot, .trend .tr-pt:focus .tr-dot { r: 6.5; }

/* חיפוש מהיר Ctrl+K */
.palette-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 900; display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.palette { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette-in { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-in input { flex: 1; border: 0; background: transparent; font-size: 16px; padding: 4px 0; color: var(--text); outline: none; box-shadow: none; }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-list h6 { margin: 8px 8px 4px; font-size: 11px; color: var(--muted); font-weight: 600; }
.palette-list button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.palette-list button.on { background: var(--primary-soft); }
kbd { font: 11px/1 ui-monospace, Consolas, monospace; padding: 3px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--bg, transparent); color: var(--muted); }

/* במחשב: רק אזור התוכן נגלל. פס הגלילה של התוכן בצד שמאל של החלון, ושל תפריט הצד בצד השמאלי שלו */
@media (min-width: 901px) {
  #app { height: 100vh; overflow: hidden; }
  .main { height: 100vh; overflow-y: auto; }
}
@media print { #app, .main { height: auto !important; overflow: visible !important; } }

/* ===== מכתבים על בלנק העסק ===== */
.modal-body:has(> .lt-edit) { overflow: hidden; display: flex; }
.lt-edit { flex: 1; display: grid; grid-template-columns: minmax(340px, 1fr) minmax(0, 1.15fr); min-height: 0; }
.lt-form { padding: 16px 18px; overflow-y: auto; border-inline-end: 1px solid var(--border); background: var(--surface); min-height: 0; }
.lt-fs { border: 0; padding: 0; margin: 0; min-width: 0; }
.lt-sec-h { margin: 16px 0 6px; }
.lt-sec { border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
.lt-sec.off { opacity: .55; }
.lt-sec textarea { width: 100%; resize: vertical; }
.lt-prev-wrap { display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); }
.lt-prev-h { display: flex; justify-content: space-between; padding: 8px 14px; }
.lt-preview { overflow: auto; padding: 0 12px 16px; flex: 1; min-height: 0; contain: inline-size; }
.lt-prev-wrap, .lt-form { min-width: 0; }
.lt-preview > div { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.lt-preview .lt-page { box-shadow: 0 4px 18px rgba(0, 0, 0, .18); }
.lt-set-prev { max-height: 72vh; padding: 0; background: var(--surface-2); border-radius: 10px; padding: 12px; }
.lt-page { position: relative; width: 210mm; height: 297mm; background: #fff; color: #111; overflow: hidden; flex: none; font-family: Arial, "Segoe UI", sans-serif; font-size: 12pt; line-height: 1.55; direction: rtl; text-align: right; }
.lt-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.lt-content { position: absolute; overflow: hidden; }
.lt-pno { position: absolute; font-size: 9pt; color: #666; text-align: center; line-height: 1; }
.lt-p { margin: 0 0 .45em; white-space: pre-wrap; overflow-wrap: anywhere; }
.lt-bul { padding-inline-start: 1em; text-indent: -1em; }
.lt-h { margin: .9em 0 .3em; font-size: 12.5pt; font-weight: 700; }
.lt-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10mm; margin-bottom: 7mm; }
.lt-to { white-space: pre-wrap; }
.lt-date { text-align: left; white-space: nowrap; }
.lt-conf { display: inline-block; font-weight: 700; border: 1.5px solid #111; padding: 0 6px; margin-bottom: 4px; letter-spacing: 1px; }
.lt-subj { font-weight: 700; text-align: center; text-decoration: underline; margin: 0 0 6mm; }
.lt-open { margin-bottom: .8em; }
.lt-end { margin-top: 7mm; }
.lt-end .lt-p { margin: 0; }
.lt-sig { display: block; max-height: 24mm; max-width: 60mm; margin: 2mm 0 1mm; }
.lt-sig-space { height: 12mm; }
.lt-sig-n { font-weight: 700; }
.lt-biz { display: flex; gap: 5mm; align-items: center; border-bottom: 1px solid #bbb; padding-bottom: 4mm; margin-bottom: 8mm; font-size: 10pt; color: #333; }
.lt-biz-n { font-size: 16pt; font-weight: 700; color: #111; }
.lt-logo { max-height: 20mm; max-width: 45mm; object-fit: contain; }
.lt-measure { position: fixed; left: -10000px; top: 0; visibility: hidden; pointer-events: none; }
.show-area .lt-content { outline: 1.5px dashed #d9534f; }
.lt-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.lt-kind { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: start; padding: 12px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; color: var(--text); font: inherit; }
.lt-kind:hover, .lt-kind:focus-visible { border-color: var(--primary); }
.lt-kind svg { color: var(--primary); }
@media (max-width: 900px) {
  .modal-body:has(> .lt-edit) { overflow-y: auto; display: block; }
  .lt-edit { display: block; }
  .lt-form { border: 0; overflow: visible; }
}
@page letter { size: A4; margin: 0; }
@media print {
  #print-area .lt-print { margin: 0; }
  #print-area .lt-page { page: letter; break-after: page; box-shadow: none; }
  #print-area .lt-page:last-child { break-after: auto; }
}

/* ===== תחושת אפליקציה (התקנה בנייד / חלון נפרד) ===== */
/* בלי "משיכה לרענון" ובלי קפיצת גלילה: רענון הדף מוחק את מפתח ההצפנה מהזיכרון ומחייב כניסה מחדש */
html, body { overscroll-behavior-y: none; }
/* בלי השהיית הקשה כפולה ובלי סימון טקסט בלחיצה ארוכה על כפתורים וניווט */
button, .btn, a, [role="tab"], .bottom-nav { touch-action: manipulation; }
.btn, .bottom-nav, .nav, .fab, .modal-head h2 { -webkit-user-select: none; user-select: none; }
@media (max-width: 900px) {
  /* טלפונים עם חור למצלמה / אזור מעוגל: התוכן לא נחתך בצדדים ובחלק העליון */
  .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar) + env(safe-area-inset-top)); padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .content { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .fab { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .quick-menu { bottom: calc(142px + env(safe-area-inset-bottom)); }
  .modal.sheet .modal-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .modal.sheet .modal-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* הודעת "גרסה חדשה מוכנה" */
.update-bar { position: fixed; z-index: 70; bottom: calc(20px + env(safe-area-inset-bottom)); inset-inline-start: 50%; transform: translateX(50%);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 10px 14px; font-size: 14px; }
@media (max-width: 900px) { .update-bar { bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100vw - 24px); } }
@media print { .update-bar { display: none !important; } }
