/* Brand faces live in fonts.css, which every layout links before this file. */
@import url('fonts.css');

:root {
  --bg-canvas: #0B1220;
  --bg-card: #121A2C;
  --bg-inset: #1A2440;
  --bg-raised: #243150;
  --bg-light: #FAF6EE;
  --surface-light: #FFFFFF;
  --ink: #F4EBDA;
  --ink-soft: #D6CDB9;
  --muted: #8A93A8;
  --fg-light: #1B2236;
  --gold: #F4B860;
  --gold-soft: rgba(244, 184, 96, 0.12);
  --gold-btn: #E8B45A;
  --gold-btn-hi: #F0C574;
  --gold-btn-lo: #D4A04A;
  --gold-btn-ink: #1A2238;
  --coral: #E36F4C;
  --crimson: #B23A3A;
  --mint: #6FCF97;
  --sand-1: #E8C99B;
  --sand-2: #C99A5B;
  --sand-3: #8A6F40;
  --border-dark: rgba(201, 154, 91, 0.18);
  --border-dark-hover: rgba(244, 184, 96, 0.45);
  --shell-bg: rgba(11, 18, 32, 0.78);
  --topbar-bg: rgba(11, 18, 32, 0.55);
  --nav-hover-bg: rgba(36, 49, 80, 0.5);
  --nav-active-bg: rgba(26, 36, 64, 0.72);
  --status-ontime: #6FCF97;
  --status-delayed: #F4B860;
  --status-incident: #E36F4C;
  --sidebar-w: 232px;
  --sidebar-collapsed: 64px;
  --topbar-h: 60px;
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --font: "Noto Sans", system-ui, sans-serif;
  --sans: "Noto Sans", system-ui, sans-serif;
  --arabic: "Noto Kufi Arabic", "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Liberation Mono", Menlo, Consolas, monospace;
}

html.light {
  --bg-canvas: var(--bg-light);
  --bg-card: var(--surface-light);
  --bg-inset: #F0EBE0;
  --bg-raised: #E8E0D0;
  --ink: var(--fg-light);
  --ink-soft: #4A5568;
  --muted: #6B7280;
  --shell-bg: rgba(255, 255, 255, 0.92);
  --topbar-bg: rgba(255, 255, 255, 0.88);
  --nav-hover-bg: rgba(244, 184, 96, 0.12);
  --nav-active-bg: rgba(244, 184, 96, 0.18);
  --border-dark: rgba(138, 111, 64, 0.18);
  --border-dark-hover: rgba(244, 184, 96, 0.55);
}

*, *::before, *::after { box-sizing: border-box; }
/* Form controls do not inherit the page font by default in any browser — without
   this, buttons and typed input render in the OS default face. */
button, input, select, textarea, optgroup, .btn { font-family: inherit; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg-canvas);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-height: 100%;
  overflow: hidden;
}
body.login-page,
body.register-page {
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background: url('/assets/background.jpg') center/cover no-repeat;
  opacity: 0.14; pointer-events: none; z-index: 0;
}
html.light body::before { opacity: 0.32; }

.billing-alert-banner,
#platformAnnouncementBanner,
.impersonation-banner {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.admin-shell {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--shell-bg);
  backdrop-filter: blur(10px);
  border-inline-end: 1px solid var(--border-dark);
  display: flex; flex-direction: column;
  transition: width 220ms ease;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 14px; border-bottom: 1px solid var(--border-dark);
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(135deg, var(--gold), var(--sand-2));
  display: grid; place-items: center; flex-shrink: 0;
  color: #fff; font-weight: 800; font-size: 14px;
}
.brand-logo-img {
  width: 34px; height: 34px; border-radius: 8px;
  object-fit: contain; flex-shrink: 0;
}
.brand-logo-full {
  display: block; width: 100%; max-width: 280px; height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25));
}
.login-brand .brand-logo-full { max-width: 300px; }
.brand-name { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .brand-name,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .user-meta { display: none; }

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); padding: 12px 12px 4px; opacity: 0.7;
}
.nav-group {
  border: none;
  margin: 0;
  padding: 0;
}
.nav-group-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-group-summary::-webkit-details-marker { display: none; }
.nav-group-summary::after {
  content: '▸';
  font-size: 10px;
  opacity: 0.7;
  transition: transform var(--dur-fast) ease;
}
.nav-group[open] > .nav-group-summary::after { transform: rotate(90deg); }
html[dir="rtl"] .nav-group-summary::after { content: '◂'; }
html[dir="rtl"] .nav-group[open] > .nav-group-summary::after { transform: rotate(-90deg); }
.nav-group-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none;
  border: 1px solid transparent;
  transition: all var(--dur-fast) ease;
}
.nav-item:hover { background: var(--nav-hover-bg); color: var(--ink); }
.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--ink);
  border-color: var(--border-dark);
}
.nav-item i { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-user {
  padding: 14px; border-top: 1px solid var(--border-dark);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sidebar-user .user-meta { flex: 1; min-width: 0; }
.sidebar-user .user-meta .name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logout-form { margin: 0; }
.logout-form button { color: var(--muted); }
.logout-form button:hover { color: var(--gold); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-raised); border: 1px solid var(--border-dark);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.user-meta .name { font-size: 12px; font-weight: 600; }
.user-meta .role { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-dark);
  backdrop-filter: blur(10px);
  background: var(--topbar-bg);
  flex-shrink: 0;
  position: relative;
  z-index: 1100; /* above page content + Leaflet panes */
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--border-dark); background: transparent;
  color: var(--ink-soft); cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--dur-fast);
}
.icon-btn:hover { border-color: var(--border-dark-hover); color: var(--ink); }
.page-title { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.topbar-spacer { flex: 1; }
.search-bar {
  min-width: 220px; height: 36px; border-radius: 10px;
  background: var(--bg-inset); border: 1px solid var(--border-dark);
  padding: 0 12px; color: var(--ink); font-size: 12px;
}
.seg-ctrl {
  display: inline-flex; background: var(--bg-inset);
  border: 1px solid var(--border-dark); border-radius: 9999px; padding: 2px;
}
.seg-ctrl button,
.seg-ctrl a {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  padding: 5px 12px; border-radius: 9999px; font-size: 11px;
  font-weight: 600; cursor: pointer;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.seg-ctrl button.active,
.seg-ctrl a.active {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--ink);
}

.notif-wrap { position: relative; z-index: 1; }
#notifBell.has-alerts { position: relative; }
#notifBell.has-alerts::after {
  content: ""; position: absolute; top: 6px; inset-inline-end: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--bg-canvas);
}
#notifBell.has-critical::after {
  background: var(--crimson);
  width: 9px; height: 9px;
  top: 5px;
  inset-inline-end: 5px;
  box-shadow: 0 0 0 2px rgba(178,58,58,0.35);
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0;
  width: min(360px, calc(100vw - 24px));
  background: var(--bg-card); border: 1px solid var(--border-dark);
  border-radius: 12px; box-shadow: 0 16px 40px -16px rgba(0,0,0,0.45);
  z-index: 1200; overflow: hidden;
}
.notif-dropdown-header {
  padding: 12px 14px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  border-bottom: 1px solid var(--border-dark);
}
.notif-dropdown-list { max-height: 320px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border-dark);
}
.notif-item:last-child { border-bottom: none; }
.notif-item-icon { color: var(--mint); flex-shrink: 0; }
.notif-item.warn .notif-item-icon { color: var(--status-delayed); }
.notif-item.critical {
  background: rgba(178,58,58,0.1);
  border-inline-start: 3px solid var(--crimson);
}
.notif-item.critical .notif-item-icon { color: var(--crimson); }
.notif-item-text { font-size: 12px; line-height: 1.4; }
.notif-item-time { font-size: 10px; color: var(--muted); margin-top: 2px; }
.notif-empty { padding: 24px 14px; text-align: center; color: var(--muted); font-size: 12px; }

.form-field-header { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.field-hint { font-size: 11px; color: var(--muted); font-weight: 400; }
.student-search {
  width: 100%; height: 36px; border-radius: 10px;
  background: var(--bg-inset); border: 1px solid var(--border-dark);
  padding: 0 12px; color: var(--ink); font-size: 12px; margin-bottom: 8px;
}
.student-picker {
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--border-dark); border-radius: 10px;
  background: var(--bg-inset);
}
.student-picker-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--border-dark);
  cursor: pointer;
}
.student-picker-item:last-child { border-bottom: none; }
.student-picker-item:hover { background: var(--nav-hover-bg); }
.student-picker-item input { margin-top: 3px; accent-color: var(--gold); }
.student-picker-name { display: block; font-size: 12px; font-weight: 600; }
.student-picker-detail { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.student-picker-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 12px; }

.page-content { flex: 1; padding: 16px 20px 20px; overflow: auto; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.page-content:has(.rb-shell) { overflow: hidden; padding-bottom: 16px; }

/* Command Center: fill viewport — no page scroll for map */
.dashboard-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.dashboard-page .kpi-rail { flex-shrink: 0; }
.dashboard-main {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 14px;
}
.dashboard-page .map-card {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.dashboard-page #fleetMap {
  flex: 1;
  min-height: 0;
  height: auto;
}

.broadcast-bar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto minmax(120px, 220px) minmax(0, 1fr);
  align-items: center;
  gap: 12px 14px;
  padding: 10px 14px;
}
.broadcast-bar-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.broadcast-bar-label i { width: 16px; height: 16px; color: var(--gold); flex-shrink: 0; }
.broadcast-bar-chips {
  max-height: 64px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  scrollbar-width: thin;
}
.broadcast-bar-chips .chip { flex-shrink: 0; }
.broadcast-bar-compose {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.broadcast-bar-input {
  flex: 1;
  min-width: 140px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-dark);
  background: var(--bg-inset);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
}
.broadcast-bar-input:focus {
  outline: none;
  border-color: var(--border-dark-hover);
}
.broadcast-bar-templates { flex-shrink: 0; flex-wrap: nowrap; }
.broadcast-bar-send { flex-shrink: 0; height: 38px; padding: 0 16px; white-space: nowrap; }

@media (max-width: 1100px) {
  .broadcast-bar {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .broadcast-bar-compose { flex-wrap: wrap; }
  .broadcast-bar-input { min-width: 100%; flex: 1 1 100%; }
}

.card {
  background: linear-gradient(180deg, rgba(244,184,96,0.04) 0%, transparent 60%), var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: 14px;
  box-shadow: 0 1px 0 0 rgba(244,184,96,0.06) inset, 0 8px 24px -12px rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
}
.card.hoverable { transition: all var(--dur-fast); cursor: pointer; }
.card.hoverable:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: var(--border-dark-hover);
  box-shadow: 0 8px 24px -10px rgba(244,184,96,0.22);
}
.card-inset { background: var(--bg-inset); border-radius: 10px; border: 1px solid var(--border-dark); }

.kpi-rail { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.kpi-card { padding: 13px 15px; display: flex; gap: 12px; align-items: flex-start; min-width: 0; }

/* Reports page layout */
.reports-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.reports-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.reports-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.reports-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.reports-kpi {
  gap: 14px;
}
.reports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-width: 0;
}
.reports-panel {
  padding: 16px 18px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.reports-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.reports-panel-title {
  font-weight: 700;
  font-size: 13px;
}
.reports-table-card {
  padding: 8px 0;
  overflow: hidden;
  min-width: 0;
}
.reports-table-card .table-scroll {
  padding: 0 4px;
}
.reports-empty,
.reports-empty-cell {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
}
.reports-note {
  padding: 10px 12px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--gold);
}
.reports-chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
  min-height: 220px;
}
.reports-chart-wrap.reports-chart-tall {
  height: 320px;
}
.reports-chart-wrap.reports-chart-wide {
  height: 280px;
}
.reports-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
.kpi-icon {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--gold-soft); display: grid; place-items: center; flex-shrink: 0;
  color: var(--gold);
}
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--muted); margin: 0; }
.kpi-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 2px 0; }
.kpi-trend { font-size: 11px; color: var(--mint); }
.kpi-trend.down { color: var(--coral); }
.kpi-flash { animation: kpiFlash 300ms ease; }
@keyframes kpiFlash { 50% { color: var(--gold); } }

.flex-row { display: flex; gap: 14px; flex: 1; min-height: 0; }
.flex-col { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.flex-1 { flex: 1; min-width: 0; min-height: 0; }

.map-card { position: relative; overflow: hidden; min-height: 420px; }
#fleetMap { width: 100%; height: 100%; min-height: 420px; background: var(--bg-inset); }
.map-overlay {
  position: absolute; z-index: 500;
  background: linear-gradient(180deg, rgba(244,184,96,0.04) 0%, transparent 60%), var(--bg-card);
  border: 1px solid var(--border-dark); border-radius: 14px;
  backdrop-filter: blur(8px); padding: 12px;
}
.map-overlay.tl { top: 14px; inset-inline-start: 14px; }
.map-overlay.tr { top: 14px; inset-inline-end: 14px; }
.map-overlay.bl { bottom: 14px; inset-inline-start: 14px; }
.map-overlay.br { bottom: 14px; inset-inline-end: 14px; }
/* Keep clear of Leaflet zoom (+/−) which sits in the bottom end corner */
.map-overlay-stack {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 10px;
}
.map-status-legend {
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  font-size: 11px; font-weight: 600; color: var(--ink-soft);
}
.map-status-legend .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-inline-end: 4px; vertical-align: middle;
}
.map-status-legend .dot.ontime { background: var(--mint); }
.map-status-legend .dot.delayed { background: var(--gold); }
.map-status-legend .dot.incident { background: var(--coral); }
.live-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 9999px;
  border: 1px solid var(--border-dark); font-size: 11px; font-weight: 600;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--mint);
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(111,207,151,0.6); } 50% { box-shadow: 0 0 0 6px rgba(111,207,151,0); } }

.right-rail { width: 392px; flex-shrink: 0; }
.panel-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border-dark);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.panel-header > span,
.icon-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}
/* Lucide replaces <i> with <svg> — keep icons centered with adjacent titles */
.panel-header svg,
.icon-label svg,
.btn svg,
.icon-btn svg,
.nav-item svg,
.live-badge svg,
.alert-icon svg,
.kpi-icon svg,
.notif-item-icon svg {
  display: block;
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  vertical-align: middle;
}
.panel-header svg { width: 14px; height: 14px; }
.btn svg,
.icon-btn svg { width: 16px; height: 16px; }
.btn.btn-sm svg { width: 14px; height: 14px; }
.tabs { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border-dark); }
.tab-btn {
  flex: 1; padding: 7px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 11px;
  font-weight: 600; cursor: pointer;
}
.tab-btn.active { background: var(--bg-inset); color: var(--ink); }

.route-row {
  padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--border-dark); margin-bottom: 8px;
  cursor: pointer; transition: all var(--dur-fast);
}
.route-row:hover { border-color: var(--border-dark-hover); background: color-mix(in srgb, var(--gold) 6%, transparent); }
.route-row.selected { border-color: var(--gold); background: transparent; }
.route-row-top { display: flex; align-items: center; gap: 10px; }
.bus-badge {
  width: 34px; height: 34px; border-radius: 9px;
  border: 2px solid var(--status-ontime);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  flex-shrink: 0;
  font-family: inherit;
}
.bus-badge.delayed { border-color: var(--status-delayed); }
.bus-badge.incident { border-color: var(--status-incident); }
.bus-badge.offline { border-color: var(--coral); color: var(--coral); }
.fleet-signal-off { color: var(--coral); font-size: 14px; line-height: 1; flex-shrink: 0; }
.route-meta { flex: 1; min-width: 0; }
.route-code { font-size: 13px; font-weight: 700; }
.route-area { font-size: 11px; color: var(--muted); }
.route-right { text-align: end; }
.status-label { font-size: 11px; font-weight: 700; }
.status-label.ontime { color: var(--status-ontime); }
.status-label.delayed { color: var(--status-delayed); }
.status-label.incident { color: var(--status-incident); }
.status-label.offline { color: var(--coral); }
.progress-bar { height: 5px; border-radius: 9999px; background: var(--bg-inset); margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 9999px; background: var(--status-ontime); transition: width 400ms ease; }

.alert-row {
  display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border-dark); margin-bottom: 8px; align-items: flex-start;
}
.alert-row.good { border-color: rgba(111,207,151,0.3); }
.alert-row.warn { border-color: rgba(244,184,96,0.3); }
.alert-row.critical { border-color: rgba(178,58,58,0.4); background: rgba(178,58,58,0.08); }
.alert-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; flex-shrink: 0;
}
.alert-row.good .alert-icon { background: rgba(111,207,151,0.15); color: var(--mint); }
.alert-row.warn .alert-icon { background: rgba(244,184,96,0.15); color: var(--gold); }
.alert-row.critical .alert-icon { background: rgba(178,58,58,0.15); color: var(--crimson); }
.alert-text { font-size: 12px; flex: 1; }
.alert-time { font-size: 10px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 12px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-dark); cursor: pointer; transition: all var(--dur-fast);
  background: var(--bg-inset); color: var(--ink-soft);
  text-decoration: none;
}
.btn:hover { border-color: var(--border-dark-hover); color: var(--ink); }
.btn-gold,
.btn-primary {
  background: linear-gradient(180deg, var(--gold-btn-hi) 0%, var(--gold-btn) 48%, var(--gold-btn-lo) 100%);
  color: var(--gold-btn-ink);
  border: 1px solid color-mix(in srgb, var(--sand-3) 65%, #000 10%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 6px 14px -8px rgba(0, 0, 0, 0.55);
  font-weight: 700;
  text-shadow: none;
}
.btn-gold:hover,
.btn-primary:hover,
.btn-gold:focus-visible,
.btn-primary:focus-visible {
  filter: none;
  background: linear-gradient(180deg, #F6CEA0 0%, #EBC07A 50%, #DEA85A 100%);
  color: var(--gold-btn-ink);
  border-color: var(--sand-2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 8px 18px -8px rgba(0, 0, 0, 0.5);
}
.btn-gold:active,
.btn-primary:active {
  background: linear-gradient(180deg, var(--gold-btn-lo), var(--sand-2));
  color: var(--gold-btn-ink);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
}
.page-content a.btn-gold,
.page-content a.btn-primary,
.page-content a.btn-gold:visited,
.page-content a.btn-primary:visited,
.page-content a.btn-gold:hover,
.page-content a.btn-primary:hover {
  color: var(--gold-btn-ink);
  border-bottom: 1px solid color-mix(in srgb, var(--sand-3) 65%, #000 10%);
  text-decoration: none;
}
.btn-ghost {
  background: transparent; border: 1px solid var(--border-dark); color: var(--ink-soft);
}
.btn-ghost:hover { border-color: var(--border-dark-hover); color: var(--ink); }
.btn-crimson { background: rgba(178,58,58,0.15); border: 1px solid rgba(178,58,58,0.4); color: var(--crimson); }
.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: 8px; }
.btn-full { width: 100%; }

.pill {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 9999px; font-size: 11px; font-weight: 600;
}
.pill-gold { background: var(--gold-soft); color: var(--gold); border: 1px solid rgba(244,184,96,0.3); }
.pill-mint { background: rgba(111,207,151,0.15); color: var(--mint); }
.pill-coral { background: rgba(227,111,76,0.15); color: var(--coral); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 10px; border-radius: 9999px; font-size: 11px;
  border: 1px solid var(--border-dark); background: transparent;
  color: var(--muted); cursor: pointer;
}
.chip.selected {
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--ink);
}

textarea, input[type=text], input[type=search], select {
  width: 100%; background: var(--bg-inset); border: 1px solid var(--border-dark);
  border-radius: 10px; padding: 8px 12px; color: var(--ink); font-family: inherit; font-size: 13px;
}
textarea:focus, input:focus { outline: none; border-color: var(--border-dark-hover); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: start; padding: 10px 12px; font-size: 11px;
  font-weight: 600; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--border-dark);
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-dark); font-size: 12px; }
.data-table tr:hover td { background: var(--gold-soft); }
.data-table tr.sa-row-link {
  cursor: pointer;
}
.data-table tr.sa-row-link:focus-visible td {
  background: var(--gold-soft);
  outline: none;
}
.data-table tr.sa-row-link:focus-visible {
  outline: 2px solid rgba(244, 184, 96, 0.55);
  outline-offset: -2px;
}

.list-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-dark);
  background: var(--bg-inset, transparent);
}
.list-pager:empty,
.list-pager[hidden] { display: none !important; }
.list-pager-info {
  font-size: 12px;
  color: var(--muted);
  min-width: 140px;
}
.list-pager-sizes {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--bg-raised, rgba(0,0,0,.04));
  overflow: visible;
}
.list-pager-size {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  min-width: 40px;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  box-sizing: border-box;
}
.list-pager-size:hover:not(:disabled) { color: var(--ink); }
.list-pager-size.active {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--ink);
}
.page-content .list-pager a.list-pager-size,
.page-content .list-pager a.list-pager-size:visited {
  border: 1px solid transparent;
  border-bottom-style: solid;
  color: var(--muted);
}
.page-content .list-pager a.list-pager-size:hover {
  border: 1px solid transparent;
  color: var(--ink);
}
.page-content .list-pager a.list-pager-size.active,
.page-content .list-pager a.list-pager-size.active:visited,
.page-content .list-pager a.list-pager-size.active:hover {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--ink);
}
.page-content .list-pager a.btn {
  border-bottom: none;
}
.list-pager-size:disabled { opacity: 0.5; cursor: default; }
.list-pager-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
  flex-wrap: wrap;
}
.list-pager-page {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 7em;
  text-align: center;
}
@media (max-width: 720px) {
  .list-pager-actions { margin-inline-start: 0; width: 100%; }
  .list-pager-info { width: 100%; }
}
.student-cell { display: flex; align-items: center; gap: 10px; }
.student-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-raised); display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: var(--sand-1);
}

.stop-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border-dark); border-radius: 10px; margin-bottom: 8px;
}
.stop-row.skipped { opacity: 0.6; }
.stop-row.skipped .stop-name { text-decoration: line-through; }
.stop-num {
  width: 22px; height: 22px; border-radius: 7px;
  border: 1px solid var(--sand-2); display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0;
}
.stop-meta { font-size: 11px; color: var(--muted); }
.skip-stop-btn {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px;
  min-height: 34px !important;
  border-radius: 10px;
  flex-shrink: 0;
  color: var(--muted);
}
.skip-stop-btn i,
.skip-stop-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}
.skip-stop-btn:hover {
  color: var(--coral);
  border-color: rgba(227, 111, 76, 0.45);
}
.skip-stop-btn.is-skipped {
  color: var(--mint);
  border-color: rgba(111, 207, 151, 0.4);
}

.timeline { position: relative; padding-inline-start: 0; }
.timeline::before { display: none; }
.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  padding: 0 0 14px;
  padding-inline-start: 0;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: static;
  inset: auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  border: none;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent);
}

.chart-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chart-bar-label { width: 80px; font-size: 12px; font-weight: 700; }
.chart-bar-track { flex: 1; height: 8px; border-radius: 9999px; background: var(--bg-inset); overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 9999px; transition: width 400ms ease; }
.chart-bar-val { width: 40px; text-align: end; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

.vchart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 20px; }
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vbar { width: 100%; border-radius: 6px 6px 0 0; transition: height 400ms ease; min-height: 4px; }
.vbar-label { font-size: 10px; color: var(--muted); }
.vbar-count { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed;
  bottom: 28px;
  inset-inline-end: 28px;
  z-index: 10050;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 12px 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}
.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.toast-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.toast-icon svg {
  width: 16px;
  height: 16px;
}
.toast-body {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
  font-weight: 600;
}
.toast-dismiss {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.toast-dismiss:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}
.toast-dismiss svg {
  width: 14px;
  height: 14px;
}
.toast-success {
  background: #1a3d2e;
  border: 1px solid rgba(111, 207, 151, 0.55);
  color: #9fe0b8;
}
.toast-success .toast-icon {
  background: rgba(111, 207, 151, 0.18);
  color: #6fcf97;
}
.toast-error {
  background: #3d1a1a;
  border: 1px solid rgba(227, 111, 76, 0.55);
  color: #f0a090;
}
.toast-error .toast-icon {
  background: rgba(227, 111, 76, 0.18);
  color: #e36f4c;
}
html.light .toast-success {
  background: #e8f7ee;
  border-color: rgba(46, 140, 90, 0.35);
  color: #1b6b3f;
}
html.light .toast-success .toast-icon {
  background: rgba(46, 140, 90, 0.12);
  color: #1b6b3f;
}
html.light .toast-error {
  background: #fdecea;
  border-color: rgba(180, 60, 50, 0.35);
  color: #9b2c1f;
}
html.light .toast-error .toast-icon {
  background: rgba(180, 60, 50, 0.12);
  color: #9b2c1f;
}
html.light .toast-dismiss:hover {
  background: rgba(0, 0, 0, 0.06);
}

.recalc-banner {
  padding: 8px 12px; border-radius: 10px; margin-bottom: 10px;
  background: rgba(111,207,151,0.12); border: 1px solid rgba(111,207,151,0.3);
  color: var(--mint); font-size: 12px;
}

.filter-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-panel { width: 300px; flex-shrink: 0; padding: 16px; }
.detail-panel .detail-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid var(--gold); display: grid; place-items: center;
  font-size: 18px; font-weight: 700; margin-bottom: 12px;
}

/* Compact stop timeline (still used by Command Center) */
.route-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.route-timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  padding-bottom: 16px;
}
.route-timeline-item:last-child { padding-bottom: 0; }
.route-timeline-rail {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 28px;
  flex-shrink: 0;
}
.route-timeline-rail::after {
  content: "";
  position: absolute;
  top: 28px;
  bottom: -16px;
  width: 2px;
  background: linear-gradient(180deg, var(--gold), color-mix(in srgb, var(--gold) 35%, transparent));
}
.route-timeline-item:last-child .route-timeline-rail::after { display: none; }
.route-timeline-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  z-index: 1;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent);
  flex-shrink: 0;
}
.route-timeline-body {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}
.route-timeline-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  word-break: break-word;
}
.route-timeline-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
  word-break: break-word;
}

/* —— Map-first Route Builder —— */
.rb-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.rb-rail {
  display: grid;
  grid-template-rows: minmax(200px, 0.9fr) minmax(280px, 1.2fr);
  gap: 14px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: transparent;
  border: 0;
}
.rb-rail:has(#rbEditor[hidden]) {
  grid-template-rows: 1fr;
}
.rb-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  border: 1px solid var(--border-dark);
  border-radius: 18px;
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--gold) 8%, transparent), transparent 42%),
    var(--bg-card);
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}
.rb-card-routes {
  min-height: 0;
}
.rb-card-editor {
  min-height: 0;
  background:
    linear-gradient(200deg, color-mix(in srgb, var(--gold) 6%, transparent), transparent 38%),
    var(--bg-card);
}
.rb-card-editor[hidden] {
  display: none !important;
}
.rb-rail-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  flex-shrink: 0;
}
.rb-rail-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.rb-kicker {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.rb-search-wrap {
  margin: 0 14px 10px;
}
.rb-search {
  width: 100%;
  border: 1px solid var(--border-dark);
  background: var(--bg-inset, rgba(0,0,0,.14));
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
}
.rb-routes {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 12px 12px;
  overscroll-behavior: contain;
}
.rb-route-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: start;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  margin-bottom: 6px;
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}
.rb-route-card:hover {
  border-color: var(--border-dark);
  background: color-mix(in srgb, var(--gold) 6%, transparent);
}
.rb-route-card.selected {
  border-color: var(--gold);
  background: transparent;
  box-shadow: none;
}
.rb-route-status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rb-route-status.on { background: var(--status-ontime); }
.rb-route-status.off { background: var(--coral); }
.rb-route-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rb-route-code { font-size: 13px; font-weight: 800; }
.rb-route-name {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-route-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }

.rb-editor-head {
  padding: 14px 16px 8px;
  flex-shrink: 0;
  min-width: 0;
}
.rb-editor-title {
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rb-editor-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rb-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 12px 10px;
  flex-shrink: 0;
}
.rb-step {
  border: 1px solid var(--border-dark);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.rb-step.active {
  color: var(--ink);
  background: transparent;
  border-color: var(--gold);
}

.rb-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: none;
  flex-direction: column;
  padding: 0 12px 12px;
  overflow-x: hidden;
  overflow-y: auto;
}
.rb-panel.active { display: flex; }

.rb-plot-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed color-mix(in srgb, var(--gold) 55%, var(--border-dark));
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  margin-bottom: 10px;
  flex-shrink: 0;
}
.rb-plot-banner strong { display: block; font-size: 13px; }
.rb-plot-banner p {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}
.rb-shell.is-plotting .rb-plot-banner {
  border-style: solid;
  animation: rb-pulse 1.8s ease-in-out infinite;
}
@keyframes rb-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 0%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--gold) 16%, transparent); }
}

.rb-stops-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  flex-shrink: 0;
}
.rb-stops-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-inline-end: 2px;
  overscroll-behavior: contain;
}
.rb-stop {
  display: grid;
  grid-template-columns: 18px 28px minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border-dark);
  background: var(--bg-card);
  margin-bottom: 8px;
  transition: border-color var(--dur-fast), transform var(--dur-fast);
}
.rb-stop.is-dragging { opacity: 0.55; }
.rb-stop.drag-over { border-color: var(--gold); transform: translateY(1px); }
.rb-stop-handle {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  padding: 0;
  font-size: 12px;
  letter-spacing: -2px;
}
.rb-stop-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.rb-stop-main {
  border: 0;
  background: transparent;
  text-align: start;
  color: inherit;
  padding: 0;
  cursor: pointer;
  min-width: 0;
}
.rb-stop-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-stop-addr {
  display: block;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-stop-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  border-radius: 8px;
}
.rb-stop-remove:hover { color: var(--coral); background: color-mix(in srgb, var(--coral) 12%, transparent); }

.rb-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-dark);
  margin-top: 8px;
  flex-shrink: 0;
}
.rb-editor-actions .btn-gold { margin-inline-start: auto; }
#btnSaveStops.is-dirty {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 45%, transparent);
}

.rb-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}
.rb-form .btn { align-self: flex-start; margin-top: auto; }
.rb-check-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rb-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-dark);
  cursor: pointer;
}
.rb-check:hover { border-color: color-mix(in srgb, var(--gold) 50%, var(--border-dark)); }
.rb-check input { margin-top: 3px; }
.rb-check strong { display: block; font-size: 13px; }
.rb-check small { color: var(--muted); font-size: 11px; }

.rb-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.rb-empty-soft { padding: 18px 8px; font-size: 12px; }
.rb-modal-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.modal.modal-compact { max-width: 420px; }
.rb-coords {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rb-stops-footer {
  flex-shrink: 0;
  margin-top: 8px;
}
.rb-optimize-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border-dark);
  flex-shrink: 0;
}
.rb-optimize-goal {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.rb-goal-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-dark);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.rb-goal-option:has(input:checked) {
  border-color: var(--gold);
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, transparent);
}
.rb-goal-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.rb-optimize-pins {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
}
.rb-check-inline {
  font-size: 12px;
}

.rb-map-pane {
  position: relative;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border-dark);
  background: #0d1424;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 8%, transparent);
}
.rb-map { position: absolute; inset: 0; }
.rb-map-chrome {
  position: absolute;
  inset: 14px 14px auto 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 500;
}
.rb-map-chip {
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-card) 92%, transparent);
  border: 1px solid var(--border-dark);
  backdrop-filter: blur(8px);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  max-width: min(420px, 70%);
}
.rb-map-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
  border: 1px solid var(--border-dark);
  font-size: 11px;
  color: var(--muted);
}
.rb-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  margin-inline-end: 4px;
}
.rb-marker-wrap { background: transparent !important; border: 0 !important; }
.rb-marker {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  background: linear-gradient(160deg, #F6C273, #D99F55);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(0,0,0,.35);
  border: 2px solid #fff;
}
.rb-marker span {
  transform: rotate(45deg);
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}
.rb-shell.is-plotting .rb-map {
  cursor: crosshair;
}
.rb-shell.is-plotting .rb-map-chip {
  border-color: var(--gold);
  color: var(--gold);
}

.rb-map-pane.is-route-loading {
  animation: rb-map-glow 1.6s ease-in-out infinite;
}
.rb-map-pane.is-route-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 450;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 0%,
    color-mix(in srgb, var(--gold) 14%, transparent) 45%,
    color-mix(in srgb, var(--gold) 22%, transparent) 50%,
    color-mix(in srgb, var(--gold) 14%, transparent) 55%,
    transparent 100%
  );
  background-size: 220% 100%;
  animation: rb-route-scan 2s ease-in-out infinite;
  opacity: 0.85;
}
.rb-map-pane.is-route-loading .rb-map-chip.is-tracing {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 35%, transparent);
  animation: rb-chip-pulse 1.4s ease-in-out infinite;
}
.rb-map-pane.is-route-loading .rb-map-chip.is-tracing::after {
  content: '…';
  display: inline-block;
  margin-inline-start: 2px;
  animation: rb-trace-dots 1.2s ease-in-out infinite;
}
.rb-route-line.is-hidden {
  opacity: 0 !important;
  pointer-events: none;
}
.rb-route-line.is-fallback {
  opacity: 0.55 !important;
  stroke-dasharray: 8 10;
}

@keyframes rb-map-glow {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--gold) 10%, transparent),
      inset 0 0 28px color-mix(in srgb, var(--gold) 4%, transparent);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--gold) 28%, transparent),
      inset 0 0 42px color-mix(in srgb, var(--gold) 10%, transparent);
  }
}
@keyframes rb-route-scan {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}
@keyframes rb-chip-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 20%, transparent); }
  50% { box-shadow: 0 0 18px 2px color-mix(in srgb, var(--gold) 35%, transparent); }
}
@keyframes rb-trace-dots {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-1px); }
}

@media (max-width: 1100px) {
  .page-content:has(.rb-shell) {
    overflow: hidden;
  }

  .rb-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    gap: 0;
  }

  /* Map on top — fixed height, always visible */
  .rb-map-pane {
    order: -1;
    flex: 0 0 30vh;
    min-height: 160px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
  }

  /* Rail below — scrollable bottom sheet */
  .rb-rail {
    order: 1;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 12px calc(20px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }

  .rb-rail:has(#rbEditor:not([hidden])) .rb-card-routes {
    display: none;
  }

  .rb-kicker {
    display: none;
  }

  /* Cards grow with content; route list card can scroll inside. */
  .rb-rail .rb-card {
    flex: 0 0 auto;
    max-height: none;
    border-radius: 14px;
  }

  .rb-rail:has(#rbEditor[hidden]) .rb-card-routes {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .rb-rail .rb-card-editor {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .rb-card-editor .rb-panel.active {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  .rb-card-editor .rb-stops-list,
  .rb-card-editor .rb-check-list {
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
  }

  .rb-stops-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-top: 10px;
    padding: 10px 0 calc(8px + env(safe-area-inset-bottom, 0px));
    background:
      linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--bg-card) 88%, transparent) 12%, var(--bg-card) 28%),
      var(--bg-card);
    border-top: 1px solid var(--border-dark);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.35);
  }

  .rb-stops-footer .rb-optimize-bar {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
  }

  .rb-stops-footer .rb-editor-actions {
    border-top: 0;
    margin-top: 4px;
    padding-top: 8px;
  }
}

.scroll-y { overflow-y: auto; flex: 1; padding: 10px 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 1200px) {
  .kpi-rail { grid-template-columns: repeat(3, 1fr); }
  .reports-kpi { grid-template-columns: repeat(3, 1fr); }
  .right-rail { width: 320px; }
}

/* Login page — body flex centers shell in LTR + RTL (grid place-items breaks in RTL) */
body.login-page {
  height: auto;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(24px, 4vw, 40px) clamp(16px, 4vw, 24px);
  box-sizing: border-box;
  margin: 0;
}
body.login-page::before {
  opacity: 0.28;
  background:
    linear-gradient(160deg, rgba(11, 18, 32, 0.72) 0%, rgba(18, 26, 44, 0.55) 45%, rgba(11, 18, 32, 0.85) 100%),
    radial-gradient(ellipse at 20% 10%, rgba(244, 184, 96, 0.18), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(54, 88, 160, 0.22), transparent 50%),
    url('/assets/background.jpg') center/cover no-repeat;
}
body.login-page::after {
  content: "";
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: min(42vh, 360px);
  background: url('/assets/skyline.svg') center bottom / cover no-repeat;
  opacity: 0.22;
  pointer-events: none;
  z-index: 0;
  mask-image: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
}
.login-shell {
  position: relative; z-index: 1;
  width: 100%;
  max-width: 520px;
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
}
.login-card {
  width: 100%; max-width: 520px; padding: 28px 28px 24px;
  background:
    linear-gradient(180deg, rgba(244,184,96,0.08) 0%, transparent 42%),
    rgba(18, 26, 44, 0.82);
  border: 1px solid rgba(244, 184, 96, 0.28);
  border-radius: 20px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03) inset,
    0 28px 80px rgba(0,0,0,0.45),
    0 0 60px rgba(244, 184, 96, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand h1 { margin: 12px 0 4px; font-size: 1.5rem; font-weight: 800; }
.login-subtitle { color: var(--muted); margin: 0; font-size: 13px; letter-spacing: 0.02em; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-top: 10px; }
.field-input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border-dark); background: rgba(26, 36, 64, 0.9);
  color: var(--ink); font-size: 14px; font-family: inherit;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.field-input:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(244, 184, 96, 0.15);
}
.remember-row {
  display: flex; align-items: center; gap: 8px; margin: 12px 0 16px;
  font-size: 13px; color: var(--ink-soft); cursor: pointer;
}
.login-btn {
  width: 100%; padding: 13px; border-radius: 12px; font-size: 14px; font-weight: 700;
  cursor: pointer; letter-spacing: 0.02em;
}
.login-error { color: var(--coral); font-size: 13px; margin-bottom: 8px; }
.login-error ul { margin: 0; padding-inline-start: 1.1em; }
.login-error.validation-summary-valid { display: none; }
.login-success {
  color: var(--mint); font-size: 13px; margin-bottom: 12px; padding: 10px 12px;
  border-radius: 10px; background: rgba(90, 200, 160, 0.12);
  border: 1px solid rgba(90, 200, 160, 0.3); text-align: center;
}
.login-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin: 14px 0 18px;
}
.login-row .remember-row { margin: 0; }
.account-link {
  color: var(--gold); font-size: 13px; font-weight: 600;
  text-decoration: none; transition: color var(--dur-fast);
}
.account-link:hover { text-decoration: underline; filter: brightness(1.1); }
.public-support {
  text-align: center;
  margin: 18px 0 0;
  font-size: 13px;
}
.public-support a {
  color: var(--gold);
  font-weight: 600;
  text-decoration: none;
}
.public-support a:hover { text-decoration: underline; }

/* Register page — wider card, top-aligned scroll layout, desert-night links */
body.register-page {
  /* column flex: align-items = horizontal, justify = vertical */
  align-items: center;
  justify-content: flex-start;
  padding-top: clamp(28px, 5vw, 48px);
  padding-bottom: clamp(40px, 6vw, 64px);
}
body.register-page .login-shell {
  max-width: 560px;
}
body.register-page .login-card.register-card {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: clamp(22px, 5vw, 32px);
  box-sizing: border-box;
}
body.legal-page {
  align-items: center;
  justify-content: flex-start;
  padding-top: clamp(28px, 5vw, 48px);
  padding-bottom: clamp(40px, 6vw, 64px);
}
body.legal-page .legal-shell {
  max-width: 720px;
}
body.legal-page .legal-card {
  max-width: none;
  text-align: start;
}
body.legal-page .legal-doc {
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.65;
}
body.legal-page .legal-doc h2 {
  color: var(--ink);
  font-size: 1.05rem;
  margin: 22px 0 8px;
}
body.legal-page .legal-doc p,
body.legal-page .legal-doc ul {
  margin: 0 0 12px;
}
body.legal-page .legal-doc ul {
  padding-inline-start: 1.2em;
}
body.legal-page .register-footer {
  margin-top: 24px;
  text-align: center;
}
body.register-page .login-form,
body.register-page .register-section {
  width: 100%;
}
body.register-page .login-form {
  gap: 22px;
}
body.register-page .register-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 22px;
  padding-top: 20px;
}
body.register-page .register-section-first {
  margin-top: 0;
  padding-top: 0;
}
body.register-page .field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
body.register-page .field-label {
  margin: 0;
}
body.register-page .field-input {
  width: 100%;
  max-width: 100%;
}
body.register-page select.field-input {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-inline-end: 2.4rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23C49A5B' d='M1 1.5 L6 6.5 L11 1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
}
html[dir="rtl"] body.register-page select.field-input {
  background-position: left 14px center;
}
body.register-page select.field-input option {
  background: #1a2440;
  color: var(--ink);
}
body.register-page .register-section-title {
  margin: 0 0 2px;
}
.register-plan-chip {
  margin: 0 0 22px;
  padding: 14px 18px;
  border-radius: 14px;
  text-align: center;
  background: rgba(244, 184, 96, 0.1);
  border: 1px solid rgba(244, 184, 96, 0.22);
  color: var(--ink-soft);
}
.register-plan-chip strong { color: var(--ink); font-weight: 700; }
.register-plan-chip .register-plan-price { color: var(--gold); font-weight: 600; }
.register-plan-chip .register-plan-note {
  font-size: 12px;
  margin-top: 6px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.register-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(201, 154, 91, 0.15);
}
.register-section-first {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.register-lang-row {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.register-section-title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.register-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 520px) {
  body.register-page {
    padding-inline: 14px;
  }
  body.register-page .register-grid-2 { grid-template-columns: 1fr; gap: 16px; }
}
.register-terms {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 6px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
  cursor: pointer;
}
body.register-page .login-btn {
  margin-top: 4px;
}
.register-terms input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--gold);
}
.login-page a:not(.btn):not(.account-link) {
  color: var(--gold);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(244, 184, 96, 0.35);
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.login-page a:not(.btn):not(.account-link):hover {
  color: var(--sand-1);
  border-bottom-color: var(--gold);
}
.register-footer {
  text-align: center;
  margin-top: 16px;
  margin-bottom: 2px;
  font-size: 13px;
}

.dev-reset-box {
  margin-top: 20px; padding: 16px; border-radius: 12px;
  background: var(--bg-inset); border: 1px dashed var(--border-dark-hover);
  display: flex; flex-direction: column; gap: 12px;
}
.dev-reset-label {
  margin: 0; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); text-align: center;
}
.demo-hint {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-dark);
  font-size: 12px; color: var(--muted);
}
.demo-hint-title { font-weight: 600; color: var(--ink-soft); margin: 0 0 10px; text-align: center; }
.demo-accounts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 520px) {
  .demo-accounts { grid-template-columns: 1fr; }
}
.demo-account {
  min-width: 0; padding: 8px 10px; border-radius: 10px;
  background: var(--bg-inset); border: 1px solid var(--border-dark);
  text-align: start;
}
.demo-account-label {
  display: block; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px;
}
.demo-copy {
  display: block; width: 100%; margin: 0 0 4px; padding: 7px 8px;
  border-radius: 6px; border: 1px solid transparent;
  background: rgba(0,0,0,0.2); color: var(--gold);
  font-family: var(--mono); font-size: 11px; line-height: 1.3;
  cursor: pointer; user-select: all; text-align: start;
  appearance: none; -webkit-appearance: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.demo-copy:last-child { margin-bottom: 0; }
.demo-copy:hover { border-color: var(--border-dark-hover); background: rgba(244, 184, 96, 0.08); }
.demo-copy.copied { border-color: var(--mint); color: var(--mint); }
.demo-hint code {
  background: var(--bg-inset); padding: 2px 6px; border-radius: 4px;
  color: var(--gold); font-family: var(--mono); font-size: 11px;
}

/* Modals */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55); place-items: center; padding: 24px;
}
.modal-overlay.open { display: grid; }
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border-dark);
  border-radius: 14px; padding: 24px;
}
.modal-wide { max-width: 640px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.two-col { grid-template-columns: 1fr 1fr; }
.form-grid.three-col { grid-template-columns: 1fr 1fr 1fr; }
.day-picker-wrap { display: flex; flex-direction: column; gap: 10px; }
.day-picker {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.day-chip {
  position: relative;
  margin: 0;
  cursor: pointer;
  user-select: none;
}
.day-chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.day-chip-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid var(--border-dark);
  background: var(--bg-inset);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.day-chip:hover .day-chip-label {
  border-color: var(--border-dark-hover);
  color: var(--ink);
}
.day-chip input:checked + .day-chip-label {
  background: transparent;
  border-color: var(--gold);
  color: var(--ink);
  box-shadow: none;
}
.day-chip input:focus-visible + .day-chip-label {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.day-picker-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
@media (max-width: 720px) {
  .day-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .day-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.form-field label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--border-dark); background: var(--bg-inset); color: var(--ink);
}
.form-field input[type="checkbox"],
.form-field input[type="radio"] {
  width: auto;
  min-width: 1rem;
  height: auto;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  flex-shrink: 0;
  accent-color: var(--gold);
}
.form-field label:has(> input[type="checkbox"]),
.form-field label:has(> input[type="radio"]) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 0;
  cursor: pointer;
}
.role-fields { display: none; padding-top: 8px; border-top: 1px solid var(--border-dark); margin-top: 8px; }
.role-fields.active { display: block; }

/* Profile page */
.profile-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px; align-items: start;
}
.profile-card { display: flex; flex-direction: column; }
.profile-form { padding: 16px; }
.profile-form .panel-header { text-transform: none; }
.field-readonly { opacity: 0.7; cursor: not-allowed; }
.form-error-box { color: var(--coral); font-size: 12px; }
.profile-banner {
  padding: 12px 14px; border-radius: 12px; font-size: 13px; font-weight: 600;
}
.profile-banner-success {
  color: var(--mint); background: rgba(90, 200, 160, 0.12);
  border: 1px solid rgba(90, 200, 160, 0.3);
}
.sidebar-user .user-avatar, .sidebar-user .user-meta { text-decoration: none; color: inherit; }
.sidebar-user .user-avatar { cursor: pointer; transition: border-color var(--dur-fast); }
.sidebar-user .user-avatar:hover { border-color: var(--gold); }
.sidebar-user .user-meta { cursor: pointer; }
.sidebar-user .user-meta:hover .name { color: var(--gold); }

/* RTL — html[dir=rtl] mirrors flex rows; logical props handle edges.
   Do not use flex-direction:row-reverse here (it cancels the natural flip). */
html[dir="rtl"] body { font-family: var(--arabic); }
html[dir="rtl"] .nav-section-label { letter-spacing: 0; }
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select,
html[dir="rtl"] .form-field label,
html[dir="rtl"] .page-title,
html[dir="rtl"] .search-bar { text-align: start; }

/* Global search dropdown */
.search-bar-wrap { position: relative; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  max-height: 360px; overflow-y: auto; padding: 8px;
  background: var(--bg-card); border: 1px solid var(--border-dark);
  border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.search-section { margin-bottom: 8px; }
.search-section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding: 4px 8px;
}
.search-hit {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: 8px; text-decoration: none; color: inherit;
}
.search-hit:hover { background: var(--nav-hover-bg); }
.search-hit-label { font-weight: 600; }
.search-hit-sub { font-size: 11px; color: var(--muted); }
.search-empty { padding: 12px; color: var(--muted); text-align: center; }

tr.row-highlight,
.route-list-item.row-highlight {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--gold) 12%, transparent);
}

.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.45);
}
.sidebar-backdrop.open { display: block; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    inset-inline-end: auto;
    z-index: 30;
    transform: translateX(-105%);
    transition: transform var(--dur-base);
    width: min(280px, 86vw);
  }
  html[dir="rtl"] .sidebar {
    transform: translateX(105%);
  }
  .sidebar.mobile-open,
  html[dir="rtl"] .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar.collapsed { width: min(280px, 86vw); }
  .main-area { width: 100%; }
  .flex-row { flex-direction: column; }
  .right-rail, .detail-panel, .routes-list { width: 100% !important; max-width: none; }
  .composer-panel, .map-overlay.bl { width: min(100%, 360px) !important; }
  .reports-grid { grid-template-columns: 1fr; }
  .reports-kpi { grid-template-columns: repeat(2, 1fr); }
  .dashboard-page {
    overflow: auto;
    height: auto;
  }
  .dashboard-main {
    flex-direction: column;
    flex: none;
  }
  .dashboard-page .map-card,
  .dashboard-page #fleetMap {
    min-height: 360px;
    height: 50vh;
  }
}

@media (max-width: 768px) {
  .kpi-rail { grid-template-columns: repeat(2, 1fr); }
  .form-grid.two-col, .form-grid.three-col, .reports-grid { grid-template-columns: 1fr; }
  .topbar .search-bar-wrap { display: none; }
  .topbar.search-open .search-bar-wrap {
    display: block; position: absolute;
    inset-inline: 12px; top: calc(var(--topbar-h) - 4px);
  }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .page-title { font-size: 1rem; }
  .map-overlay.tl, .map-overlay.tr, .map-overlay.bl, .map-overlay.br {
    position: static; margin: 8px; width: auto !important;
  }
  .map-card { display: flex; flex-direction: column; }
  .data-table { min-width: 640px; }
  .card:has(.data-table) { overflow-x: auto; }
}

@media (max-width: 480px) {
  .kpi-rail { grid-template-columns: 1fr; }
  .modal-overlay { padding: 0; }
  .modal, .modal-wide {
    max-width: 100%; max-height: 100vh; height: 100%;
    border-radius: 0; padding: 16px;
  }
  .btn, .icon-btn, .day-chip-label { min-height: 44px; }
  .nav-item { min-height: 44px; }
  .topbar-spacer { display: none; }
}


/* ---------------------------------------------------------------------------
   Leaflet ships its own font stack ("Helvetica Neue", Arial, ...) on
   .leaflet-container, which loads after this file and therefore wins. Re-assert
   the brand face with higher specificity so map labels, controls and our own
   .bus-badge markers match the rest of the product (and switch to Kufi in RTL).
   --------------------------------------------------------------------------- */
body .leaflet-container,
body .leaflet-container .leaflet-control,
body .leaflet-control-attribution,
body .leaflet-popup-content,
body .leaflet-tooltip,
body .leaflet-control-zoom-in,
body .leaflet-control-zoom-out {
  font-family: inherit;
}

/* ---------------------------------------------------------------------------
   SuperAdmin / platform forms & in-content links
   --------------------------------------------------------------------------- */
/* Use :where() so gold in-content links don't override chip/pager/filter active borders. */
.page-content :where(a:not(.btn):not(.nav-item):not(.user-avatar):not(.user-meta):not(.list-pager-size):not(.sa-filter-clear)) {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.page-content :where(a:not(.btn):not(.nav-item):not(.user-avatar):not(.user-meta):not(.list-pager-size):not(.sa-filter-clear)):hover {
  color: var(--sand-1);
  border-bottom-color: rgba(244, 184, 96, 0.55);
}
/* Filter / segment controls: keep a full 1px box border — never zero out border-bottom
   (that was clipping the selected gold outline along the bottom edge). */
.page-content .sa-stats-ranges a,
.page-content .sa-stats-ranges a:visited,
.page-content .sa-stats-ranges a:hover,
.page-content .seg-ctrl a,
.page-content .seg-ctrl a:visited,
.page-content .seg-ctrl a:hover {
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom-style: solid;
  text-decoration: none;
}
.page-content .sa-stats-ranges a.active,
.page-content .sa-stats-ranges a.active:visited,
.page-content .sa-stats-ranges a.active:hover,
.page-content .seg-ctrl a.active,
.page-content .seg-ctrl a.active:visited,
.page-content .seg-ctrl a.active:hover {
  color: var(--ink);
  border: 1px solid var(--gold);
  background: transparent;
}
.page-content a.btn {
  text-decoration: none;
  border-bottom: none;
}
.data-table a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
}
.data-table a:hover {
  color: var(--sand-1);
}

.sa-form-shell {
  max-width: 920px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sa-form-intro {
  padding: 18px 22px;
}
.sa-form-intro-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.sa-form-intro-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 58ch;
  line-height: 1.5;
}
.sa-form {
  max-width: none;
  padding: 8px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sa-form-errors.validation-summary-valid {
  display: none;
}
.sa-form-errors.validation-summary-errors {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(227, 111, 76, 0.35);
  background: rgba(227, 111, 76, 0.1);
  color: var(--coral);
}
.sa-form-errors.validation-summary-errors ul {
  margin: 0;
  padding-inline-start: 1.1em;
}
.sa-form-block {
  padding: 18px 0;
  border-bottom: 1px solid var(--border-dark);
}
.sa-form-block:last-of-type {
  border-bottom: none;
}
.sa-form-block-head {
  margin-bottom: 14px;
}
.sa-form-block-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sa-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
  align-items: start;
}
.sa-form-grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.sa-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.sa-field.span-2 { grid-column: 1 / -1; }
.sa-field-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sa-field-label-inline {
  flex-direction: row;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}
.sa-field-label > span:first-child {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
}
.sa-field-label > span[lang="ar"],
.sa-field-label > span:nth-child(2) {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.sa-field-hint-inline {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}
.sa-field .search-bar,
.sa-field select.search-bar,
.sa-field textarea.search-bar {
  width: 100%;
  min-width: 0;
  height: 42px;
  border-radius: 11px;
  box-sizing: border-box;
  font: inherit;
  font-size: 13px;
  line-height: 1.25;
  color: var(--ink);
  vertical-align: middle;
}
.sa-field input.search-bar {
  display: block;
  padding-block: 0;
  padding-inline: 12px;
}
.sa-field input[type="date"].search-bar,
.sa-field input[type="datetime-local"].search-bar {
  display: flex;
  align-items: center;
  line-height: normal;
}
.sa-field input[type="date"].search-bar::-webkit-datetime-edit,
.sa-field input[type="date"].search-bar::-webkit-datetime-edit-fields-wrapper,
.sa-field input[type="datetime-local"].search-bar::-webkit-datetime-edit,
.sa-field input[type="datetime-local"].search-bar::-webkit-datetime-edit-fields-wrapper {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0;
  line-height: 1.25;
}
.sa-field input[type="date"].search-bar::-webkit-calendar-picker-indicator,
.sa-field input[type="datetime-local"].search-bar::-webkit-calendar-picker-indicator {
  align-self: center;
  margin-block: 0;
}
.sa-field select.search-bar {
  display: block;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  background-color: var(--bg-inset);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-block: 0;
  padding-inline: 12px 30px;
  /* Keep selected text optically centered in the control */
  line-height: 40px;
  text-overflow: ellipsis;
}
.sa-field select.search-bar option {
  line-height: 1.4;
  padding: 8px;
}
.sa-field .search-bar::placeholder,
.sa-field textarea.search-bar::placeholder {
  color: var(--muted);
  opacity: 0.75;
}
.sa-field .search-bar:focus,
.sa-field select.search-bar:focus,
.sa-field textarea.search-bar:focus {
  outline: none;
  border-color: var(--border-dark-hover);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.sa-field textarea.search-bar {
  display: block;
  height: auto;
  min-height: 92px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.45;
}
html[dir="rtl"] .sa-field select.search-bar {
  background-position: 16px calc(50% - 2px), 11px calc(50% - 2px);
  padding-inline-end: 12px;
  padding-inline-start: 30px;
}
.sa-field-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
/* Safari contact/autofill person icon inside email fields */
.sa-field input[type="email"].search-bar::-webkit-contacts-auto-fill-button,
.sa-field input[type="email"].search-bar:not(:-webkit-autofill)::-webkit-contacts-auto-fill-button {
  background-color: #fff;
}
html.light .sa-field input[type="email"].search-bar::-webkit-contacts-auto-fill-button,
html.light .sa-field input[type="email"].search-bar:not(:-webkit-autofill)::-webkit-contacts-auto-fill-button {
  background-color: #1B2236;
}
.sa-settings-shell {
  max-width: 760px;
}
.sa-settings-intro-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.sa-settings-intro-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--gold-soft);
  border: 1px solid rgba(244, 184, 96, 0.28);
  color: var(--gold);
}
.sa-settings-intro-icon svg {
  width: 22px;
  height: 22px;
}
.sa-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.sa-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  min-height: 44px;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px solid var(--border-dark);
  background: var(--bg-inset);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.sa-check:hover {
  border-color: var(--border-dark-hover);
  background: var(--gold-soft);
  color: var(--ink);
}
.sa-check.is-on {
  border-color: var(--gold);
  background: transparent;
  color: var(--ink);
}
.sa-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
  flex-shrink: 0;
  margin: 0;
}
.sa-form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--border-dark);
}
.sa-form-block-hint {
  margin: 4px 0 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.sa-form-block-subhead {
  margin: 18px 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Announcement compose */
.sa-announce-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1120px;
}
.sa-announce-intro-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.sa-announce-intro-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--gold-soft);
  border: 1px solid rgba(244, 184, 96, 0.28);
  color: var(--gold);
}
.sa-announce-intro-icon svg {
  width: 22px;
  height: 22px;
}
.sa-announce-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.75fr);
  gap: 14px;
  align-items: start;
}
.sa-announce-layout .sa-form {
  max-width: none;
}
.sa-announce-body {
  min-height: 120px !important;
}
.sa-announce-audience-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.sa-school-pick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 4px;
  max-height: 240px;
  overflow: auto;
  padding: 2px;
}
.sa-school-chip span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sa-school-chip strong {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sa-school-chip small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.sa-announce-preview {
  padding: 16px 18px 18px;
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(244, 184, 96, 0.1), transparent 70%),
    var(--surface, transparent);
}
.sa-announce-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sa-announce-preview-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sa-announce-preview-card {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border-dark);
  background: var(--bg-inset);
  min-height: 160px;
}
.sa-announce-preview-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.sa-announce-preview-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
.sa-announce-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
@media (max-width: 960px) {
  .sa-announce-layout {
    grid-template-columns: 1fr;
  }
  .sa-announce-preview {
    position: static;
  }
  .sa-school-pick,
  .sa-announce-audience-mode {
    grid-template-columns: 1fr;
  }
}
  border-top: 1px solid var(--border-dark);
}
@media (max-width: 820px) {
  .sa-form-grid,
  .sa-form-grid.cols-4,
  .sa-check-grid {
    grid-template-columns: 1fr;
  }
  .sa-form,
  .sa-form-intro {
    padding-inline: 16px;
  }
}

.sa-list-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sa-list-title {
  margin: 0;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.sa-list-sub {
  margin: 4px 0 0;
  max-width: 52ch;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.sa-filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.sa-list-card {
  min-height: 280px;
}
.sa-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--gold-soft);
  border: 1px solid rgba(244, 184, 96, 0.22);
  color: var(--ink);
}
.sa-pill-paid {
  background: rgba(111, 207, 151, 0.16);
  border-color: rgba(111, 207, 151, 0.35);
  color: var(--mint);
}
.sa-pill-unpaid {
  background: rgba(227, 111, 76, 0.14);
  border-color: rgba(227, 111, 76, 0.35);
  color: var(--coral);
}

.sa-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 56px 28px;
  min-height: 260px;
  position: relative;
  background:
    radial-gradient(ellipse 60% 50% at 50% 28%, rgba(244, 184, 96, 0.08), transparent 70%);
}
.sa-empty-visual {
  position: relative;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
}
.sa-empty-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(244, 184, 96, 0.18);
  pointer-events: none;
}
.sa-empty-ring-outer {
  inset: 0;
  animation: sa-empty-pulse 3.2s ease-in-out infinite;
}
.sa-empty-ring-inner {
  inset: 12px;
  border-color: rgba(244, 184, 96, 0.28);
}
.sa-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  border: 1px solid rgba(244, 184, 96, 0.32);
  color: var(--gold);
  box-shadow: 0 8px 24px rgba(244, 184, 96, 0.12);
  z-index: 1;
}
.sa-empty-icon svg {
  width: 26px;
  height: 26px;
}
.sa-empty-title {
  margin: 0;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.sa-empty-copy {
  margin: 0 0 10px;
  max-width: 44ch;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}
.card > .sa-empty {
  border-top: none;
  border-radius: inherit;
}
.sa-empty.sa-empty-compact {
  min-height: 150px;
  padding: 28px 16px;
  background: transparent;
}
.sa-empty.sa-empty-compact .sa-empty-visual {
  width: 72px;
  height: 72px;
  margin-bottom: 0;
}
.sa-empty.sa-empty-compact .sa-empty-ring-inner {
  inset: 10px;
}
.sa-empty.sa-empty-compact .sa-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: none;
}
.sa-empty.sa-empty-compact .sa-empty-icon svg {
  width: 20px;
  height: 20px;
}
.sa-empty.sa-empty-compact .sa-empty-title {
  font-size: 14px;
}
.sa-empty.sa-empty-compact .sa-empty-copy {
  font-size: 12px;
  margin-bottom: 0;
}

@keyframes sa-empty-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.06); opacity: 1; }
}

/* SuperAdmin live map — school campus pins */
.sa-live-map-card {
  padding: 0;
  overflow: hidden;
  height: min(72vh, 720px);
  min-height: 420px;
}
.sa-live-map {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: var(--surface-2, #1a2030);
}
.sa-school-pin-wrap {
  background: transparent !important;
  border: 0 !important;
}
.sa-school-pin {
  position: relative;
  width: 40px;
  height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}
.sa-school-pin-head {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, #F8D08A, #E0A65A 55%, #C8883A);
  border: 2.5px solid #fff;
  z-index: 2;
  position: relative;
}
.sa-school-pin-point {
  width: 14px;
  height: 14px;
  margin-top: -8px;
  background: linear-gradient(160deg, #E0A65A, #C8883A);
  transform: rotate(45deg);
  border-radius: 0 0 4px 0;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  z-index: 1;
}
.sa-school-pin-pulse {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 18px;
  height: 6px;
  margin-left: -9px;
  border-radius: 50%;
  background: rgba(27, 34, 54, 0.28);
  z-index: 0;
}
.sa-school-pin.is-active .sa-school-pin-head {
  background: linear-gradient(160deg, #7DDEB0, #3CB87A 55%, #2A9A64);
  color: #0d2a1c;
}
.sa-school-pin.is-active .sa-school-pin-point {
  background: linear-gradient(160deg, #3CB87A, #2A9A64);
}
.sa-school-pin.is-trial .sa-school-pin-head {
  background: linear-gradient(160deg, #F8D08A, #E0A65A 55%, #C8883A);
}
.sa-school-pin.is-suspended .sa-school-pin-head {
  background: linear-gradient(160deg, #F2A3A3, #D96B6B 55%, #C04E4E);
  color: #3a1212;
}
.sa-school-pin.is-suspended .sa-school-pin-point {
  background: linear-gradient(160deg, #D96B6B, #C04E4E);
}
.leaflet-popup.sa-school-popup-wrap .leaflet-popup-content-wrapper {
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(244, 184, 96, 0.22);
}
.leaflet-popup.sa-school-popup-wrap .leaflet-popup-content {
  margin: 12px 14px;
  min-width: 160px;
}
.sa-school-popup-code {
  margin-bottom: 4px;
}
.sa-school-popup-code code {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--gold-soft, rgba(244, 184, 96, 0.16));
}
.sa-school-popup-name {
  display: block;
  font-size: 14px;
  letter-spacing: -0.02em;
}
.sa-school-popup-ar {
  font-size: 12px;
  color: var(--muted, #8b93a7);
  margin-top: 2px;
}
.sa-school-popup-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted, #8b93a7);
}
.sa-school-popup-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 650;
  color: var(--gold, #e0a65a) !important;
  text-decoration: none !important;
}
.sa-school-popup-link:hover {
  text-decoration: underline !important;
}

.sa-audit-explain {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
}
.sa-audit-explain-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--gold-soft);
  border: 1px solid rgba(244, 184, 96, 0.28);
  color: var(--gold);
}
.sa-audit-explain-icon svg {
  width: 20px;
  height: 20px;
}
.sa-audit-explain h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.sa-audit-explain p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 72ch;
}
.sa-audit-triggers {
  margin: 12px 0 0;
  padding-inline-start: 18px;
  display: grid;
  gap: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.sa-audit-when {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}
.sa-audit-action {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  background: var(--gold-soft);
  border: 1px solid rgba(244, 184, 96, 0.22);
  color: var(--ink);
  white-space: nowrap;
}
.sa-stats-filters {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}
.sa-filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.sa-filter-clear {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted) !important;
  text-decoration: none !important;
  border-bottom: none !important;
  white-space: nowrap;
  padding: 4px 2px;
}
.sa-filter-clear:hover {
  color: var(--ink) !important;
  border-bottom: none !important;
}
.page-content a.sa-filter-clear,
.page-content a.sa-filter-clear:hover {
  border-bottom: none;
}
.sa-stats-ranges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  overflow: visible;
}
/* Wrapping status filters must not use the single-row capsule — it clips the bottom row. */
.sa-stats-ranges.seg-ctrl {
  border-radius: 12px;
  padding: 6px;
  gap: 6px;
  background: var(--bg-inset);
  border: 1px solid var(--border-dark);
  overflow: visible;
}
.sa-stats-ranges a {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  line-height: 1.3;
  box-sizing: border-box;
}
.sa-stats-ranges a.active {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--ink);
}
.page-content .sa-stats-ranges a.active,
.page-content .sa-stats-ranges a.active:visited,
.page-content .sa-stats-ranges a.active:hover {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--ink);
}
.sa-stats-filter-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin: 0;
}
.sa-stats-filter-row .sa-field .search-bar {
  min-width: 0;
}
.sa-stats-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}
.sa-stats-ccy {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.sa-stats-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}
.sa-stats-panel-wide {
  grid-column: 1 / -1;
}
@media (max-width: 1100px) {
  .sa-stats-filter-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sa-stats-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sa-stats-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 640px) {
  .sa-stats-filter-row,
  .sa-stats-kpis {
    grid-template-columns: 1fr;
  }
}

/* SuperAdmin invoices / tickets filters */
.sa-invoice-filters,
.sa-ticket-filters {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

/* Support ticket conversation thread */
.ticket-thread-card {
  padding: 18px;
  margin-bottom: 16px;
}
.ticket-thread-title {
  margin: 0 0 14px;
  font-size: 1rem;
}
.ticket-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.ticket-msg {
  max-width: min(78%, 520px);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
}
.ticket-msg--school {
  align-self: flex-start;
  margin-inline-end: auto;
  background: rgba(90, 140, 220, 0.14);
  border-color: rgba(90, 140, 220, 0.28);
  border-start-start-radius: 4px;
}
.ticket-msg--platform {
  align-self: flex-end;
  margin-inline-start: auto;
  background: rgba(244, 184, 96, 0.14);
  border-color: rgba(244, 184, 96, 0.32);
  border-start-end-radius: 4px;
}
.ticket-msg--internal {
  background: rgba(244, 184, 96, 0.08);
  border-style: dashed;
  border-color: rgba(244, 184, 96, 0.45);
}
.ticket-msg-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.ticket-msg-who {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}
.ticket-msg--school .ticket-msg-who { color: #9eb7e8; }
.ticket-msg--platform .ticket-msg-who { color: var(--gold); }
.ticket-msg-body {
  white-space: pre-wrap;
  line-height: 1.55;
  color: var(--ink);
  font-size: 14px;
}
.ticket-reply {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border-dark);
}
/* The internal toggle now defaults to off, so the composer has to make an armed private
   note obvious — otherwise it looks identical to a reply the school will receive. */
.ticket-internal-toggle {
  color: var(--muted);
  font-size: 13px;
  transition: color var(--dur-fast) ease;
}
.ticket-internal-toggle:has(input:checked) {
  color: var(--crimson);
  font-weight: 700;
}
.ticket-thread-closed {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
}
.sa-invoice-school-field {
  max-width: 320px;
}
.sa-invoice-school-field .search-bar {
  min-width: 0;
  width: 100%;
}

/* School details panels */
.sa-school-panel {
  padding: 20px 22px 22px;
  margin-bottom: 16px;
}
.sa-school-panel-head {
  margin-bottom: 16px;
}
.sa-school-panel-head h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.sa-school-panel-head p {
  margin: 0;
  max-width: 52ch;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.sa-impersonate-form {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr) auto;
  gap: 14px 16px;
  align-items: end;
}
.sa-impersonate-form .sa-field {
  margin: 0;
}
.sa-impersonate-form .search-bar {
  width: 100%;
  min-width: 0;
}
.sa-impersonate-actions {
  display: flex;
  align-items: end;
  padding-bottom: 1px;
}
.sa-impersonate-actions .btn {
  min-height: 42px;
  padding-inline: 18px;
}
@media (max-width: 820px) {
  .sa-impersonate-form {
    grid-template-columns: 1fr;
  }
  .sa-impersonate-actions {
    justify-content: flex-start;
  }
}

.sa-subscription-current,
.sa-subscription-assign,
.sa-subscription-invoice {
  padding-top: 4px;
}
.sa-subscription-current,
.sa-subscription-assign {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-dark);
}
.sa-subscription .sa-form-block-subhead {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.sa-subscription-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.sa-subscription-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--ink-soft);
}
.sa-subscription-meta {
  color: var(--muted);
  font-size: 12px;
}
.sa-subscription-cancel,
.sa-subscription-assign-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px 16px;
  align-items: end;
}
.sa-subscription-assign-form {
  grid-template-columns: minmax(220px, 1fr) auto auto;
}
.sa-subscription-cancel .search-bar,
.sa-subscription-assign-form .search-bar {
  width: 100%;
  min-width: 0;
}
.sa-subscription-renew {
  align-self: end;
  margin-bottom: 1px;
  white-space: nowrap;
}
.sa-subscription-actions {
  display: flex;
  align-items: end;
  padding-bottom: 1px;
}
.sa-subscription-actions .btn,
.sa-subscription-invoice .btn {
  min-height: 42px;
  padding-inline: 18px;
}
@media (max-width: 820px) {
  .sa-subscription-cancel,
  .sa-subscription-assign-form {
    grid-template-columns: 1fr;
  }
  .sa-subscription-actions,
  .sa-subscription-renew {
    justify-self: start;
  }
}

.sa-features-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) auto minmax(160px, 1fr) auto;
  gap: 14px 16px;
  align-items: end;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-dark);
}
.sa-features-form .search-bar {
  width: 100%;
  min-width: 0;
}
.sa-features-enabled {
  align-self: end;
  margin-bottom: 1px;
  white-space: nowrap;
}
.sa-features-actions {
  display: flex;
  align-items: end;
  padding-bottom: 1px;
}
.sa-features-actions .btn {
  min-height: 42px;
  padding-inline: 18px;
}
.sa-features-list .sa-form-block-subhead {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.sa-features-row-actions {
  width: 1%;
  white-space: nowrap;
  text-align: end;
}
.sa-pill-on {
  background: rgba(111, 207, 151, 0.16);
  border-color: rgba(111, 207, 151, 0.3);
  color: var(--mint);
}
.sa-pill-off {
  background: rgba(178, 58, 58, 0.12);
  border-color: rgba(178, 58, 58, 0.28);
  color: var(--crimson);
}
@media (max-width: 900px) {
  .sa-features-form {
    grid-template-columns: 1fr 1fr;
  }
  .sa-features-enabled,
  .sa-features-actions {
    justify-self: start;
  }
}
@media (max-width: 640px) {
  .sa-features-form {
    grid-template-columns: 1fr;
  }
}




/* —— SOS console —— */
.sos-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 980px;
}
.sos-console {
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(178, 58, 58, 0.35);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(178, 58, 58, 0.2), transparent 55%),
    linear-gradient(135deg, rgba(178, 58, 58, 0.1), rgba(20, 24, 36, 0.35));
}
html[dir="rtl"] .sos-console {
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(178, 58, 58, 0.2), transparent 55%),
    linear-gradient(225deg, rgba(178, 58, 58, 0.1), rgba(20, 24, 36, 0.35));
}
.sos-console-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 20px;
  padding: 18px 20px;
}
.sos-hero-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: 0;
  flex: 1 1 240px;
}
.sos-hero-icon {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(178, 58, 58, 0.28);
  color: #ffb4b4;
  border: 1px solid rgba(255, 180, 180, 0.18);
}
.sos-hero-icon svg { width: 22px; height: 22px; }
.sos-hero-copy { min-width: 0; }
.sos-hero-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sos-hero-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}
.sos-hero-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 46ch;
}
.sos-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 120px));
  gap: 10px;
  flex: 0 0 auto;
}
.sos-kpi {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
}
.sos-kpi-open {
  border-color: rgba(178, 58, 58, 0.45);
  background: rgba(178, 58, 58, 0.16);
}
.sos-kpi-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  line-height: 1.2;
}
.sos-kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  color: #ffb4b4;
  font-variant-numeric: tabular-nums;
}

.sos-console-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 12px 14px;
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.12);
}
.sos-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  width: 220px;
  flex: 0 0 auto;
}
.sos-filter .input {
  width: 100%;
}
.sos-filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.sos-console-toolbar .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: 40px;
}
.sos-console-toolbar .btn svg { width: 14px; height: 14px; }

.sos-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  align-items: stretch;
}
.sos-empty {
  grid-column: 1 / -1;
  padding: 36px 24px;
  text-align: center;
  color: var(--muted);
}
.sos-empty-error { color: var(--coral); }

.sos-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--bg-card);
}
.sos-card-open {
  border-color: rgba(178, 58, 58, 0.55);
  box-shadow: inset 3px 0 0 #c45a5a;
}
html[dir="rtl"] .sos-card-open {
  box-shadow: inset -3px 0 0 #c45a5a;
}
.sos-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.sos-card-identity { min-width: 0; flex: 1 1 auto; }
.sos-card-route {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
  color: var(--ink);
  word-break: break-word;
}
.sos-card-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
.sos-card-desc {
  margin: 0;
  flex: 1 1 auto;
  line-height: 1.45;
  font-size: 0.95rem;
  color: var(--ink-soft);
  word-break: break-word;
}
.sos-card-coords {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.sos-card-coords svg { width: 12px; height: 12px; flex: 0 0 auto; }
.sos-card-reporter {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sos-card-reporter-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.sos-card-reporter-name {
  font-size: 0.88rem;
  color: var(--ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sos-card-footer {
  display: block;
  padding-top: 12px;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sos-card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.sos-card-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}
.sos-card-actions .btn svg { width: 13px; height: 13px; flex: 0 0 auto; }
.sos-card-actions:has(> :nth-child(1):last-child) {
  grid-template-columns: 1fr;
}
.sos-card-actions:has(> :nth-child(2):last-child) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 720px) {
  .sos-console-top {
    flex-direction: column;
    align-items: stretch;
  }
  .sos-kpis {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }
  .sos-console-toolbar {
    align-items: stretch;
  }
  .sos-filter {
    width: 100%;
  }
  .sos-console-toolbar .btn {
    width: 100%;
    justify-content: center;
  }
  .sos-card-actions {
    grid-template-columns: 1fr;
  }
}


/* —— Onboarding tour —— */
body.tour-active { overflow: hidden; }
.tour-root {
  position: fixed;
  inset: 0;
  z-index: 10050;
  pointer-events: none;
}
.tour-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 22, 0.62);
  pointer-events: auto;
}
.tour-highlight {
  position: absolute;
  border-radius: 12px;
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 0 9999px rgba(8, 12, 22, 0.62);
  background: transparent;
  pointer-events: none;
  transition: top 160ms ease, left 160ms ease, width 160ms ease, height 160ms ease;
  z-index: 1;
}
.tour-root .tour-overlay { opacity: 0; }
.tour-tip {
  position: absolute;
  z-index: 2;
  width: min(360px, calc(100vw - 32px));
  padding: 16px 16px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-dark);
  background: var(--bg-raised, var(--shell-bg));
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}
.tour-tip-progress {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.tour-tip-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 800;
}
.tour-tip-body {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft, var(--muted));
}
.tour-tip-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tour-tip-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
html[dir="rtl"] .tour-tip-progress { letter-spacing: 0; }

/* —— Billing page —— */
.billing-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1100px;
}
.billing-flash {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}
.billing-flash-ok {
  color: var(--mint);
  background: rgba(90, 200, 160, 0.12);
  border: 1px solid rgba(90, 200, 160, 0.3);
}
.billing-flash-error {
  color: var(--coral);
  background: rgba(227, 111, 76, 0.12);
  border: 1px solid rgba(227, 111, 76, 0.3);
}
.billing-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}
.billing-banner i { width: 18px; height: 18px; flex-shrink: 0; }
.billing-banner-trial {
  color: var(--gold);
  background: rgba(244, 184, 96, 0.12);
  border: 1px solid rgba(244, 184, 96, 0.28);
}
.billing-banner-danger {
  color: var(--coral);
  background: rgba(227, 111, 76, 0.12);
  border: 1px solid rgba(227, 111, 76, 0.3);
}
.billing-plan {
  padding: 22px 22px 20px;
  background:
    linear-gradient(135deg, rgba(244, 184, 96, 0.1), transparent 55%),
    var(--bg-raised, var(--shell-bg));
}
.billing-plan-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.billing-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
html[dir="rtl"] .billing-kicker { letter-spacing: 0; }
.billing-plan-name {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.billing-plan-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft, var(--muted));
  font-size: 13px;
}
.billing-meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.55;
}
.billing-plan-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  margin-inline-start: auto;
}
html[dir="rtl"] .billing-plan-price { align-items: flex-start; }
.billing-price-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -0.02em;
}
.billing-portal-form { margin: 0; }
.billing-portal-form .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.billing-portal-form .btn i { width: 16px; height: 16px; }

.billing-usage-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.billing-section-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}
.billing-section-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.billing-kpi-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.billing-kpi {
  position: relative;
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
}
.billing-kpi::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gold);
  opacity: 0.85;
}
.billing-kpi-students::before { background: #6ea8fe; }
.billing-kpi-buses::before { background: var(--gold); }
.billing-kpi-routes::before { background: #8fd3b0; }
.billing-kpi-staff::before { background: #c4a7e7; }

.billing-kpi-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.billing-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(244, 184, 96, 0.14);
  color: var(--gold);
}
.billing-kpi-students .billing-kpi-icon {
  background: rgba(110, 168, 254, 0.16);
  color: #8bbcff;
}
.billing-kpi-buses .billing-kpi-icon {
  background: rgba(244, 184, 96, 0.16);
  color: var(--gold);
}
.billing-kpi-routes .billing-kpi-icon {
  background: rgba(111, 207, 151, 0.16);
  color: var(--mint);
}
.billing-kpi-staff .billing-kpi-icon {
  background: rgba(196, 167, 231, 0.16);
  color: #d2b8f0;
}
.billing-kpi-icon i { width: 20px; height: 20px; }
.billing-kpi-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
html[dir="rtl"] .billing-kpi-label { letter-spacing: 0; text-transform: none; }

.billing-kpi-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.billing-kpi-used {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.billing-kpi-sep {
  font-size: 22px;
  font-weight: 600;
  color: var(--muted);
  opacity: 0.7;
}
.billing-kpi-max {
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
}

.billing-kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.billing-kpi-pct {
  font-weight: 800;
  color: var(--ink-soft, var(--ink));
}

.billing-meter {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
html.light .billing-meter { background: rgba(138, 111, 64, 0.14); }
.billing-meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 280ms ease;
}
.billing-meter-ok .billing-meter > span {
  background: linear-gradient(90deg, #4db88a, var(--mint));
}
.billing-meter-warn .billing-meter > span {
  background: linear-gradient(90deg, #d4a017, var(--gold));
}
.billing-meter-critical .billing-meter > span {
  background: linear-gradient(90deg, #c45c3e, var(--coral));
}
.billing-meter-warn .billing-kpi-pct { color: var(--gold); }
.billing-meter-critical .billing-kpi-pct { color: var(--coral); }

.billing-empty {
  padding: 40px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.billing-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(244, 184, 96, 0.14);
  color: var(--gold);
  margin-bottom: 4px;
}
.billing-empty-icon i { width: 24px; height: 24px; }
.billing-empty h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}
.billing-empty p {
  margin: 0;
  max-width: 36ch;
  color: var(--muted);
  line-height: 1.45;
}
@media (max-width: 1100px) {
  .billing-kpi-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .billing-kpi-rail { grid-template-columns: 1fr; }
  .billing-plan-price { align-items: stretch; width: 100%; }
  .billing-plan-price .btn { width: 100%; justify-content: center; }
  .billing-price-value { font-size: 22px; }
  .billing-plan-name { font-size: 24px; }
  .billing-kpi-used { font-size: 30px; }
}

/* —— Google OAuth buttons —— */
.oauth-form { margin: 0 0 14px; }
.btn-oauth-google {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-dark);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
html.light .btn-oauth-google { background: #fff; }
.btn-oauth-google:hover { border-color: var(--border-dark-hover); }
.oauth-google-icon {
  flex-shrink: 0;
  display: block;
  width: 18px;
  height: 18px;
}
.oauth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
html[dir="rtl"] .oauth-divider { letter-spacing: 0; text-transform: none; }
.oauth-divider::before,
.oauth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-dark);
}
.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}
input.field-input[readonly] {
  opacity: 0.85;
  cursor: default;
}
.google-connected-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(66, 133, 244, 0.35);
  background: rgba(66, 133, 244, 0.08);
}
.google-connected-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.google-connected-copy strong {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
html[dir="rtl"] .google-connected-copy strong {
  letter-spacing: 0;
  text-transform: none;
}
.google-connected-email {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.google-switch-link {
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.register-step-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--ink-soft);
}
.register-optional {
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid var(--border-dark);
  background: rgba(255, 255, 255, 0.02);
  padding: 0 12px;
}
.register-optional > summary {
  cursor: pointer;
  list-style: none;
  padding: 11px 0;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  user-select: none;
}
.register-optional > summary::-webkit-details-marker { display: none; }
.register-optional > summary::after {
  content: "+";
  float: inline-end;
  font-weight: 700;
  color: var(--gold);
}
.register-optional[open] > summary::after { content: "–"; }
.register-optional-body {
  padding: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
