/* פריסה: כותרת עם לוגואים וחיפוש; רשימת סדר טיפול (ימין) | מפה | תקציר מנהלים (שמאל); תיק מבנה; נתוני מנהל */
:root {
  --bg: #f3f5f7; --surface: #ffffff; --surface-2: #eceff3; --line: #d8dee5;
  --fg: #1a222b; --muted: #5a6673; --accent: #1d5f8f; --accent-fg: #ffffff;
  --good: #2c8554; --warn: #d9a21b; --bad: #c4372d; --na: #87929e;
  --on-warn: #1a222b;
  --map-bg: #e8edf0; --map-block: #dce3e8; --map-road: #ffffff; --map-road-line: #c3ccd4; --map-water: #b7d0df;
  --map-label: #44505c; --map-halo: #ffffff;
  --font: "Heebo", "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10151a; --surface: #192027; --surface-2: #222b33; --line: #2f3a44;
    --fg: #e6ebf0; --muted: #9aa7b3; --accent: #6db3e3; --accent-fg: #0b1620;
    --good: #4fb77d; --warn: #e2b43d; --bad: #ef6a5e; --na: #7d8894;
    --map-bg: #1b242b; --map-block: #222c34; --map-road: #33404b; --map-road-line: #43515d; --map-water: #234559;
    --map-label: #aab6c1; --map-halo: #192027;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10151a; --surface: #192027; --surface-2: #222b33; --line: #2f3a44;
  --fg: #e6ebf0; --muted: #9aa7b3; --accent: #6db3e3; --accent-fg: #0b1620;
  --good: #4fb77d; --warn: #e2b43d; --bad: #ef6a5e; --na: #7d8894;
  --map-bg: #1b242b; --map-block: #222c34; --map-road: #33404b; --map-road-line: #43515d; --map-water: #234559;
  --map-label: #aab6c1; --map-halo: #192027;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select, [data-act], label:has(input[type="checkbox"]) { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.code { font-family: var(--mono); font-size: 12px; direction: ltr; unicode-bidi: isolate; }

.app { padding-inline: 16px; padding-block: 12px 28px; max-width: 1680px; margin-inline: auto; }

/* כותרת */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-block: 4px 12px; }
.logos { display: flex; gap: 8px; align-items: stretch; }
.logo-wrap { position: relative; }
.logo-slot { width: 150px; height: 52px; border: 1px dashed var(--line); border-radius: 8px; background: var(--surface); display: grid; place-items: center; padding: 4px; color: var(--muted); font-size: 12px; text-align: center; overflow: hidden; }
.logo-slot:hover { border-color: var(--accent); }
.logo-slot img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-slot.has { border-style: solid; }
.logo-x { position: absolute; inset-block-start: -6px; inset-inline-start: -6px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); line-height: 1; font-size: 13px; padding: 0; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; }
.brand .auth { color: var(--muted); font-size: 13px; }
.demo-tag { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.score-pick { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
select, input[type="text"], input[type="number"], input[type="date"], textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; max-width: 100%; }

.search { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px; position: relative; }
.search form { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 15px; }
.search .go { background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 8px; padding: 0 20px; font-weight: 600; }
.sugg { position: absolute; inset-inline: 10px; inset-block-start: 58px; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / .18); overflow: hidden; }
.sugg button { display: flex; width: 100%; gap: 10px; align-items: center; text-align: start; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; }
.sugg button:hover, .sugg button:focus-visible { background: var(--surface-2); }
.sugg button:last-child { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.chips .lbl { color: var(--muted); font-size: 12px; }
.chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.chip:hover { border-color: var(--accent); }
.search .note { color: var(--muted); font-size: 12px; margin: 0; }

/* גוף ראשי */
.main { display: grid; gap: 12px; margin-block-start: 12px; grid-template-columns: 340px minmax(0, 1fr) 350px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.panel > h2 { margin: 0; padding: 12px 14px 8px; font-size: 14px; font-weight: 700; }
.panel .sub { color: var(--muted); font-weight: 400; font-size: 12px; }
.qhead { display: flex; align-items: center; gap: 8px; padding: 12px 14px 4px; }
.qhead h2 { margin: 0; font-size: 14px; }
.qhead .btn { margin-inline-start: auto; }
.how { padding: 0 14px 8px; font-size: 12px; color: var(--muted); }
.how summary { cursor: pointer; color: var(--accent); }
.how p { margin: 6px 0; }
.how code { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }

.btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .55; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }

.queue ol { list-style: none; margin: 0; padding: 0 8px 8px; max-height: 600px; overflow-y: auto; display: grid; gap: 4px; }
.row { width: 100%; text-align: start; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 8px; display: grid; grid-template-columns: 22px 34px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.row:hover { background: var(--surface-2); }
.row[aria-pressed="true"] { background: var(--surface-2); border-color: var(--accent); }
.row.ia { border-inline-start: 4px solid var(--bad); }
.rank { color: var(--muted); font-size: 12px; text-align: center; }
.row .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .why { color: var(--muted); font-size: 12px; }
.row .sc { font-weight: 700; font-size: 17px; text-align: end; color: var(--st); }
.iatag { display: inline-block; background: var(--bad); color: #fff; border-radius: 4px; padding: 0 6px; font-size: 11px; font-weight: 700; margin-inline-start: 6px; }
.glyph { width: 34px; height: 34px; border-radius: 8px; background: var(--st); display: grid; place-items: center; }
.glyph svg { width: 22px; height: 22px; stroke: var(--st-fg); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.st-good { --st: var(--good); --st-fg: #fff; }
.st-warn { --st: var(--warn); --st-fg: var(--on-warn); }
.st-bad { --st: var(--bad); --st-fg: #fff; }
.st-na { --st: var(--na); --st-fg: #fff; }
.glyph.st-na { background: transparent; border: 2px dashed var(--na); }
.glyph.st-na svg { stroke: var(--na); }

/* מפה */
.mapwrap { position: relative; overflow: hidden; }
.map { display: block; width: 100%; height: auto; background: var(--map-bg); border-radius: 10px; }
.map.placing { cursor: crosshair; }
.map .blk { fill: var(--map-block); }
.map .water { fill: none; stroke: var(--map-water); stroke-width: 22; stroke-linecap: round; }
.map .rd-line { fill: none; stroke: var(--map-road-line); stroke-width: 15; stroke-linecap: round; }
.map .rd { fill: none; stroke: var(--map-road); stroke-width: 12; stroke-linecap: round; }
.map .rd.minor-line { stroke-width: 9; } .map .rd.minor { stroke-width: 6; }
.map text.lbl { fill: var(--map-label); font-size: 12px; font-family: var(--font); paint-order: stroke; stroke: var(--map-halo); stroke-width: 3px; }
.map .grid { stroke: var(--map-road-line); stroke-width: 1; opacity: .8; fill: none; }
.map .scale { stroke: var(--map-label); stroke-width: 2; fill: none; }
.map .mk { cursor: pointer; }
.map .mk rect.body { fill: var(--st); stroke: var(--map-halo); stroke-width: 2; }
.map .mk.na rect.body { fill: var(--map-halo); stroke: var(--na); stroke-dasharray: 4 3; stroke-width: 2.5; }
.map .mk path { stroke: var(--st-fg); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map .mk.na path { stroke: var(--na); }
.map .mk .ring { fill: none; stroke: var(--accent); stroke-width: 3; opacity: 0; }
.map .mk.sel .ring { opacity: 1; }
.map .mk .iaring { fill: none; stroke: var(--bad); stroke-width: 3; stroke-dasharray: 5 3; }
.map .mk text { font-size: 12px; font-weight: 700; fill: var(--fg); paint-order: stroke; stroke: var(--map-halo); stroke-width: 3.5px; text-anchor: middle; font-family: var(--font); }
.legend { position: absolute; inset-block-end: 10px; inset-inline-start: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; display: grid; gap: 4px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--st); display: inline-block; }
.legend i.na { background: transparent; border: 2px dashed var(--na); }
.legend i.ia { background: transparent; border: 2px dashed var(--bad); }
.legend small { color: var(--muted); }
.types { position: absolute; inset-block-start: 10px; inset-inline-start: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: 70%; }
.types span { display: inline-flex; align-items: center; gap: 5px; }
.types svg { width: 16px; height: 16px; stroke: var(--fg); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.place { position: absolute; inset-block-start: 10px; inset-inline-end: 10px; background: var(--accent); color: var(--accent-fg); border-radius: 8px; padding: 8px 12px; font-weight: 600; display: flex; gap: 10px; align-items: center; }
.place button { background: var(--accent-fg); color: var(--accent); border: 0; border-radius: 6px; padding: 2px 8px; }

/* תוצאות */
.results { position: absolute; inset: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgb(0 0 0 / .18); overflow: auto; padding: 14px; display: grid; gap: 12px; align-content: start; }
.results header { display: flex; align-items: start; gap: 12px; }
.results h3 { margin: 0; font-size: 16px; }
.results .q { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.close { margin-inline-start: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }
.tblwrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: start; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--surface-2); }
td.r, th.r { text-align: end; }
tr.pick { cursor: pointer; }
tr.pick:hover td { background: var(--surface-2); }
.report { border: 1px dashed var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 6px; background: var(--bg); }
.report h4 { margin: 0; font-size: 14px; }
.report p { margin: 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
p.hint, .hint.plain { margin: 0; }

/* תקציר מנהלים */
.sum { padding-bottom: 14px; }
.sum .hd { padding: 12px 14px 0; display: grid; gap: 4px; }
.sum .hd .kind { color: var(--muted); font-size: 12px; }
.sum .hd h2 { padding: 0; font-size: 18px; margin: 0; }
.sum .body { padding: 10px 14px 0; display: grid; gap: 14px; }
.iabox { border: 1px solid var(--bad); border-inline-start-width: 5px; background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-radius: 8px; padding: 8px 10px; font-size: 13px; display: grid; gap: 2px; }
.iabox b { color: var(--bad); }
.big { display: flex; align-items: baseline; gap: 10px; }
.big b { font-size: 40px; line-height: 1; font-weight: 700; color: var(--st); }
.big span { color: var(--muted); font-size: 13px; }
.meter { position: relative; height: 10px; border-radius: 999px; background: linear-gradient(to left, var(--bad) 0 51%, var(--warn) 51% 81%, var(--good) 81% 100%); margin-block: 8px 18px; }
.meter i { position: absolute; top: -5px; width: 4px; height: 20px; background: var(--fg); border-radius: 2px; transform: translateX(50%); }
.meter small { position: absolute; top: 14px; font-size: 11px; color: var(--muted); transform: translateX(50%); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; min-width: 0; }
.sum h3 { margin: 0 0 4px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.sum ul { margin: 0; padding-inline-start: 18px; display: grid; gap: 4px; font-size: 13px; }
.pill { display: inline-block; border-radius: 999px; padding: 0 8px; font-size: 11px; font-weight: 600; background: var(--st); color: var(--st-fg); }
.sum .foot { padding: 12px 14px 0; display: flex; gap: 8px; flex-wrap: wrap; }

/* נתוני מנהל */
.mgr { margin-block-start: 12px; display: grid; gap: 12px; }
.mgr h2 { margin: 0; font-size: 15px; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { padding: 12px 14px; display: grid; gap: 2px; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 26px; font-weight: 700; line-height: 1.2; }
.tile .d { color: var(--muted); font-size: 12px; }
.twocol { display: grid; gap: 12px; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.dist { padding: 14px; display: grid; gap: 10px; }
.stack { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.stack div { background: var(--st); color: var(--st-fg); font-size: 12px; font-weight: 700; display: grid; place-items: center; min-width: 0; }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 110px minmax(0, 1fr) 40px; gap: 8px; align-items: center; font-size: 13px; }
.bar .track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar .track i { display: block; height: 100%; background: var(--st); }
.upc { padding: 14px; }
.upc ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.upc li { display: flex; gap: 10px; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.upc li span:last-child { margin-inline-start: auto; color: var(--muted); }
.late { color: var(--bad); font-weight: 600; }
.foot-note { color: var(--muted); font-size: 12px; margin: 0; }
.foot-note .link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 0; }

/* תיק מבנה */
.dossier { margin-block-start: 12px; display: grid; gap: 12px; }
.dos-head { padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.dos-head h2 { margin: 0; font-size: 18px; padding: 0; }
.dos-head .meta { color: var(--muted); font-size: 13px; }
.dos-head .spacer { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dtabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.dtab { background: transparent; border: 0; border-bottom: 3px solid transparent; padding: 8px 12px; color: var(--muted); font-weight: 500; }
.dtab:hover { color: var(--fg); }
.dtab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.dbody { padding: 14px; display: grid; gap: 14px; }
.dgrid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 8px; align-content: start; background: var(--bg); min-width: 0; }
.card h3 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.pillrow { display: flex; flex-wrap: wrap; gap: 8px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.stat b { font-size: 18px; margin-inline-end: 4px; }
.file { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; font-size: 12px; }
.file::before { content: ""; width: 10px; height: 12px; border: 1.5px solid var(--muted); border-radius: 2px; display: inline-block; }
.locked { color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.diag { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 4px; background: var(--surface); }
.ph { aspect-ratio: 4 / 3; max-width: 100%; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }
.ph svg { width: 56px; height: 56px; stroke: var(--muted); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tag { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 600; background: var(--st); color: var(--st-fg); }
td select { padding: 3px 6px; font-size: 12px; }
.total td { font-weight: 700; background: var(--surface-2); }
.over { color: var(--bad); font-weight: 600; }

/* חלון הוספה / עריכה */
.modal { position: fixed; inset: 0; background: rgb(0 0 0 / .45); display: grid; place-items: start center; padding: 24px 12px; overflow-y: auto; z-index: 50; }
.modal-box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: min(720px, 100%); padding: 16px; display: grid; gap: 14px; }
.modal-box h2 { margin: 0; font-size: 17px; }
.fgrid { display: grid; gap: 10px 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fgrid .full { grid-column: 1 / -1; }
.fgrid label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
.fgrid label small { color: var(--muted); font-weight: 400; }
.fgrid input, .fgrid select, .fgrid textarea { width: 100%; }
.chk { display: flex !important; align-items: center; gap: 8px; }
.chk input { width: auto !important; }
.err { color: var(--bad); font-size: 13px; margin: 0; }
.mfoot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mfoot .sp { margin-inline-start: auto; }

@media (max-width: 1280px) {
  .main { grid-template-columns: 330px minmax(0, 1fr); }
  .main .sum-col { grid-column: 1 / -1; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .main { grid-template-columns: minmax(0, 1fr); }
  .queue ol { max-height: 420px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .twocol, .dgrid, .fgrid { grid-template-columns: minmax(0, 1fr); }
  .score-pick { margin-inline-start: 0; }
  .types { position: static; max-width: none; border-radius: 0; border-width: 0 0 1px; }
  .results { inset: 6px; }
  .logo-slot { width: 120px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* מסכי כניסה */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: grid; gap: 14px; }
.auth-box h1 { margin: 0; font-size: 20px; }
.auth-box p { margin: 0; color: var(--muted); font-size: 13px; }
.auth-box label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
.auth-box input { width: 100%; padding: 10px 12px; font-size: 15px; }
.userbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.tenant-pick select { font-weight: 600; }
.loading { color: var(--muted); padding: 24px; text-align: center; }
.toast { position: fixed; inset-block-end: 16px; inset-inline-start: 16px; background: var(--fg); color: var(--bg); border-radius: 8px; padding: 10px 14px; font-size: 14px; z-index: 80; max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); color: #fff; }
.seg { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }

a.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; }
