/* פריש — עיצוב. בלי גופנים / משאבים חיצוניים (CSP: הכל מ-self). */
:root {
  --brand: #1f3b57; --brand-2: #2c5a85; --accent: #c8922b;
  --bg: #f4f6f9; --card: #fff; --ink: #1c2530; --muted: #6b7684; --line: #dfe4ea; --soft: #eef2f6;
  --ok: #1f7a4d; --ok-bg: #e5f4ec; --warn: #9a5b00; --warn-bg: #fff3dc; --bad: #b42318; --bad-bg: #fde8e6;
  --r: 10px; --sh: 0 1px 2px rgba(20, 30, 45, .06), 0 2px 8px rgba(20, 30, 45, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Arial, "Noto Sans Hebrew", sans-serif; color: var(--ink); background: var(--bg); }
body.has-modal { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h3 { font-size: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.boot { padding: 80px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.sm { font-size: 12.5px; }
.ltr { direction: ltr; text-align: right; }
.grow { flex: 1 1 auto; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.warn-t { color: var(--warn); }
.hint { color: var(--muted); font-size: 12.5px; margin: .3em 0 .8em; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------- כפתורים ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 13px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: #b9c3ce; background: var(--soft); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.big { padding: 11px 18px; font-size: 15px; width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.busy { opacity: .6; pointer-events: none; }
.btn.busy::after { content: '…'; }
.link { background: none; border: 0; padding: 0; color: var(--brand-2); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.x { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); padding: 2px 6px; line-height: 1; }
.x.sm { font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- שדות ---------- */
.f { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.f.inl { flex-direction: row; align-items: center; margin: 0; gap: 6px; }
.f input, .f select, .f textarea, .toolbar input, .toolbar select, input.grow, #m-q, textarea#p-txt, .m-foot select {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--ink); min-width: 0; }
.f input:focus, .f select:focus, .f textarea:focus, .toolbar input:focus, .toolbar select:focus { border-color: var(--brand-2); outline: none; box-shadow: 0 0 0 3px rgba(44, 90, 133, .15); }
.f small { font-size: 11.5px; }
textarea { width: 100%; resize: vertical; }
#m-q, textarea#p-txt { width: 100%; margin: 6px 0; }
.chk { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 8px; cursor: pointer; }
.chk.sm { font-size: 12.5px; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px 2px; margin: 8px 0; }
fieldset.bare { border: 0; padding: 0; margin: 0; }
legend { padding: 0 6px; color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 0 12px; }
.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)); }

/* ---------- כניסה ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #1f3b57 0%, #2c5a85 60%, #3d6f9b 100%); }
.login-box { width: min(380px, 100%); text-align: center; }
.login-box .logo { display: block; margin: 0 auto 6px; }
.login-box h1 { font-size: 26px; margin: 0; }
.login-box .sub { color: var(--muted); margin: 0 0 16px; }
.login-box .f { text-align: right; }
.login-box .err { color: var(--bad); min-height: 1.5em; margin: 10px 0 0; }

/* ---------- מסגרת ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--brand); color: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.brand img { border-radius: 8px; background: #fff; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.top .tab { background: transparent; border: 0; color: #d6e2ee; padding: 8px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.top .tab:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.top .tab.on { background: #fff; color: var(--brand); font-weight: 600; }
.me { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25); color: #fff; border-radius: 20px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.viewbar { background: var(--accent); color: #2a1c00; padding: 8px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#main { max-width: 1500px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin: 0 0 14px; box-shadow: var(--sh); }
.hero h1 { font-size: 22px; }
.hero p { margin: 0; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; }
.toolbar input[type=search] { flex: 1 1 260px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.seg .tab { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 14px; cursor: pointer; }
.seg .tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- כרטיסי מספרים ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 0 0 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; border-inline-start: 4px solid var(--brand-2); box-shadow: var(--sh); }
.kpi span { display: block; color: var(--muted); font-size: 12.5px; }
.kpi b { display: block; font-size: 20px; margin: 2px 0; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.ok { border-inline-start-color: var(--ok); }
.kpi.warn { border-inline-start-color: var(--accent); }
.kpi.bad { border-inline-start-color: var(--bad); }
.kpi.bad b { color: var(--bad); }

/* ---------- תגיות / התראות ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; white-space: nowrap; background: var(--soft); color: var(--muted); }
.ok-b { background: var(--ok-bg); color: var(--ok); }
.warn-b { background: var(--warn-bg); color: var(--warn); }
.bad-b { background: var(--bad-bg); color: var(--bad); }
.grey-b { background: var(--soft); color: var(--muted); }
.alert { border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.alert.warn { background: var(--warn-bg); color: #5c3800; }
.alert.bad { background: var(--bad-bg); color: #7a1a12; }
.box { background: var(--soft); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.box.row { display: flex; }

/* ---------- טבלאות ---------- */
.tbl-wrap { overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--line); border-radius: 8px; }
.tbl-wrap.short { max-height: 46vh; }
.rt { width: 100%; border-collapse: collapse; font-size: 13px; }
.rt th, .rt td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.rt thead th { position: sticky; top: 0; z-index: 1; background: #f7f9fb; color: var(--muted); font-weight: 600; white-space: nowrap; }
.rt th.sortable { cursor: pointer; }
.rt th.sortable:hover { color: var(--ink); }
.rt tfoot td { position: sticky; bottom: 0; background: #f7f9fb; border-top: 2px solid var(--line); }
.rt .num { text-align: left; direction: ltr; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rt td.wrap { white-space: normal; min-width: 160px; }
.rt.click tbody tr { cursor: pointer; }
.rt.click tbody tr:hover td, .rt tbody tr[data-act]:hover td { background: #f3f7fb; }
.rt tr.off td { color: var(--muted); }
.rt tr.dup-row td:first-child { box-shadow: inset -3px 0 0 var(--bad); }
.rt tr.open td:first-child { box-shadow: inset -3px 0 0 var(--accent); }
.rt tr.green td { color: #3f4b58; }
.rt tr.picked td { background: #e9f2fb; }
.rt tr.amtmatch td:nth-child(6) { font-weight: 700; color: var(--ok); }
.rt .empty-row { text-align: center; color: var(--muted); padding: 20px; }
.more { text-align: center; padding: 10px; }
.acts { white-space: nowrap; }

/* דוח רווח והפסד */
.rt.pl th { white-space: nowrap; }
.rt.pl tbody th { text-align: right; position: sticky; right: 0; background: #fff; z-index: 1; }
.rt.pl tr.hl th, .rt.pl tr.hl td { background: #eef4fa; font-weight: 700; }
.rt.pl tr.sub th, .rt.pl tr.sub td { background: #f7f9fb; font-weight: 600; }
.rt.pl tr.sep th { background: transparent; color: var(--muted); font-weight: 600; padding-top: 14px; }
.rt.pl tr.warnrow th, .rt.pl tr.warnrow td { background: var(--warn-bg); }
.rt.pl td.tot { font-weight: 700; border-inline-start: 2px solid var(--line); }
.rt.pl .link { color: inherit; text-decoration: none; }
.rt.pl .link:hover { text-decoration: underline; }

/* גיליון */
.grid-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.sheet { border-collapse: collapse; font-size: 12.5px; }
.sheet th, .sheet td { border: 1px solid #e3e7ec; padding: 3px 6px; min-width: 70px; max-width: 260px; height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet thead th { position: sticky; top: 0; background: #f2f4f7; color: var(--muted); font-weight: 500; z-index: 2; text-align: center; }
.sheet th.rn { position: sticky; right: 0; background: #f2f4f7; color: var(--muted); min-width: 38px; text-align: center; z-index: 1; }
.sheet thead th.rn { z-index: 3; }
.sheet td.n { text-align: left; direction: ltr; }
.sheet td.fx { color: #18466f; }
.sheet td.cached { color: #6b4d0f; background: #fffaf0; }
.sheet td.cached::before { content: '≈ '; color: var(--accent); }
.sheet td.err { color: var(--bad); }
.sheet td.pend { background: #e7f6ec; }
.sheet .cell-in { width: 100%; min-width: 160px; border: 2px solid var(--brand-2); padding: 2px 4px; border-radius: 3px; }

/* ---------- חלונות ---------- */
.ov { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow: auto; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); padding: 16px 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { width: min(900px, 100%); }
.modal.xwide { width: min(1250px, 100%); }
.m-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.m-head h3 { margin: 0; flex: 1; }
.m-sub { color: var(--muted); font-size: 12.5px; width: 100%; order: 3; }
.m-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.files .file { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.upl { margin: 6px 0 2px; }
.am-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; }
.am-card.on { border-color: var(--brand-2); background: #f6faff; }
.am-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; }
.am-head .num { margin-inline-start: auto; }
.am-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0; }
.pc-list { max-height: 45vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 8px 0; }
.pc-month { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.pc-row { display: flex; margin: 2px 0; padding-inline-start: 22px; }
.rt.perms th { width: 45%; font-weight: 500; }

/* ---------- ראשי ---------- */
.todo { list-style: none; padding: 0; margin: 0; }
.todo li { padding: 8px 10px; border-radius: 8px; border-inline-start: 4px solid var(--accent); background: #fffaf0; margin: 0 0 6px; }
.todo li.bad { border-inline-start-color: var(--bad); background: #fff5f4; }
.todo li.soft { border-inline-start-color: var(--brand-2); background: #f3f7fb; }

/* ---------- הודעות ---------- */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 30px); background: #1c2530; color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 90vw; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--bad); }

/* ---------- טלפון ---------- */
@media (max-width: 760px) {
  .top { flex-wrap: wrap; padding: 6px 10px; gap: 6px; }
  .tabs { order: 3; width: 100%; flex: 1 1 100%; }
  .who { margin-inline-start: auto; }
  #main { padding: 10px; }
  .g2, .g3, .g4, .am-grid { grid-template-columns: 1fr; }
  .kpi b { font-size: 17px; }
  .modal { padding: 12px; }
  .tbl-wrap { max-height: none; }
}

/* ---------- הדפסה ---------- */
@media print {
  .top, .viewbar, .toolbar, .seg, .more, #toast, .hint { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .tbl-wrap, .grid-wrap { max-height: none; overflow: visible; border: 0; }
  .rt thead th, .rt tfoot td, .rt.pl tbody th { position: static; }
  #main { max-width: none; padding: 0; }
}
