/* PatrolLog — לוח בקרה לסיורים. הכיוון: דשבורד ניהולי סטנדרטי בגימור של Stripe / Google Analytics
   (בחירת ברק, 15/10/2026 — PRODUCT.md). בהיר בלבד: שימוש בשטח באור יום ובמשרד. */

:root {
  --canvas: #f6f8fa;
  --panel: #ffffff;
  --line: #e3e8ee;
  --line-strong: #cfd7df;
  --ink: #0a2540;
  --ink-2: #425466;
  --ink-3: #697386;
  --accent: #1f6feb;
  --accent-ink: #0b4fc4;
  --accent-soft: #e8f0fe;
  --ok: #1a7f37;     --ok-soft: #e6f4ea;
  --warn: #9a5b00;   --warn-soft: #fff4e0;   --warn-line: #f2c46d;
  --bad: #c62828;    --bad-soft: #fdecea;
  --none: #6e7781;   --none-soft: #f1f3f5;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(10, 37, 64, .06), 0 2px 8px rgba(10, 37, 64, .05);
  --shadow-lift: 0 6px 24px rgba(10, 37, 64, .14);
  --bar-h: 56px;
  --tab-h: 60px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  scroll-padding-top: calc(var(--bar-h) + 12px);
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100dvh;
}
::selection { background: #cfe0fd; color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, a, [role="button"], .tab, .chip { touch-action: manipulation; }
button, [role="button"], .tab, .chip { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
input, select { font: inherit; font-size: 16px; color: var(--ink); }

/* ---------- app bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar-in {
  max-width: 1200px; margin: 0 auto; height: var(--bar-h);
  display: flex; align-items: center; gap: 20px; padding: 0 16px;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--ink); text-decoration: none; direction: ltr; }
.fresh { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.fresh svg { width: 15px; height: 15px; }
.fresh.stale { color: var(--warn); }
.fresh.down { color: var(--bad); font-weight: 600; }
.fresh .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }

.tabs-top { display: none; gap: 2px; height: 100%; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px;
  border-bottom: 2px solid transparent; transition: color 150ms var(--ease), border-color 150ms var(--ease);
}
.tab[aria-current="page"] { color: var(--accent-ink); border-bottom-color: var(--accent); }

.tabs-bottom {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs-bottom .tab {
  flex-direction: column; justify-content: center; gap: 3px; height: var(--tab-h);
  font-size: 11.5px; border-bottom: 0; padding: 0 4px; position: relative;
}
.tabs-bottom .tab svg { width: 22px; height: 22px; }
.tabs-bottom .tab[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; inset-inline: 28%; height: 2px; background: var(--accent); border-radius: 0 0 2px 2px;
}
.tab:active { color: var(--accent-ink); }

/* ---------- layout ---------- */
main {
  max-width: 1200px; margin: 0 auto;
  padding: 16px 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom, 0px));
  outline: none;
}
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.page-head h1 { font-size: 22px; font-weight: 650; }
.page-head .sub { color: var(--ink-3); font-size: 13px; }
.stack { display: grid; gap: 16px; }
/* פריט ברשת לא מתכווץ מתחת לרוחב התוכן — בלי זה טבלה רחבה מרחיבה את כל העמוד במקום לגלול בתוך הלוח */
.stack > *, .grid-3 > *, .split > * { min-width: 0; }
.grid-3 { display: grid; gap: 16px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px 0;
}
.panel-head h2 { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.panel-body { padding: 12px 16px 16px; }
.panel-link { font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; gap: 2px; }
.panel-link svg { width: 15px; height: 15px; }

/* ---------- status values ---------- */
.big { font-size: 34px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.big small { font-size: 17px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.muted { color: var(--ink-3); }
.meta { color: var(--ink-3); font-size: 13px; }

.meter { height: 8px; border-radius: 4px; background: var(--none-soft); overflow: hidden; margin: 12px 0 10px; display: flex; }
.meter span { background: var(--ok); }
.meter span.open { background: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 3px 10px;
  border-radius: 999px; font-size: 13px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  cursor: pointer; font-family: inherit;
}
.chip svg { width: 14px; height: 14px; }
.chip.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.chip.none { background: var(--none-soft); border-color: transparent; color: var(--none); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 1px 7px; border-radius: 5px; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.none { background: var(--none-soft); color: var(--none); }

.shift { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.shift div { background: var(--canvas); border-radius: var(--radius-sm); padding: 8px 10px; }
.shift b { display: block; font-size: 18px; font-weight: 650; }
.shift span { font-size: 12px; color: var(--ink-3); }
.shift .is-bad b { color: var(--bad); }

/* ---------- action list ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; width: 100%;
  background: none; border: 0; text-align: start; font: inherit; color: inherit; cursor: pointer;
  transition: background-color 120ms var(--ease);
}
.row:active { background: var(--canvas); }
.row .lead { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.row .lead.bad { background: var(--bad-soft); color: var(--bad); }
.row .lead.warn { background: var(--warn-soft); color: var(--warn); }
.row .lead.ok { background: var(--ok-soft); color: var(--ok); }
.row .lead.none { background: var(--none-soft); color: var(--none); }
.row .txt { min-width: 0; flex: 1; }
.row .t1 { font-weight: 600; font-size: 14.5px; }
.row .t2 { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.row .end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 13px; }
.row .chev { width: 16px; height: 16px; color: var(--line-strong); }

.empty { padding: 22px 16px; color: var(--ink-3); font-size: 14px; display: flex; align-items: center; gap: 10px; }
.empty svg { color: var(--ok); }

.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius);
  background: var(--warn-soft); color: #6b3f00; font-size: 14px; border: 1px solid var(--warn-line);
}
.notice.bad { background: var(--bad-soft); color: #8a1c1c; border-color: #f1b5ad; }

/* ---------- buttons, filters ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background-color 120ms var(--ease), transform 100ms var(--ease);
}
.btn:active { transform: scale(.97); background: var(--canvas); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-ink); }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 8px; border: 0;
  background: none; color: var(--ink-2); cursor: pointer;
}
.icon-btn:active { background: var(--canvas); }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters label { display: grid; gap: 4px; font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.filters label.wide { grid-column: 1 / -1; }
.field {
  height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 0 10px; background: var(--panel); width: 100%;
}
.field:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ---------- reports ---------- */
.rep { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 16px; }
.rep + .rep { border-top: 1px solid var(--line); }
.rep .when { font-weight: 600; font-size: 14.5px; }
.rep .when span { color: var(--ink-3); font-weight: 400; }
.rep .who { font-size: 13px; color: var(--ink-2); }
.rep .tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.rep .fence { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); }
.rep .fence b { font-weight: 600; color: var(--ink); }
.rep .note { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-3); overflow-wrap: anywhere; }
.rep .act { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 4px; align-items: start; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th {
  position: sticky; top: 0; background: #fafbfc; color: var(--ink-3); font-weight: 600; font-size: 12px;
  text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.sticky, th.sticky { position: sticky; inset-inline-start: 0; background: var(--panel); z-index: 1; }
th.sticky { background: #fafbfc; z-index: 2; }
td.num, th.num { text-align: center; }
.cell { display: inline-flex; align-items: center; justify-content: center; min-width: 54px; height: 26px; padding: 0 6px; border-radius: 6px; font-size: 12.5px; }
.cell.ok { background: var(--ok-soft); color: var(--ok); }
.cell.bad { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.cell.open, .cell.none { background: var(--none-soft); color: var(--none); }
.site-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; text-align: start; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 12px 16px; font-size: 12.5px; color: var(--ink-3); border-top: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- fence ---------- */
.zones { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.zone {
  border-radius: 7px; padding: 6px 4px; text-align: center; font-size: 12px; line-height: 1.2; border: 1px solid transparent;
}
.zone b { display: block; font-size: 14px; font-weight: 650; }
.zone.g { background: var(--ok-soft); color: var(--ok); }
.zone.y { background: var(--warn-soft); color: var(--warn); }
.zone.r { background: var(--bad-soft); color: var(--bad); }
.zone.x { border-color: var(--bad); }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv div { background: var(--canvas); border-radius: var(--radius-sm); padding: 10px; }
.kv b { display: block; font-size: 20px; font-weight: 650; }
.kv span { font-size: 12px; color: var(--ink-3); }

/* ---------- sheet ---------- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(10, 37, 64, .35); z-index: 40; opacity: 0; transition: opacity 200ms var(--ease); }
.sheet-scrim.on { opacity: 1; }
.sheet {
  position: fixed; z-index: 41; inset-inline: 0; bottom: 0; max-height: 88dvh;
  background: var(--panel); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform 260ms var(--ease);
}
.sheet.on { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 18px; font-weight: 650; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px calc(20px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; }

/* ---------- toast, skeleton ---------- */
.toast {
  position: fixed; z-index: 50; inset-inline: 16px; bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom, 0px));
  max-width: 420px; margin: 0 auto; background: var(--ink); color: #fff; padding: 11px 14px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow-lift);
}
.sk { background: linear-gradient(90deg, #eef1f4 0%, #f6f8fa 50%, #eef1f4 100%); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

.gate { max-width: 440px; margin: 12dvh auto 0; text-align: center; display: grid; gap: 12px; padding: 0 16px; }
.gate h1 { font-size: 22px; }
.gate p { color: var(--ink-2); margin: 0; }
.gate .kform { display: flex; gap: 8px; }
.gate .kform input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); }
.gate .gbtn { display: flex; justify-content: center; min-height: 44px; }
.gate .meta a { color: var(--accent-ink); }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .tabs-top { display: flex; }
  .tabs-bottom { display: none; }
  main { padding: 24px 24px 40px; }
  .grid-3 { grid-template-columns: 1.2fr 1fr 1fr; }
  .split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
  .filters { grid-template-columns: 2fr 1fr 1fr; }
  .filters label.wide { grid-column: auto; }
  /* לוח צד בקצה השמאלי (סוף השורה ב-RTL), נכנס משמאל */
  .sheet { inset-inline: auto 0; top: 0; bottom: 0; max-height: none; width: 460px; border-radius: 0; transform: translateX(-100%); }
  .toast { bottom: 24px; }
}

@media (hover: hover) and (pointer: fine) {
  .tab:hover { color: var(--ink); }
  .row:hover { background: #fafbfc; }
  .btn:hover { background: var(--canvas); }
  .btn.primary:hover { background: var(--accent-ink); }
  .icon-btn:hover { background: var(--canvas); color: var(--ink); }
  .chip:hover { border-color: var(--line-strong); }
  .site-link:hover { color: var(--accent-ink); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
