:root {
  color-scheme: light;
  --page: #f5f5fa;
  --surface: #ffffff;
  --surface-2: #fafaff;
  --text: #16162a;
  --text-2: #4a4a66;
  --muted: #6b6b85;
  --line: #e6e6f0;
  --line-2: #d5d5e3;
  --accent: #5b4de0;
  --accent-strong: #4336c4;
  --accent-soft: #eeecfd;
  --in: #177a44;
  --in-soft: #e5f5ec;
  --out: #c2332b;
  --out-soft: #fdecea;
  --warn: #b35a00;
  --warn-soft: #fff3e3;
  --shadow: 0 1px 2px rgba(22, 22, 60, 0.05), 0 6px 20px rgba(22, 22, 60, 0.05);
  --radius: 16px;
  --fs: 16px;
  --fs-sm: 14px;
  --fs-xs: 13px;
  --fs-h: 24px;
  --fs-metric: 36px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--page); color: var(--text);
  font: 400 var(--fs)/1.6 system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; inset-inline-start: 8px; top: -80px; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 10px; z-index: 50; }
.skip:focus { top: 8px; }

/* מספרים: רוחב אחיד, כיוון שמאל-לימין בתוך טקסט עברי */
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
code.cmd { display: inline-block; direction: ltr; unicode-bidi: isolate; white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
code { background: #f0f0f7; border-radius: 6px; padding: 1px 6px; font-family: ui-monospace, Menlo, monospace; font-size: 0.92em; }
.in { color: var(--in); }
.out { color: var(--out); }
.warn-t { color: var(--warn); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }

/* ---------- מסגרת ---------- */
.app { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-inline-end: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { font-size: 20px; font-weight: 800; padding: 4px 10px 16px; letter-spacing: -0.01em; }
.nav a, .nav button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; padding: 11px 12px; border-radius: 12px; color: var(--text-2); text-decoration: none; background: none; border: 0; font-size: var(--fs); }
.nav a:hover, .nav button:hover { background: var(--page); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.nav .ico { width: 22px; text-align: center; }
.side .foot { margin-top: auto; font-size: var(--fs-xs); color: var(--muted); padding: 8px 10px; line-height: 1.5; }
main { min-width: 0; padding: 22px 28px 60px; max-width: 1240px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { font-size: var(--fs-h); font-weight: 800; letter-spacing: -0.01em; }
.topbar .spacer { flex: 1; }
.updated { font-size: var(--fs-sm); color: var(--muted); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-size: var(--fs-sm); color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 11px; font-size: var(--fs-xs); font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); white-space: nowrap; }
.chip.ok { background: var(--in-soft); color: var(--in); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--out-soft); color: var(--out); border-color: transparent; }
.chip.acc { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
button.chip:hover { border-color: var(--accent); }

/* ---------- כרטיסים ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; min-width: 0; }
.card h2 { font-size: 20px; font-weight: 750; margin-bottom: 2px; }
.card .sub { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-grid { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.g-chart { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); }
.metric { margin-bottom: 0; display: flex; flex-direction: column; gap: 6px; }
.metric .label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.metric .value { font-size: var(--fs-metric); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.metric .explain { font-size: var(--fs-sm); color: var(--text-2); }
details.how { margin-top: 4px; }
details.how > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--accent-strong); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; padding: 4px 0; }
details.how > summary::-webkit-details-marker { display: none; }
details.how > summary::before { content: "ⓘ"; }
details.how[open] > summary { margin-bottom: 6px; }
.howbox { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.7; }
.howbox ul { padding-inline-start: 18px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 7px; }
.tag.est { background: var(--warn-soft); color: var(--warn); }
.tag.known { background: var(--in-soft); color: var(--in); }

/* ---------- רשימות ---------- */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: var(--fs-xs); color: var(--muted); }
.attn { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.attn.warn { background: var(--warn-soft); border-color: #f5d7ae; }
.attn.danger { background: var(--out-soft); border-color: #f4c3be; }
.attn .ico { font-size: 18px; line-height: 1.4; }
.attn button { margin-inline-start: auto; }
.btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.linkbtn { border: 0; background: none; color: var(--accent-strong); font-weight: 600; font-size: var(--fs-sm); padding: 4px 0; }

/* ---------- טבלאות ---------- */
.tablewrap { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 12px; }
.tablewrap.tall { max-height: 70vh; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: start; font-size: var(--fs-xs); color: var(--text-2); font-weight: 700; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; background: var(--surface); }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: end; }
.stick { position: sticky; inset-inline-start: 0; z-index: 1; background: inherit; box-shadow: -1px 0 0 var(--line) inset; }
th.stick { z-index: 3; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.open td { background: var(--accent-soft); }
tr.detail td { background: var(--surface-2); }
.total td { font-weight: 800; background: var(--surface-2); }

/* ---------- טפסים ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.filters label, .field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; background: var(--surface); font-size: var(--fs-sm); min-width: 0; width: 100%;
}
input[type=range] { width: 100%; accent-color: var(--accent); }
.editbox { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; align-items: end; margin-top: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-size: var(--fs-sm); }
.summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.summary .chip { font-size: var(--fs-sm); }

/* ---------- גרף ---------- */
.chart { position: relative; direction: ltr; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 6px 10px; font-size: var(--fs-xs); direction: rtl; box-shadow: var(--shadow); white-space: nowrap; display: none; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: var(--fs-xs); color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 20px; height: 0; border-top-width: 3px; border-top-style: solid; display: inline-block; }

/* ---------- ג'רוויס ---------- */
.jv { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; height: calc(100vh - 44px); }
.jv-main { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.jv-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.jv-head .btn { white-space: nowrap; }
.jv-head h1 { font-size: 22px; font-weight: 800; }
.jv-thread { flex: 1; overflow-y: auto; padding: 22px 22px 10px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 780px; }
.msg.user { align-self: flex-start; background: var(--accent-soft); color: var(--accent-strong); padding: 10px 15px; border-radius: 16px 16px 16px 4px; font-weight: 600; white-space: pre-wrap; }
.msg.assistant { align-self: stretch; }
.msg.assistant .bubble { white-space: pre-wrap; line-height: 1.75; font-size: 17px; }
.msg .caveat { display: inline-flex; gap: 6px; background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 3px 10px; font-size: var(--fs-xs); font-weight: 700; margin-bottom: 6px; }
.msg .evline { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.proposal { border: 1px dashed var(--accent); border-radius: 12px; padding: 12px; margin-top: 8px; background: var(--accent-soft); }
.jv-starters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.jv-starters .chip { white-space: normal; text-align: start; font-size: var(--fs-sm); padding: 7px 13px; }
.jv-main, .jv-thread, .msg, .jv-empty { min-width: 0; overflow-wrap: anywhere; }
.jv-empty { margin: auto; text-align: center; max-width: 560px; padding: 20px; }
.jv-empty h2 { font-size: 24px; margin-bottom: 6px; }
.composer { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-end; background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); }
.composer textarea { resize: none; max-height: 180px; min-height: 46px; font-size: var(--fs); line-height: 1.5; padding: 11px 13px; }
.composer .btn.primary { padding: 11px 20px; font-size: var(--fs); white-space: nowrap; flex-shrink: 0; }
.jv-panel { overflow-y: auto; min-height: 0; }
.jv-panel .card { padding: 16px 18px; }
.ev h3 { font-size: 16px; font-weight: 750; }
.ev .big { font-size: 28px; font-weight: 800; margin: 2px 0 6px; }
.ev dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: var(--fs-xs); color: var(--text-2); }
.ev dt { font-weight: 700; color: var(--text); }
.typing { color: var(--muted); font-style: italic; }

/* ---------- מובייל ---------- */
.bottomnav { display: none; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 15, 40, 0.35); z-index: 40; display: flex; align-items: flex-end; }
.sheet { background: var(--surface); width: 100%; border-radius: 20px 20px 0 0; padding: 14px 14px calc(18px + env(safe-area-inset-bottom)); }
.mcard { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; background: var(--surface); }
.mcard summary { list-style: none; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.mcard summary::-webkit-details-marker { display: none; }
.only-m { display: none; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-chart { grid-template-columns: minmax(0, 1fr); }
  .jv { grid-template-columns: minmax(0, 1fr); }
  .jv-panel { display: none; }
  .ev-inline { display: block; }
}
@media (min-width: 1101px) { .ev-inline { display: none; } }
@media (max-width: 760px) {
  :root { --fs: 16px; --fs-h: 22px; --fs-metric: 30px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  main { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .card { padding: 16px; border-radius: 14px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .only-d { display: none !important; }
  .only-m { display: block; }
  .bottomnav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; bottom: 0; inset-inline: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--text-2); text-decoration: none; background: none; border: 0; padding: 6px 0; border-radius: 10px; }
  .bottomnav .ico { font-size: 20px; }
  .bottomnav [aria-current="page"] { color: var(--accent-strong); font-weight: 700; background: var(--accent-soft); }
  .jv { height: calc(100dvh - 84px - env(safe-area-inset-bottom)); }
  .jv-thread { padding: 14px 12px; }
  .composer { position: sticky; bottom: 0; }
  .topbar .seg { width: 100%; justify-content: space-between; }
  .topbar .seg button { flex: 1; padding: 8px 4px; }
}

/* חלון "איך חושב?" */
#howDlg { margin: auto; border: 0; padding: 0; border-radius: 18px; width: min(760px, 92vw); max-height: 86vh; box-shadow: 0 20px 60px rgba(20, 20, 60, 0.25); color: var(--text); background: var(--surface); overflow: hidden; }
#howDlg::backdrop { background: rgba(15, 15, 40, 0.42); }
#howDlg .dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
#howDlg .dlg-head h2 { font-size: 20px; font-weight: 750; }
#howDlg .dlg-body { border: 0; border-radius: 0; margin: 0; padding: 16px 20px 20px; max-height: calc(86vh - 64px); overflow: auto; font-size: var(--fs); line-height: 1.75; }
#howDlg .dlg-body table { font-size: var(--fs-sm) !important; }
#howDlg .dlg-body ul { margin: 6px 0; }
.how-btn { align-self: flex-start; margin-top: 4px; }
@media (max-width: 760px) {
  #howDlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 88dvh; }
}
#howDlg.demo .num, #howDlg.demo .dlg-body { filter: blur(0.45em); }

/* מצב הדגמה: המספרים מטושטשים */
body.demo .num, body.demo .ev dl, body.demo .howbox { filter: blur(0.45em); user-select: none; }

/* יעדים, כללים ודוחות */
.pbar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 8px; min-width: 60px; }
.pbar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.pbar.ok > span { background: var(--in); }
.pbar.bad > span { background: var(--out); }
.pbar.warn > span { background: var(--warn); }
.bul { padding-inline-start: 20px; display: grid; gap: 4px; font-size: var(--fs-sm); }
.h3 { font-size: 16px; font-weight: 750; margin: 14px 0 6px; }
.deep-out { white-space: pre-wrap; line-height: 1.75; font-size: var(--fs-sm); }
@media print {
  .side, .bottomnav, .topbar .seg, .noprint, .skip, .attn { display: none !important; }
  body { background: #fff; }
  .app { display: block; }
  main { padding: 0 !important; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .tablewrap { overflow: visible; }
}

[hidden] { display: none !important; }

.jv-remind { margin: 10px 16px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.jv-remind > summary { padding: 8px 12px; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.jv-remind-body { padding: 0 10px 10px; max-height: 40vh; overflow-y: auto; }
#learnCard > details > summary { cursor: pointer; }

/* מסך ראשון במובייל */
.hero { display: none; }
.hero-t { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.hero-v { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
@media (max-width: 760px) {
  .hero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
  .hero-v { font-size: 17px; }
  .metric .value { font-size: 26px; }
  .card { padding: 14px 14px; }
  .attn { padding: 10px 10px; }
  .attn button { margin-inline-start: 0; }
}
@media (max-width: 360px) { .hero-v { font-size: 16px; } }
.attn, .card, .row, .sub, .small { text-align: start; }
