:root {
  --space-navy: #0b1f3a;
  --solar-yellow: #ffd43b;
  --teal: #087f8c;
  --blue: #2166b1;
  --green: #237a57;
  --attention: #a94700;
  --brand-magenta: #087f8c;
  --brand-purple: #e155d4;
  --brand-coral: #fd6b63;
  --brand-orange: #fead1b;
  --brand-yellow: #f5cb14;
  --brand-lime: #aad65d;
  --brand-mint: #57f29f;
  --brand-cyan: #2cebe0;

  --bg: #f7f9fb;
  --fg: #171a1f;
  --muted: #5b677a;
  --border: #dbe3ee;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --input-fg: #111827;
  --input-placeholder: #6b7280;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --content-width: 1440px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);

  --brand-gradient: var(--space-navy);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
}

main.container {
  flex: 1 0 auto;
}

.container {
  max-width: var(--content-width);
  width: 100%;
  margin: 16px auto;
  padding: 0 16px;
}

.hidden {
  display: none !important;
}

.commissioning-panel { max-width: 720px; margin: 32px auto; }
.commissioning-panel .card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin: 16px 0; padding: 18px; }
.commissioning-panel input { display: block; margin: 6px 0 12px; max-width: 12rem; padding: 8px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.commissioning-pin { margin-top: 12px; padding: 12px; border-radius: 8px; background: #fff4c2; font-weight: 700; }

/* Header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 2000;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--solar-yellow);
}

.console-nav { display:flex; justify-content:space-between; gap:12px; padding:10px 16px; border-bottom:3px solid var(--solar-yellow); background:var(--space-navy); overflow-x:auto; }
.console-nav-group { display:flex; gap:4px; align-items:center; white-space:nowrap; }
.console-nav-system { padding-left:12px; border-left:1px solid var(--border); }
.console-nav-link { color:#e6eff8; text-decoration:none; font-weight:700; padding:9px 10px; border-radius:var(--radius-sm); min-height:40px; display:inline-flex; align-items:center; }
.console-nav-link:hover, .console-nav-link:focus-visible { background:#17466f; color:#fff; outline:2px solid var(--solar-yellow); outline-offset:2px; }
.console-nav-link.is-current { background:var(--solar-yellow); color:var(--space-navy); }
.page-eyebrow { color:var(--teal); font-size:11px; font-weight:800; letter-spacing:.09em; text-transform:uppercase; margin:0 0 4px; }
.card-title, .page-title, .section-title, .location-title { color:var(--space-navy); -webkit-text-fill-color:currentColor; }
.technical-evidence { margin-top:16px; border-top:1px solid var(--border); padding-top:12px; }
.technical-evidence summary { cursor:pointer; color:var(--blue); font-weight:700; }
/* The shared shell owns navigation. Legacy per-page overflow menus remain in
   markup for this incremental migration but are not presented twice. */
.topbar .menu-btn, .quicknav, .backdrop { display:none !important; }
@media (max-width: 640px) { .console-nav { padding:8px 12px; } .console-nav-link { padding:8px 9px; } .console-nav-system { border-left:0; padding-left:0; } }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  display: block;
  height: 36px;
  width: 104px;
  object-fit: contain;
  object-position: left center;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.page-title {
  margin: 0;
  justify-self: center;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.menu-btn {
  position: relative;
  z-index: 2101;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.quicknav {
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 2100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(80vw, 260px);
  max-height: calc(100vh - 88px);
  overflow: auto;
  padding: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.quicknav .nav-item {
  width: 100%;
  justify-content: space-between;
}

.quicknav .nav-item.active {
  border-color: var(--brand-magenta);
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 2090;
  background: rgba(0, 0, 0, 0.15);
}

/* Footer */

.footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  color: var(--muted);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
}

.footer #region {
  background: none;
  border: 0;
  padding: 0;
  box-shadow: none;
  border-radius: 0;
  font: inherit;
  color: inherit;
}

/* Common layout */

.tab {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 16px;
  align-items: stretch;
  width: 100%;
}

.card {
  display: flex;
  flex-direction: column;
  margin: 12px 0;
  padding: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-title {
  margin-bottom: 8px;
  font-weight: 800;
  letter-spacing: 0.2px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subname,
.li-subname {
  color: var(--muted);
  font-size: 12px;
  margin-top: -2px;
}

.actions,
.card .actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px 12px;
  align-items: center;
}

.kv strong {
  color: var(--muted);
  font-weight: 600;
}

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

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #111827;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--solar-yellow);
  outline-offset: 2px;
}

.btn-primary {
  border: none;
  color: #ffffff;
  background-image: var(--brand-gradient);
  box-shadow: 0 6px 16px rgba(245, 84, 161, 0.25);
}

.alarm-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  text-decoration: none;
  color: #ffffff;
  background: var(--brand-magenta);
  font-size: 12px;
  font-weight: 800;
}

.alarm-pill:hover {
  opacity: 0.85;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f2f6fb;
  color: #5b677a;
  font-size: 12px;
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-magenta);
}

.muted {
  color: var(--muted);
}

/* Forms */

input,
select,
textarea,
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--input-fg);
  font: inherit;
  caret-color: var(--input-fg);
}

input::placeholder,
textarea::placeholder {
  color: var(--input-placeholder);
  opacity: 1;
}

input:focus,
select:focus,
textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 2px rgba(44, 235, 224, 0.22);
}

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

.field-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.field-help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* Password field */

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: #111827;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.password-toggle:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 8px;
}

/* Lists */

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

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

.li-name {
  font-weight: 800;
  letter-spacing: 0.2px;
}

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

/* Wi-Fi page */

.wifi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.wifi-status-box {
  margin-top: 8px;
}

.wifi-form {
  margin-top: 10px;
}

.wifi-list {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.wifi-list .list-item {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

.wifi-list .list-item:last-child {
  border-bottom: 0;
}

.saved-network-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.wifi-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
}

.wifi-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

.wifi-item.active {
  background: rgba(245, 84, 161, 0.08);
}

.wifi-ssid {
  font-weight: 800;
  letter-spacing: 0.2px;
}

.wifi-sub {
  font-size: 12px;
  margin-top: 2px;
}

.wifi-right {
  display: flex;
  align-items: center;
}

.wifi-signal {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Tables */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.table thead {
  background: #f1f4f8;
}

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

.table tr:last-child td {
  border-bottom: 0;
}

/* Demo/status cards */

.demo-card {
  margin-top: 0;
}

.demo-subtitle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

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

.demo-metric {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfcfe;
  padding: 12px;
}

.demo-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.demo-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  color: #7b1fa2;
}

.demo-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  color: var(--fg);
}

.demo-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.demo-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.demo-filter span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.section-heading,
.section-title {
  margin: 1.25rem 0 0.5rem;
  font-size: 18px;
  font-weight: 800;
  color: var(--fg);
}

/* Charts/history */

.history-block {
  margin-top: 14px;
}

.history-heading {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--fg);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.chart-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
}

.chart-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--fg);
}

.sparkline {
  width: 100%;
  height: 80px;
  display: block;
  color: #7b1fa2;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--fg);
  opacity: 0.72;
}

.history-toggle-row {
  margin-top: 10px;
  margin-bottom: 6px;
}

.history-toggle-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0.85;
}

.history-toggle-btn:hover {
  opacity: 1;
}

.summary-actions {
  display: flex;
  flex: 0 0 auto;
}

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

.summary-header .card-title {
  margin-bottom: 0;
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 0;
}

/* Map */

.device-map {
  width: 100%;
  height: 520px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 12px;
}

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

.device-pin-wrapper {
  background: transparent;
  border: 0;
}

.device-pin {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Network layout */

#network.tab {
  display: block;
}

.network-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.network-layout > .summary-card {
  width: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 16px;
}

.location-block {
  display: block;
}

.location-title {
  margin: 0 0 10px 2px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--fg);
}

.location-cards {
  column-count: 1;
  column-gap: 16px;
  column-fill: balance;
}

.location-cards > .status-card {
  width: 100%;
  margin: 0 0 16px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.status-card .demo-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

/* TreeGuard */

.treeguard-card,
.treeguard-detail-card {
  border-left: 4px solid var(--brand-mint);
}

.treeguard-card .demo-value {
  font-size: 20px;
}

.treeguard-detail-card .demo-value {
  font-size: 22px;
}

.treeguard-card .demo-label::before,
.treeguard-detail-card .demo-label::before {
  content: "🌳 ";
}

.treeguard-card .card-title::after {
  content: " TreeGuard";
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  margin-left: 6px;
}

.treeguards-page .page-section {
  margin-bottom: 1.25rem;
}

.treeguard-list {
  display: grid;
  gap: 1rem;
}

/* Stage 2D: compact operational status and fleet-scale device inventory. */
.operational-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: .75rem;
  margin-top: 1rem;
}
.status-strip-item {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  min-height: 70px;
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--fg);
}
.status-strip-item strong, .status-strip-item small { display: block; }
.status-strip-item small { color: var(--muted); margin-top: .2rem; }
.status-link { text-decoration: none; }
.status-link:hover { border-color: var(--accent); }
.status-shape { flex: 0 0 12px; width: 12px; height: 12px; margin-top: .3rem; border-radius: 50%; background: #8492a6; }
.status-ok { background: #159b8a; }
.status-pending, .status-attention { background: #e2ad16; }
.status-urgent { background: #c94040; }
.status-unavailable, .status-unknown { background: #8492a6; }

.device-toolbar { display:flex; flex-wrap:wrap; gap:.75rem; align-items:end; margin:1rem 0 .5rem; }
.device-toolbar label { display:grid; gap:.3rem; font-size:.9rem; color:var(--muted); }
.device-toolbar select, .device-toolbar input { min-height:36px; padding:.4rem .55rem; }
.device-search-label { min-width:min(100%, 270px); }
.treeguard-inventory { display:grid; gap:.5rem; }
.treeguard-row { display:grid; grid-template-columns:minmax(150px, 1.15fr) minmax(145px, 1fr) minmax(105px, .6fr) minmax(200px, 1.35fr) auto; gap:.8rem; align-items:center; padding:.75rem .85rem; border:1px solid var(--border); border-left:4px solid #159b8a; border-radius:9px; background:var(--card-bg); }
.treeguard-row.needs-attention { border-left-color:#d29d0b; }
.treeguard-row > div { min-width:0; }
.treeguard-row strong, .treeguard-row small { display:block; overflow:hidden; text-overflow:ellipsis; }
.treeguard-row small { margin-top:.2rem; color:var(--muted); font-size:.82rem; }
.device-state { font-size:.85rem; font-weight:700; }
.state-missing { color:#c94040; }
.state-approaching_overdue { color:#b88200; }
.state-sleeping_normal { color:#137d70; }
.device-expand details { margin:0; }
.device-expand summary { white-space:nowrap; }
.device-details { display:grid; grid-template-columns:repeat(2, minmax(130px, 1fr)); gap:.5rem 1rem; margin:.75rem 0 0; }
.device-details div { min-width:0; }
.device-details dt { color:var(--muted); font-size:.78rem; }
.device-details dd { margin:.1rem 0 0; overflow-wrap:anywhere; }
.historical-devices { margin-top:1.5rem; }
.historical-devices > summary { cursor:pointer; font-weight:700; }
.location-form { display:flex; flex-wrap:wrap; gap:.45rem; align-items:end; margin-top:.65rem; }
.location-form label { display:grid; gap:.2rem; font-size:.82rem; color:var(--muted); }
.location-form input { width:9rem; min-height:34px; }
.detection-events { display:grid; grid-template-columns:repeat(auto-fit, minmax(220px, 1fr)); gap:.55rem; margin-top:.65rem; max-height:31rem; overflow:auto; padding-right:.15rem; }
.detection-event { border:1px solid var(--border); border-radius:7px; padding:.55rem .65rem; }
.detection-event strong, .detection-event small { display:block; }
.detection-event small { color:var(--muted); margin-top:.2rem; }
.detection-event details { margin-top:.35rem; }
.event-evidence { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:.35rem .65rem; margin:.5rem 0; }
.event-evidence dt { color:var(--muted); font-size:.76rem; }
.event-evidence dd { margin:0; font-weight:700; }
.event-meta { color:var(--muted); overflow-wrap:anywhere; }
.audible-control { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.7rem .85rem; margin:0 0 .75rem; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--card-bg); }
.audible-control small { display:block; color:var(--muted); margin-top:.15rem; }
.switch-control { display:inline-flex; align-items:center; gap:.45rem; min-height:40px; cursor:pointer; font-weight:700; }
.switch-control input { position:absolute; opacity:0; width:1px; height:1px; }
.switch-control span { position:relative; width:42px; height:24px; border-radius:999px; background:#718096; transition:background .15s; }
.switch-control span::after { content:""; position:absolute; width:18px; height:18px; top:3px; left:3px; border-radius:50%; background:#fff; transition:transform .15s; }
.switch-control input:checked + span { background:var(--teal); }
.switch-control input:checked + span::after { transform:translateX(18px); }
.switch-control input:focus-visible + span { outline:3px solid var(--solar-yellow); outline-offset:3px; }
.alarm-empty { margin:.25rem 0 .75rem; color:var(--green); font-weight:700; }
.alarm-history { margin:.6rem 0; }
.alarm-history > summary { cursor:pointer; font-weight:700; }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }
.map-missing { margin:0 0 12px; }
.map-gesture-hint { position:absolute; z-index:500; bottom:10px; left:50%; transform:translateX(-50%); padding:.35rem .55rem; border-radius:6px; color:#fff; background:rgba(11,31,58,.8); font-size:.8rem; pointer-events:none; }

/* Responsive */

@media (max-width: 900px) {
  .demo-grid,
  .demo-grid-compact,
  .demo-meta {
    grid-template-columns: 1fr 1fr;
  }
  .operational-status { grid-template-columns:repeat(2, minmax(180px, 1fr)); }
  .treeguard-row { grid-template-columns:repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .brand img { height: 30px; width: 88px; }
  .container {
    margin: 12px 0;
    padding: 0 12px;
  }

  .grid,
  .li-grid {
    grid-template-columns: 1fr;
  }
  .operational-status, .treeguard-row { grid-template-columns:1fr; }
  .device-expand { grid-column:auto; }
  .device-details { grid-template-columns:1fr; }
  .detection-events, .event-evidence { grid-template-columns:1fr; max-height:none; }
  .audible-control { align-items:flex-start; }

  .table {
    min-width: 720px;
  }

  .table-wrap {
    margin: 8px 0;
  }

  .li-top {
    align-items: flex-start;
  }

  .brand-title {
    display: none;
  }
}

@media (max-width: 560px) {
  .tab,
  .wifi-grid,
  .demo-grid,
  .demo-grid-compact,
  .demo-meta {
    grid-template-columns: 1fr;
  }

  .demo-value {
    font-size: 20px;
  }

  .summary-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    padding: 10px 12px;
  }

  .page-title {
    font-size: 16px;
  }
}

@media (min-width: 1024px) {
  .card {
    min-height: 220px;
  }
}

@media (min-width: 760px) {
  .location-cards {
    column-count: 2;
  }
}

@media (min-width: 1100px) {
  .desktop-half-card {
    width: 100%;
    max-width: 100%;
  }
}

@media (min-width: 1600px) {
  .location-cards {
    column-count: 3;
  }
}

/* Dark mode */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --fg: #f4f7fb;
    --muted: #a9b3c3;
    --border: #202632;
    --card-bg: #141a22;

    /* Keep actual form controls readable. */
    --input-bg: #ffffff;
    --input-fg: #111827;
    --input-placeholder: #6b7280;
  }

  .topbar,
  .card,
  .quicknav {
    background: var(--card-bg);
    border-color: var(--border);
  }
  .card-title, .page-title, .section-title, .location-title { color:#f4f7fb; }
  a { color:#8dd9e0; }

  .table-wrap {
    background: var(--card-bg);
    border-color: var(--border);
  }

  .table thead {
    background: #1a202a;
  }

  .demo-metric {
    background: #111722;
  }

  .wifi-item:hover {
    background: rgba(255, 255, 255, 0.04);
  }

  .btn {
    background: #ffffff;
    color: #111827;
  }

  .menu-btn {
    background: var(--card-bg);
    color: var(--fg);
  }
}
