/* ══════════════════════════════════════════════════════════════════════════
   RF-SCAVENGER — terminal theme (mobile-first)

   Green phosphor on black. Amber for warnings, red for alerts; everything
   else is differentiated by brightness rather than hue, so the palette stays
   monochrome-feeling while alert severity still reads at a glance.

   No scanline overlay, no glow, no flicker — sharp text on a phone matters
   more than the CRT costume. Sharp corners and monospace throughout.

   Base rules target phones; layout grows at 640 / 900 / 1100px.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --font-family: 'Cascadia Mono', 'JetBrains Mono', 'Fira Mono', Consolas,
                 'DejaVu Sans Mono', 'Courier New', monospace;

  /* Green ramp — brightness is the primary encoding channel */
  --g-100: #ccffdd;  /* brightest: headings, active values */
  --g-200: #7dffab;  /* emphasis */
  --g-300: #33ff77;  /* primary body text */
  --g-400: #22cc5c;  /* secondary */
  --g-500: #158f3d;  /* labels, muted text */
  --g-600: #0d5c27;  /* borders */
  --g-700: #082f16;  /* hairlines, subtle fills */
  --g-800: #04180b;  /* raised panel */

  --bg-dark: #000000;
  --bg-panel: #030b05;
  --bg-raised: #061209;

  --panel-glass: var(--bg-panel);
  --border-glass: var(--g-700);

  --text-primary: var(--g-300);
  --text-secondary: var(--g-500);

  /* Semantic accents — the only non-green hues in the system */
  --warn-color: #ffb300;
  --danger-color: #ff3b30;

  /* Legacy names still referenced from app.js inline styles */
  --sdr1-color: #33ff77;
  --sdr2-color: #7dffab;
  --sat-color: #ccffdd;
  --glow-sdr1: none;
  --glow-sdr2: none;
  --glow-sat: none;

  --tap-min: 44px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  border-radius: 0 !important; /* nothing in a terminal is rounded */
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  font-size: 13px;
  line-height: 1.45;
  font-variant-ligatures: none;
}

/* Decorative space-scene layers from the old theme — no place here. */
.stars-bg,
.aurora-glow { display: none !important; }

::selection { background: var(--g-300); color: #000; }

/* Scrollbars styled as terminal gutters */
* { scrollbar-width: thin; scrollbar-color: var(--g-600) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--g-700); border: 1px solid var(--g-600); }
*::-webkit-scrollbar-thumb:hover { background: var(--g-600); }

/* ─── Shell ──────────────────────────────────────────────────────────────── */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.main-content {
  order: 1;
  flex-grow: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 10px calc(80px + var(--safe-bottom)) 10px;
  padding-left: calc(10px + var(--safe-left));
  padding-right: calc(10px + var(--safe-right));
  padding-top: calc(10px + var(--safe-top));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

/* Bottom tab bar on phones; becomes a left sidebar at ≥1100px */
.sidebar-panel {
  order: 2;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: calc(58px + var(--safe-bottom));
  padding: 0 2px calc(var(--safe-bottom)) 2px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  border-top: 1px solid var(--g-600);
  z-index: 1000;
}

.logo-area { display: none; }
.sidebar-footer { display: none; }

.nav-menu {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: stretch;
  width: 100%;
  height: 100%;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-menu::-webkit-scrollbar { display: none; }

.nav-item {
  flex: 1 0 auto;
  min-width: 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  color: var(--g-500);
  font-size: 9px;
  font-weight: 600;
  font-family: var(--font-family);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 6px 3px;
  cursor: pointer;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
}

.nav-icon { font-size: 17px; line-height: 1; filter: grayscale(1) brightness(1.4); }

.nav-item.active { color: var(--g-100); background: var(--g-800); }
.nav-item.active .nav-icon { filter: none; }

.nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0; right: 0;
  height: 2px;
  background: var(--g-300);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.action-btn-glass,
.submit-btn,
.btn-small,
.close-btn {
  background: transparent;
  border: 1px solid var(--g-600);
  color: var(--g-300);
  padding: 10px 16px;
  min-height: var(--tap-min);
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s linear, color 0.12s linear;
  width: 100%;
}

.action-btn-glass:hover,
.submit-btn:hover,
.btn-small:hover { background: var(--g-300); color: #000; border-color: var(--g-300); }

.action-btn-glass:active,
.submit-btn:active { background: var(--g-200); }

.btn-small {
  width: auto;
  min-height: 0;
  padding: 5px 10px;
  font-size: 10px;
}

.close-btn {
  width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0;
  font-size: 16px;
  border-color: transparent;
  color: var(--g-500);
}
.close-btn:hover { color: var(--danger-color); background: transparent; border-color: var(--danger-color); }

.export-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.export-buttons .btn-small { flex: 1 1 auto; }

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 12px;
  margin: 0 0 10px 0;
  background: var(--bg-panel);
  border: 1px solid var(--g-600);
}

.header-title-section h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--g-100);
}
.header-title-section h1::before { content: '> '; color: var(--g-500); }

.header-title-section p { display: none; }

.mobile-settings-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  padding: 0 !important;
  font-size: 16px !important;
  width: auto !important;
  min-width: var(--tap-min);
}

.header-status-area { display: flex; width: 100%; gap: 6px; margin-top: 8px; }

.status-indicator {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
  background: var(--bg-raised);
  border: 1px solid var(--g-700);
  border-left: 2px solid var(--g-500);
  padding: 5px 7px;
}

.status-label { display: none; }

.indicator-group { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }

.status-detail {
  font-size: 10px;
  color: var(--g-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid currentColor;
  background: transparent;
}

/* Note: these classes carry no animation on purpose. app.js reassigns
   className on a 1s tick, which would restart any animation mid-cycle and
   read as a stutter — the "glitchiness" the old theme had. */
.badge-glow { color: var(--g-200); }
.badge-sweeping { color: var(--g-400); }
.badge-recording { color: var(--warn-color); }
.badge-conn { color: var(--g-300); }
.badge-offline { color: var(--danger-color); }

/* Inverted fill is the strongest signal available in a monochrome scheme,
   so it marks the one state worth spotting across the room: a live decode. */
.badge-locked { background: var(--g-200); color: #000; border-color: var(--g-200); }

.sat-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 1px 4px;
  border: 1px solid currentColor;
  vertical-align: middle;
}
.sat-badge.apt { color: var(--g-500); }
.sat-badge.lrpt { color: var(--g-100); }

.sensor-model-badge,
.sat-info-badge,
.flight-peek-tag,
.chip-count {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border: 1px solid var(--g-700);
  color: var(--g-400);
  background: var(--g-800);
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.glass-card,
.large-card,
.timeline-card,
.map-container-card,
.stat-count-card,
.sensor-widget,
.meter-box,
.flights-summary-box,
.flight-detail-panel {
  background: var(--bg-panel);
  border: 1px solid var(--g-600);
  padding: 12px;
  position: relative;
}

/* Terminal-style titled frame: the heading sits in the top border */
.glass-card > h2,
.glass-card > h3,
.large-card > h2,
.large-card > h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--g-100);
  margin: -19px 0 10px -4px;
  padding: 0 6px;
  background: var(--bg-panel);
  display: inline-block;
}

h1, h2, h3, h4 { font-weight: 700; letter-spacing: 1px; }

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

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.space-layout-grid,
.stats-tables-row,
.stats-totals-row,
.sensor-cards-grid,
.sdr-meters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.text-center { text-align: center; }

.empty-state {
  color: var(--g-500);
  font-size: 11px;
  text-align: center;
  padding: 18px 10px;
  border: 1px dashed var(--g-700);
}
.empty-state::before { content: '— '; }
.empty-state::after { content: ' —'; }

/* ─── Stats ──────────────────────────────────────────────────────────────── */
.stat-number,
.stat-val,
.summary-stat {
  font-size: 22px;
  font-weight: 700;
  color: var(--g-100);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.stat-label,
.stat-desc,
.meter-title,
.sensor-unit {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--g-500);
}

.stat-icon { font-size: 18px; filter: grayscale(1) brightness(1.5); }
.stat-info { min-width: 0; }

.sensor-value { font-size: 20px; font-weight: 700; color: var(--g-100); font-variant-numeric: tabular-nums; }
.sensor-value-row { display: flex; align-items: baseline; gap: 5px; }
.sensor-widget-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.sensor-footer { font-size: 9px; color: var(--g-500); margin-top: 6px; }
.sensor-sparkline { width: 100%; height: 26px; display: block; }

/* ─── Gauges ─────────────────────────────────────────────────────────────── */
/* The old theme drew these as conic-gradient rings. A terminal has no such
   thing, so they become bracketed readout panels — same information, and the
   band label finally gets room to be legible. */
.radial-gauge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 10px 18px;
  border: 1px solid var(--g-700);
  background: #000;
}

/* [ ] brackets that brighten while the SDR is actively scanning */
.radial-gauge::before,
.radial-gauge::after {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  line-height: 1;
  color: var(--g-700);
}
.radial-gauge::before { content: '['; left: 5px; }
.radial-gauge::after  { content: ']'; right: 5px; }

.radial-gauge.active-scan { border-color: var(--g-500); }
.radial-gauge.active-scan::before,
.radial-gauge.active-scan::after { color: var(--g-300); }

.radial-gauge.recording-active { border-color: var(--warn-color); }
.radial-gauge.recording-active::before,
.radial-gauge.recording-active::after { color: var(--warn-color); }

.gauge-center { display: flex; flex-direction: column; align-items: center; justify-content: center; }

.gauge-val {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--g-300);
  text-align: center;
  white-space: nowrap;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-scroll { width: 100%; }

table { width: 100%; border-collapse: collapse; font-size: 11px; }

thead th {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--g-500);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--g-600);
  white-space: nowrap;
}

tbody td {
  padding: 6px 8px;
  color: var(--g-300);
  font-variant-numeric: tabular-nums;
}

/* Mobile: each row becomes a stacked card keyed off td[data-label] */
table.responsive-table thead { display: none; }

table.responsive-table tbody tr {
  display: block;
  border: 1px solid var(--g-700);
  border-left: 2px solid var(--g-600);
  margin-bottom: 6px;
  padding: 4px 0;
  background: var(--bg-raised);
}

table.responsive-table tbody tr:hover td { background: none; }

table.responsive-table tbody tr td[colspan] {
  display: block;
  text-align: center;
  color: var(--g-500);
}

table.responsive-table td {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 3px 9px;
  border: none;
  text-align: right;
}

table.responsive-table td::before {
  content: attr(data-label);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--g-500);
  text-align: left;
  flex-shrink: 0;
}

table.responsive-table td:not([data-label])::before { content: none; }

table:not(.responsive-table) { min-width: 100%; }
.table-scroll:has(table:not(.responsive-table)) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─── Band Watch ─────────────────────────────────────────────────────────── */
.band-watch-list { display: flex; flex-direction: column; gap: 3px; }

.band-watch-row {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid var(--g-700);
  background: var(--bg-raised);
  font-size: 11px;
}

.band-watch-dot { width: 6px; height: 6px; background: var(--g-500); }
.band-watch-row.active .band-watch-dot { background: var(--g-200); }

.band-watch-label { color: var(--g-300); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.band-watch-yield { color: var(--g-100); font-variant-numeric: tabular-nums; font-weight: 700; }
.band-watch-affinity { color: var(--g-500); font-size: 9px; letter-spacing: 0.5px; }
.band-watch-idle { color: var(--g-500); font-size: 9px; font-variant-numeric: tabular-nums; }

.band-watch-priority-bar { grid-column: 1 / -1; height: 2px; background: var(--g-800); }
.band-watch-priority-fill { height: 100%; background: var(--g-400); }

/* ─── Train Watch ────────────────────────────────────────────────────────── */
.train-watch-btn {
  background: transparent;
  border: 1px solid var(--warn-color);
  color: var(--warn-color);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 12px;
  min-height: var(--tap-min);
  width: 100%;
  font-family: var(--font-family);
  font-size: 12px;
  cursor: pointer;
}
.train-watch-btn:hover { background: var(--warn-color); color: #000; }

.train-watch-active { border-color: var(--danger-color); color: var(--danger-color); }
.train-watch-active:hover { background: var(--danger-color); color: #000; }

.countdown-container { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.countdown-time {
  font-size: 26px;
  font-weight: 700;
  color: var(--g-100);
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
}

/* ─── Log console ────────────────────────────────────────────────────────── */
.log-card { display: flex; flex-direction: column; flex-grow: 1; }

.log-filter-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }

.filter-chip {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 8px;
  border: 1px solid var(--g-700);
  background: transparent;
  color: var(--g-500);
  cursor: pointer;
  font-family: var(--font-family);
}
.filter-chip.active { border-color: var(--g-300); color: var(--g-100); background: var(--g-800); }

.log-console {
  flex-grow: 1;
  min-height: 180px;
  max-height: 340px;
  overflow-y: auto;
  background: #000;
  border: 1px solid var(--g-700);
  padding: 7px;
  font-size: 11px;
  line-height: 1.5;
}

.log-line {
  padding: 1px 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--g-400);
}
.log-line::before { content: '· '; color: var(--g-700); }

.log-line.system { color: var(--g-500); }
.log-line.ism { color: var(--g-300); }
.log-line.aircraft { color: var(--g-200); }
.log-line.satellite { color: var(--g-100); }
.log-line.alert { color: var(--danger-color); }
.log-line.warn { color: var(--warn-color); }

/* ─── Map ────────────────────────────────────────────────────────────────── */
.map-wrapper, .live-map, .heatmap-wrapper { width: 100%; background: #000; border: 1px solid var(--g-700); }
.live-map { min-height: 260px; }

.map-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: 9px; color: var(--g-500); }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-color { width: 8px; height: 8px; border: 1px solid var(--g-600); }

/* Leaflet popups themed to match */
.leaflet-popup-content-wrapper {
  background: var(--bg-panel) !important;
  color: var(--g-300) !important;
  border: 1px solid var(--g-600);
  font-family: var(--font-family);
  font-size: 11px;
}
.leaflet-popup-tip { background: var(--bg-panel) !important; border: 1px solid var(--g-600); }

/* ─── Satellite gallery ──────────────────────────────────────────────────── */
.gallery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.gallery-item {
  border: 1px solid var(--g-700);
  background: var(--bg-raised);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.gallery-item:hover { border-color: var(--g-300); }

.gallery-item img { width: 100%; height: 70%; object-fit: cover; background: #000; }

.gallery-info { padding: 5px; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
.gallery-title { font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--g-200); }
.gallery-time { font-size: 9px; color: var(--g-500); }

.sat-details { font-size: 10px; color: var(--g-500); }
.sat-name { font-weight: 700; color: var(--g-100); letter-spacing: 1px; }

.image-overlay-content { max-width: 96vw; max-height: 88vh; }
.image-overlay-content img { max-width: 100%; max-height: 80vh; object-fit: contain; border: 1px solid var(--g-600); }
.overlay-caption { font-size: 11px; color: var(--g-400); margin-top: 6px; text-align: center; }

/* ─── Flights ────────────────────────────────────────────────────────────── */
.flight-peek-list { display: flex; flex-direction: column; gap: 3px; }
.summary-stat { font-size: 18px; }

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert-banner {
  border: 1px solid var(--danger-color);
  border-left: 3px solid var(--danger-color);
  color: var(--danger-color);
  background: rgba(255, 59, 48, 0.06);
  padding: 9px 11px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.alert-banner::before { content: '!! '; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.form-row { display: flex; flex-direction: column; gap: 10px; }

label {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--g-500);
}

input, select, textarea {
  background: #000;
  border: 1px solid var(--g-600);
  color: var(--g-200);
  padding: 9px 10px;
  min-height: var(--tap-min);
  font-family: var(--font-family);
  font-size: 13px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--g-300); background: var(--g-800); }
input::placeholder { color: var(--g-700); }

/* ─── Modals ─────────────────────────────────────────────────────────────── */
/* Hidden until app.js adds .active. Defaulting this to `display: flex` leaves
   all three overlays permanently covering the page at z-index 2000, which
   looks exactly like the dashboard failing to load. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 2000;
  padding: 0;
}

.modal-overlay.active { display: flex; }

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--g-500);
  padding: 16px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2, .modal-content h3 {
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--g-100);
  margin-bottom: 4px;
}

.modal-subtitle { font-size: 10px; color: var(--g-500); margin-bottom: 12px; }
.modal-actions { display: flex; gap: 6px; margin-top: 14px; }
.modal-actions > * { flex: 1; }

/* ══════════════════════════════════════════════════════════════════════════
   TABLET (≥640px)
   ══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  body { font-size: 13px; }

  .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .sensor-cards-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-totals-row { grid-template-columns: repeat(2, 1fr); }
  .sdr-meters { grid-template-columns: repeat(2, 1fr); }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }

  .app-header { flex-direction: row; align-items: center; justify-content: space-between; }
  .header-status-area { width: auto; margin-top: 0; }
  .form-row { flex-direction: row; }
  .form-row > * { flex: 1; }

  .modal-overlay { align-items: center; padding: 20px; }
  .modal-content { max-width: 520px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   ≥900px — tables become real tables again
   ══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 900px) {
  table.responsive-table thead { display: table-header-group; }

  table.responsive-table tbody tr {
    display: table-row;
    border: none;
    border-bottom: 1px solid var(--g-800);
    margin-bottom: 0;
    padding: 0;
    background: transparent;
  }

  table.responsive-table tbody tr:hover td { background: var(--g-800); }
  table.responsive-table tbody tr td[colspan] { display: table-cell; text-align: center; }

  table.responsive-table td {
    display: table-cell;
    text-align: left;
    padding: 6px 8px;
    border: none;
  }

  table.responsive-table td::before { content: none; }

  .stats-tables-row { grid-template-columns: repeat(2, 1fr); }
  .space-layout-grid { grid-template-columns: 1.6fr 1fr; }
  .sensor-cards-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ══════════════════════════════════════════════════════════════════════════
   DESKTOP (≥1100px) — sidebar nav replaces the bottom bar
   ══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1100px) {
  body { overflow: hidden; }

  .app-container { flex-direction: row; }

  .main-content { order: 2; padding: 22px; height: 100vh; height: 100dvh; }

  .sidebar-panel {
    order: 1;
    position: relative;
    width: 220px;
    height: 100vh;
    height: 100dvh;
    padding: 18px 14px;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    border-top: none;
    border-right: 1px solid var(--g-600);
  }

  .logo-area { display: flex; align-items: center; gap: 8px; margin-bottom: 22px; }
  .logo-icon { font-size: 18px; filter: grayscale(1) brightness(1.6); }
  .logo-text {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--g-100);
  }

  .sidebar-footer { display: block; font-size: 9px; color: var(--g-700); letter-spacing: 1px; }
  .mobile-settings-btn { display: none !important; }

  .nav-menu { flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 1px; flex-grow: 1; overflow-x: visible; overflow-y: auto; }

  .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 9px;
    min-width: 0;
    padding: 7px 9px;
    font-size: 11px;
    text-align: left;
    border-left: 2px solid transparent;
  }

  .nav-item:hover { color: var(--g-200); background: var(--g-800); }
  .nav-item.active { border-left-color: var(--g-300); }
  .nav-item.active::after { display: none; }

  .nav-icon { font-size: 14px; }

  .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .gallery-grid { grid-template-columns: repeat(4, 1fr); }
  .stats-totals-row { grid-template-columns: repeat(4, 1fr); }

  .modal-content { max-width: 560px; padding: 22px; }
}

/* Users who prefer reduced motion get no transitions at all */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
