/* ==========================================================================
   HYDRO & CAMIP — Clean Light Operational Dashboard
   ========================================================================== */

:root {
  --bg-deep: #F4F6F9;
  --bg-sidebar: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-solid: #FFFFFF;
  --bg-elevated: #F1F5F9;
  --bg-input: #F8FAFC;

  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-accent: #0284C7;
  --border-inner: #F1F5F9;

  --text-main: #0F172A;
  --text-sub: #475569;
  --text-dim: #64748B;

  --cyan: #0284C7;
  --cyan-bright: #0284C7;
  --blue: #2563EB;
  --emerald: #059669;
  --amber: #D97706;
  --red: #DC2626;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Lexend', 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --sidebar-w: 236px;
  --topbar-h: 58px;
  --radius: 11px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   1. SHELL & SIDEBAR
   ========================================================================== */

.platform-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
  transition: transform 0.24s var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 14px;
  border-bottom: 1px solid var(--border);
}

.brand-emblem {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-emblem img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-title {
  display: block;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 16px 10px 6px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.nav-btn {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-btn svg {
  flex-shrink: 0;
  opacity: 0.75;
}

.nav-btn span:nth-child(2) {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
}

.nav-btn.active {
  background: #E0F2FE;
  color: #0369A1;
  font-weight: 600;
}

.nav-btn.active svg {
  opacity: 1;
  stroke: #0369A1;
}

.nav-btn.camip-highlight {
  margin-top: 2px;
  background: #FEF2F2;
  border-color: #FECACA;
  color: #B91C1C;
}

.nav-btn.camip-highlight:hover {
  background: #FEE2E2;
}

.nav-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-sub);
}

.pill-ai {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: #FEE2E2;
  color: #B91C1C;
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.source-pills a {
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-sub);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  text-align: center;
}

.source-pills a:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

.health-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.health-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-sub);
}

.health-row strong {
  color: var(--text-main);
  font-weight: 600;
}

.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.led.ok { background: var(--emerald); }
.led.offline { background: var(--amber); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 35;
}

/* ==========================================================================
   2. MAIN AREA & TOPBAR
   ========================================================================== */

.main-area {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.topbar-left > div {
  min-width: 0;
  flex: 1;
}

.topbar-left h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-left p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.clock-pill {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
}

.btn-top-ghost,
.icon-btn {
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-btn {
  width: 34px;
  padding: 0;
}

.btn-top-ghost:hover,
.icon-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.btn-top-camip {
  height: 34px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid #FECACA;
  background: #FEF2F2;
  color: #B91C1C;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.btn-top-camip:hover {
  background: #FEE2E2;
}

.top-cam-label-short {
  display: none;
}

.cam-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}

.cam-live-dot.online {
  background: var(--emerald);
}

.mobile-only {
  display: none;
}

/* ==========================================================================
   3. EMERGENCY ALERT BAR
   ========================================================================== */

.emergency-bar {
  flex-shrink: 0;
  background: #DC2626;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #FFFFFF;
}

.emg-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.emg-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.emg-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.emg-title-line strong {
  font-size: 13.5px;
}

.emg-title-line span {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.22);
}

.emg-left p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.92;
}

.emg-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-emg-open {
  height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  border: none;
  background: #FFFFFF;
  color: #B91C1C;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.btn-emg-mute {
  height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* ==========================================================================
   4. WORKSPACE SCROLL & PAGES
   ========================================================================== */

.workspace-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 28px;
}

.page-view {
  display: none;
  max-width: 1400px;
  margin: 0 auto;
}

.page-view.active {
  display: block;
}

/* ==========================================================================
   5. COMPACT KPI STRIP (4 METRICS)
   ========================================================================== */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.kpi-tile.clickable-tile {
  cursor: pointer;
  border-color: #BAE6FD;
}

.kpi-tile.clickable-tile:hover {
  background: #F0F9FF;
  border-color: var(--cyan);
}

.kpi-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.kpi-badge.cyan { background: #E0F2FE; color: #0284C7; }
.kpi-badge.blue { background: #DBEAFE; color: #2563EB; }
.kpi-badge.emerald { background: #D1FAE5; color: #059669; }
.kpi-badge.amber { background: #FEF3C7; color: #D97706; }
.kpi-badge.cam { background: #FEE2E2; color: #DC2626; }

.kpi-copy {
  min-width: 0;
  flex: 1;
}

.kpi-copy span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}

.kpi-copy strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin: 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-copy small {
  display: block;
  font-size: 11px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   6. SEGMENTED VIEW SWITCH (MAP vs STATIONS LIST)
   ========================================================================== */

.overview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.view-switch {
  display: inline-flex;
  background: #E2E8F0;
  padding: 3px;
  border-radius: 9px;
  gap: 3px;
}

.view-switch-btn {
  height: 30px;
  padding: 0 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-sub);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.view-switch-btn.active {
  background: #FFFFFF;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

/* ==========================================================================
   7. CARDS, HEADERS & INPUTS
   ========================================================================== */

.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.padded-card {
  padding: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card-header h2,
.card-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.card-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.dark-select,
.dark-input-sm,
.search-box-sm input {
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-main);
  font-size: 12.5px;
  outline: none;
}

.dark-select:focus,
.dark-input-sm:focus,
.search-box-sm input:focus {
  border-color: var(--cyan);
}

.section-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
  flex-wrap: wrap;
}

.section-title-bar h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
}

.hint-text {
  font-size: 12px;
  color: var(--text-dim);
}

/* ==========================================================================
   8. GIS MAP STAGE
   ========================================================================== */

.map-command-card {
  overflow: hidden;
}

.map-header {
  padding: 12px 16px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.map-controls-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.map-layer-filters {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-elevated);
  padding: 3px;
  border-radius: 8px;
}

.map-chip {
  height: 27px;
  padding: 0 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.map-chip.active {
  background: #FFFFFF;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.map-chip.cam-chip.active {
  background: #FEE2E2;
  color: #B91C1C;
}

.btn-fly-camip {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #BAE6FD;
  background: #E0F2FE;
  color: #0369A1;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-fly-camip:hover {
  background: #BAE6FD;
}

.map-stage-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 280px);
  min-height: 420px;
  background: #E2E8F0;
}

.flood-map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-floating-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 400;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-sub);
}

.lg-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.lg-dot.cam { background: var(--red); }
.lg-dot.res { background: var(--cyan); }
.lg-dot.safe { background: var(--emerald); }
.lg-dot.alert { background: var(--amber); }

.custom-gis-icon {
  background: transparent !important;
  border: none !important;
}

.gis-pin-camip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: max-content;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 999px;
  background: #DC2626;
  border: 2px solid #FFFFFF;
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.gis-pin-camip.cam-online {
  background: #16A34A;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.35), 0 3px 10px rgba(0, 0, 0, 0.35);
}

.gis-pin-camip.cam-offline {
  background: #DC2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3), 0 3px 10px rgba(0, 0, 0, 0.35);
}

.gis-pin-camip.cam-disconnected {
  background: #64748B;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.gis-pin-hydro {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: max-content;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1.5px solid #FFFFFF;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.gis-pin-hydro strong {
  font-family: var(--font-mono);
  font-weight: 700;
}

.gis-pin-hydro.reservoir,
.gis-pin-hydro.res { background: #0284C7; }
.gis-pin-hydro.safe { background: #059669; }
.gis-pin-hydro.bd1 { background: #D97706; }
.gis-pin-hydro.bd2 { background: #EA580C; }
.gis-pin-hydro.bd3,
.gis-pin-hydro.alert { background: #DC2626; }

.leaflet-popup-content-wrapper {
  background: #FFFFFF !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border);
  border-radius: 10px !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-popup-tip {
  background: #FFFFFF !important;
}

.map-popup-box {
  font-size: 12.5px;
  line-height: 1.45;
  min-width: 185px;
}

.map-popup-box strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 4px;
}

.map-popup-btn {
  margin-top: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid #BAE6FD;
  background: #E0F2FE;
  color: #0369A1;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ==========================================================================
   9. RESERVOIR & RIVER STATION GRIDS
   ========================================================================== */

.reservoir-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.res-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--res-color, var(--cyan));
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.res-card:hover {
  border-color: var(--border-strong);
}

.res-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.res-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.res-river {
  font-size: 11.5px;
  color: var(--text-dim);
}

.res-time {
  font-size: 11px;
  color: var(--text-dim);
}

.res-reading {
  font-size: 21px;
  font-weight: 700;
  margin: 8px 0 2px;
  color: var(--text-main);
}

.res-mndbt {
  font-size: 11.5px;
  color: var(--text-sub);
}

.res-diff-note {
  font-size: 11.5px;
  color: var(--emerald);
  margin-top: 2px;
}

.res-diff-note.over {
  color: var(--amber);
  font-weight: 600;
}

.res-flows {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.flow-cell span {
  display: block;
  font-size: 10.5px;
  color: var(--text-dim);
}

.flow-cell strong {
  display: block;
  font-size: 12.5px;
  color: var(--text-main);
  margin-top: 1px;
}

.station-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.st-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.st-card:hover {
  border-color: var(--border-strong);
}

.st-card.is-alert {
  border-color: #FCA5A5;
  background: #FEF2F2;
}

.st-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.st-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.st-river {
  font-size: 11.5px;
  color: var(--text-dim);
}

.st-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.st-badge.safe { background: #D1FAE5; color: #047857; }
.st-badge.bd1 { background: #FEF3C7; color: #B45309; }
.st-badge.bd2 { background: #FFEDD5; color: #C2410C; }
.st-badge.bd3,
.st-badge.alert { background: #FEE2E2; color: #B91C1C; }

.st-level {
  font-size: 21px;
  font-weight: 700;
  margin: 8px 0 4px;
  color: var(--text-main);
}

.st-thresholds {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   10. ANALYTICS & FORECAST
   ========================================================================== */

.chart-header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chart-quick-presets,
.chart-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chart-chip {
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.chart-chip.active {
  background: #E0F2FE;
  border-color: #7DD3FC;
  color: #0369A1;
  font-weight: 600;
}

.chart-stage {
  position: relative;
  height: 340px;
  width: 100%;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 13px;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.fc-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.fc-card.special-dbt {
  border-color: #FCD34D;
  background: #FFFBEB;
}

.fc-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}

.fc-val {
  font-size: 18px;
  font-weight: 700;
  margin: 5px 0 2px;
  color: var(--cyan);
}

.fc-trend {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
}

.fc-note {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 5px;
}

/* ==========================================================================
   11. COMMUNITY REPORTS
   ========================================================================== */

.community-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
}

.field input,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--cyan);
}

.btn-primary-full {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: var(--cyan);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary-full:hover {
  background: #0369A1;
}

.comm-feed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 540px;
  overflow-y: auto;
}

.comm-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
}

.comm-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.comm-card-top strong {
  font-size: 13.5px;
  color: var(--text-main);
}

.comm-card-top span {
  font-size: 11px;
  color: var(--text-dim);
}

.comm-body {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
}

.comm-del-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 11.5px;
  cursor: pointer;
}

.comm-del-btn:hover {
  color: var(--red);
}

/* ==========================================================================
   12. CAMIP MODAL (LIGHT SHELL + DARK VIDEO STAGE)
   ========================================================================== */

.camip-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.camip-command-window {
  width: 100%;
  max-width: 1240px;
  height: 88vh;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
}

.camip-win-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.camip-win-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.camip-pulse-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #FEE2E2;
  color: #DC2626;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.camip-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.camip-title-row h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
}

.camip-win-brand p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-dim);
}

.conn-pill,
.threat-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
}

.conn-pill.online { background: #D1FAE5; color: #047857; }
.conn-pill.offline { background: #FEF3C7; color: #B45309; }
.threat-tag.safe { background: #D1FAE5; color: #047857; }
.threat-tag.warn { background: #FEF3C7; color: #B45309; }
.threat-tag.danger,
.threat-tag.critical { background: #FEE2E2; color: #B91C1C; }

.sim-mode-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: #E0F2FE;
  color: #0369A1;
}

.camip-win-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-elevated);
  padding: 3px;
  border-radius: 9px;
}

.cam-tab {
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.cam-tab.active {
  background: #FFFFFF;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.win-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-sub);
  font-size: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.win-close-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
}

.camip-win-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-deep);
}

.cam-subview {
  display: none;
  height: 100%;
}

.cam-subview.active {
  display: block;
}

.cam-live-grid {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 16px;
  height: 100%;
}

.cam-stage-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.cam-video-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0F172A;
  border-radius: 10px;
  overflow: hidden;
}

.live-stream-img,
.sim-live-canvas,
.sim-replay-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.live-zone-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stream-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #0F172A;
  color: #CBD5E1;
  text-align: center;
  padding: 20px;
}

.stream-placeholder h4 { margin: 4px 0 0; font-size: 14px; color: #FFFFFF; }
.stream-placeholder p { margin: 0; font-size: 12px; color: #94A3B8; }

.cam-hud-tl,
.cam-hud-bottom {
  position: absolute;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.78);
  color: #F8FAFC;
  font-size: 11px;
}

.cam-hud-tl { top: 10px; left: 10px; font-weight: 600; }

.cam-hud-bottom {
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cam-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.cam-act-btn {
  height: 33px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cam-act-btn:hover { background: var(--bg-elevated); }
.cam-act-btn.primary { background: #E0F2FE; border-color: #BAE6FD; color: #0369A1; }
.cam-act-btn.ai { background: #D1FAE5; border-color: #A7F3D0; color: #047857; }
.cam-act-btn.danger { background: #FEE2E2; border-color: #FECACA; color: #B91C1C; }

.cam-dock-col {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cam-dock-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.cam-dock-head h3 { margin: 0; font-size: 13.5px; font-weight: 700; }
.cam-dock-head p { margin: 2px 0 0; font-size: 11.5px; color: var(--text-dim); }

.cam-rec-banner {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
}

.cam-rec-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #B91C1C;
}

.cam-rec-row strong { margin-left: auto; }

.cam-rec-bar {
  margin-top: 6px;
  height: 4px;
  border-radius: 999px;
  background: #FEE2E2;
  overflow: hidden;
}

.cam-rec-bar > div { height: 100%; width: 0; background: var(--red); }

.cam-feed-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cam-feed-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  min-width: 0;
  flex-shrink: 0;
  overflow: hidden;
}

.cam-feed-card:hover { border-color: var(--cyan); }

.cam-feed-top {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  min-width: 0;
  margin-bottom: 8px;
}

.cam-feed-thumb {
  width: 92px;
  height: 60px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 6px;
  margin-top: 0;
}

/* Video Vault */
.cam-vault-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-pills { display: flex; gap: 6px; }

.v-chip {
  height: 32px;
  padding: 0 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.v-chip.active {
  background: #E0F2FE;
  border-color: #BAE6FD;
  color: #0369A1;
}

.cam-vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.v-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}

.v-card:hover { border-color: var(--cyan); }

.v-poster {
  position: relative;
  height: 130px;
  background: #0F172A;
  display: grid;
  place-items: center;
}

.v-poster img { width: 100%; height: 100%; object-fit: cover; }

.v-play-icon {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  display: grid;
  place-items: center;
}

.v-meta { padding: 10px 12px; font-size: 12px; color: var(--text-sub); }
.v-meta strong { display: block; color: var(--text-main); font-size: 13px; margin-bottom: 2px; }

/* Water Zone Studio */
.cam-zone-layout {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 16px;
}

.zone-canvas-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0F172A;
  border-radius: 10px;
  overflow: hidden;
}

.zone-canvas-box canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }

.zone-coord-tag {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.8);
  font-size: 11px;
  color: #FFFFFF;
}

.zone-scan-laser {
  position: absolute;
  inset: 0;
  background: rgba(2, 132, 199, 0.16);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
}

.cam-zone-side {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.cam-zone-side h3 { margin: 0; font-size: 14px; }

.vertices-scroll {
  margin-top: 10px;
  flex: 1;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vtx-row {
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-sub);
  display: flex;
  justify-content: space-between;
}

/* Alerts Table */
.table-scroll {
  overflow-x: auto;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.cam-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }

.cam-table th,
.cam-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.cam-table th {
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.cam-table img { width: 64px; height: 38px; object-fit: cover; border-radius: 5px; }

.btn-watch-20s {
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid #BAE6FD;
  background: #E0F2FE;
  color: #0369A1;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

/* Settings Grid */
.cam-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.glass-subcard {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.glass-subcard h3 { margin: 0; font-size: 14.5px; }

.pwd-row,
.btn-row { display: flex; gap: 8px; align-items: center; }
.pwd-row input { flex: 1; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ==========================================================================
   13. 20s VIDEO REPLAY PLAYER MODAL
   ========================================================================== */

.player-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.player-dialog {
  width: 100%;
  max-width: 820px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  padding: 14px 16px 16px;
  box-shadow: var(--shadow-md);
}

.player-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.badge-20s {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: #E0F2FE;
  color: #0369A1;
  margin-right: 8px;
}

.player-head strong { font-size: 14px; }
.player-head small { display: block; font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

.player-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0F172A;
  border-radius: 10px;
  overflow: hidden;
}

.player-video-wrap video { width: 100%; height: 100%; object-fit: contain; }

.player-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  color: #CBD5E1;
  font-size: 12.5px;
}

.phase-pill {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.phase-pill.before { background: #0284C7; color: #fff; }
.phase-pill.after { background: #DC2626; color: #fff; }
.phase-pill.impact { background: #D97706; color: #fff; }

.speed-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 11.5px;
  cursor: pointer;
}

.scrubber-wrap { margin-top: 12px; }

.scrubber-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.scrubber-labels .fall { color: #DC2626; font-weight: 700; }

.scrubber-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  cursor: pointer;
}

.seg-pre,
.seg-post,
.seg-prog { position: absolute; top: 0; height: 100%; border-radius: 999px; }
.seg-pre { left: 0; background: #BAE6FD; }
.seg-post { right: 0; background: #FECACA; }
.seg-prog { left: 0; background: var(--cyan); }

.seg-pin {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 16px;
  background: var(--red);
  border-radius: 2px;
}

.seg-thumb {
  position: absolute;
  top: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid #FFFFFF;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transform: translateX(-50%);
}

.player-controls-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.player-btns { display: flex; align-items: center; gap: 6px; }

.btn-play-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--cyan);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.btn-jump-impact {
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid #FECACA;
  background: #FEE2E2;
  color: #B91C1C;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ==========================================================================
   14. SPINNERS, TOASTS & RESPONSIVE
   ========================================================================== */

.spinner,
.spinner-xs {
  border-radius: 50%;
  border: 2px solid #E2E8F0;
  border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
}

.spinner { width: 28px; height: 28px; }
.spinner-xs { width: 14px; height: 14px; }

@keyframes spin { to { transform: rotate(360deg); } }

.empty-msg { padding: 24px; text-align: center; color: var(--text-dim); font-size: 13px; }

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 14px;
  border-radius: 9px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
}

.toast.error { border-color: #FCA5A5; background: #FEF2F2; color: #B91C1C; }
.toast.success { border-color: #A7F3D0; background: #ECFDF5; color: #047857; }

/* Station Detail Modal & Single-Station Bar Chart */
.chart-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-chip input {
  display: none;
}

.fc-card {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.fc-card:hover {
  border-color: var(--cyan);
  transform: translateY(-1px);
}

.station-detail-dialog {
  max-width: 780px;
}

.detail-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-metric-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
}

.detail-metric-box span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}

.detail-metric-box strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin: 3px 0 2px;
}

.detail-metric-box small {
  display: block;
  font-size: 11.5px;
  color: var(--text-sub);
}

.detail-chart-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
}

.detail-chart-stage {
  position: relative;
  height: 250px;
  width: 100%;
}

@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reservoir-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .station-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(272px, 84vw);
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.14);
  }
  .sidebar.open { transform: translateX(0); }
  .cam-live-grid,
  .cam-zone-layout,
  .community-layout,
  .cam-settings-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  .cam-subview {
    height: auto;
  }
  .cam-dock-col {
    max-height: 360px;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: 54px;
    padding: 0 10px;
    gap: 6px;
  }
  .topbar-left {
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }
  .topbar-left > div {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }
  .topbar-left h1 {
    font-size: 13.5px;
    line-height: 1.25;
  }
  .topbar-left p {
    font-size: 10.5px;
    line-height: 1.2;
  }
  .topbar-right {
    gap: 5px;
    flex-shrink: 0;
  }
  .clock-pill { display: none; }
  #txtRefreshBtn { display: none; }
  #btnRefreshAll,
  .icon-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    flex-shrink: 0;
  }
  .btn-top-camip {
    height: 32px;
    padding: 0 10px;
    font-size: 11.5px;
    gap: 5px;
    flex-shrink: 0;
  }
  .top-cam-label-full {
    display: none;
  }
  .top-cam-label-short {
    display: inline;
  }
  .emergency-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
    gap: 10px;
  }
  .emg-right {
    width: 100%;
  }
  .btn-emg-open {
    flex: 1;
  }
  .workspace-scroll {
    padding: 10px 10px 24px;
  }
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }
  .kpi-tile {
    padding: 9px 10px;
    gap: 8px;
    align-items: flex-start;
  }
  .kpi-badge {
    width: 28px;
    height: 28px;
    margin-top: 2px;
  }
  .kpi-badge svg {
    width: 15px;
    height: 15px;
  }
  .kpi-copy span {
    font-size: 10.5px;
  }
  .kpi-copy strong {
    font-size: 12.5px;
    line-height: 1.25;
  }
  .kpi-copy small {
    font-size: 10px;
  }
  .overview-toolbar {
    margin-bottom: 10px;
  }
  .view-switch {
    width: 100%;
  }
  .view-switch-btn {
    flex: 1;
    text-align: center;
  }
  .map-header {
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .map-controls-bar {
    width: 100%;
    gap: 6px;
  }
  .map-layer-filters {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, auto);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .map-layer-filters::-webkit-scrollbar { display: none; }
  .map-chip {
    padding: 0 7px;
    font-size: 11px;
    white-space: nowrap;
    text-align: center;
  }
  #selMapBaseLayer,
  .btn-fly-camip {
    flex: 1;
    height: 32px;
    font-size: 12px;
  }
  .map-stage-wrap {
    height: 380px;
    min-height: 330px;
  }
  .gis-pin-camip {
    padding: 3px 7px;
    font-size: 10px;
    gap: 4px;
    border-width: 1.5px;
  }
  .gis-pin-hydro {
    padding: 2px 6px;
    font-size: 9.5px;
    gap: 3px;
    border-width: 1px;
  }
  .map-floating-legend {
    left: 6px;
    right: 6px;
    bottom: 6px;
    padding: 4px 8px;
    gap: 6px 10px;
    justify-content: center;
  }
  .legend-item {
    font-size: 10px;
  }
  .reservoir-grid,
  .station-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .res-flows {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .section-title-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .search-box-sm,
  .search-box-sm input {
    width: 100%;
  }
  .padded-card {
    padding: 12px;
  }
  .chart-header-controls {
    width: 100%;
  }
  .chart-header-controls select {
    flex: 1;
  }
  .chart-chips-wrap {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .chart-chip {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .chart-stage {
    height: 250px;
  }
  .forecast-grid {
    grid-template-columns: 1fr;
  }
  /* Modals on mobile */
  .camip-modal-backdrop,
  .player-backdrop {
    padding: 6px;
  }
  .camip-command-window {
    height: 95vh;
    height: 95dvh;
    border-radius: 12px;
  }
  .camip-win-header {
    padding: 10px 12px;
    gap: 8px;
    position: relative;
  }
  .camip-win-brand {
    width: calc(100% - 40px);
    min-width: 0;
  }
  .camip-title-row h2 {
    font-size: 13.5px;
  }
  .camip-win-header .win-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
  }
  .camip-win-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .camip-win-tabs::-webkit-scrollbar { display: none; }
  .cam-tab {
    flex: 1 0 auto;
    white-space: nowrap;
    padding: 0 10px;
    font-size: 12px;
  }
  .camip-win-body {
    padding: 10px;
  }
  .cam-hud-tl {
    font-size: 9.5px;
    padding: 3px 6px;
    top: 6px;
    left: 6px;
  }
  .cam-hud-bottom {
    font-size: 9.5px;
    padding: 3px 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    flex-wrap: wrap;
    gap: 4px;
  }
  .cam-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .cam-act-btn {
    width: 100%;
    padding: 0 8px;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #btnSaveZone {
    grid-column: 1 / -1;
    margin-left: 0 !important;
  }
  .cam-vault-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-pills {
    width: 100%;
    overflow-x: auto;
  }
  .v-chip {
    flex: 1;
    white-space: nowrap;
  }
  #inpSearchVideos {
    width: 100%;
  }
  .cam-vault-grid {
    grid-template-columns: 1fr;
  }
  .cam-table th,
  .cam-table td {
    padding: 8px 9px;
    font-size: 11.5px;
    white-space: nowrap;
  }
  .cam-table td:nth-child(3) {
    white-space: normal;
    min-width: 160px;
  }
  .btn-row {
    flex-wrap: wrap;
  }
  .btn-row > * {
    flex: 1;
  }
  .player-dialog {
    max-height: 94vh;
    max-height: 94dvh;
    overflow-y: auto;
    padding: 12px;
    border-radius: 12px;
  }
  .player-head {
    align-items: flex-start;
  }
  .scrubber-labels {
    font-size: 10px;
  }
  .player-controls-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .player-btns {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  .detail-metrics-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .detail-metric-box {
    padding: 9px 11px;
  }
  .detail-metric-box strong {
    font-size: 15.5px;
  }
  .detail-chart-stage {
    height: 210px;
  }
  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .toast {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .btn-top-camip span:last-child {
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 340px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }
}
