:root {
  --bg: #f8fafc; --panel: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #1d4ed8; --accent-ink: #fff; --bad: #b91c1c; --warn-bg: #fef3c7; --warn-ink: #92400e;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: "Assistant", system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
button { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover { border-color: #94a3b8; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0 4px; text-decoration: underline; }
button.on { outline: 2px solid var(--ink); }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: #fff; max-width: 100%; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row.end { justify-content: flex-end; }
.chk { display: flex; gap: 6px; align-items: center; }

.topbar { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: var(--ink); color: #fff; }
.brand { font-weight: 800; font-size: 16px; }
.brand span { font-weight: 400; opacity: .7; font-size: 13px; margin-inline-start: 8px; }
.top-actions { display: flex; gap: 12px; align-items: center; }
.date-filter { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.date-filter .link { color: #93c5fd; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #e2e8f0; color: var(--ink); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.draft { background: #e2e8f0; } .badge.review { background: #fef3c7; } .badge.approved { background: #dcfce7; } .badge.rejected { background: #fee2e2; }

.layout { position: relative; display: grid; grid-template-columns: 360px 1fr; height: calc(100% - 48px); }
.side { background: var(--panel); border-inline-end: 1px solid var(--line); overflow: auto; padding: 10px; }
#map { height: 100%; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; font-weight: 600; }
.tabs button.active { border-bottom-color: var(--accent); color: var(--accent); }
.tab { display: none; } .tab.active { display: block; }
#proj-search { flex: 1; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 6px; border-bottom: 1px solid var(--line); }
#proj-list li[data-plan] { display: flex; gap: 8px; cursor: pointer; }
#proj-list li[data-plan]:hover { background: #f1f5f9; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; }
.list .t { font-weight: 700; }
.list .s { color: var(--muted); font-size: 12px; }
.group > .t { margin-bottom: 4px; }
.arr { padding: 6px; border: 1px solid var(--line); border-radius: 6px; margin: 6px 0; }
.arr.inactive { opacity: .5; }

.card { position: absolute; top: 10px; inset-inline-end: 10px; width: 400px; max-height: calc(100% - 20px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: 0 8px 24px rgba(15,23,42,.18); z-index: 900; }
.card h2 { margin: 0 0 4px; font-size: 18px; padding-inline-end: 24px; }
.card h3 { margin: 14px 0 6px; font-size: 14px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.card .close { position: absolute; top: 8px; inset-inline-end: 8px; border: 0; font-size: 20px; line-height: 1; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 4px; text-align: center; font-size: 12px; color: var(--muted); }
.kpis div { background: #f1f5f9; border-radius: 8px; padding: 6px; }
.kpis span { display: block; font-size: 22px; font-weight: 800; color: var(--ink); }
.people { width: 100%; border-collapse: collapse; }
.people th { text-align: start; width: 100px; color: var(--muted); font-weight: 600; vertical-align: top; padding: 3px 0; }
.src { font-size: 11px; background: #e2e8f0; border-radius: 8px; padding: 0 6px; color: var(--muted); white-space: nowrap; }
.src.manual { background: #dbeafe; color: #1e40af; }
.src.warn { background: var(--warn-bg); color: var(--warn-ink); }
.edit-people label { display: block; margin: 4px 0; }
.edit-people input, .edit-people textarea { width: 100%; }
.note { background: #f8fafc; border-inline-start: 3px solid var(--accent); padding: 4px 8px; }
.sites, .permits, .arrs, .flags { padding-inline-start: 18px; margin: 4px 0; }
.sites li, .permits li { margin-bottom: 6px; }

.cmp { width: 100%; border-collapse: collapse; font-size: 12px; }
.cmp th, .cmp td { border-bottom: 1px solid var(--line); padding: 4px; text-align: center; }
.cmp td:first-child, .cmp th:first-child { text-align: start; }
.flags li { color: var(--warn-ink); margin-bottom: 4px; }
.lg { display: flex; gap: 8px; align-items: center; font-size: 12px; margin: 2px 0; }
.lg i { width: 22px; border-top: 4px solid; display: inline-block; }
#layer-toggles .chk { justify-content: space-between; padding: 3px 0; }

.pt { border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.pt th { text-align: start; color: var(--muted); padding-inline-end: 8px; font-weight: 600; }
.leaflet-container { font-family: inherit; }
.kind-pin span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 12px; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }

.draw-bar { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 1000; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px; display: flex; gap: 6px; flex-wrap: wrap; max-width: 92vw; align-items: center; box-shadow: 0 8px 24px rgba(15,23,42,.2); }
.draw-bar button[data-kind] { border-inline-start: 6px solid var(--c); }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 16px; width: min(520px, 94vw); }
dialog h2 { margin-top: 0; }
dialog label { display: block; margin: 6px 0; }
dialog label input:not([type=checkbox]), dialog label select, dialog label textarea { display: block; width: 100%; margin-top: 2px; }
dialog .row label { flex: 1; }
dialog fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }

.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 2000; }
.login-card { background: #fff; padding: 24px; border-radius: 12px; border: 1px solid var(--line); width: min(380px, 92vw); display: grid; gap: 10px; }
.toast { position: fixed; bottom: 16px; inset-inline-start: 16px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 3000; max-width: 60vw; }
.toast.bad { background: var(--bad); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 45% 55%; }
  .side { order: 2; border: 0; border-top: 1px solid var(--line); }
  .card { width: auto; inset-inline: 8px; }
  .brand span { display: none; }
}

/* while digitizing, only the work layer is interactive */
.drawing .leaflet-bg-pane .leaflet-interactive,
.drawing .leaflet-plans-pane .leaflet-interactive { pointer-events: none !important; }

.street-jump { display: flex; gap: 4px; }
.street-jump button { background: transparent; color: #e2e8f0; border-color: #334155; font-size: 13px; padding: 2px 10px; }
.street-jump button:hover { background: #1e293b; }
.hn { font-size: 11px; font-weight: 700; color: #334155; text-shadow: 0 0 2px #fff, 0 0 2px #fff; white-space: nowrap; transform: translate(-50%, -50%); }
.hn.focus { color: #0f172a; font-size: 12px; }
@media (max-width: 760px) { .street-jump { display: none; } }

/* street view */
.st-pills { display: flex; gap: 4px; margin-bottom: 6px; }
.st-pill { border-radius: 14px; }
.st-pill.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.strip { display: block; margin: 8px 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.strip .sx { cursor: pointer; }
.pls { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.pl i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; vertical-align: middle; }
.st-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; font-size: 11px; color: var(--muted); text-align: center; }
.st-kpis div { background: #f1f5f9; border-radius: 8px; padding: 6px 4px; }
.st-kpis span { display: block; font-size: 20px; font-weight: 800; color: var(--ink); }
.st-kpis .bad { background: #fee2e2; } .st-kpis .bad span { color: #b91c1c; }
.flags li.bad { color: #b91c1c; font-weight: 700; }
.tl { position: relative; font-size: 11px; }
.tl-row { display: flex; align-items: center; height: 20px; }
.tl-lab { width: 110px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; flex: 1; height: 10px; background: #f1f5f9; border-radius: 5px; }
.tl-bar { position: absolute; top: 0; height: 10px; border: 0; border-radius: 5px; padding: 0; cursor: pointer; }
.tl-now { position: absolute; top: 0; bottom: 18px; width: 2px; background: #0f172a; }
.tl-axis { display: flex; justify-content: space-between; margin-inline-start: 110px; color: var(--muted); }
.proj-label { background: rgba(255,255,255,.85); border: 0; font-weight: 700; font-size: 12px; box-shadow: none; }
.proj-label::before { display: none; }
.arrow-head span { display: block; color: #f97316; font-size: 16px; line-height: 18px; text-align: center; text-shadow: 0 0 2px #fff; }
.kind-pin span { width: 26px; height: 26px; font-size: 14px; }
.leaflet-control-layers { font-size: 12px; }

.cmp .warn-c { background: #fef3c7; } .cmp .bad-c { background: #fee2e2; font-weight: 700; }
.sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 4px; }

.login-card textarea, .login-card input { width: 100%; }
#req-dialog { width: min(820px, 96vw); }

.appr summary { cursor: pointer; font-weight: 700; margin: 12px 0 4px; }
.kind-pin.tree span { width: 16px; height: 16px; font-size: 9px; border-width: 1.5px; }
#map.nobase { background: #f8fafc; }
.sname { pointer-events: none; }
.sname span { position: absolute; white-space: nowrap; font: 700 12px/1 system-ui, sans-serif; color: #334155;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; }
#map:not(.z16) .sname { display: none; }
/* Leaflet positions tooltips/popups assuming an LTR container — in an RTL page they float off to
   the side. The map itself is LTR; the Hebrew text inside it stays RTL. */
.leaflet-container { direction: ltr; }
.leaflet-tooltip, .leaflet-popup-content, .leaflet-control-layers, .leaflet-control-attribution,
.sname span, .proj-label, .hn { direction: rtl; }
.gate-pin span { display: inline-block; transform: translate(-50%, -140%); white-space: nowrap; background: #7c3aed; color: #fff; font: 700 11px/1 system-ui, sans-serif; padding: 3px 6px; border-radius: 10px; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); direction: rtl; }
.lg .sw { flex: none; width: 34px; height: 16px; }
#map:not(.z18) .gate-pin { display: none; }
.sw-open span { display: inline-block; transform: translate(-50%, -50%); white-space: nowrap; background: #fff; color: #15803d; border: 1.5px solid #15803d; font: 700 10px/1 system-ui, sans-serif; padding: 2px 5px; border-radius: 8px; direction: rtl; }
#map:not(.z18) .sw-open { display: none; }
.path-blocked span { display: inline-block; transform: translate(-50%, -50%); white-space: nowrap; background: #7f1d1d; color: #fff; font: 700 10px/1 system-ui, sans-serif; padding: 3px 6px; border-radius: 8px; border: 1.5px solid #fff; direction: rtl; }
#map:not(.z18) .path-blocked { display: none; }
.xw-x span { display: inline-block; transform: translate(-50%, -50%); color: #dc2626; font: 900 18px/1 system-ui, sans-serif; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.xw-pt span { display: block; width: 12px; height: 12px; border-radius: 2px; background: repeating-linear-gradient(90deg, #334155 0 2px, #fff 2px 4px); border: 1px solid #334155; }

.login-msg { margin: 0; font-size: 14px; line-height: 1.5; border-radius: 8px; }
.login-msg.ok { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; padding: 10px 12px; }
.login-msg.bad { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; padding: 10px 12px; }
.login-card button:disabled { opacity: .6; cursor: default; }

.plan-name { transform: translate(-50%, -50%); pointer-events: none; }
.plan-name span { display: block; direction: rtl; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
  font-size: 11px; font-weight: 600; color: #7f1d1d; background: rgba(255,255,255,.8); padding: 1px 5px; border-radius: 4px; }
.plan-name.focus span { font-size: 12px; font-weight: 700; }
.plan-name span { pointer-events: auto; cursor: pointer; }
.plan-name span:hover { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.plan-popup .leaflet-popup-content { direction: rtl; text-align: right; margin: 10px 12px; font-family: inherit; }
.plan-pop h3 { margin: 0 0 2px; font-size: 14px; }
.plan-pop h4 { margin: 8px 0 4px; font-size: 12px; }
.plan-pop .pop-kpis { display: flex; gap: 6px; margin: 6px 0; }
.plan-pop .pop-kpis div { flex: 1; background: #f1f5f9; border-radius: 6px; padding: 4px; text-align: center; font-size: 11px; }
.plan-pop .pop-kpis span { display: block; font-size: 16px; font-weight: 800; }
.plan-pop table.seg { width: 100%; font-size: 11px; }
.plan-pop .pop-card { margin-top: 6px; width: 100%; }
#map:not(.z17) .plan-name { display: none; }

.gate-ic span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid #7c3aed; font-size: 11px; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
#map:not(.z17) .gate-ic { display: none; }
.side { display: flex; flex-direction: column; }
#legend-dock { margin-top: auto; position: sticky; bottom: -10px; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 0 8px; max-height: 45vh; overflow: auto; }
#legend-dock summary { font-weight: 700; cursor: pointer; padding: 2px 0 4px; }
#legend-dock .lg { font-size: 12px; }
