/* ===== RF Sight — Operator Dashboard ===== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f15;
  --panel: #131b25;
  --panel-2: #0f161e00;
  --item: #161f2a99;
  --map-bg: #0a0e13;
  --accent: #e67e22;
  --brand-a: #143b52;
  --brand-b: #1f6089;
  --text: #e7ecf3;
  --muted: #94a2b4;
  --border: #26313f;
  --input-bg: #0d131a;
  --mono: #86e5cf;
  --shadow: rgba(0, 0, 0, .55);
  --op-color: #8ac6f0;
  --op-text: #0b2740;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f6f8fb;
  --item: #f2f4f8;
  --map-bg: #f4f6fa;
  --accent: #d35400;
  --brand-a: #1a5276;
  --brand-b: #2874a6;
  --text: #1b2430;
  --muted: #5b6572;
  --border: #d6dbe3;
  --input-bg: #ffffff;
  --mono: #0e7c66;
  --shadow: rgba(0, 0, 0, .15);
  --op-color: #2f80c9;
  --op-text: #ffffff;
}
/* high-contrast "sunlight" mode — maximum legibility on outdoor tablets */
:root[data-theme="sunlight"] {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --item: #ffffff;
  --map-bg: #ffffff;
  --accent: #b30000;
  --brand-a: #003a66;
  --brand-b: #00558c;
  --text: #000000;
  --muted: #2b2b2b;
  --border: #000000;
  --input-bg: #ffffff;
  --mono: #005a3c;
  --shadow: rgba(0, 0, 0, .45);
  --op-color: #1f5f9e;
  --op-text: #ffffff;
}
:root[data-theme="sunlight"] .card,
:root[data-theme="sunlight"] .panel,
:root[data-theme="sunlight"] .set-check,
:root[data-theme="sunlight"] .map-btn { border-width: 2px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
/* while switching themes, kill all transitions so the change lands in one
   consistent frame (no brief high-contrast / half-themed flash) */
:root.theme-switching *,
:root.theme-switching *::before,
:root.theme-switching *::after { transition: none !important; }
body {
  font-family: 'Segoe UI', 'Arial Hebrew', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s, color .25s;
}

/* ===== HEADER ===== */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  color: #fff;
  flex-shrink: 0;
}
header .brand {
  font-family: 'Audiowide', 'Segoe UI', sans-serif; font-weight: 400; font-size: 1.4em; letter-spacing: 2px;
  color: #fff; /* fallback if background-clip:text is unsupported */
  background: linear-gradient(100deg,
      rgba(255,255,255,0.66) 0%,
      rgba(255,255,255,0.66) 42%,
      #ffffff 49%,
      #ffffff 51%,
      rgba(255,255,255,0.66) 58%,
      rgba(255,255,255,0.66) 100%);
  background-size: 300% 100%;
  background-position: 150% 0;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: brand-flashlight 5s ease-in-out infinite;
}

/* red edge glow across the header while an incident is live */
body.incident-live header {
  box-shadow: inset 0 -3px 0 0 #c0392b, 0 5px 22px rgba(192, 57, 43, .5);
  animation: incidentGlow 2s ease-in-out infinite;
}
@keyframes incidentGlow {
  50% { box-shadow: inset 0 -3px 0 0 #e74c3c, 0 5px 30px rgba(231, 76, 60, .75); }
}

/* three-mode indicator */
.mode-indicator {
  margin-inline-start: auto;
  display: flex; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, .22); border-radius: 20px; padding: 3px;
}
.mode-indicator .mi {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8em; font-weight: 700; color: rgba(255, 255, 255, .6);
  padding: 4px 12px; border-radius: 16px; white-space: nowrap;
  transition: background .15s, color .15s;
}
.mode-indicator .mi i { font-style: normal; opacity: .85; font-size: 1em; line-height: 1; }
.mode-indicator .mi.active { color: #fff; }
.mode-indicator .mi.active[data-mode="idle"] { background: #5d6d7e; }
.mode-indicator .mi.active[data-mode="live"] { background: var(--accent); animation: pulse 1.6s infinite; }
.mode-indicator .mi.active[data-mode="playback"] { background: #8e44ad; }
@keyframes pulse { 50% { opacity: .6; } }
.conn { font-size: .8em; padding: 3px 12px; border-radius: 12px; min-width: 106px; box-sizing: border-box; text-align: center; }
.conn.pending { background: var(--border); color: var(--muted); }
.conn.on { background: #27ae60; }
.conn.off { background: #c0392b; }
.header-tools { display: flex; align-items: center; gap: 10px; }
.pill-btn {
  background: rgba(255, 255, 255, .18); color: #fff; border: none; cursor: pointer;
  font-weight: 700; font-size: .8em; padding: 5px 12px; border-radius: 12px;
}
.pill-btn:hover { background: rgba(255, 255, 255, .3); }

/* theme toggle */
.theme-toggle {
  width: 44px; height: 24px; border-radius: 12px; border: none; cursor: pointer;
  position: relative; background: rgba(0, 0, 0, .3); padding: 2px; display: flex; align-items: center;
}
.theme-toggle .toggle-knob {
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
  transition: transform .3s;
}
:root[data-theme="light"] .theme-toggle .toggle-knob { transform: translateX(20px); }
:root[dir="rtl"][data-theme="light"] .theme-toggle .toggle-knob { transform: translateX(-20px); }
:root[data-theme="sunlight"] .theme-toggle .toggle-knob { transform: translateX(20px); }
:root[dir="rtl"][data-theme="sunlight"] .theme-toggle .toggle-knob { transform: translateX(-20px); }
:root[data-theme="sunlight"] .theme-toggle { background: #b30000; }

/* ===== LAYOUT — three mode views ===== */
.mode-view { display: none; flex: 1; min-height: 0; padding: 14px; gap: 14px; }
#viewManagement.active { display: flex; }
#viewOps.active { display: grid; }

/* MODE 1 — management: three columns */
#viewManagement { overflow: hidden; gap: 0; }
.mgmt-col { flex: 1; min-width: 0; display: flex; }
.mgmt-col .panel { flex: 1; overflow: hidden; min-height: 0; }
/* keep the tab title / counter / add-controls fixed; scroll only the list */
.mgmt-col .panel > :not(.device-list):not(.people-list):not(.scenario-list):not(.team-list) { flex-shrink: 0; }
.mgmt-col .device-list,
.mgmt-col .people-list,
.mgmt-col .scenario-list,
.mgmt-col .team-list { flex: 1 1 0; min-height: 0; overflow-y: auto; padding-inline-end: 2px; }
#viewManagement .mgmt-col:nth-of-type(1) { flex: 1; } /* devices */
#viewManagement .mgmt-col:nth-of-type(2) { flex: 1; } /* people */
#viewManagement .mgmt-col:nth-of-type(3) { flex: 1; } /* scenarios */
/* per-column minimum widths honoured by the column resizer. Personnel keeps
   enough room for at least the first two letters of a person's name. */
#viewManagement .mgmt-col:nth-of-type(1) { min-width: 356px; } /* devices */
#viewManagement .mgmt-col:nth-of-type(2) { min-width: 336px; } /* personnel: room for the name (≥2 letters) + team selector */
#viewManagement .mgmt-col:nth-of-type(3) { min-width: 200px; } /* incidents */
/* draggable splitters (.mgmt-resizer / .splitter) live in shared/base.css */
.panel-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mgmt-collapse-btn { display: none; } /* only shown when the columns stack (narrow screens) */
.mgmt-collapse-btn .collapse-caret { display: block; transform-origin: center; }
@media (max-width: 940px) {
  #viewManagement { flex-direction: column; overflow-y: auto; gap: 14px; scrollbar-gutter: stable; }
  /* stacked: lay each column out as a plain block so it sizes to its content
     (full width, natural height) and a collapse only changes its height */
  .mgmt-col,
  #viewManagement .mgmt-col:nth-child(1),
  #viewManagement .mgmt-col:nth-child(2),
  #viewManagement .mgmt-col:nth-child(3) { flex: 0 0 auto; display: block; }
  .mgmt-resizer { display: none; } /* no side-by-side splitters when stacked */
  /* show each list at its natural height (the page scrolls, not the list) */
  .mgmt-col .device-list,
  .mgmt-col .people-list,
  .mgmt-col .scenario-list,
  .mgmt-col .team-list { flex: 0 0 auto; overflow-y: visible; }
  .mgmt-collapse-btn { display: inline-flex; align-items: center; justify-content: center; transform-origin: center; transition: transform .2s; }
  .mgmt-col.collapsed .panel > *:not(.row-between) { display: none; } /* collapse to the header line */
  .mgmt-col.collapsed .row-between > .icon-btn:not(.mgmt-collapse-btn) { display: none; } /* hide the + when collapsed */
  .mgmt-col.collapsed .mgmt-collapse-btn { transform: rotate(180deg); } /* up when open, down when collapsed */
}

/* ── wide screens: collapse a management column to a vertical title strip ── */
@media (min-width: 941px) {
  .mgmt-collapse-btn { display: inline-flex; align-items: center; justify-content: center; transform-origin: center; transition: transform .2s; }
  .mgmt-col:not(.collapsed) .mgmt-collapse-btn { transform: rotate(-90deg); }  /* ◄ : click to collapse */
  #viewManagement .mgmt-col.collapsed { flex: 0 0 46px !important; min-width: 46px !important; }
  .mgmt-col.collapsed .panel { align-items: center; padding: 12px 4px; }
  .mgmt-col.collapsed .panel > *:not(.row-between) { display: none; }
  .mgmt-col.collapsed .row-between { flex-direction: column; align-items: center; justify-content: flex-start; gap: 12px; height: 100%; width: 100%; }
  .mgmt-col.collapsed .panel-title { flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
  .mgmt-col.collapsed .panel-title h2 { writing-mode: vertical-rl; text-orientation: mixed; white-space: nowrap; min-height: 0; }
  .mgmt-col.collapsed .panel-title .count { display: none; }
  .mgmt-col.collapsed .mgmt-collapse-btn { transform: rotate(90deg); order: -1; } /* ► : click to expand, kept at the top of the strip */
  /* Hebrew (RTL): the horizontal collapse arrows are mirrored */
  [dir="rtl"] .mgmt-col:not(.collapsed) .mgmt-collapse-btn { transform: rotate(90deg); }
  [dir="rtl"] .mgmt-col.collapsed .mgmt-collapse-btn { transform: rotate(-90deg); }
}

/* ── responsive: adapt to tablets & phones ── */
@media (max-width: 720px) {
  header { flex-wrap: wrap; gap: 8px 10px; padding: 10px 14px; }
  header .brand { font-size: 1.2em; }
  .mode-indicator { margin-inline-start: 0; order: 3; width: 100%; justify-content: center; }
  .conn { order: 2; }
  .header-tools { order: 2; margin-inline-start: auto; }
  .mode-view { padding: 10px; gap: 10px; }
}
/* short viewports (e.g. a phone held in landscape) — trim vertical chrome */
@media (max-height: 480px) {
  header { padding: 6px 14px; }
  header .brand { font-size: 1.15em; }
  .mode-view { padding: 8px; gap: 8px; }
}
/* the ops (map + panel) grid narrows its side panel on smaller screens */
@media (max-width: 1100px) { #viewOps { grid-template-columns: 1fr 14px 300px; } }
@media (max-width: 860px) { #viewOps { grid-template-columns: 1fr 12px 260px; } }

/* ── phones: use landscape only (prompt to rotate when held in portrait) ── */
#rotateNotice { display: none; }
@media (max-width: 600px) and (orientation: portrait) {
  #rotateNotice {
    display: flex; position: fixed; inset: 0; z-index: 4000;
    flex-direction: column; align-items: center; justify-content: center; gap: 18px;
    background: var(--bg); color: var(--text); text-align: center; padding: 30px;
  }
  #rotateNotice .rotate-ico { font-size: 3.4em; animation: rotateHint 2.4s ease-in-out infinite; }
  #rotateNotice p { font-size: 1.1em; max-width: 320px; line-height: 1.5; }
}
@keyframes rotateHint { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }

/* MODE 2 & 3 — ops: map + splitter + side panel + transport bar */
#viewOps {
  grid-template-columns: 1fr 16px 360px;
  grid-template-rows: 1fr auto;
  grid-template-areas: "map resize panel" "transport resize panel";
  gap: 14px 0;
}
.map-wrap { grid-area: map; display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
/* holder wraps the Leaflet map + the floating buildings panel (kept OUT of #map) */
.map-holder { position: relative; flex: 1; min-height: 0; display: flex; }
.map-holder #map { flex: 1; min-height: 0; }
#opsResizer { grid-area: resize; }
#opsPanel { grid-area: panel; display: flex; flex-direction: column; overflow: hidden; }
#opsPanel .panel { flex: 1; }
#transportBar { grid-area: transport; }
#pbExitBtn { min-height: 56px; }

.map-toolbar { display: flex; align-items: center; gap: 10px; font-size: .82em; color: var(--muted); }
.map-toolbar .spacer { flex: 1; }
.op-loc { font-weight: 600; }
.map-btn {
  background: var(--item); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 10px; font-size: .95em; font-weight: 600; cursor: pointer;
  font-family: inherit; white-space: nowrap; transition: filter .15s, border-color .15s;
}
.map-btn:hover { filter: brightness(1.12); border-color: var(--accent); }
label.map-btn { display: inline-flex; align-items: center; gap: 4px; }
/* fixed width so the label swap (Satellite <-> Street) never shifts the toolbar */
#basemapBtn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: 118px; box-sizing: border-box; }
.map-btn.on { background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); color: #fff; border-color: transparent; }
.map-btn.hidden { display: none; }
/* ===== BUILDINGS PANEL (floating over the map) ===== */
.buildings-panel {
  /* always pin to the physical top-right so it clears the top-left zoom control
     in both LTR and RTL (Hebrew) */
  position: absolute; top: 10px; right: 10px; left: auto; z-index: 500;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; box-shadow: 0 6px 20px var(--shadow); max-width: 260px;
  font-size: .82em; display: flex; flex-direction: column; gap: 6px;
}
.buildings-panel.hidden { display: none; }.buildings-panel .bp-head { font-weight: 700; color: var(--muted); font-size: .9em; }
.buildings-panel .bp-row { display: flex; align-items: center; gap: 6px; }
.buildings-panel .bp-name {
  flex: 1 1 60px; min-width: 50px; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; font-family: inherit; font-weight: 600;
}
.buildings-panel .bp-name:focus { outline: none; border-color: var(--accent); }
.buildings-panel .bp-floor {
  flex: 0 0 auto; background: var(--item); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; font-family: inherit;
}
.buildings-panel .icon-btn.del { flex: 0 0 auto; }
/* which building/floor a unit is inside, shown on its card */
.card .bldg { font-size: .82em; font-weight: 600; color: var(--accent); margin-top: 2px; }

#map {
  width: 100%; flex: 1; min-height: 0; background: var(--map-bg);
  border-radius: 10px; border: 1px solid var(--border); overflow: hidden;
}
.leaflet-container { background: var(--map-bg); font: inherit; }
/* soften the dark basemap so it is not too dark */
#map.map-dark .maplibregl-canvas,
#map.map-dark .leaflet-tile-pane { filter: brightness(1.22) saturate(0.95); }
/* live mouse coordinate readout, pinned to the bottom-left of the map */
.map-coord {
  position: absolute; bottom: 8px; left: 8px; z-index: 500; pointer-events: none;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px; font-size: .78em; font-weight: 600;
  font-variant-numeric: tabular-nums; box-shadow: 0 2px 8px var(--shadow);
  opacity: 0; transition: opacity .15s; white-space: nowrap;
}
.map-coord.show { opacity: .92; }
.op-marker {
  background: var(--op-color); width: 16px; height: 16px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 0 0 2px var(--op-color);
}
.dev-marker-label {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
/* a unit in distress / man-down gets a red border and an inline tag by its name */
.dev-marker-label.has-alert { border-color: #e74c3c; }
.map-alert-tag {
  background: #e74c3c; color: #fff; font-size: 9px; font-weight: 700;
  padding: 0 5px; border-radius: 7px; margin-inline-start: 4px; white-space: nowrap;
  animation: pulse 1.2s infinite;
}
/* pulsing red halo for a critical (man-down / low-battery) unit */
.crit-halo {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(231, 76, 60, .30); border: 2px solid #e74c3c;
  animation: critPulse 1.1s ease-out infinite;
}
/* low-zoom cluster: a count bubble standing in for several overlapping units */
.cluster-bubble {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
  border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent); cursor: pointer;
}
@keyframes critPulse {
  0% { transform: scale(.4); opacity: .95; }
  100% { transform: scale(1.7); opacity: 0; }
}
/* colour the tooltip's little arrow so it connects to the name */
.dev-marker-label.leaflet-tooltip-right::before { border-right-color: var(--panel); }
.dev-marker-label.leaflet-tooltip-left::before { border-left-color: var(--panel); }
/* in Hebrew the label sits to the LEFT of the icon, so move the arrow to the
   right edge of the name and point it right (toward the icon) */
html[dir="rtl"] .dev-marker-label.leaflet-tooltip-right::before {
  left: auto; right: 0; margin-left: 0; margin-right: -12px;
  border-right-color: transparent; border-left-color: var(--panel);
}
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82em; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }

/* ops head + recording indicator */
.ops-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rec { display: inline-flex; align-items: center; gap: 5px; font-size: .72em; font-weight: 700; color: #e74c3c; }
.rec i { width: 9px; height: 9px; border-radius: 50%; background: #e74c3c; animation: pulse 1.2s infinite; }

/* sub-tabs (People / Event Log) */
.subtabs { display: flex; gap: 6px; }
.subtab {
  flex: 1; background: var(--item); color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px; font-size: .82em; font-weight: 600; cursor: pointer; font-family: inherit;
}
.subtab.active { color: #fff; background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); border-color: transparent; }
.tab-ico { font-style: normal; margin-inline-end: 2px; }
.autoscroll-btn {
  flex: 0 0 auto; width: 36px; background: var(--item); color: var(--muted);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 1em; font-weight: 700;
  transition: filter .15s, background .15s, color .15s;
}
.autoscroll-btn.on { background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); color: #fff; border-color: transparent; }
.autoscroll-btn:hover { filter: brightness(1.12); }
.subcontent { flex: 1; overflow: hidden auto; }
.subcontent.hidden { display: none; }

/* event log */
.log-list { display: flex; flex-direction: column; gap: 4px; }
.log-row {
  display: flex; gap: 8px; align-items: baseline; background: var(--item);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; font-size: .8em;
}
.log-row .log-t { color: var(--mono); font-family: 'Consolas', monospace; font-size: .92em; flex-shrink: 0; }
.log-row .log-body { color: var(--text); }
.log-row.alert { border-color: #e74c3c; border-inline-start: 3px solid #e74c3c; background: color-mix(in srgb, #e74c3c 12%, var(--item)); }
.log-row.ack { border-inline-start: 3px solid var(--success); }
.log-row.ack .log-body { color: var(--muted); }
#pbLog .log-row { cursor: pointer; }
#pbLog .log-row:hover { filter: brightness(1.12); }
#pbLog .log-row.cur { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--item)); }

/* transport bar (media-player style) */
.transport-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px;
}
.transport-bar.hidden { display: none; }
.transport-bar .seek-wrap { flex: 1; position: relative; display: flex; align-items: center; }
.transport-bar .seek-wrap .seek { width: 100%; }
/* alert/ack event ticks overlaid on the playback seek bar */
.seek-ticks { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; }
.seek-tick {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 3px; height: 14px; border-radius: 2px; pointer-events: auto; cursor: pointer;
  background: #e67e22; box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
.seek-tick.distress, .seek-tick.lostsignal { background: #e74c3c; }
.seek-tick:hover { height: 18px; }

aside { display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow: hidden auto; flex: 1; min-width: 0;
}
.panel.hidden { display: none; }
.panel h2 { font-size: 1.02em; color: var(--text); display: flex; align-items: center; gap: 6px; min-height: 29px; }
.panel h2.mt { margin-top: 6px; }
/* balance the title: space beneath it should match the padding above it
   (drop the min-height on a lone title so its box hugs the text — no centering skew) */
.panel > h2:first-child { min-height: 0; margin-bottom: 4px; }
.panel > .ops-head:first-child { margin-bottom: 4px; }
.count {
  color: var(--muted); font-weight: 700; font-size: .72rem;
  background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px;
  position: relative; top: 2px;
}
/* pulsing indicator on the Active incidents tab while an incident is running */
.tab-live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  flex: 0 0 auto; animation: pulse 1.6s infinite;
}
.tab-live-dot.hidden { display: none; }
.accent-text { color: var(--accent); }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.hint { font-size: .78em; color: var(--muted); line-height: 1.4; }
.add-row { display: flex; gap: 6px; min-height: 48px; }
.add-row input { flex: 1; min-width: 0; }
/* factory-id entry: fixed "RFS-" prefix + the 8-char body the operator types */
.fid-input {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px;
}
.fid-input .fid-prefix { color: var(--muted); font-weight: 700; letter-spacing: .5px; }
.fid-input input {
  flex: 1; min-width: 0; background: transparent; border: 0; padding: 0;
  color: var(--text); font-family: inherit; letter-spacing: 1px; text-transform: uppercase;
}
.fid-input input:focus { outline: none; }
.fid-input:focus-within { border-color: var(--accent); }
.add-row .icon-btn { width: 48px; height: 48px; padding: 0; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15em; }

/* ===== FORM ===== */
.field { display: flex; flex-direction: column; gap: 4px; font-size: .82em; color: var(--muted); }
.field input, input[type="text"] {
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 10px; font-size: .95em; font-family: inherit;
}
/* ===== DEVICE / PEOPLE REGISTRY ===== */
.device-list, .people-list { display: flex; flex-direction: column; gap: 6px; }
.device-row {
  display: flex; align-items: center; gap: 8px; background: var(--item);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; flex-wrap: nowrap;
}
.device-row .fid { font-family: 'Consolas', monospace; font-size: .82em; font-weight: 700; direction: ltr; flex: 0 300 100px; min-width: 40px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input.fid {
  background: transparent; border: 1px solid transparent; border-radius: 5px;
  color: var(--text); padding: 3px 5px;
}
input.fid[readonly] { cursor: default; }
input.fid:not([readonly]) { border-color: var(--accent); background: var(--input-bg); }
input.fid:focus { outline: none; }
.fid-edit { padding: 3px 6px; font-size: .8em; flex-shrink: 0; }
.device-row .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.device-row select {
  flex: 1 1 66px; min-width: 66px; overflow: hidden; text-overflow: ellipsis; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px; font-family: inherit; font-size: .85em;
}
.device-row .conn-toggle {
  font-size: .72em; font-weight: 700; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; background: var(--input-bg); color: var(--muted); white-space: nowrap; flex-shrink: 0;
  min-width: 96px; text-align: center;
}
.device-row .conn-toggle.on { background: var(--input-bg); color: var(--brand-b); border-color: var(--border); }
.person-row {
  display: flex; align-items: center; gap: 8px; background: var(--item);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.person-row .p-name { flex: 1; font-weight: 600; font-size: .9em; min-width: 46px; }
input.p-name {
  min-width: 46px; background: transparent; border: 1px solid transparent; border-radius: 5px;
  color: var(--text); padding: 3px 5px; font-family: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
input.p-name[readonly] { cursor: default; }
input.p-name:not([readonly]) { border-color: var(--accent); background: var(--input-bg); }
input.p-name:focus { outline: none; }
.person-row.op-row .op-name { color: var(--op-color); padding: 3px 5px; border: 1px solid transparent; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-edit { padding: 3px 6px; font-size: .8em; flex-shrink: 0; }
.person-row .p-count { font-size: .72em; color: var(--muted); flex-shrink: 0; }
.person-row .p-count.zero { color: #e74c3c; font-weight: 700; }
.person-row .p-team { flex: 0 0 96px; width: 96px; box-sizing: border-box; }
/* Personnel / Teams management sub-tabs (also Incidents Active/Saved) */
.mgmt-subtabs, .inc-subtabs { margin: 2px 0 6px; }
/* keep the counter inline with the tab label, with a little breathing room */
.mgmt-subtab, .inc-subtab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
/* counters inside a tab share the tab's colour — transparent background so an
   inactive tab shows the panel colour and an active tab shows its gradient */
.mgmt-subtab .count, .inc-subtab .count { top: 0; background: transparent; }
/* on an active tab the background is the dark brand gradient, so force the
   counter text to white — readable in light & sunlight modes (bg stays transparent) */
.subtab.active .count {
  color: #fff; border-color: rgba(255, 255, 255, 0.55);
}
/* in dark mode the gradient is dark enough that the muted tone (same as the
   Devices counter) reads well and looks more consistent */
:root[data-theme="dark"] .subtab.active .count { color: var(--muted); }
.mgmt-people.hidden, .mgmt-teams.hidden, .inc-active.hidden, .inc-saved.hidden { display: none; }
/* Teams management list */
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-row {
  display: flex; align-items: center; gap: 8px; background: var(--item);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.team-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.team-row .t-name {
  flex: 1; min-width: 40px; background: transparent; border: 1px solid transparent; border-radius: 5px;
  color: var(--text); padding: 3px 5px; font-family: inherit; font-weight: 600; font-size: .9em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.team-row .t-name[readonly] { cursor: default; }
.team-row .t-name:not([readonly]) { border-color: var(--accent); background: var(--input-bg); }
.team-row .t-name:focus { outline: none; }
.team-row .t-count { font-size: .72em; color: var(--muted); flex-shrink: 0; }

/* ===== BUTTONS ===== */
/* the .btn family (.btn / :hover / .primary / .danger / .ghost / .sm) is
   provided by /shared/base.css. Dashboard-specific button rules stay below. */

/* consistent slight hover for the other interactive controls */
.icon-btn, .conn-toggle, .tbtn, .subtab, .tab, .pill-btn, .theme-toggle,
.device-row select, .speed, .add-row input {
  transition: filter .15s, background .15s, border-color .15s, color .15s;
}
.icon-btn:hover, .conn-toggle:hover, .tbtn:hover, .subtab:hover {
  filter: brightness(1.12); border-color: var(--accent);
}
/* comboboxes: both the hovered control and the highlighted option in the open
   list use the tabs' background colour (the brand tone), not the browser blue */
select { accent-color: var(--brand-b); }
select:hover { border-color: var(--brand-b); filter: brightness(1.08); }
/* the device-row person picker hovers like the other combos/buttons (accent) */
.device-row select:hover { border-color: var(--accent); filter: brightness(1.12); }
select option:checked { background: var(--brand-b); color: #fff; }
/* hovered item in the open list: a lighter tint of the selected colour */
select option:hover { background: color-mix(in srgb, var(--brand-b) 40%, #fff); color: var(--text); }

/* scenarios column: align the input / Start button with the People rows */
#scenarioName { min-height: 48px; }
#viewManagement .btn.primary { min-height: 44px; }

/* ===== STATS ===== */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 0; }
.stats > div { background: var(--item); border: 1px solid var(--border); border-radius: 8px; padding: 9px; text-align: center; }
.stats b { display: block; font-size: 1.35em; color: var(--accent); }
.stats span { font-size: .7em; color: var(--muted); }

/* ===== CARDS ===== */
.cards { display: flex; flex-direction: column; gap: 8px; }
/* registry / personnel search + sort toolbars */
.reg-tools, .card-tools { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.card-tools.hidden { display: none; }
.reg-search { flex: 1; min-width: 0; background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 5px 9px; font-family: inherit; font-size: .85em; }
.reg-search:focus { outline: none; border-color: var(--accent); }
.reg-sort { flex: 0 0 auto; background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px; font-family: inherit; font-size: .85em; }
/* fixed width so the field/arrow label swap (e.g. "Connection ↑") never shifts
   the toolbar; scoped to the sort dropdowns so it doesn't affect the team select */
.reg-sort[data-sort] { width: 120px; box-sizing: border-box; }
.reg-sort:hover { filter: brightness(1.12); border-color: var(--accent); }
/* per-unit stat chips on personnel cards */
.cstats { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 4px; }
.cstat { font-size: .74em; color: var(--muted); background: var(--item); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; display: inline-flex; align-items: center; gap: 3px; }
.cstat.warn { color: #fff; background: #c0392b; border-color: transparent; }
/* muster / accountability board — second stat row (3 equal boxes) + team chips */
.muster { margin-top: -2px; }
.mstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mstats > div { background: var(--item); border: 1px solid var(--border); border-radius: 8px; padding: 9px; text-align: center; }
.mstats b { display: block; font-size: 1.35em; }
.mstats span { font-size: .7em; color: var(--muted); }
.mstats .ok b { color: #27ae60; }
.mstats .warn b { color: #c0392b; }
.mstats .lost b { color: #7f8c8d; }
.muster-teams { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mu { font-size: .76em; font-weight: 700; border: 1px solid var(--border); border-radius: 7px; padding: 3px 8px; display: inline-flex; align-items: center; gap: 4px; background: var(--item); }
/* team chips + card tags are clickable to focus the list/map on one team */
.mu.team { cursor: pointer; transition: filter .12s; }
.mu.team:hover { filter: brightness(1.12); }
.mu.team.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px currentColor; }
/* team tag on a personnel card + team selector in detail */
.team-tag { font-size: .7em; font-weight: 700; color: #fff; border-radius: 5px; padding: 1px 6px; cursor: pointer; }
.team-tag.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px #fff; }
.team-sel { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; font-family: inherit; }
/* signal-lost "seen ago" label on the map marker */
.map-since { opacity: .85; font-style: italic; }
/* per-alert-type sound/speech matrix in settings */
.alert-matrix { display: grid; gap: 4px; margin: 4px 0 10px; }
.am-row { display: grid; grid-template-columns: 1fr 48px 48px 48px 48px; align-items: center; gap: 4px; font-size: .9em; }
.am-row.am-head { color: var(--muted); font-size: .8em; text-align: center; }
.am-row.am-head span:first-child { text-align: start; }
.am-row input[type=checkbox] { justify-self: center; }
.card {
  background: var(--item); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px;
  border-inline-start: 4px solid #7f8c8d; cursor: pointer; transition: filter .15s;
}
.card:hover { filter: brightness(1.12); }
.card .name { font-weight: bold; display: flex; align-items: center; gap: 6px; }
.card .name .id { color: var(--muted); font-size: .8em; font-weight: normal; }
.card.crit { border-color: #e74c3c; box-shadow: 0 0 0 1px rgba(231, 76, 60, .4); }
.follow-lock {
  margin-inline-start: auto; background: transparent; border: none; cursor: pointer;
  font-size: .95em; line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.follow-lock:hover { filter: brightness(1.3); }
.alert-badge {
  background: #e74c3c; color: #fff; font-size: .68em; font-weight: 700;
  padding: 1px 7px; border-radius: 8px; margin-inline-start: 4px; white-space: nowrap;
  animation: pulse 1.2s infinite;
}
.card .loc { font-size: .8em; color: var(--mono); direction: ltr; font-family: 'Consolas', monospace; }
:root[dir="rtl"] .card .loc { text-align: right; }
.card .meta { font-size: .76em; color: var(--muted); margin-top: 2px; }

/* ===== SAVED SCENARIOS ===== */
.scenario-list { display: flex; flex-direction: column; gap: 6px; }
/* active incident rows (join a live incident) */
.active-row {
  display: flex; align-items: center; gap: 8px; background: var(--item);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.active-row .a-name {
  display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.active-row .a-meta { font-size: .72em; color: var(--muted); margin-top: 3px; }
.active-row .live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  flex: 0 0 auto; animation: pulse 1.6s infinite;
}
.active-row .a-joined { font-size: .78em; font-weight: 600; color: var(--muted); white-space: nowrap; }
/* join / close share one size (width + height), differ only by colour */
.active-row .btn {
  flex: 0 0 auto; box-sizing: border-box; width: 124px; height: 34px; min-height: 0;
  display: inline-flex; align-items: center; justify-content: center;
  text-align: center; white-space: nowrap; padding: 0 12px;
}
/* the Join button is .btn.primary, which #viewManagement forces to 44px tall —
   neutralise that in the compact active row so Join and Close match exactly */
#viewManagement .active-row .btn.primary { min-height: 0; height: 34px; }
.btn.sm { padding: 5px 12px; font-size: .82em; } /* base also defines this; kept for the compact active-row height override above */
/* real-time action buttons (exit / close incident) */
.ops-actions { display: flex; gap: 8px; }
.ops-actions .btn { flex: 1; }
.ops-actions.hidden { display: none; }
.scenario-row {
  display: flex; align-items: center; gap: 8px; background: var(--item);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
.scenario-row .s-name { line-height: 1.25; }
.scenario-row .s-meta { line-height: 1.2; margin-top: 4px; }
.scenario-row .s-name { flex: 1; font-weight: 600; font-size: .9em; }
input.s-name {
  width: 100%; background: transparent; border: 1px solid transparent; border-radius: 5px;
  color: var(--text); padding: 2px 4px; font-family: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
input.s-name[readonly] { cursor: default; }
input.s-name:not([readonly]) { border-color: var(--accent); background: var(--input-bg); }
input.s-name:focus { outline: none; }
.scenario-row .s-meta { font-size: .72em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; padding: 4px 8px; font-size: .9em; color: var(--text);
}
.icon-btn:hover { background: var(--panel-2); filter: brightness(1.2); }
.icon-btn.del:hover { color: #e74c3c; }
.empty { font-size: .82em; color: var(--muted); text-align: center; padding: 10px; }

/* ===== TRANSPORT (playback) ===== */
.transport { display: flex; align-items: center; gap: 8px; }
.tbtn {
  background: var(--item); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; width: 38px; height: 34px; font-size: 1em; cursor: pointer;
}
.tbtn:hover { filter: brightness(1.2); }
.tbtn.play { background: linear-gradient(135deg, #7d3c98, #8e44ad); color: #fff; border: none; }
.speed { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 6px; font-family: inherit; }
.pb-time { margin-inline-start: auto; font-size: .82em; color: var(--muted); font-variant-numeric: tabular-nums; }
.seek { width: 100%; accent-color: var(--accent); }

/* ===== DETAIL DIALOG ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
  display: none; align-items: center; justify-content: center; z-index: 10000;
}
.overlay.show { display: flex; }
/* device detail is a movable, non-modal floating card (map stays usable) */
#detailOverlay { background: transparent; pointer-events: none; }
#detailOverlay .detail-box { pointer-events: auto; }
.detail-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: min(420px, 92vw); box-shadow: 0 20px 60px var(--shadow); overflow: hidden;
}
.detail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); color: #fff;
  font-weight: 700; font-size: 1.05em; cursor: default; user-select: none;
}
/* only the device-detail modal is draggable, so only it shows the move cursor */
.detail-box .detail-head { cursor: move; }
.detail-head .x { background: transparent; border: none; color: #fff; font-size: 1.1em; cursor: pointer; }
.detail-box dl { padding: 14px 18px; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; }
.detail-box dt { color: var(--muted); font-size: .85em; }
.detail-box dd {
  text-align: end; font-weight: 600; font-size: .9em;
}
.detail-box dd.mono { direction: ltr; font-family: 'Consolas', monospace; color: var(--mono); }
.detail-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 18px 0; margin-bottom: -4px;
}
.detail-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--item); color: var(--muted);
  border: 1px solid var(--border); cursor: pointer;
  font-family: inherit; font-size: .82em; font-weight: 600;
  transition: background .15s, color .15s, border-color .15s;
}
.detail-tab:hover { border-color: var(--accent); }
.detail-tab.active { background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); color: #fff; border-color: transparent; }
.detail-tab .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.badge-status { padding: 2px 8px; border-radius: 8px; color: #fff; font-size: .82em; }
.detail-actions { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.detail-actions .btn { flex: 1; padding: 8px; font-size: .85em; }
.detail-actions .btn.on { background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); color: #fff; border-color: transparent; }

/* ===== TOASTS ===== */
.toast-container {
  position: fixed; inset-block-end: 16px; inset-inline-end: 16px;
  display: flex; flex-direction: column; gap: 8px; z-index: 30000;
}
.toast {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-inline-start: 4px solid var(--accent); border-radius: 8px;
  padding: 10px 16px; font-size: .9em; box-shadow: 0 8px 24px var(--shadow);
  animation: slidein .25s ease;
}
.toast.ok { border-inline-start-color: #27ae60; }
.toast.err { border-inline-start-color: #c0392b; }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } }

/* keep lists/rows within their column (no horizontal scrollbars) */
.device-list, .people-list, .scenario-list, .cards, .log-list { min-width: 0; }
.scenario-row > div { min-width: 0; }
.card .loc, .log-row .log-body, .scenario-row .s-name, .scenario-row .s-meta,
.person-row .p-name { min-width: 0; overflow-wrap: anywhere; }
.log-row .log-body { flex: 1; }

/* ===== CONFIRM DIALOG ===== */
.confirm-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: min(380px, 92vw); padding: 20px; box-shadow: 0 20px 60px var(--shadow);
  display: flex; flex-direction: column; gap: 18px;
}
.confirm-msg { color: var(--text); font-size: 1em; line-height: 1.4; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.confirm-actions .btn { min-width: 92px; }
/* the export dialog holds four choices — give it room so they sit on one row */
#exportOverlay .confirm-box { width: min(480px, 92vw); }
#exportOverlay .confirm-actions .btn { min-width: 84px; flex: 1 1 auto; }
/* Cancel is a dismiss action: keep it narrow and separated from the formats */
#exportOverlay .confirm-actions .btn.ghost { flex: 0 0 auto; margin-inline-end: auto; }

/* ===== ACTIVE ALERTS FEED ===== */
.alerts-feed { display: flex; flex-direction: column; gap: 6px; }
.alerts-feed.hidden { display: none; }
.alerts-feed .af-head {
  font-size: .78em; font-weight: 700; color: var(--danger);
  text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 6px;
}
.alert-item {
  display: flex; align-items: center; gap: 8px; background: var(--item);
  border: 1px solid #e74c3c; border-inline-start: 4px solid #e74c3c;
  border-radius: 8px; padding: 6px 9px;
}
.alert-item.nomotion { border-color: #e67e22; border-inline-start-color: #e67e22; }
.alert-item.lowbat { border-color: #e67e22; border-inline-start-color: #e67e22; }
.alert-item.acked { opacity: .5; filter: grayscale(.4); }
.alert-item .ai-body { flex: 1; min-width: 0; }
.alert-item .ai-name { font-weight: 600; font-size: .9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-item .ai-meta { font-size: .72em; color: var(--muted); }
.alert-item .ai-tag {
  font-size: .68em; font-weight: 700; color: #fff; background: #e74c3c;
  padding: 1px 6px; border-radius: 7px; white-space: nowrap;
}
.alert-item.nomotion .ai-tag, .alert-item.lowbat .ai-tag { background: #e67e22; }
.alert-item .icon-btn { padding: 3px 6px; font-size: .85em; flex-shrink: 0; }
.alert-item .acked-mark { color: var(--success); cursor: default; border-color: transparent; background: transparent; }
.alert-item .ack-when { color: var(--success); font-weight: 700; font-size: .74em; white-space: nowrap; flex-shrink: 0; align-self: center; }

/* ===== SETTINGS / NOTES DIALOG ===== */
.settings-box {
  pointer-events: auto; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; width: min(440px, 94vw); max-height: 88vh; overflow: hidden;
  box-shadow: 0 20px 60px var(--shadow); display: flex; flex-direction: column;
}
.settings-body { padding: 6px 18px 14px; overflow-y: auto; }
.settings-body h4 {
  color: var(--secondary); font-size: .82em; text-transform: uppercase; letter-spacing: .6px;
  margin: 16px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border);
}
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0; font-size: .9em; }
.set-row input,
.set-row select {
  width: 130px; box-sizing: border-box; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-family: inherit; font-size: 1em;
}
.set-row input:focus,
.set-row select:focus { outline: none; border-color: var(--accent); }
.set-row input:disabled { opacity: .4; cursor: not-allowed; }
.set-check { display: flex; align-items: center; gap: 9px; margin: 9px 0; font-size: .9em; cursor: pointer; }
.set-check input { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--accent); }
.set-hint { font-size: .78em; color: var(--muted); margin: 6px 2px 2px; line-height: 1.4; }
.settings-box .confirm-actions { padding: 0 18px 16px; }
.notes-for { font-size: .82em; color: var(--muted); margin: 6px 0 10px; }
.notes-text {
  width: 100%; background: var(--input-bg); color: var(--text); resize: vertical;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-family: inherit; font-size: .92em; line-height: 1.5;
}
.notes-text:focus { outline: none; border-color: var(--accent); }

/* ===== THEMED SCROLLBARS ===== */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ===== AUTH (login / forgot / reset / change password) ===== */
.auth-overlay {
  position: fixed; inset: 0; z-index: 20000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-a), var(--bg) 70%);
}
.auth-overlay[hidden] { display: none; }
/* A session hint (set before first paint) hides the login overlay so an
   authenticated refresh shows the dashboard directly — no login flash. When
   logged out there's no hint, so the overlay covers the app from the first
   paint and the dashboard never flickers behind it on F5. */
:root.has-session #authOverlay { display: none; }
.auth-card {
  width: min(400px, 94vw); background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 24px 70px var(--shadow); padding: 28px 26px 14px;
  display: flex; flex-direction: column; gap: 18px;
  position: relative;
}
/* language selector on the login card (the header toggle is covered by the overlay) */
.auth-lang { position: absolute; top: 16px; inset-inline-end: 16px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; direction: ltr; }
.auth-brand .brand-eye { width: 56px; height: auto; }
.auth-brand .brand {
  font-family: 'Audiowide', system-ui, sans-serif; font-size: 1.5em; letter-spacing: .5px;
  color: var(--text); /* fallback if background-clip:text is unsupported */
  background: linear-gradient(100deg,
      rgba(255,255,255,0.66) 0%, rgba(255,255,255,0.66) 42%,
      #ffffff 49%, #ffffff 51%,
      rgba(255,255,255,0.66) 58%, rgba(255,255,255,0.66) 100%);
  background-size: 300% 100%;
  background-position: 150% 0;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: brand-flashlight 5s ease-in-out infinite;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.auth-form[hidden] { display: none; }
.auth-form.compact { gap: 12px; }
.auth-form h2 { margin: 0; font-size: 1.15em; color: var(--text); text-align: center; }
.auth-hint { margin: 0; color: var(--muted); font-size: .9em; text-align: center; line-height: 1.4; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: .85em; color: var(--muted); }
.auth-form input {
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 11px 12px; font-family: inherit; font-size: 1em;
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
/* Hebrew: while a field is empty, right-align its placeholder. Once the user
   types, dir="auto" (set in JS) flips the text to match the first character's
   language — Hebrew -> right, English -> left. */
:root[dir="rtl"] input:placeholder-shown,
:root[dir="rtl"] textarea:placeholder-shown { text-align: right; }
.auth-form .btn.primary { padding: 12px; font-size: 1em; }
.linklike {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font: inherit; font-size: .85em; padding: 2px; align-self: center;
}
.linklike:hover { text-decoration: underline; }

/* header account menu */
.user-wrap { position: relative; display: inline-flex; }
.user-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 15000;
  min-width: 190px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 34px var(--shadow); padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.user-menu[hidden] { display: none; }
.user-info { padding: 6px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }
.user-info strong { color: var(--text); font-size: .92em; }
.user-info span { color: var(--muted); font-size: .8em; }
.user-menu button {
  background: none; border: none; text-align: start; color: var(--text);
  padding: 8px 8px; border-radius: 7px; cursor: pointer; font: inherit; font-size: .88em;
}
.user-menu button:hover { background: var(--item); }
.user-menu button.menu-pref { display: flex; align-items: center; gap: 8px; }
.user-menu button.menu-pref[hidden] { display: none; } /* keep [hidden] working despite the flex rule above */
.menu-pref .mi-ico { font-size: 1em; width: 1.2em; text-align: center; }
.menu-pref .mi-val { margin-inline-start: auto; color: var(--muted); font-weight: 700; font-size: .82em; }
.user-menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* admin impersonation banner */
.imp-banner {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  background: #0f2c40; color: #fff;
  padding: 6px 14px; font-size: .85em; font-weight: 600;
}
.imp-banner[hidden] { display: none; }
