/* =============================================================
   static/mock/theme-base.css
   Shared structure and layout for the Mission Control mock UI.
   All color/visual tokens are supplied by theme-lab.css or
   theme-hightech.css via CSS custom properties on the body class.
   ============================================================= */

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

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--color-text);
  background: var(--body-bg);
  min-height: 100vh;
  overflow-x: hidden; /* prevent fixed/absolute children from widening the page */
  transition: background 0.3s, color 0.3s;
}

/* ── Theme switcher bar ─────────────────────────────── */
.mock-theme-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--color-line);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-muted);
  position: sticky;
  top: 0;
  z-index: 200;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.mock-theme-label {
  font-weight: 900;
  color: var(--color-text);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.mock-theme-btn {
  height: 32px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--color-line);
  background: transparent;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.mock-theme-btn:hover {
  color: var(--color-text);
  border-color: var(--color-blue);
}
.mock-theme-btn.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-color);
  border-color: var(--nav-active-border);
}
.mock-theme-note {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.55;
  font-style: italic;
}

/* ── Theme-conditional visibility ───────────────────── */
.theme-only-lab,
.theme-only-hightech { display: none; }
.theme-lab .theme-only-lab         { display: inline; }
.theme-hightech .theme-only-hightech { display: inline; }

/* ── Page shell ─────────────────────────────────────── */
.shell { padding: 24px; }
.canvas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: calc(100vh - 101px);
}

/* ── Screen container ───────────────────────────────── */
.screen {
  background: var(--screen-bg);
  border: 1px solid var(--screen-border);
  border-radius: 24px;
  box-shadow: var(--screen-shadow);
  overflow: hidden;
  min-height: 880px;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 26px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--color-line);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.logo {
  width: 54px; height: 54px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,.85), rgba(240,247,251,.95));
  border: 1px solid var(--color-line);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.logo svg { width: 38px; height: 38px; }
.brand h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.brand-green { color: #58ab7e; }
.brand small { display: block; color: var(--color-muted); margin-top: 3px; font-size: 13px; font-weight: 600; }

/* ── Brand logo (SVG-only, no text beside it) ───────── */
.brand-logo {
  height: 64px;
  width: auto;
  display: block;
  background: var(--logo-bg, transparent);
  border: 1px solid var(--logo-border, transparent);
  border-radius: 10px;
  padding: 4px;
  box-sizing: content-box;
}
.actions { display: flex; gap: 12px; align-items: center; }
.btn, select.fake {
  height: 40px; border-radius: 12px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--color-text); font-weight: 700; padding: 0 16px;
  cursor: pointer; font-family: inherit; font-size: 14px;
  transition: opacity 0.15s, border-color 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover, select.fake:hover {
  opacity: 0.85;
  border-color: var(--color-blue);
}

/* ── Content layout ─────────────────────────────────── */
.content-wrap {
  display: grid;
  grid-template-columns: 168px 1fr;
  flex: 1;
  min-height: 0;
}
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--color-line);
  padding: 18px 16px 20px;
  display: flex;
  flex-direction: column;
}
.nav-icon {
  width: 16px; text-align: center; font-size: 13px; flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 46px; padding: 0 14px;
  border-radius: 12px; color: var(--nav-color);
  font-weight: 700; cursor: pointer; font-size: 14px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: var(--nav-hover-bg, rgba(110,166,201,.08));
  color: var(--color-text);
}
.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-color);
  border-color: var(--nav-active-border);
}
.nav-divider {
  height: 1px; background: var(--color-line);
  margin: 10px 0;
}
.nav-logout {
  margin-top: auto;
}
.screen-main { padding: 18px 22px 24px; overflow: auto; }

/* ── Section title bar (title + action button row) ─── */
.section-title-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin: 6px 0 14px;
}
.section-title-bar .section-title { margin: 0; }
.mc-add-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 6px; font-family: inherit; cursor: pointer;
  color: var(--color-muted); background: transparent; border: 1px solid var(--color-line);
  transition: color .15s, border-color .15s;
}
.mc-add-btn:hover { color: var(--color-blue); border-color: var(--color-blue); }
.mc-add-btn.mc-del-btn:hover { color: var(--color-red); border-color: var(--color-red); }

/* ── Section title ──────────────────────────────────── */
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 19px; font-weight: 800; letter-spacing: -.02em;
  margin: 6px 0 14px;
}

/* ── Room cards ─────────────────────────────────────── */
.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Dynamic grid — columns set inline via style attribute (from route) */
.room-cards-grid { display: grid; gap: 16px; }

.room-card {
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 230px;
  cursor: default;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.room-card.active {
  border-color: var(--color-blue);
  box-shadow: var(--shadow), 0 0 0 2px var(--card-active-glow, rgba(110,166,201,.25));
}
.room-card .header {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 10px;
}
.status {
  display: inline-flex; align-items: center;
  gap: 8px; font-weight: 800; font-size: 15px;
}
.status .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--dot-good);
  box-shadow: 0 0 0 4px var(--dot-good-glow);
}
.status.warning .dot {
  background: var(--dot-warn);
  box-shadow: 0 0 0 4px var(--dot-warn-glow);
}
.badge {
  height: 30px; display: inline-flex; align-items: center;
  padding: 0 12px; border-radius: 999px;
  font-size: 12px; font-weight: 800;
  border: 1px solid var(--color-line);
  color: var(--color-muted);
  background: var(--color-panel-2);
}
.badge.warning, .badge.warn {
  background: var(--badge-warn-bg);
  color: var(--badge-warn-color);
  border-color: var(--badge-warn-border);
}
.badge.good {
  background: var(--chip-good-bg);
  color: var(--chip-good-color);
  border-color: var(--chip-good-border);
}
.badge.alert {
  background: var(--chip-alert-bg);
  color: var(--chip-alert-color);
  border-color: var(--chip-alert-border);
}
.metric-big {
  font-size: 52px; line-height: 1;
  letter-spacing: -.05em; font-weight: 900;
  color: var(--metric-color);
}
.metric-big.red,
.metric-big.alert { color: var(--metric-red-color); }
.metric-big.warn  { color: var(--color-orange); }
.metric-big.good  { color: var(--metric-color); }
.mini-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px 14px; color: var(--color-muted);
  font-size: 13px; font-weight: 700;
}
.mini-grid strong { color: var(--color-text); font-weight: 800; }
.room-actions { margin-top: auto; display: flex; gap: 10px; }
.room-actions .btn { flex: 1; }

/* ── Alerts panel ───────────────────────────────────── */
.alerts {
  margin-top: 18px;
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.alerts .head {
  padding: 18px 20px;
  font-size: 17px; font-weight: 800;
  border-bottom: 1px solid var(--color-line);
  display: flex; justify-content: space-between; align-items: center;
}
.alert-row {
  display: flex; align-items: flex-start;
  gap: 14px;
  padding: 14px 20px;
  border-top: 1px solid var(--color-line);
}
.alert-pill {
  flex-shrink: 0;
  height: 22px; padding: 0 9px;
  border-radius: 999px; display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 900;
  text-transform: uppercase; letter-spacing: .05em;
  margin-top: 2px;
}
.alert-pill.critical { background: var(--chip-alert-bg); color: var(--chip-alert-color); border: 1px solid var(--chip-alert-border); box-shadow: 0 0 0 2px var(--chip-alert-border); }
.alert-pill.alert    { background: var(--pill-alert-bg); color: var(--pill-alert-color); }
.alert-pill.warn     { background: var(--pill-warn-bg);  color: var(--pill-warn-color); }
.alert-pill.info     { background: var(--color-panel-2); color: var(--color-muted); border: 1px solid var(--color-line); }
.alert-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.alert-cat-row { display: flex; align-items: center; gap: 6px; margin-bottom: 1px; }
.alert-cat  {
  font-size: 10px; font-weight: 900; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-muted);
}
.alert-room-tag {
  font-size: 10px; font-weight: 800; letter-spacing: .03em;
  background: var(--color-panel-2); color: var(--color-muted);
  border: 1px solid var(--color-line); border-radius: 4px;
  padding: 0 5px; line-height: 16px;
}
.alert-msg  { font-size: 13px; font-weight: 700; color: var(--alert-row-color); }
.alert-detail { font-size: 11px; font-weight: 600; color: var(--color-muted); margin-top: 2px; }
.alert-empty {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px; font-size: 13px; font-weight: 700; color: var(--color-muted);
}
.alert-all-good { color: var(--color-green); }
.alert-all-good i { font-size: 16px; }
.alerts-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px; font-size: 12px; font-weight: 900;
}
.alerts-count-badge.critical { background: var(--chip-alert-bg); color: var(--chip-alert-color); border: 1px solid var(--chip-alert-border); }
.alerts-count-badge.alert    { background: var(--pill-alert-bg); color: var(--pill-alert-color); }
.alerts-count-badge.warn     { background: var(--pill-warn-bg);  color: var(--pill-warn-color); }
.foot-note { margin-top: 18px; color: var(--foot-note-color); font-size: 13px; font-weight: 700; }
.muted { color: var(--color-muted); }

/* ── Hero / room overview header ────────────────────── */
.hero {
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-line);
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
}
.hero-title { font-size: 18px; font-weight: 900; letter-spacing: -.02em; }
.hero-sub { margin-top: 4px; color: var(--color-muted); font-size: 14px; font-weight: 700; }
.hero-stamp { color: var(--color-muted); font-size: 13px; font-weight: 800; }

/* ── Gauge grid ─────────────────────────────────────── */
.gauge-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.gauge-card, .system-card, .chart-card {
  background: var(--gauge-card-bg);
  border: 1px solid var(--color-line);
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(71,105,130,.06);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow grid items to shrink below content size */
}
.gauge-card-head, .system-card-head, .chart-head {
  display: flex; justify-content: space-between;
  align-items: center; gap: 12px; margin-bottom: 12px;
}
.gauge-card h3, .system-card h3, .chart-card h3 {
  margin: 0; font-size: 18px; font-weight: 900; letter-spacing: -.02em;
}
.status-chip {
  display: inline-flex; align-items: center;
  height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: 12px; font-weight: 900;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status-chip.good  { background: var(--chip-good-bg);  color: var(--chip-good-color);  border-color: var(--chip-good-border); }
.status-chip.warn  { background: var(--chip-warn-bg);  color: var(--chip-warn-color);  border-color: var(--chip-warn-border); }
.status-chip.alert { background: var(--chip-alert-bg); color: var(--chip-alert-color); border-color: var(--chip-alert-border); }

/* ── SVG Arc Gauge ───────────────────────────────────── */
.gauge-wrap {
  position: relative;
  width: 168px; height: 168px;
  margin: 4px auto 14px;
}
.gauge-svg { display: block; width: 100%; height: 100%; }
.gauge-inner {
  fill: var(--gauge-bg);
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.18));
}
.gauge-track {
  fill: none;
  stroke: var(--gauge-arc-empty);
  stroke-width: 18;
  stroke-linecap: round;
}
.gauge-fill {
  fill: none;
  stroke-width: 18;
  stroke-linecap: round;
  transition: stroke-dasharray .55s cubic-bezier(.4,0,.2,1), stroke .3s ease;
}
.gauge-fill.good    { stroke: var(--color-green); }
.gauge-fill.warn    { stroke: var(--color-orange); }
.gauge-fill.alert   { stroke: var(--color-red); }
.gauge-fill.unknown { stroke: var(--gauge-arc-empty); }
.dial-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
  color: var(--color-text);
}
.dial-value  { font-size: 24px; font-weight: 900; letter-spacing: -.04em; }
.dial-label  { margin-top: 4px; font-size: 12px; font-weight: 900; letter-spacing: .12em; color: var(--dial-label-color); text-transform: uppercase; }
.dial-status { margin-top: 6px; font-size: 11px; font-weight: 800; color: var(--dial-status-color); text-transform: uppercase; letter-spacing: .08em; }

/* ── Overview list ──────────────────────────────────── */
.overview-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.overview-list.compact li { font-size: 13px; }
.overview-list li {
  display: flex; justify-content: space-between; gap: 12px;
  color: var(--color-muted); font-size: 14px; font-weight: 700;
  padding-top: 10px; border-top: 1px solid var(--color-line);
}
.overview-list strong { color: var(--color-text); font-weight: 800; }

/* ── System grid ─────────────────────────────────────── */
.system-grid {
  margin-top: 18px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.system-key {
  font-size: 32px; line-height: 1.08; font-weight: 900;
  letter-spacing: -.04em; color: var(--system-key-color); margin-bottom: 14px;
}

/* ── Analytics / charts ─────────────────────────────── */
.analytics-grid { margin-top: 18px; display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }
.chart-range { color: var(--color-muted); font-size: 13px; font-weight: 800; }
.line-chart {
  display: grid;
  grid-template-columns: 42px 1fr;
  grid-template-rows: 1fr auto;
  gap: 10px; align-items: stretch;
}
.chart-y-labels {
  display: flex; flex-direction: column; justify-content: space-between;
  color: var(--color-muted); font-size: 12px; font-weight: 800; padding: 6px 0;
}
.chart-svg {
  width: 100%; height: 220px;
  background: var(--chart-bg);
  border: 1px solid var(--color-line); border-radius: 14px;
}
.line { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.temp-line     { stroke: var(--color-green); }
.humidity-line { stroke: var(--color-blue); }
.co2-line      { stroke: var(--color-orange); }
.chart-x-labels {
  grid-column: 2;
  display: flex; justify-content: space-between;
  color: var(--color-muted); font-size: 12px; font-weight: 800; padding: 0 8px;
}
.chart-legend {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
  margin-top: 12px; color: var(--color-muted); font-size: 13px; font-weight: 800;
}
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.legend-dot.temp, .legend-dot.healthy { background: var(--color-green); }
.legend-dot.humidity                   { background: var(--color-blue); }
.legend-dot.co2, .legend-dot.warning   { background: var(--color-orange); }
.legend-dot.alert                       { background: var(--color-red); }

.bar-chart {
  height: 258px; display: flex; align-items: flex-end;
  justify-content: space-around; gap: 18px;
  padding: 18px 12px 8px;
  background: var(--chart-bg);
  border: 1px solid var(--color-line); border-radius: 14px;
}
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--color-muted); font-size: 12px; font-weight: 800; }
.bar { width: 18px; border-radius: 8px 8px 4px 4px; }
.bar.good { background: var(--color-green); }
.bar.warn { background: var(--color-orange); }
.bar.bad  { background: var(--color-red); }

/* ── Lifts toolbar ──────────────────────────────────── */
.lifts-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 0 0 16px;
}
.ls-select-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 800; color: var(--color-text); cursor: pointer;
  white-space: nowrap;
}
.ls-select-label input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--color-blue); }

/* ── Lifts / Lights room tabs (Chrome-style, same as env-tab-bar) ── */
.lifts-tabs {
  display: flex; align-items: flex-end; gap: 3px;
  padding: 0 2px;
  border-bottom: 1px solid var(--color-line); margin-bottom: 18px;
}
.lifts-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 20px 7px;
  border: 1px solid transparent;
  border-radius: 7px 7px 0 0; margin-bottom: -1px;
  font-size: 13px; font-weight: 700; font-family: inherit;
  color: var(--color-muted); background: transparent;
  cursor: pointer; white-space: nowrap; position: relative;
  transition: color .15s, background .15s, border-color .15s;
  text-decoration: none; user-select: none;
}
.lifts-tab:hover { background: var(--color-panel-2); border-color: var(--color-line); color: var(--color-text); }
.lifts-tab.active {
  background: var(--tab-active-bg);
  border-color: var(--color-line);
  border-bottom-color: var(--tab-active-bg);
  color: var(--color-text);
  position: relative; z-index: 1;
}

/* ── Lifts table rows ───────────────────────────────── */
.lt-grid {
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 14px; overflow: hidden;
}
.lt-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; min-height: 54px;
  border-top: 1px solid var(--color-line);
}
.lt-row:first-child { border-top: 0; }
.lt-cb { flex-shrink: 0; width: 15px; height: 15px; accent-color: var(--color-blue); cursor: pointer; }
.lt-code {
  width: 36px; text-align: center; flex-shrink: 0;
  font-size: 12px; font-weight: 900;
  background: var(--color-panel-2); border: 1px solid var(--color-line);
  border-radius: 7px; padding: 3px 7px; color: var(--color-text);
}
.lt-psu-wrap { display: flex; gap: 8px; align-items: center; flex-shrink: 0; width: 200px; }
.lt-psu-item { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; font-family: monospace; min-width: 42px; }
.lt-psu-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.lt-psu-dot.empty { background: transparent !important; border-width: 2px; border-style: solid; }
.lt-date { font-size: 11px; color: var(--color-muted); font-weight: 700; flex-shrink: 0; width: 84px; }
.lt-desc {
  flex: 1; min-width: 120px;
  font-size: 13px; font-weight: 700; color: var(--color-text);
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 5px 8px; font-family: inherit;
}
.lt-desc:not(:disabled):not([readonly]) { border-color: var(--btn-border); background: var(--btn-bg); }
.lt-actions { display: flex; gap: 5px; align-items: center; flex-shrink: 0; }
.lt-ibtn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; cursor: pointer; color: var(--color-muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.lt-ibtn:hover { background: var(--btn-bg); border-color: var(--btn-border); color: var(--color-text); }
.lt-ibtn.del:hover { color: var(--metric-red-color); border-color: var(--metric-red-color); }
.lt-ibtn:disabled { opacity: 0.22; cursor: not-allowed; pointer-events: none; }
.lt-ibtn.pressing {
  background: var(--color-blue) !important;
  border-color: var(--color-blue) !important;
  color: #fff !important;
}

/* ── Operator modal ─────────────────────────────────── */
.op-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.52); z-index: 9000;
  align-items: center; justify-content: center;
}
.op-modal-overlay.open { display: flex; }
.op-modal {
  background: var(--color-panel); border: 1px solid var(--color-line);
  border-radius: 18px; box-shadow: 0 24px 64px rgba(0,0,0,.35);
  width: 100%; max-width: 480px; margin: 20px; overflow: hidden;
}
.op-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 14px; border-bottom: 1px solid var(--color-line);
}
.op-modal-title { font-size: 15px; font-weight: 900; color: var(--color-text); margin: 0; }
.op-modal-close {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--color-line);
  background: transparent; color: var(--color-muted); font-size: 17px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.op-modal-close:hover { color: var(--color-text); background: var(--btn-bg); }
.op-modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.op-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.op-form-group { display: flex; flex-direction: column; gap: 4px; }
.op-form-label {
  font-size: 11px; font-weight: 800; color: var(--color-muted);
  text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; gap: 5px;
}
.op-form-input {
  height: 38px; border-radius: 10px;
  border: 1px solid var(--btn-border); background: var(--btn-bg);
  color: var(--color-text); font-size: 13px; font-weight: 700;
  padding: 0 11px; font-family: inherit;
}
.op-form-input:focus { outline: none; border-color: var(--color-blue); }
.op-form-small { font-size: 11px; color: var(--color-muted); font-weight: 600; }
.op-modal-divider { height: 1px; background: var(--color-line); }
.op-modal-section { font-size: 13px; font-weight: 900; color: var(--color-text); }
.op-psu-swatch { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.op-modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px 20px 16px; border-top: 1px solid var(--color-line);
}
.btn-primary {
  height: 40px;
  border-radius: 12px;
  border: 1px solid #35517a;
  background: linear-gradient(180deg, #111a2b 0%, #c8dcf0 100%);
  color: var(--color-text);
  font-weight: 700;
  padding: 0 16px;
}
.btn-primary:hover { opacity: 0.88; border-color: #4a78b0; }
.btn-danger {
  height: 40px; border-radius: 12px;
  background: var(--chip-alert-bg, #4a1a1a); color: var(--chip-alert-color, #e05252);
  border: 1px solid var(--chip-alert-border, #7a2a2a);
  font-size: 13px; font-weight: 700; padding: 0 16px; cursor: pointer;
}
.btn-danger:hover { opacity: 0.85; }

/* ── Hardware bus status indicators ─────────────────── */
.hw-status-panel {
  margin-bottom: 14px;
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 14px; overflow: hidden;
}
.hw-status-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px 9px;
  border-bottom: 1px solid var(--color-line);
}
.hw-status-title { font-size: 13px; font-weight: 900; color: var(--color-text); }
.hw-status-list { padding: 8px 0; }
.hw-status-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px;
}
.hw-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  transition: background 0.3s;
}
.hw-status-dot.connecting { background: var(--color-orange); animation: hwPulse 1.2s ease-in-out infinite; }
.hw-status-dot.connected  { background: var(--color-green); }
.hw-status-dot.simulation { background: var(--color-blue-2); }
.hw-status-dot.failed     { background: var(--color-red); }
.hw-status-dot.unknown    { background: var(--color-muted); }
@keyframes hwPulse {
  0%, 100% { opacity: 1; } 50% { opacity: 0.35; }
}
.hw-status-name { font-size: 12px; font-weight: 700; color: var(--color-text); flex: 1; }
.hw-status-label { font-size: 11px; font-weight: 700; color: var(--color-muted); text-transform: capitalize; }

/* ── Lifts grid spinner ─────────────────────────────── */

.ls-spinner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 36px 20px; color: var(--color-muted);
}
.ls-spin-icon {
  width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid var(--color-line);
  border-top-color: var(--color-blue);
  animation: lsSpin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes lsSpin { to { transform: rotate(360deg); } }
.ls-spin-text { font-size: 13px; font-weight: 700; }

/* ── Environmental Trends chart ─────────────────────── */
.env-trends-card {
  margin-top: 14px;
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 14px; overflow: hidden;
}
.env-trends-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px 10px;
  border-bottom: 1px solid var(--color-line);
}
.env-trends-title { font-size: 14px; font-weight: 900; color: var(--color-text); }
.env-trends-period { font-size: 12px; font-weight: 700; color: var(--color-muted); }
.env-trends-wrap { padding: 12px 10px 8px; }

/* ══ Lights room overview card ═══════════════════════════ */
.lx-sched-key {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 800; color: var(--color-text);
  margin-bottom: 12px;
}
.lx-led {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: var(--color-muted);
  transition: background 0.3s;
}
.lx-led.running {
  background: var(--color-green);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
  animation: lx-led-pulse 2.2s ease-in-out infinite;
}
.lx-led.stopped { background: var(--color-orange); box-shadow: none; }
.lx-led.unknown { background: var(--color-muted);  box-shadow: none; }
@keyframes lx-led-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25); }
  50%       { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.08); }
}

.lx-health-dots { display: flex; align-items: center; gap: 8px; }
.lx-health-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 11px; font-weight: 900; color: #fff; flex-shrink: 0;
  line-height: 1;
}
.lx-health-dot.green  { background: var(--color-green); }
.lx-health-dot.orange { background: var(--color-orange); }
.lx-health-dot.red    { background: var(--color-red); }

/* ── Top nav link in right panel header ── */
.topbar-nav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-nav-link {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700;
  color: var(--color-muted); text-decoration: none;
  padding: 5px 12px; border-radius: 8px;
  border: 1px solid var(--color-line);
  background: transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.topbar-nav-link:hover {
  color: var(--color-text);
  background: var(--color-panel-2);
  border-color: var(--color-muted);
}

/* ══ Lights panel ════════════════════════════════════════ */
.lx-check-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
  color: var(--color-muted);
  background: var(--color-panel-2);
  border: 1px solid var(--color-line);
  cursor: pointer; transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.lx-check-btn:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-panel);
  border-color: var(--color-muted);
}
.lx-check-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.lx-status-bar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 8px 0 14px;
}
.lx-status-item { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--color-muted); }
.lx-status-item strong { color: var(--color-text); }

.lx-card {
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 14px; overflow: hidden;
  margin-bottom: 16px;
}
.lx-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px 11px;
  border-bottom: 1px solid var(--color-line);
  font-size: 14px; font-weight: 900; color: var(--color-text); gap: 10px;
}
.lx-card-body { padding: 18px; }
.lx-card-body--flush { padding: 0; }

/* ── Channel sliders ── */
.lx-channel-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 900px) { .lx-channel-grid { grid-template-columns: repeat(2, 1fr); } }
.lx-ch-wrap { display: flex; flex-direction: column; gap: 6px; }
.lx-ch-label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--color-text); }
.lx-ch-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.lx-ch-val { font-size: 12px; color: var(--color-muted); font-weight: 700; margin-left: 2px; }
.lx-slider-wrap { position: relative; height: 24px; }
.lx-slider-offzone {
  position: absolute; top: 8px; left: 0; height: 8px;
  background: repeating-linear-gradient(45deg, rgba(220,53,69,.18), rgba(220,53,69,.18) 4px, rgba(220,53,69,.30) 4px, rgba(220,53,69,.30) 8px);
  border-radius: 4px 0 0 4px; pointer-events: none; z-index: 1;
}
.lx-slider {
  position: absolute; top: 0; left: 0; width: 100%;
  z-index: 2; cursor: pointer; margin: 0;
  -webkit-appearance: none; appearance: none;
  height: 24px; background: transparent;
}
.lx-slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--color-blue) 0%, var(--color-blue) var(--fill, 0%), var(--color-line) var(--fill, 0%), var(--color-line) 100%);
}
.lx-slider::-moz-range-track {
  height: 6px; border-radius: 3px; background: var(--color-line);
}
.lx-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--color-blue); border: 2px solid var(--color-bg);
  margin-top: -5px; cursor: pointer;
}
.lx-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--color-blue); border: 2px solid var(--color-bg); cursor: pointer;
}
.lx-ch-range { font-size: 11px; color: var(--color-muted); font-weight: 600; }
.lx-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ── Schedule entries ── */
.lx-sched-entry {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--color-line);
  background: var(--color-panel-2);
  margin-bottom: 8px; cursor: default;
}
.lx-sched-info { display: flex; flex-direction: column; gap: 2px; min-width: 130px; }
.lx-sched-nm { font-size: 13px; font-weight: 800; color: var(--color-text); }
.lx-sched-time { font-size: 12px; color: var(--color-muted); font-weight: 600; }
.lx-sched-levels { flex: 1; font-size: 12px; color: var(--color-text); font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.lx-ch-pip { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 2px; }
.lx-sched-actions { display: flex; gap: 6px; margin-left: auto; }
.lx-sched-edit-btn, .lx-sched-del-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--color-line);
  background: transparent; cursor: pointer; color: var(--color-muted);
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  transition: color 0.15s, background 0.15s;
}
.lx-sched-edit-btn:hover { color: var(--color-blue); background: rgba(67,198,255,.08); }
.lx-sched-del-btn:hover  { color: var(--color-red);  background: rgba(255,93,108,.10); }
.lx-empty-note { font-size: 13px; color: var(--color-muted); font-weight: 600; padding: 6px 0; }

/* ── PSU telemetry ── */
.lx-telem-group { border-bottom: 1px solid var(--color-line); }
.lx-telem-group:last-child { border-bottom: none; }
.lx-telem-header {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 18px; cursor: pointer; user-select: none;
  font-size: 13px; color: var(--color-text);
  transition: background 0.15s;
}
.lx-telem-header:hover { background: var(--color-panel-2); }
.lx-telem-chevron { color: var(--color-muted); font-size: 11px; transition: transform 0.2s; }
.lx-telem-header.lx-collapsed .lx-telem-chevron { transform: rotate(-90deg); }
.lx-telem-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.lx-telem-desc { color: var(--color-muted); font-size: 12px; font-weight: 600; }
.lx-telem-detail { overflow: hidden; transition: max-height 0.3s ease; }
.lx-telem-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px; color: var(--color-text);
}
.lx-telem-table thead tr { background: var(--color-panel-2); }
.lx-telem-table th {
  padding: 7px 14px; text-align: left; font-weight: 800;
  font-size: 11px; color: var(--color-muted); white-space: nowrap;
  border-bottom: 1px solid var(--color-line);
}
.lx-telem-table td { padding: 7px 14px; border-bottom: 1px solid var(--color-line); vertical-align: middle; }
.lx-telem-table tr:last-child td { border-bottom: none; }
.lx-muted { color: var(--color-muted) !important; }
.lx-badge {
  display: inline-block; padding: 2px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 800; letter-spacing: .02em;
}
.lx-badge-on  { background: var(--chip-good-bg);   color: var(--chip-good-color); }
.lx-badge-off { background: rgba(100,120,150,.15); color: var(--color-muted); }
.lx-badge-err { background: var(--chip-alert-bg);  color: var(--chip-alert-color); }

/* ── Section placeholder (right pane stubs) ─────────── */
.pane-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 400px;
}
.placeholder-body {
  text-align: center;
  padding: 40px;
}
.placeholder-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--color-text);
  margin-bottom: 12px;
}
.placeholder-sub {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-muted);
}

/* ── System card Manage button ───────────────────────── */
.system-card-manage {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: auto; padding-top: 14px;
  padding-bottom: 2px;
  padding-left: 14px; padding-right: 14px;
  border-radius: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: var(--color-blue); border: 1px solid var(--color-blue);
  background: transparent; text-decoration: none;
  transition: background .15s, color .15s;
}
.system-card-manage:hover { background: var(--color-blue); color: #fff; }

/* ── Environment browser-style tabs (Chrome-style) ──── */
.env-tab-bar {
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--color-line);
  margin-bottom: 18px;
  padding: 0 2px;
  gap: 3px;
}
.env-tab {
  padding: 8px 20px 7px;
  font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  font-family: inherit;
  color: var(--color-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px 7px 0 0;
  margin-bottom: -1px;
  position: relative;
  transition: color .15s, background .15s, border-color .15s;
}
.env-tab:hover {
  color: var(--color-text);
  background: var(--color-panel-2);
  border-color: var(--color-line);
}
.env-tab.active {
  color: var(--color-text);
  background: var(--tab-active-bg);
  border-color: var(--color-line);
  border-bottom-color: var(--tab-active-bg);
  z-index: 1;
}

/* ══ Environment panel ═══════════════════════════════ */
.env-device-card {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--color-line);
}
.env-device-card:last-child { border-bottom: none; }
.env-device-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.env-device-name { font-size: 13px; font-weight: 800; color: var(--color-text); }
.env-device-sub  { font-size: 12px; color: var(--color-muted); }
.env-hw-state    { font-size: 11px; color: var(--color-muted); min-height: 14px; }
.env-table-badge {
  font-size: 10px; font-weight: 700; background: var(--color-panel-2);
  border: 1px solid var(--color-line); border-radius: 4px;
  padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}
.env-device-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.env-state-btns     { display: flex; gap: 4px; }
.env-state-btn {
  padding: 4px 11px; border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--color-line); background: var(--color-panel-2); color: var(--color-muted);
  transition: background .12s, color .12s, border-color .12s;
}
.env-state-btn:disabled { opacity: .45; cursor: not-allowed; }
.env-state-btn.env-state-active.env-state-on  { background: var(--color-green);  color: #fff; border-color: var(--color-green); }
.env-state-btn.env-state-active.env-state-off { background: var(--color-red);    color: #fff; border-color: var(--color-red); }
.env-state-btn.env-state-active.env-state-auto{ background: var(--color-blue);   color: #fff; border-color: var(--color-blue); }

.env-sched-entry {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--color-line);
}
.env-sched-entry:last-child { border-bottom: none; }
.env-sched-info    { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.env-sched-name    { font-size: 13px; font-weight: 800; color: var(--color-text); }
.env-sched-time    { font-size: 12px; color: var(--color-muted); }
.env-sched-devices { font-size: 11px; color: var(--color-muted); }

.env-checkboxes {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 160px; overflow-y: auto;
  padding: 8px; background: var(--color-panel-2);
  border: 1px solid var(--color-line); border-radius: 6px;
}
.env-cb-label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; color: var(--color-text); }

.env-days-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.env-day-btn {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--color-line); background: var(--color-panel-2);
  color: var(--color-muted); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.env-day-btn.env-day-sel { background: var(--color-blue); color: #fff; border-color: var(--color-blue); }

.env-btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--color-line); background: transparent; color: var(--color-muted);
  font-size: 12px; transition: background .12s, color .12s;
}
.env-btn-icon:hover { background: var(--color-panel-2); color: var(--color-text); }

/* ══ Sensors panel ══════════════════════════════════ */
.sx-sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.sx-sensor-card {
  background: var(--color-panel-2);
  border: 1px solid var(--color-line);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sx-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.sx-sensor-name { font-size: 13px; font-weight: 700; color: var(--color-text); }
.sx-sensor-meta { font-size: 11px; color: var(--color-muted); margin-top: 2px; }
.sx-health-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(0,0,0,.1); margin-top: 2px;
}
.sx-health-dot.green  { background: var(--color-green);  box-shadow: 0 0 6px rgba(82,196,110,.5); }
.sx-health-dot.orange { background: var(--color-orange); box-shadow: 0 0 6px rgba(255,155,66,.5); }
.sx-health-dot.red    { background: var(--color-red);    box-shadow: 0 0 6px rgba(255,100,64,.5); }
.sx-readings { display: flex; flex-direction: column; gap: 0; }
.sx-reading-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0;
  border-top: 1px solid var(--color-line);
}
.sx-reading-row:first-child { border-top: none; }
.sx-reading-label {
  font-size: 12px; color: var(--color-muted);
  display: flex; align-items: center; gap: 5px;
}
.sx-reading-value {
  font-size: 18px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sx-no-data { font-size: 13px; font-weight: 400; color: var(--color-muted); }
.sx-val-temp  { color: var(--color-red); }
.sx-val-humid { color: var(--color-blue); }
.sx-val-co2   { color: #8b5cf6; }
.sx-val-soil  { color: var(--color-green); }
.sx-footer {
  font-size: 11px; color: var(--color-muted);
  border-top: 1px solid var(--color-line);
  padding-top: 6px; margin-top: 2px;
}
.sx-empty {
  text-align: center; padding: 28px 16px;
  color: var(--color-muted); font-size: 13px; line-height: 2;
}
.sx-empty i { font-size: 26px; display: block; margin-bottom: 6px; opacity: .5; }
.sx-section-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; border-radius: 11px;
  background: var(--color-panel); border: 1px solid var(--color-line);
  font-size: 11px; font-weight: 700; color: var(--color-muted); padding: 0 6px;
}

/* ── Sensor threshold admin editor ─────────────────── */
.thr-section {
  border: 1px solid var(--color-line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--color-panel-2);
}
.thr-section-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.thr-section-title { font-size: 14px; font-weight: 800; color: var(--color-text); }
.thr-unit-badge {
  font-size: 11px; font-weight: 700; color: var(--color-muted);
  background: var(--color-panel); border: 1px solid var(--color-line);
  border-radius: 6px; padding: 2px 8px;
}
.thr-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.thr-field-group {
  display: flex; flex-direction: column; gap: 6px;
}
.thr-group-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-muted);
  margin-bottom: 2px;
}
.thr-field-group label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; font-weight: 700; color: var(--color-muted);
}
.thr-field-group label input.lx-input { margin-top: 2px; }
@media (max-width: 900px) {
  .thr-fields { grid-template-columns: 1fr 1fr; }
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 1500px) {
  .canvas { grid-template-columns: 1fr; }
  .screen { min-height: 720px; }
}
@media (max-width: 980px) {
  .content-wrap { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--color-line); }
  .cards-3, .analytics-grid { grid-template-columns: 1fr; }
  /* gauge-grid and system-grid handled by explicit range breakpoints below */
  .topbar { height: auto; padding: 18px; flex-wrap: wrap; }
  .mock-theme-bar { flex-wrap: wrap; gap: 8px; }
  .mock-theme-note { margin-left: 0; }
}

/* ── Tablet (768 – 1023px) ──────────────────────────── */
@media (max-width: 1023px) {
  /* Lifts PSU column can shrink on tablet */
  .lt-psu-wrap { width: 160px; }
}

/* Gauge + system grids: explicit column rules independent of cascade order.
   641–1023px → 2 columns (comfortable fit at those widths).
   ≤640px     → 1 column  (safe floor for narrow panels).                  */
@media (min-width: 641px) and (max-width: 1023px) {
  .gauge-grid  { grid-template-columns: repeat(2, 1fr); }
  .system-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .gauge-grid  { grid-template-columns: 1fr; }
  .system-grid { grid-template-columns: 1fr; }
}

/* ── Mobile (< 768px) ───────────────────────────────── */
@media (max-width: 767px) {
  /* Charts and canvases must not exceed the viewport */
  canvas { max-width: 100%; }

  /* Lights telemetry table: allow horizontal scroll inside the card
     while preserving the max-height collapse animation (overflow-y stays
     hidden via the shorthand set earlier; override only x here).          */
  .lx-telem-detail { overflow-x: auto !important; }
  .lx-telem-table  { min-width: 420px; }

  /* Shell padding tighter */
  .shell       { padding: 10px 10px 18px; }
  .screen-main { padding: 12px 14px 18px; }

  /* PRIMARY FIX — Mission Control room cards: single-column stack.
     !important is required to override the server-injected inline style
     grid-template-columns: repeat(N, 1fr) on .room-cards-grid            */
  .room-cards-grid { grid-template-columns: 1fr !important; }

  /* Scale down the large temperature number so it fits inside a 1-column card */
  .metric-big { font-size: 36px; }

  /* Brand logo: slightly smaller so topbar doesn't push to two lines */
  .brand-logo { height: 46px; }

  /* Sidebar nav: switch to a wrapping horizontal row to save vertical space */
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
  }
  .nav-item   { height: 36px; padding: 0 10px; font-size: 13px; }
  .nav-logout { margin-top: 0; }
  .nav-divider {
    width: 1px; height: 20px;
    margin: auto 4px; align-self: center;
  }
  /* Demo status card must go full-width when sidebar is horizontal */
  .demo-status-card { width: 100%; margin-top: 4px; }

  /* Section title row: wrap so Add/Delete buttons don't push off-screen */
  .section-title-bar { flex-wrap: wrap; gap: 8px; }

  /* Lifts rows are too wide for mobile — allow the table to scroll internally.
     The page itself stays at 100vw with no horizontal overflow.              */
  .lt-grid { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .lt-row  { min-width: 500px; flex-wrap: nowrap; }
  /* Relax fixed width columns so they don't add unnecessary minimum width */
  .lt-psu-wrap { width: 160px; }
  .lt-date     { width: 70px; }

  /* Gauge grid: tighter padding/gap on mobile */
  .gauge-grid  { padding: 12px; gap: 12px; }

  /* Card head: allow wrapping so long h3 + status chip don't overflow */
  .gauge-card-head, .system-card-head { flex-wrap: wrap; gap: 6px; }
  .gauge-card h3, .system-card h3     { font-size: 15px; }

  /* Gauges: a bit smaller so they still fit in a collapsed 1-column panel */
  .gauge-wrap { width: 136px; height: 136px; }

  /* Theme-switcher bar: compact buttons, hide the note to save space */
  .mock-theme-btn  { padding: 0 10px; height: 28px; font-size: 11px; }
  .mock-theme-note { display: none; }

  /* Modal margins inside viewport */
  .op-modal { margin: 12px; max-width: calc(100vw - 24px); }
}

/* ── Small mobile (< 480px) ─────────────────────────── */
@media (max-width: 480px) {
  /* Further metric scaling */
  .metric-big { font-size: 30px; }

  /* Light channel sliders: single column on very small screens */
  .lx-channel-grid { grid-template-columns: 1fr; }

  /* Sensor threshold fields: single column */
  .thr-fields { grid-template-columns: 1fr; }

  /* Smaller gauge */
  .gauge-wrap { width: 118px; height: 118px; }

  /* Dial text scales with gauge */
  .dial-value  { font-size: 20px; }
  .dial-label  { font-size: 10px; }

  /* Analytics chart: don't force tall container on small screen */
  .chart-svg { height: 160px; }

  /* Theme switcher label hidden to save space */
  .mock-theme-label { display: none; }
}
