/* ============================================================
   Metropolitan Ward — sleek modern theme
   (3D-view styles are preserved verbatim and must not change)
   ============================================================ */
:root {
  /* legacy tokens — kept for the untouched 3D overlay (labels, pin, HUD) */
  --white: #f4f4f5;
  --paper: #ffffff;
  --ink: #1a1a1d;
  --red: #ff1133;
  --red-deep: #cc0a26;
  --red-soft: #ffd6dd;
  --grey: #d8d8dc;
  --grey-mid: #b6b6bd;
  --warn: #ff8a00;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  /* both tokens now use the modern sans — Inter reads cleanly for Greek
     labels where a monospace looked off; "mono" kept as a name for the
     label/caps treatment used throughout the UI. */
  --sans: "Inter", ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: var(--sans);

  /* modern design tokens */
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --line: rgba(20, 28, 46, 0.08);
  --line-strong: rgba(20, 28, 46, 0.16);
  --text: #1b2030;
  --text-muted: #667085;
  --text-faint: #98a1b3;
  --accent: #ff1f3d;
  --accent-deep: #cc0a26;
  --accent-soft: #ffe1e6;
  --accent-grad: linear-gradient(135deg, #ff3b54, #ff1133);
  --ink-grad: linear-gradient(135deg, #2c3342, #1b2030);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, 0.09), 0 2px 5px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 18px 40px rgba(16, 24, 40, 0.16), 0 6px 12px rgba(16, 24, 40, 0.07);
  --ring: 0 0 0 3px rgba(255, 31, 61, 0.16);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1100px 560px at 88% -12%, rgba(255, 31, 61, 0.06), transparent 60%),
    linear-gradient(135deg, #f7f9fc 0%, #eef1f7 58%, #e9edf4 100%);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* refined scrollbars */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(20, 28, 46, 0.18); border-radius: var(--radius-pill);
  border: 3px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(20, 28, 46, 0.32); background-clip: padding-box; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; flex: 0 1 auto; }
.brand .hosp-chip { flex: 0 1 auto; min-width: 14ch; }
/* The topbar is over-subscribed at ~1280px once the badge + toggles are in.
   Let the discretionary bits give way first: actions may shrink, and the user
   badge ellipsizes, so the brand and the hospital pill keep readable width. */
.topbar-actions { min-width: 0; flex: 0 1 auto; }
.user-badge { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.brand-mark {
  width: 18px; height: 18px; flex: none;   /* never let flex squash the mark */
  background: var(--accent-grad);
  border-radius: 6px;
  transform: rotate(45deg);
  box-shadow: 0 2px 10px rgba(255, 31, 61, 0.45);
}
.brand h1 {
  font-size: 19px;
  letter-spacing: 2px;
  margin: 0;
  font-weight: 800;
  color: var(--text);
  /* the wordmark is fixed furniture: never wrapped, never shrunk, never clipped */
  white-space: nowrap; flex: none;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
/* gap already spaces the badge; the extra margin was double-spacing it */
.topbar-actions .user-badge { margin-right: 0; }

/* group divider between button clusters */
.tb-sep { width: 1px; height: 26px; background: var(--line-strong); flex: none; }

/* signed-in user badge, next to the logout button */
.user-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  margin-right: 8px;
  white-space: nowrap;
}

/* info button + popover (holds the stats & colour legend) */
.info-wrap { position: relative; }
.icon-btn {
  width: 38px; height: 38px; flex: none; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-family: var(--mono); font-size: 15px; font-weight: 700; font-style: italic;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .12s ease;
}
.icon-btn:hover, .icon-btn.active { background: var(--ink-grad); color: #fff; border-color: transparent; transform: translateY(-1px); }
/* language toggle: a two-letter code reads better upright than in the
   italic mono the other icon buttons use */
.lang-btn { font-style: normal; font-size: 13px; letter-spacing: .04em; }
.info-pop {
  position: absolute; top: calc(100% + 12px); left: 0; z-index: 30;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-lg);
}
.info-pop.hidden { display: none; }
.info-pop .stats { border-right: none; padding-right: 0; white-space: nowrap; }
.info-pop .legend { flex-direction: column; align-items: flex-start; gap: 9px; }

/* ---------- Ward selector ---------- */
.ward-select {
  display: flex; align-items: center; gap: 8px;
  border-right: 1px solid var(--line); padding-right: 16px;
}
.ward-select-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-muted);
}
.ward-select select {
  font-family: var(--mono); font-size: 12px; letter-spacing: .5px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
  cursor: pointer;
}
.ward-select select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.stats {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-muted);
}
.stats b { color: var(--accent); }
.legend { display: flex; gap: 14px; font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 1px; }
.legend-item { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
.swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line-strong); }
.swatch-empty { background: var(--surface); }
.swatch-occupied { background: var(--accent); }
.swatch-clash { background: repeating-linear-gradient(45deg, var(--accent) 0 4px, var(--text) 4px 8px); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 1px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--ink-grad);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .16s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { background: #fff; border-color: var(--text); color: var(--text); }
.btn-danger { background: var(--accent-grad); border-color: transparent; color: #fff; box-shadow: 0 4px 16px rgba(255, 31, 61, 0.4); }
.btn-danger:hover { box-shadow: 0 6px 22px rgba(255, 31, 61, 0.5); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 232px 1fr 320px;
  height: calc(100% - 63px);
}
/* Tray hidden by default; revealed via the "Προβολή / Επεξεργασία" toggle */
.layout.tray-collapsed { grid-template-columns: 232px 1fr; }
.layout.tray-collapsed .tray { display: none; }

/* ---------- Floor rail (elevator / cross-section) ---------- */
.floor-rail {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.rail-head {
  font-family: var(--mono); font-size: 11px; letter-spacing: 3px;
  padding: 16px 18px 12px; color: var(--text-faint);
  border-bottom: 1px solid var(--line);
}
.rail-list { display: flex; flex-direction: column; overflow: auto; flex: 1; padding: 8px; gap: 4px; }
/* highest floor at top -> rendered reversed in JS */
.floor-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}
.floor-item:hover { background: rgba(20, 28, 46, 0.04); }
.floor-item .fl-level {
  width: 32px; height: 32px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  font-family: var(--mono); font-weight: 800; font-size: 14px;
}
.floor-item .fl-text { min-width: 0; }
.floor-item .fl-name { font-size: 12px; font-weight: 700; line-height: 1.2; }
.floor-item .fl-occ {
  font-family: var(--mono); font-size: 10px; color: var(--text-muted); margin-top: 2px;
}
/* occupied floors get an accent bed-count dot */
.floor-item .fl-dot {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  background: var(--accent); color: #fff; padding: 1px 7px; border-radius: var(--radius-pill);
}
.floor-item.active {
  background: var(--ink-grad); color: #fff; box-shadow: var(--shadow-md);
}
.floor-item.active .fl-level { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 2px 8px rgba(255, 31, 61, 0.5); }
.floor-item.active .fl-occ { color: rgba(255, 255, 255, 0.6); }
.floor-item.has-occ:not(.active) .fl-level { color: var(--accent); border-color: rgba(255, 31, 61, 0.45); }
.floor-item.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Floor banner (ward header) ---------- */
.floor-banner { margin-bottom: 6px; }
.floor-banner .fb-title { display: flex; align-items: baseline; gap: 10px; }
.floor-banner .fb-level {
  font-family: var(--mono); font-size: 12px; letter-spacing: 1px;
  background: var(--accent); color: #fff; padding: 3px 10px; border-radius: var(--radius-pill);
}
.floor-banner h2 { margin: 0; font-size: 18px; letter-spacing: 1px; text-transform: uppercase; font-weight: 800; }
.floor-banner .fb-depts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.floor-banner .fb-dept {
  font-family: var(--mono); font-size: 10px; letter-spacing: .5px;
  border: 1px solid var(--line-strong); color: var(--text-muted); padding: 3px 9px; border-radius: var(--radius-pill);
}
.ward { padding: 24px 28px; overflow: auto; }
.ward-head h2 { margin: 0 0 2px; font-size: 16px; letter-spacing: 2px; text-transform: uppercase; }
.hint { margin: 0 0 18px; font-size: 12px; color: var(--text-muted); font-family: var(--mono); }

/* ---------- Rooms grid (2D) ---------- */
.rooms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 14px;
}
.room {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, transform .14s ease, border-color .18s ease;
}
.room:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.room.occupied { border-color: rgba(255, 31, 61, 0.32); box-shadow: 0 0 0 1px rgba(255, 31, 61, 0.22), var(--shadow-md); }
.room.override::after {
  content: "OVERRIDE";
  position: absolute; top: 8px; right: 8px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 1px; font-weight: 700;
  background: var(--text); color: #fff;
  padding: 3px 7px; border-radius: var(--radius-pill);
}
.room.drag-over { transform: translateY(-2px) scale(1.01); box-shadow: 0 0 0 2px var(--accent), var(--shadow-lg); border-color: var(--accent); }
/* locked: reserved for its occupant — amber outline + reserved beds */
.room.locked { border-color: rgba(255, 149, 0, 0.5); box-shadow: 0 0 0 1px rgba(255, 149, 0, 0.32), var(--shadow-md); }
.room.locked.occupied { border-color: rgba(255, 149, 0, 0.6); box-shadow: 0 0 0 1px rgba(255, 149, 0, 0.4), var(--shadow-md); }
.bed-empty.reserved {
  border-style: solid; border-color: rgba(255, 149, 0, 0.6); color: #b36b00;
  background: repeating-linear-gradient(45deg, rgba(255, 149, 0, 0.08) 0 6px, transparent 6px 12px);
}
.room-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.room-light {
  width: 9px; height: 9px; flex: none; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
}
.room-light.free { background: #18c462; box-shadow: 0 0 8px rgba(24, 196, 98, 0.85); }
.room-light.full { background: #b6bccb; box-shadow: none; }
.room-name { font-weight: 800; letter-spacing: .3px; font-size: 12px; }
.room-cap { font-family: var(--mono); font-size: 11px; color: var(--text-muted); margin-left: auto; }
/* lock toggle — reserve the whole room for its occupant */
.room-lock {
  flex: none; margin-left: 6px; padding: 2px 6px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 12px; line-height: 1.4; cursor: pointer; border-radius: var(--radius-sm);
  transition: background .12s ease, transform .1s ease, border-color .12s ease;
}
.room-lock:hover { transform: translateY(-1px); border-color: var(--text); }
.room-lock.on { background: #fff4e3; border-color: rgba(255, 149, 0, 0.6); }
.room.occupied .room-head { background: var(--accent-grad); color: #fff; border-bottom-color: transparent; }
.room.occupied .room-cap { color: rgba(255, 255, 255, 0.82); }
.room.occupied .room-light.full { background: rgba(255, 255, 255, 0.85); border-color: rgba(255, 255, 255, 0.6); }
.room.occupied .room-lock { border-color: rgba(255, 255, 255, 0.55); background: rgba(255, 255, 255, 0.14); }
.beds { display: flex; flex-direction: column; gap: 6px; padding: 9px; flex: 1; }
.bed-empty {
  flex: 1;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  min-height: 30px;
}
.bed-icon { width: 24px; height: 24px; opacity: .85; }
.bed-empty.reserved .bed-icon { opacity: .9; }

/* ---------- Patient chips / cards ---------- */
.patient {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: grab;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease;
}
.patient:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.patient.dragging { opacity: .45; }
/* Patients of the signed-in doctor get an accent left-border. */
.patient.mine { border-left: 3px solid var(--accent); }
.patient .p-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.patient .p-name { font-weight: 700; font-size: 13px; }
.patient .p-meta { font-family: var(--mono); font-size: 10px; color: var(--text-faint); white-space: nowrap; }
.patient .p-doc { margin-top: 7px; font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* "Only my patients" toggle at the top of the tray. */
.mine-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  padding: 4px 2px 10px; cursor: pointer; user-select: none;
}
.mine-toggle input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* Signed-in doctor badge in the top bar. */
.user-badge { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-right: 8px; white-space: nowrap; }

/* Occupant row that belongs to the signed-in doctor. */
.rd-occ-btn.mine { border-left: 3px solid var(--accent); }
.conds { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.pill {
  font-family: var(--mono); font-size: 9px; letter-spacing: .5px; font-weight: 600;
  padding: 3px 9px; text-transform: uppercase;
  border: 1px solid transparent; border-radius: var(--radius-pill);
}
.pill.danger { background: var(--accent); color: #fff; }
.pill.warn   { background: #fff7ed; color: #c2620a; border-color: rgba(255, 138, 0, 0.4); }
.pill.info   { background: #ecfdf5; color: #067a52; border-color: rgba(6, 170, 102, 0.35); }
.pill.ok     { background: #f3f4f6; color: #4b5563; border-color: var(--line-strong); }

/* in-bed patient is a compact chip */
.bed .patient { padding: 7px 10px; border-radius: var(--radius-sm); }
.bed .patient .conds { margin-top: 4px; }

/* ---------- Tray ---------- */
.tray {
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.tray-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.tray-head h2 { margin: 0; font-size: 15px; letter-spacing: 2px; text-transform: uppercase; }
.tray-count {
  font-family: var(--mono); font-size: 12px;
  background: var(--accent); color: #fff;
  padding: 1px 9px; margin-left: auto; border-radius: var(--radius-pill);
}
/* tray tabs: ΑΝΑΜΟΝΗ ΤΟΠΟΘΕΤΗΣΗΣ ⇄ ΤΟΠΟΘΕΤΗΜΕΝΟΙ */
.tray-tabs { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.tray-tab {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 8px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .5px; line-height: 1.25;
  text-transform: uppercase; text-align: center;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}
.tray-tab:hover { background: #fff; color: var(--text); }
.tray-tab.active { background: var(--ink-grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }
.tab-count {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  background: var(--accent); color: #fff; padding: 0 7px; flex: none; border-radius: var(--radius-pill);
}

.patient-list { padding: 18px; display: flex; flex-direction: column; gap: 14px; overflow: auto; flex: 1; }
.patient-list.drag-over { background: var(--accent-soft); border-radius: var(--radius); }
.tray-empty { color: var(--text-faint); font-family: var(--mono); font-size: 12px; text-align: center; padding: 30px 0; line-height: 1.6; }

/* ΤΟΠΟΘΕΤΗΜΕΝΟΙ — patients grouped by room */
.placed-group { display: flex; flex-direction: column; gap: 8px; }
.placed-group + .placed-group { margin-top: 4px; }
.placed-group-head {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--line); padding-bottom: 4px;
}

/* ---------- 3D ---------- */
.ward-3d { padding: 24px 28px 28px; display: flex; flex-direction: column; overflow: hidden; }
#canvas-host {
  flex: 1; position: relative; min-height: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  background:
    radial-gradient(900px 480px at 80% -10%, rgba(255, 31, 61, 0.05), transparent 60%),
    linear-gradient(135deg, #f7f9fc 0%, #eef1f7 60%, #e9edf4 100%);
}
#canvas-host canvas { display: block; }
.room3d-label {
  position: absolute; pointer-events: none; white-space: nowrap;
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .4px;
  background: rgba(255, 255, 255, 0.92); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 3px 10px;
  transform: translate(-50%, -130%);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.room3d-label.occupied {
  background: var(--accent-grad); color: #fff; border-color: transparent;
  box-shadow: 0 3px 12px rgba(255, 31, 61, 0.42);
}
.room3d-label.override::after {
  content: " ⚠"; }

/* focus pin — floats above a room when locating a placed patient */
.focus-pin {
  position: absolute; transform: translate(-50%, -120%);
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .3px;
  background: var(--ink-grad); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15); border-radius: var(--radius-pill);
  padding: 6px 8px 6px 12px;
  box-shadow: var(--shadow-lg);
  z-index: 3; white-space: nowrap; pointer-events: auto;
}
.focus-pin .fp-icon { font-size: 14px; line-height: 1; }
.focus-pin .fp-close {
  border: none; background: var(--accent); color: #fff; cursor: pointer;
  font-family: var(--mono); font-weight: 700; font-size: 11px;
  width: 20px; height: 20px; line-height: 1; padding: 0; border-radius: 50%;
}
.focus-pin .fp-close:hover { background: var(--accent-deep); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, 0.42);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal {
  background: var(--surface);
  border: 1px solid rgba(255, 31, 61, 0.4);
  border-radius: var(--radius);
  max-width: 460px; width: 90%;
  overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 50px rgba(255, 31, 61, 0.25);
  animation: snap .14s ease;
}
@keyframes snap { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-flash {
  background: var(--accent-grad); color: #fff;
  font-family: var(--mono); letter-spacing: 4px; font-weight: 800;
  padding: 12px 20px; font-size: 17px;
}
.modal-body { padding: 22px; font-size: 14px; line-height: 1.6; }
.modal-body .clash-line { margin: 0 0 12px; }
.modal-body strong { color: var(--accent-deep); }
.modal-body .who { font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; padding: 0 22px 22px; }

/* ---------- Drawer (patient calendar) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 384px;
  background: var(--surface); border-left: 1px solid var(--line);
  z-index: 41; padding: 28px; overflow: auto;
  box-shadow: -22px 0 60px rgba(16, 24, 40, 0.18);
  animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(40px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
.drawer-close { position: absolute; top: 16px; right: 18px; border: none; background: none; font-size: 28px; cursor: pointer; line-height: 1; color: var(--text-muted); transition: color .12s ease; }
.drawer-close:hover { color: var(--text); }
.drawer h3 { margin: 0 0 2px; font-size: 21px; }
.drawer .d-meta { font-family: var(--mono); font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.drawer .d-notes { background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; line-height: 1.5; margin-bottom: 20px; }
.cal-title { font-family: var(--mono); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }

/* room details drawer — capabilities & equipment bullets */
.rd-section { margin-bottom: 20px; }
.rd-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.rd-list li { font-size: 13px; line-height: 1.45; color: var(--text); }
.rd-list li::marker { color: var(--accent); }
.rd-occ-btn { width: 100%; margin-bottom: 6px; }
.cal-item { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cal-time { font-family: var(--mono); font-weight: 700; color: var(--accent); min-width: 50px; }
.cal-label { font-size: 13px; }

/* drawer action bar */
.d-actions { margin-bottom: 22px; }
.d-actions .act-title { font-family: var(--mono); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px; }
.move-scroll { max-height: 260px; overflow: auto; margin-bottom: 12px; padding-right: 4px; }
.move-floor {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--accent-deep); margin: 12px 0 6px; padding-bottom: 3px;
  border-bottom: 1px solid var(--line);
}
.move-floor:first-child { margin-top: 0; }
.move-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.move-btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: .5px;
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; text-align: left; transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.move-btn:hover:not(:disabled) { background: var(--ink-grad); color: #fff; border-color: transparent; }
.move-btn:disabled { opacity: .4; cursor: not-allowed; }
.move-btn.current { background: var(--ink-grad); color: #fff; border-color: transparent; cursor: default; }
.move-btn.clash { border-color: rgba(255, 31, 61, 0.5); color: var(--accent-deep); }
.move-btn.clash:hover { background: var(--accent); color: #fff; border-color: transparent; }
.move-btn .mb-cap { display: block; font-size: 9px; color: inherit; opacity: .7; margin-top: 2px; }
.d-ops { display: flex; gap: 8px; }
.d-ops .btn { flex: 1; justify-content: center; }

/* discharged list in tray */
.discharged-section { border-top: 1px solid var(--line); padding: 14px; }
.discharged-section h3 { margin: 0 0 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-faint); }
.discharged-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: 12px; }
.discharged-row .dr-name { color: var(--text-muted); }
.readmit-btn { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; text-transform: uppercase; transition: background .12s ease, color .12s ease; }
.readmit-btn:hover { background: var(--ink-grad); color: #fff; border-color: transparent; }

#canvas-host.drag-over { box-shadow: inset 0 0 0 2px var(--accent), var(--shadow-md); }

/* ============================================================
   Full-screen pages (Rules · Add Patient)
   ============================================================ */
.page {
  position: fixed; inset: 0; z-index: 60;
  background:
    radial-gradient(1100px 560px at 88% -12%, rgba(255, 31, 61, 0.06), transparent 60%),
    linear-gradient(135deg, #f7f9fc 0%, #eef1f7 58%, #e9edf4 100%);
  display: flex; flex-direction: column;
  animation: snap .14s ease;
}
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(150%); -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.page-head h2 { margin: 0; font-size: 18px; letter-spacing: 2px; text-transform: uppercase; }
.page-close { border: none; background: none; font-size: 30px; line-height: 1; cursor: pointer; color: var(--text-muted); transition: color .12s ease; }
.page-close:hover { color: var(--text); }
.page-body { flex: 1; overflow: auto; padding: 30px 26px; }
.page-inner { max-width: 800px; margin: 0 auto; }
.section-title {
  font-family: var(--mono); font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-faint); margin: 22px 0 10px;
}

/* --- Rules list (cards) --- */
.rules-top { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.rules-intro { flex: 1; margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-muted); }
.rules-top .btn { white-space: nowrap; flex: none; }

.rule-card {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.rule-card.is-off { opacity: .5; }

/* grouped rules: one card per illness, compact row per incompatibility */
.rule-group { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 14px; }
.rg-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.rg-illness { font-weight: 800; font-size: 15px; }
.rg-sub { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); }
.rg-count {
  margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 700;
  background: var(--ink-grad); color: #fff; padding: 2px 9px; border-radius: var(--radius-pill);
}
.rg-rows { display: flex; flex-direction: column; }
.rg-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  transition: background .12s ease;
}
.rg-row:hover { background: var(--surface-2); }
.rg-row:last-child { border-bottom: none; }
.rg-row.is-off { opacity: .45; }
.rg-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rg-with { font-weight: 700; font-size: 13px; }
.rg-reason { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }
.rule-edit-mini {
  flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  padding: 6px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.rule-edit-mini:hover { background: var(--ink-grad); color: #fff; border-color: transparent; }
.rg-row .rule-switch { width: 40px; height: 23px; }
.rg-row .rule-switch .knob { width: 15px; height: 15px; }
.rg-row .rule-switch.on .knob { left: 19px; }
.rg-row .rule-x { width: 30px; height: 30px; font-size: 12px; }

/* toggle switch */
.rule-switch {
  flex: none; width: 46px; height: 26px; border-radius: var(--radius-pill); padding: 0;
  border: 1px solid var(--line-strong); background: #e5e7eb;
  position: relative; cursor: pointer; transition: background .18s ease, border-color .18s ease;
}
.rule-switch .knob {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .18s ease;
}
.rule-switch.on { background: linear-gradient(135deg, #1fc77f, #0e9e74); border-color: transparent; }
.rule-switch.on .knob { left: 22px; }

.rule-body { flex: 1; min-width: 0; }
.rule-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rule-title { font-weight: 800; font-size: 15px; line-height: 1.25; }
.rule-badge {
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; padding: 3px 8px; white-space: nowrap; border-radius: var(--radius-pill);
}
.rule-badge.block { background: var(--accent-soft); color: var(--accent-deep); }
.rule-badge.warn  { background: #fff4e3; color: #8a5a00; }
.rule-desc { margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--text-muted); }

.rule-ctrls { display: flex; align-items: center; gap: 8px; flex: none; }
.rule-edit { padding: 8px 14px; }
.rule-x {
  width: 38px; height: 38px; flex: none; line-height: 1; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--accent);
  font-family: var(--mono); font-weight: 800; cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.rule-x:hover { border-color: transparent; background: var(--accent); color: #fff; }

/* rule editor (add / edit) */
.rule-editor { margin-bottom: 16px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.re-title { font-family: var(--mono); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 14px; color: var(--text-muted); }
.re-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.re-grid .field.full { grid-column: 1 / -1; }
.re-grid .field span {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted);
}

/* --- Add patient form --- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
.field input, .field select, .field textarea {
  font-family: var(--sans); font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.cond-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cond-chip {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  padding: 8px 13px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.cond-chip:hover { background: var(--surface-2); border-color: var(--text); }
.cond-chip.on { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 3px 12px rgba(255, 31, 61, 0.4); }
.form-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 12px; }
.form-error { color: var(--accent-deep); font-family: var(--mono); font-size: 12px; margin-top: 12px; }

/* live camera readout in the 3D view */
.cam-hud {
  display: none; /* hidden; flip to flex to re-capture a view */
  position: absolute; left: 12px; bottom: 12px; z-index: 3;
  align-items: center; gap: 8px;
  background: rgba(255,255,255,.85); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 8px; box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.cam-hud code { font-family: var(--mono); font-size: 11px; color: var(--text); white-space: nowrap; }
.cam-hud button {
  font-family: var(--mono); font-size: 13px; line-height: 1; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  padding: 4px 7px; cursor: pointer; transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.cam-hud button:hover { background: var(--ink-grad); color: #fff; border-color: transparent; }

.hidden { display: none !important; }

/* ---------- Sign-in overlay ---------- */
.signin {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(255, 31, 61, 0.1), transparent 60%),
    radial-gradient(800px 500px at 10% 110%, rgba(40, 60, 110, 0.08), transparent 55%),
    linear-gradient(135deg, #f7f9fc 0%, #eef1f7 60%, #e7ebf3 100%);
}
.signin-card {
  width: 372px; max-width: 90vw;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 36px 32px;
}
.signin-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.signin-brand-text h1 { margin: 0; font-size: 18px; letter-spacing: 2px; font-weight: 800; }
.signin-brand-text .brand-sub {
  font-family: var(--mono); font-size: 10px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--text-faint);
}
.signin-title { margin: 0 0 18px; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); }
.signin-form { display: flex; flex-direction: column; gap: 14px; }
.signin-form .field { display: flex; flex-direction: column; gap: 6px; }
.signin-form .field span {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-muted);
}
.signin-form input {
  padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 13px; background: var(--surface); color: var(--text);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.signin-form input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.signin-error { color: var(--accent); font-family: var(--mono); font-size: 11px; }
.signin-btn { margin-top: 8px; width: 100%; padding: 12px; }

/* ===== Agent dock (voice + chat) ===== */
.agent-fab { position: fixed; right: 22px; bottom: 22px; width: 56px; height: 56px; border-radius: 50%; border: none; font-size: 24px; cursor: pointer; background: var(--accent); color: #fff; box-shadow: var(--shadow-lg); z-index: 60; }
.agent-dock { position: fixed; right: 22px; bottom: 90px; width: min(520px, calc(100vw - 44px)); max-height: 70vh; display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 60; }
.agent-dock.hidden { display: none; }
.agent-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--ink-grad); color: #fff; }
.agent-title { font-weight: 700; }
.agent-min { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; line-height: 1; }
.agent-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.agent-msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; }
.agent-msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.agent-msg.bot { align-self: flex-start; background: #eef0f4; color: var(--text); border-bottom-left-radius: 4px; }
.agent-card { align-self: stretch; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px; box-shadow: var(--shadow-sm); }
.agent-card.ac-dismissed, .agent-card.ac-reverted { opacity: .5; }
.ac-desc { font-weight: 600; font-size: 14px; color: var(--text); }
.ac-why { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }
.ac-bad { color: var(--warn); font-size: 13px; margin-top: 8px; }
.ac-clash { color: var(--accent-deep); font-size: 13px; margin: 8px 0; }
.ac-actions { display: flex; gap: 8px; margin-top: 10px; }
.ac-actions .btn { padding: 6px 14px; font-size: 13px; }
.ac-undo { margin-top: 8px; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; }
.ac-done .ac-desc::before { content: '✓ '; color: #16a34a; }
.agent-composer { display: flex; gap: 8px; align-items: center; padding: 12px; border-top: 1px solid var(--line); }
.agent-composer input { flex: 1; border: 1px solid var(--line-strong); border-radius: 12px; padding: 9px 12px; font: inherit; }
.agent-mic { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 17px; }
.agent-mic.listening { background: var(--accent); border-color: var(--accent); animation: micpulse 1s infinite; }
.agent-mic:disabled { opacity: .4; cursor: not-allowed; }
.agent-mic.transcribing { cursor: progress; animation: micfade 1s ease-in-out infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,31,61,.5);} 50% { box-shadow: 0 0 0 8px rgba(255,31,61,0);} }
@keyframes micfade { 0%,100% { opacity: 1;} 50% { opacity: .45;} }

/* ===== Agent batch card ===== */
.agent-batch .ab-head { font-weight: 700; font-size: 13.5px; color: var(--text); margin-bottom: 8px; }
.agent-batch .ab-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.ab-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.ab-row:last-child { border-bottom: none; }
.ab-desc { flex: 1; }
.ab-row.ab-invalid { color: var(--text-faint); }
.ab-row.ab-excluded .ab-desc { text-decoration: line-through; opacity: .55; }
.ab-x { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 13px; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.ab-x:hover { background: var(--accent-soft); color: var(--accent-deep); }

/* ---------- HHG map of Greece (Leaflet + CARTO, hospital chooser) ---------- */
/* "choosing" mode: only the map shows; the ward + clinics + agent stay hidden */
.map-landing { display: none; }
body.choosing .layout { display: none; }
body.choosing .map-landing {
  display: flex; flex-direction: column; align-items: center;
  height: calc(100% - 63px); padding: 20px 20px 26px; overflow: hidden;
  background: #eef0f4;
}
body.choosing .topbar-actions { display: none; }
body.choosing #agent-fab, body.choosing #agent-dock { display: none !important; }
.hosp-chip { display: none; }
body:not(.choosing) .hosp-chip {
  display: inline-block; font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .4px; background: var(--accent-soft); color: var(--accent-deep);
  padding: 4px 11px; border-radius: var(--radius-pill);
  /* A pill is a single-line shape: long "Name · City" labels used to wrap and
     burst out of the rounded ends. Stay on one line and ellipsize instead.
     A min-width floor stops the flex row crushing it to a 22px stub when the
     topbar is tight: it truncates to something readable instead. */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 46ch; line-height: 1.45;
}
/* Below ~1500px the topbar's 14 controls plus the wordmark leave too little
   room: the pill would truncate to "Metropolit…" and squeeze the user badge to
   a stub too. Drop it instead — the hospital is named on the ward screen — and
   everything else keeps its full width. */
@media (max-width: 1500px) {
  body:not(.choosing) .hosp-chip { display: none; }
}

/* the "← Χάρτης HHG" button only makes sense once you're inside a hospital */
body.choosing #map-home { display: none; }

/* glassy floating title pill — matches the topbar's frosted card look */
.map-landing-head {
  text-align: center; margin-bottom: 18px; padding: 13px 26px; z-index: 500;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.map-landing-head h2 {
  margin: 0 0 4px; font-size: 18px; letter-spacing: 1.5px; font-weight: 800; color: var(--text);
}
.map-landing-head p { margin: 0; font-size: 12.5px; color: var(--text-muted); }

/* the map surface — a soft rounded card on the app's gradient */
.map-canvas {
  flex: 1; width: 100%; min-height: 0; align-self: stretch;
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--surface-2);
}
.leaflet-container { font-family: var(--sans); background: var(--surface-2); }
/* lightly soften the base tiles so the red pins stay the dominant colour */
.leaflet-tile-pane { filter: grayscale(0.4) contrast(1.02) brightness(1.02); }

/* teardrop accent pin (SVG), tip at the bottom point */
.hhg-pin svg { display: block; overflow: visible; }
.hhg-pin path {
  fill: var(--accent); stroke: #fff; stroke-width: 2;
  filter: drop-shadow(0 3px 5px rgba(16, 24, 40, 0.28)); transition: fill .14s ease;
}
.hhg-pin circle { fill: #fff; }
.hhg-pin .pg { transition: transform .14s ease; transform-box: fill-box; transform-origin: 50% 100%; }
.hhg-pin:hover .pg { transform: scale(1.16); }
.hhg-pin:hover path { fill: var(--accent-deep); }

/* clustered hospitals (e.g. Athens) — accent bubble with count */
.hhg-cluster {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-weight: 700; font-size: 14px; color: #fff;
  background: var(--accent-grad); border: 2px solid #fff; border-radius: 50%;
  box-shadow: var(--shadow-md);
}
.hhg-cluster div { line-height: 1; }

/* tooltip — modern soft card */
.leaflet-tooltip.hhg-tip {
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-family: var(--sans); font-size: 12px;
  line-height: 1.45; padding: 8px 12px; box-shadow: var(--shadow-lg); white-space: nowrap;
}
.leaflet-tooltip.hhg-tip b { font-size: 13px; font-weight: 700; }
.leaflet-tooltip.hhg-tip::before { display: none; }

/* zoom control + attribution, themed to the modern palette */
.leaflet-bar {
  border: 1px solid var(--line) !important; border-radius: var(--radius-sm) !important;
  overflow: hidden; box-shadow: var(--shadow-sm) !important;
}
.leaflet-bar a {
  background: var(--surface); color: var(--text);
  border-bottom-color: var(--line); font-weight: 600;
}
.leaflet-bar a:hover { background: var(--surface-2); color: var(--accent-deep); }
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.78); font-size: 10px; color: var(--text-faint);
  border-radius: 7px 0 0 0;
}
.leaflet-control-attribution a { color: var(--accent-deep); }

/* ============================================================
   Dark mode — toggled by [data-theme="dark"] on <html>.
   Overrides the design tokens + the few hardcoded light glass
   surfaces. 3D-view styles (#canvas-host, .room3d-label) are
   intentionally left untouched.
   ============================================================ */
:root[data-theme="dark"] {
  --surface: #171b26;
  --surface-2: #1e2431;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #e7eaf1;
  --text-muted: #9aa4b7;
  --text-faint: #6d768a;
  --accent-soft: rgba(255, 31, 61, 0.18);
  --ink-grad: linear-gradient(135deg, #3a4260, #2a3044);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.5), 0 2px 5px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.6), 0 6px 12px rgba(0, 0, 0, 0.45);
}

:root[data-theme="dark"],
:root[data-theme="dark"] body {
  background:
    radial-gradient(1100px 560px at 88% -12%, rgba(255, 31, 61, 0.10), transparent 60%),
    linear-gradient(135deg, #0e1118 0%, #12151f 58%, #0b0e16 100%);
}
:root[data-theme="dark"] .topbar { background: rgba(18, 21, 31, 0.72); }
:root[data-theme="dark"] .floor-rail { background: rgba(23, 27, 38, 0.55); }
:root[data-theme="dark"] .tray { background: rgba(23, 27, 38, 0.62); }
:root[data-theme="dark"] .btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
:root[data-theme="dark"] .tray-tab:hover { background: var(--surface-2); color: var(--text); }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16); border: 3px solid transparent; background-clip: padding-box;
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.30); background-clip: padding-box; }

/* Full-screen light gradients → dark. */
:root[data-theme="dark"] .page {
  background:
    radial-gradient(1100px 560px at 88% -12%, rgba(255, 31, 61, 0.08), transparent 60%),
    linear-gradient(135deg, #0e1118 0%, #12151f 58%, #0b0e16 100%);
}
:root[data-theme="dark"] .signin {
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(255, 31, 61, 0.12), transparent 60%),
    radial-gradient(800px 500px at 10% 110%, rgba(40, 60, 110, 0.14), transparent 55%),
    linear-gradient(135deg, #0e1118 0%, #12151f 60%, #0b0e16 100%);
}
:root[data-theme="dark"] .signin-card { background: rgba(28, 33, 46, 0.85); }
