:root {
  --color-bg: #f6f8fb;
  --color-surface: #ffffff;
  --color-surface-subtle: #f8fafc;
  --color-surface-muted: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-subtle: #94a3b8;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-soft: #eff6ff;
  --color-success: #16a34a;
  --color-success-soft: #f0fdf4;
  --color-warning: #d97706;
  --color-warning-soft: #fffbeb;
  --color-danger: #dc2626;
  --color-danger-soft: #fef2f2;
  --color-info: #0891b2;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-control: 8px;
  --radius-card: 8px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-popover: 0 16px 40px rgba(15, 23, 42, 0.12);
  --duration-fast: 160ms;
  --content-max: 1600px;

  /* Backwards-compatible aliases used by the existing page styles. */
  --bg: var(--color-bg);
  --panel: var(--color-surface);
  --soft: var(--color-surface-muted);
  --line: var(--color-border);
  --strong: var(--color-border-strong);
  --text: var(--color-text);
  --muted: var(--color-text-muted);
  --blue: var(--color-primary);
  --green: var(--color-success);
  --cyan: var(--color-info);
  --amber: var(--color-warning);
  --red: var(--color-danger);
  --shadow: var(--shadow-card);
  --shadow-sm: var(--shadow-card);
  --shadow-md: var(--shadow-popover);
  --radius: var(--radius-control);
}

html {
  width: 100%;
  max-width: 100%;
  background: var(--color-bg);
  color-scheme: light;
  overflow-x: clip;
  scrollbar-gutter: stable;
}

body {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  overflow-x: clip;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
}

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

img,
video,
svg,
canvas {
  max-width: 100%;
}

img,
video {
  height: auto;
}

main,
.shell,
.content,
.topbar,
.panel,
.grid,
[class*="-grid"] {
  min-width: 0;
  max-width: 100%;
}

input,
select,
textarea,
button {
  max-width: 100%;
}

.token,
code,
pre,
.detail strong,
.hint,
.note,
.subtitle {
  overflow-wrap: anywhere;
}

body,
button,
input,
select,
textarea {
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

button,
a,
input,
select,
textarea {
  transition-duration: var(--duration-fast);
  transition-timing-function: ease;
}

button,
.link-button,
.record-tab,
.settings-tab {
  min-height: 40px;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none !important;
  transform: none !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
select,
textarea {
  min-height: 40px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background-color: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.02);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):hover,
select:hover,
textarea:hover {
  border-color: #94a3b8;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

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

.shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  background: var(--color-bg);
}

.sidebar {
  width: 232px;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4) var(--space-4);
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: none;
}

.brand {
  gap: var(--space-2);
  padding: 0 var(--space-2) var(--space-2);
}

.brand-logo-link {
  width: 100%;
  max-width: 188px;
  padding: 0;
  border-radius: var(--radius-control);
}

.brand-logo-link:hover {
  opacity: 0.9;
}

.brand-sub {
  max-width: 100%;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav a,
.nav a.live-active {
  position: relative;
  height: 40px;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.nav a:hover,
.nav a.live-active:hover {
  border-color: var(--color-border);
  background: var(--color-surface-subtle);
  color: var(--color-text);
}

.nav a.active,
.nav a.active.live-active {
  border-color: #dbeafe;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 700;
}

.nav a .nav-dot,
.logout-button .nav-dot {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  background: currentColor;
}

.nav a.live-active .nav-dot {
  background: currentColor;
  box-shadow: none;
  animation: none;
}

.logout-button {
  min-height: 40px;
  margin-top: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.logout-button .nav-dot {
  background: currentColor;
}

.logout-button:hover {
  border-color: #fecaca;
  background: var(--color-danger-soft);
  color: #b91c1c;
  transform: none;
}

.side-panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface-subtle);
  box-shadow: none;
}

.content {
  width: 100%;
  min-width: 0;
  padding: var(--space-6) 28px;
  gap: var(--space-5);
}

.content > * {
  width: min(100%, var(--content-max));
  margin-inline: auto;
}

.topbar,
.panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.topbar {
  min-height: 72px;
  padding: var(--space-4) var(--space-5);
}

.topbar h1,
.content h1 {
  margin: 0;
  color: var(--color-text);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0;
}

.subtitle,
.note,
.hint,
.side-meta {
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.65;
}

.panel h2,
.section-title {
  color: var(--color-text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0;
}

.panel h2 {
  margin: 0 0 var(--space-5);
  padding: 0 0 var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.status,
.status-pill,
.summary-pill,
.test-clock,
.legend-chip {
  min-height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: none;
}

.status::before,
.status-pill::before,
.summary-pill::before {
  width: 7px;
  height: 7px;
  box-shadow: none;
  animation: none;
}

.status.ok,
.status-pill.good,
.status-pill.excellent {
  border-color: #bbf7d0;
  background: var(--color-success-soft);
  color: #166534;
}

.status.warn,
.status-pill.fair,
.status-pill.weak {
  border-color: #fde68a;
  background: var(--color-warning-soft);
  color: #92400e;
}

.status.bad,
.status-pill.very_weak {
  border-color: #fecaca;
  background: var(--color-danger-soft);
  color: #991b1b;
}

.primary,
button.primary,
.metric-select-toggle,
.live-config-button {
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.16);
}

.primary:hover,
button.primary:hover,
.metric-select-toggle:hover,
.live-config-button:hover,
.live-config-button[aria-expanded="true"] {
  border-color: var(--color-primary-hover);
  background: var(--color-primary-hover);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.18);
  transform: none;
}

.secondary,
button.secondary,
.export-button,
.layout-button,
.record-tab,
.date-step,
.date-display,
.date-shortcut {
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: #334155;
  box-shadow: none;
}

.secondary:hover,
button.secondary:hover,
.export-button:hover,
.layout-button:hover,
.record-tab:hover,
.date-step:hover,
.date-display:hover,
.date-shortcut:hover {
  border-color: #94a3b8;
  background: var(--color-surface-subtle);
  color: var(--color-text);
  box-shadow: none;
  transform: none;
}

.message,
.error,
.empty {
  border-radius: var(--radius-control);
  font-size: 13px;
  line-height: 1.6;
}

.message {
  border: 1px solid #bbf7d0;
  background: var(--color-success-soft);
  color: #166534;
}

.message.error,
.error {
  border: 1px solid #fecaca;
  background: var(--color-danger-soft);
  color: #991b1b;
}

[aria-busy="true"] {
  cursor: progress;
}

.mobile-nav-toggle,
.sidebar-backdrop,
.mobile-app-bar {
  display: none;
}

/* Live monitor */
.page-live {
  overflow-y: auto;
}

.page-live .topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-live .topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.page-live .live-config-button {
  height: 40px;
  min-height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-control);
  font-size: 13px;
}

.page-live .live-config-button::before {
  width: 16px;
  height: 16px;
}

.page-live .test-clock {
  height: 40px;
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-control);
  gap: var(--space-2);
}

.page-live .test-clock span:first-child {
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
}

.page-live .test-clock span:last-child {
  color: var(--color-text);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.page-live .status {
  height: 40px;
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-control);
  font-size: 12px;
}

.page-live .live-metric-popover {
  width: min(680px, calc(100dvi - 32px));
  max-height: min(620px, calc(100dvh - 112px));
  overflow: auto;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
}

.page-live .live-metric-popover-head {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.page-live .live-metric-actions button,
.page-live .live-metric-group-actions button {
  min-height: 32px;
  height: 32px;
  border-color: var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 11px;
  box-shadow: none;
}

.page-live .live-spark-toggle,
.page-live .live-metric-option {
  border-color: var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-subtle);
}

.page-live .metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  min-height: 0;
}

.page-live .metric-section {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.page-live .metric-section:not(:has(.metric:not(.is-hidden-by-user))) {
  display: none;
}

.page-live .metric-section.is-empty-by-user {
  display: none;
}

.page-live .metric-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-1);
}

.page-live .metric-section-title {
  margin: 0;
  color: var(--color-text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
}

.page-live .metric-section-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: minmax(164px, auto);
  align-items: stretch;
  gap: var(--space-3);
  min-width: 0;
}

.page-live .metric {
  --card-bg: var(--color-surface);
  --card-border: var(--color-border);
  --card-accent: var(--color-primary);
  box-sizing: border-box;
  min-width: 0;
  min-height: 164px;
  height: auto;
  padding: 16px 16px 18px;
  gap: 10px;
  justify-content: flex-start;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  cursor: default;
  overflow: hidden;
  transition-property: border-color, box-shadow, background-color;
}

.page-live .metric[role="button"] {
  cursor: pointer;
}

.page-live .primary-section .metric {
  min-height: 168px;
}

.page-live .metric::before {
  inset: -1px -1px auto;
  width: auto;
  height: 3px;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  background: var(--card-accent);
  opacity: 1;
}

.page-live .metric.wind,
.page-live .metric.windmax,
.page-live .metric.windday,
.page-live .metric.windweek,
.page-live .metric.windmonth,
.page-live .metric.windavg,
.page-live .metric.direction {
  --card-bg: var(--color-surface);
  --card-border: var(--color-border);
  --card-accent: #2563eb;
}

.page-live .metric.temp,
.page-live .metric.tempmax,
.page-live .metric.tempmin,
.page-live .metric.humidity,
.page-live .metric.wbgt,
.page-live .metric.wbgt-index-card {
  --card-bg: var(--color-surface);
  --card-border: var(--color-border);
  --card-accent: #d97706;
}

.page-live .metric.rainday,
.page-live .metric.rain10,
.page-live .metric.rainhour,
.page-live .metric.rain24,
.page-live .metric.rainevent {
  --card-bg: var(--color-surface);
  --card-border: var(--color-border);
  --card-accent: #0891b2;
}

.page-live .metric.pressure,
.page-live .metric.light {
  --card-bg: var(--color-surface);
  --card-border: var(--color-border);
  --card-accent: #64748b;
}

.page-live .metric[role="button"]:hover {
  border-color: var(--color-border-strong);
  background: #fcfdff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.page-live .metric-label {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.page-live .metric-value {
  flex: 0 0 auto;
  box-sizing: border-box;
  min-height: 58px;
  margin: auto 0 0;
  padding: 10px 0 2px;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}

.page-live .metric-value .value,
.page-live #wind_direction.value {
  color: var(--color-text);
  font-size: 36px !important;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.page-live .primary-section .metric-value .value {
  font-size: 42px !important;
}

.page-live .unit {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}

.page-live .metric-text-value {
  min-height: 58px;
  display: flex;
  align-items: center;
  margin: auto 0 0;
  padding-top: 10px;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.page-live .metric.text-only.safe .metric-text-value {
  color: var(--color-success);
}

.page-live .metric.text-only.caution .metric-text-value,
.page-live .metric.text-only.alert .metric-text-value {
  color: var(--color-warning);
}

.page-live .metric.text-only.severe .metric-text-value,
.page-live .metric.text-only.danger .metric-text-value {
  color: var(--color-danger);
}

.page-live .sparkline {
  flex: 0 0 28px;
  height: 28px;
  opacity: 0.78;
}

.page-live .metrics[data-sparklines="off"] .metric-value,
.page-live .metrics[data-sparklines="off"] .metric-text-value {
  margin-top: auto;
  margin-bottom: 0;
}

.page-live .metric.direction .metric-body {
  margin-top: 0 !important;
}

.page-live .metric.direction .metric-value {
  margin: 0 !important;
}

.page-live .compass {
  border-color: var(--color-border-strong);
  background: var(--color-surface-subtle);
  box-shadow: none;
}

/* History and graph toolbars */
.page-history,
.page-graph {
  height: 100vh;
  overflow: hidden;
}

.page-history .shell,
.page-graph .shell,
.page-history .content,
.page-graph .content {
  min-height: 0;
  height: 100vh;
}

.page-history .content,
.page-graph .content {
  overflow: hidden;
  padding-top: var(--space-5);
  padding-bottom: var(--space-5);
}

.page-history .panel,
.page-graph .panel {
  height: 100%;
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.page-history .panel-toolbar,
.page-graph .panel-toolbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.page-history .panel-actions,
.page-graph .panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.page-history .summary-pill,
.page-graph .record-toolbar-heading .summary-pill {
  height: 36px;
  min-height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-control);
  background: var(--color-surface-subtle);
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.page-graph .record-toolbar-heading .summary-pill {
  margin: 0;
}

.page-history .summary-pill::before,
.page-graph .record-toolbar-heading .summary-pill::before {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
  flex: 0 0 auto;
}

.page-history .record-tabs,
.page-graph .record-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page-history .panel-record-tabs,
.page-graph .panel-record-tabs {
  grid-row: auto;
  order: 1;
}

.page-graph .panel-actions > .column-count-toggle { order: 2; }
.page-history .panel-actions > .date-control,
.page-graph .panel-actions > .date-control { order: 4; }
.page-history .panel-actions > .export-actions,
.page-graph .panel-actions > .export-actions { order: 5; }

.page-history .view-mode-toggle,
.page-graph .view-mode-toggle,
.page-graph .chart-layout-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-muted);
}

.page-history .record-tab,
.page-graph .record-tab,
.page-graph .layout-button {
  height: 32px;
  min-height: 32px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  box-shadow: none;
}

.page-history .record-tab.active,
.page-graph .record-tab.active,
.page-graph .layout-button.active {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.page-history .metric-select-toggle,
.page-graph .metric-select-toggle {
  height: 40px;
  min-height: 40px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: #ffffff;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.16);
}

.page-history .date-control,
.page-graph .date-control {
  display: grid;
  gap: 3px;
}

.page-history .date-control-label,
.page-graph .date-control-label {
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  line-height: 1;
}

.page-history .date-nav,
.page-graph .date-nav {
  display: grid;
  grid-template-columns: 36px minmax(144px, auto) 36px;
  gap: var(--space-1);
}

.page-history .date-step,
.page-graph .date-step,
.page-history .date-display,
.page-graph .date-display {
  height: 36px;
  min-height: 36px;
  border-radius: var(--radius-control);
}

.page-history .date-step,
.page-graph .date-step {
  width: 36px;
  padding: 0;
  font-size: 18px;
}

.page-history .date-display,
.page-graph .date-display {
  min-width: 144px;
  padding: 0 var(--space-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.page-history .export-actions,
.page-graph .export-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.page-history .export-button,
.page-graph .export-button {
  height: 36px;
  min-height: 36px;
  min-width: 58px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: #334155;
  font-size: 12px;
  box-shadow: none;
}

.page-history .export-button.csv,
.page-history .export-button.pdf,
.page-graph .export-button.png,
.page-graph .export-button.pdf {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
  color: #334155;
}

.page-history .export-button:hover,
.page-graph .export-button:hover,
.page-history .export-button.csv:hover,
.page-history .export-button.pdf:hover,
.page-graph .export-button.png:hover,
.page-graph .export-button.pdf:hover {
  border-color: #94a3b8;
  background: var(--color-surface-subtle);
  color: var(--color-text);
}

.page-history .item-picker-overlay,
.page-graph .item-picker-overlay {
  display: contents;
}

.page-history .metric-tabs,
.page-graph .metric-tabs {
  position: fixed;
  left: var(--metric-picker-left, 24px);
  top: var(--metric-picker-top, 80px);
  z-index: 200;
  width: var(--metric-picker-width, min(760px, calc(100% - 48px)));
  max-width: calc(100% - 24px);
  max-height: min(520px, calc(100dvh - 96px));
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
}

.page-history .item-picker-scroll-body,
.page-graph .item-picker-scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--space-4);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.page-history .metric-tab-controls,
.page-graph .metric-tab-controls {
  display: flex;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.page-history .metric-tab-groups,
.page-graph .metric-tab-groups {
  display: grid;
  gap: var(--space-4);
  padding-top: var(--space-4);
}

.page-history .metric-tab-group + .metric-tab-group,
.page-graph .metric-tab-group + .metric-tab-group {
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.page-history .metric-tab-group-title,
.page-graph .metric-tab-group-title {
  margin-bottom: var(--space-2);
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.page-history .metric-tab-grid,
.page-graph .metric-tab-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.page-history .metric-tab,
.page-graph .metric-tab,
.page-history .metric-tab.control,
.page-graph .metric-tab.control,
.page-history .metric-tab.control[data-action],
.page-graph .metric-tab.control[data-action] {
  height: 34px;
  min-height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: #475569;
  font-size: 12px;
  box-shadow: none;
}

.page-history .metric-tab:hover,
.page-graph .metric-tab:hover,
.page-history .metric-tab.control:hover,
.page-graph .metric-tab.control:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-subtle);
  color: var(--color-text);
}

.page-history .metric-tab.active,
.page-graph .metric-tab.active,
.page-history .metric-tab.control.active,
.page-graph .metric-tab.control.active {
  border-color: #bfdbfe;
  background: var(--color-primary-soft);
  color: #1d4ed8;
  box-shadow: none;
}

.page-history .metric-tab-dot,
.page-graph .metric-tab-dot {
  width: 7px;
  height: 7px;
  background: var(--tab-color, var(--color-primary));
}

.page-history .date-popover,
.page-graph .date-popover {
  box-sizing: border-box;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
}

.page-history .calendar-weekdays,
.page-history .calendar-grid,
.page-graph .calendar-weekdays,
.page-graph .calendar-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.page-history .calendar-day,
.page-graph .calendar-day {
  width: 100%;
  min-width: 0;
}

@media (min-width: 961px) {
  .page-history .date-popover,
  .page-graph .date-popover {
    position: fixed;
    z-index: 400;
    top: 0;
    right: auto;
    bottom: auto;
    left: 0;
    width: min(520px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 32px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .page-history .date-picker-row,
  .page-graph .date-picker-row {
    grid-template-columns: minmax(0, 1fr) minmax(96px, 112px);
  }

  .page-history .date-range-fields,
  .page-history .time-range-fields,
  .page-graph .date-range-fields,
  .page-graph .time-range-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .page-history .date-field-button,
  .page-history .time-field,
  .page-history .date-popover input[type="date"],
  .page-history .date-popover input[type="time"],
  .page-graph .date-field-button,
  .page-graph .time-field,
  .page-graph .date-popover input[type="date"],
  .page-graph .date-popover input[type="time"] {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .page-history .date-apply,
  .page-graph .date-apply {
    max-width: 100%;
    box-sizing: border-box;
  }
}

.page-history .date-field-button.active,
.page-graph .date-field-button.active,
.page-history .calendar-day.selected,
.page-graph .calendar-day.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: #1d4ed8;
  box-shadow: none;
}

.page-history .date-apply,
.page-graph .date-apply {
  border-radius: var(--radius-control);
  background: var(--color-primary);
  color: #ffffff;
}

.page-history .table-wrap {
  width: 100%;
  max-width: 100%;
  align-self: stretch;
  flex: 1 1 auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--color-surface);
  box-shadow: none;
}

.page-history th,
.page-history td {
  height: 52px;
  padding-block: 0;
  border-bottom: 1px solid var(--color-border);
  color: #334155;
  font-size: 13px;
}

.page-history th {
  height: 44px;
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
  font-size: 11px;
  letter-spacing: 0;
  box-shadow: 0 1px 0 var(--color-border);
}

.page-history th:first-child,
.page-history td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: inherit;
  box-shadow: 1px 0 0 var(--color-border);
}

.page-history th:first-child {
  z-index: 3;
  background: var(--color-surface-subtle);
}

.page-history tbody tr.history-data-row.is-even {
  background: #ffffff;
}

.page-history tbody tr.history-data-row.is-odd {
  background: #f7f9fc;
}

.page-history tbody tr.history-data-row > td {
  background: inherit;
}

.page-history tbody tr.history-data-row:hover,
.page-history tbody tr.history-data-row:hover > td {
  background: #f8fbff;
}

.page-history tbody tr.alarm-row,
.page-history tbody tr.alarm-row > td {
  background: #fffafa;
}

.page-history .metric-value {
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.page-history .metric-value.alarm-value {
  color: var(--color-danger);
  background: transparent;
  font-weight: 800;
  animation: none;
}

.page-history .metric-value.alarm-value .unit {
  color: #b91c1c;
}

.page-history .unit {
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
}

.page-graph .sticky-header {
  position: relative;
  top: auto;
  z-index: 20;
  flex: 0 0 auto;
  gap: 0;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: var(--color-surface);
}

.page-graph .panel-toolbar {
  min-height: 72px;
}

.page-graph .chart-head {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0;
}

.page-graph .chart-title {
  font-size: 15px;
  font-weight: 800;
}

.page-graph .legend {
  gap: var(--space-1);
}

.page-graph .legend-chip {
  min-height: 28px;
  height: 28px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  font-size: 11px;
}

.page-graph .chart-shell {
  flex: 1 1 auto;
  min-height: 280px;
  margin: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  box-shadow: none;
}

.page-graph .chart-wrap {
  padding: var(--space-3);
  background: var(--color-surface);
}

.page-graph .chart-time-axis {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: none;
}

.page-graph .chart-hover-tooltip,
.page-lte .chart-hover-tooltip {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  backdrop-filter: none;
}

.page-graph .chart-loading {
  background: rgba(255, 255, 255, 0.62);
}

.page-graph .chart-loading span {
  min-width: 112px;
  height: 40px;
  gap: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: #334155;
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}

.page-graph .chart-loading span::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid #bfdbfe;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: ui-spin 700ms linear infinite;
}

.page-graph .meta {
  min-height: 36px;
  padding: 0 var(--space-4) var(--space-3);
  font-size: 12px;
}

/* Signage settings */
.page-signage .topbar .top-actions {
  display: none;
}

.page-signage .signage-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--space-5);
  align-items: start;
}

.page-signage .signage-editor {
  display: grid;
  gap: var(--space-5);
  min-width: 0;
}

.page-signage .panel {
  padding: var(--space-5);
}

.page-signage .form-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.page-signage label {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.page-signage .background-section {
  margin-top: var(--space-5);
  gap: var(--space-2);
}

.page-signage .background-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.page-signage .background-option {
  position: relative;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  box-shadow: none;
}

.page-signage .background-option:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-subtle);
}

.page-signage .background-option:focus-within {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 2px;
}

.page-signage .background-option.active {
  border-color: #93c5fd;
  background: var(--color-primary-soft);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.page-signage .background-option.active::after,
.page-signage .layout-option.active::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--color-primary);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 0 0 2px #ffffff;
}

.page-signage .background-preview {
  height: auto;
  aspect-ratio: 16 / 6;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background-color: var(--color-surface-muted);
}

.page-signage .layout-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.page-signage .layout-option,
.page-signage .layout-option[data-layout="1"] {
  position: relative;
  grid-column: auto;
  grid-row: auto;
  min-height: 118px;
  height: auto;
  padding: var(--space-3);
  justify-content: space-between;
  gap: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  box-shadow: none;
}

.page-signage .layout-option:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-subtle);
}

.page-signage .layout-option.active {
  border-color: #93c5fd;
  background: var(--color-primary-soft);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.page-signage .preview {
  padding: 5px;
  gap: 3px;
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  background: var(--color-surface-subtle);
}

.page-signage .preview span {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  color: var(--color-text-muted);
  font-size: 9px;
}

.page-signage .slot-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

.page-signage .slot-card,
.page-signage .slot-grid[data-layout="1"] .slot-card {
  min-height: 88px;
  padding: var(--space-3);
  gap: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-subtle);
  box-shadow: none;
}

.page-signage .slot-index {
  width: 24px;
  height: 24px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 11px;
}

.page-signage .actions {
  margin-top: var(--space-5);
  gap: var(--space-2);
}

.page-signage #open_public_signage,
.page-signage #open_signage {
  display: none;
}

.page-signage .signage-preview-panel {
  position: sticky;
  top: var(--space-5);
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.page-signage .signage-preview-head {
  display: grid;
  gap: var(--space-1);
}

.page-signage .signage-preview-head h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 15px;
}

.page-signage .signage-preview-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  background: #eef6ff center / cover no-repeat;
}

.page-signage .signage-preview-title {
  overflow: hidden;
  color: var(--color-text);
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-signage .signage-preview-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--preview-live-cols, 4), minmax(0, 1fr));
  grid-template-rows: repeat(var(--preview-live-rows, 2), minmax(0, 1fr));
  gap: 4px;
}

.page-signage .signage-preview-cell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.page-signage .signage-preview-cell span {
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 6px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-signage .signage-preview-cell strong {
  color: var(--color-text);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.page-signage .signage-preview-summary {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-control);
  background: var(--color-surface-subtle);
}

.page-signage .signage-preview-summary-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--color-text-muted);
  font-size: 11px;
}

.page-signage .signage-preview-summary-row strong {
  color: var(--color-text);
  font-weight: 700;
}

.page-signage .preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.page-signage .preview-actions button {
  min-width: 0;
  padding: 0 var(--space-2);
  white-space: nowrap;
}

/* LTE status */
.page-lte .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-lte .topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page-lte .status-pill {
  height: 36px;
  min-height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-control);
  font-size: 12px;
}

.page-lte #status_content {
  display: grid;
  gap: var(--space-5);
}

.page-lte .summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 0.72fr));
  gap: var(--space-3);
}

.page-lte .panel {
  padding: var(--space-5);
  border-color: var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.page-lte .quality-panel {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 3px solid var(--quality-color, var(--color-primary));
  background: var(--color-surface);
}

.page-lte .quality-summary {
  width: 100%;
  min-width: 0;
  padding: var(--space-5);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "main toggle"
    "scale scale";
  align-items: center;
  gap: var(--space-4);
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.page-lte .quality-summary::-webkit-details-marker {
  display: none;
}

.page-lte .quality-summary:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: -3px;
}

.page-lte .quality-summary-main {
  grid-area: main;
  min-width: 0;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: baseline;
  gap: var(--space-2);
}

.page-lte .quality-summary-main .panel-label {
  align-self: center;
}

.page-lte .quality-score {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  color: var(--quality-color, var(--color-primary));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.page-lte .quality-score strong {
  font-size: 44px;
  line-height: 1;
  font-weight: 850;
}

.page-lte .quality-score span {
  font-size: 15px;
  font-weight: 800;
}

.page-lte .quality-label {
  min-width: 0;
  overflow: hidden;
  color: var(--color-text);
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-lte .quality-details-toggle {
  grid-area: toggle;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: #475569;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.page-lte .quality-details-chevron {
  font-size: 18px;
  line-height: 1;
  transition: transform 140ms ease;
}

.page-lte .quality-summary:hover .quality-details-toggle {
  color: var(--color-primary);
}

.page-lte .quality-scale {
  grid-area: scale;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 5px;
}

.page-lte .quality-step {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
}

.page-lte .quality-step.active {
  background: var(--quality-color, var(--color-primary));
}

.page-lte .signal-raw-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.page-lte .signal-raw-card {
  min-width: 0;
  padding: var(--space-3);
  display: grid;
  gap: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
}

.page-lte .signal-raw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.page-lte .signal-raw-name {
  color: var(--color-text);
  font-size: 12px;
  font-weight: 800;
}

.page-lte .signal-raw-range {
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 650;
}

.page-lte .signal-raw-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.page-lte .signal-raw-value strong {
  font-size: 28px;
  line-height: 1;
  font-weight: 800;
}

.page-lte .signal-raw-value span {
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 650;
}

.page-lte .signal-raw-card .metric-sub {
  margin: 0;
}

.page-lte .boot-time-panel,
.page-lte .uptime-panel,
.page-lte .update-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.page-lte .boot-time-metric-value,
.page-lte .uptime-metric-value {
  align-items: flex-start;
}

.page-lte .boot-time-metric-value strong {
  font-size: 22px;
  line-height: 1.25;
}

.page-lte .uptime-metric-value strong {
  font-size: 26px;
  line-height: 1.25;
}

.page-lte .panel-label {
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 700;
}

.page-lte .quality-value {
  margin-top: var(--space-2);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0;
}

.page-lte .quality-meta,
.page-lte .metric-sub {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
}

.page-lte .metric-value {
  min-height: 42px;
  margin-top: var(--space-3);
  align-items: baseline;
}

.page-lte .metric-value strong {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.page-lte .metric-value span {
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
}

.page-lte .signal-bars {
  gap: 4px;
  margin-top: var(--space-3);
}

.page-lte .signal-bar {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
}

.page-lte details.signal-help {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 11px;
  line-height: 1.6;
}

.page-lte details.signal-help summary {
  width: fit-content;
  cursor: pointer;
  color: #475569;
  font-weight: 700;
}

.page-lte details.signal-help > div {
  margin-top: var(--space-2);
}

.page-lte .details-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
}

.page-lte .device-detail-section + .device-detail-section {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.page-lte .detail {
  min-height: 74px;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-subtle);
}

.page-lte .detail span {
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 700;
}

.page-lte .detail strong {
  margin-top: var(--space-2);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.page-lte .chart-panel {
  gap: var(--space-4);
}

.page-lte .chart-head {
  gap: var(--space-4);
}

.page-lte .chart-title {
  font-size: 15px;
}

.page-lte .chart-legend {
  gap: var(--space-1);
}

.page-lte .legend-chip {
  height: 30px;
  min-height: 30px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  font-size: 11px;
}

.page-lte .chart-frame {
  height: 300px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
}

.page-lte.signal-dialog-open,
.page-lte.signal-dialog-open body {
  overflow: hidden;
}

.page-lte .signal-detail-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: min(980px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  color: var(--color-text);
}

.page-lte .signal-detail-dialog:not([open]) {
  display: none;
}

.page-lte .signal-detail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}

.page-lte .signal-dialog-surface {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
}

.page-lte .signal-dialog-header {
  flex: 0 0 auto;
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.page-lte .signal-dialog-header h2 {
  font-size: 19px;
  line-height: 1.35;
  font-weight: 800;
}

.page-lte .signal-dialog-header p,
.page-lte .signal-detail-section-head p {
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 11px;
  line-height: 1.5;
  font-weight: 600;
}

.page-lte .signal-dialog-close {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.page-lte .signal-dialog-close:hover {
  border-color: #93c5fd;
  color: var(--color-primary);
  background: #eff6ff;
}

.page-lte .signal-dialog-close:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.page-lte .signal-dialog-body {
  min-height: 0;
  padding: var(--space-5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.page-lte .signal-detail-section-head {
  margin-bottom: var(--space-3);
}

.page-lte .signal-detail-section-head h3 {
  font-size: 15px;
  font-weight: 800;
}

.page-lte .signal-history-panel {
  margin-top: var(--space-4);
  box-shadow: none;
}

/* Settings */
.page-settings .topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-card);
}

.page-settings .settings-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-muted);
}

.page-settings .settings-tab,
.page-settings .settings-tab.profile-tab,
.page-settings .settings-tab.alarm-tab,
.page-settings .settings-tab.notification-tab {
  --tab-color: var(--color-primary);
  --tab-hover: var(--color-primary-hover);
  height: 34px;
  min-height: 34px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  box-shadow: none;
}

.page-settings .settings-tab:hover {
  background: rgba(255, 255, 255, 0.65);
  color: var(--color-text);
  transform: none;
}

.page-settings .settings-tab.active {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.page-settings .panel {
  padding: var(--space-5);
  gap: var(--space-5);
}

.page-settings .device-row {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  align-items: end;
  gap: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-subtle);
}

.page-settings .device-row label,
.page-settings .field-row label,
.page-settings .profile-grid label,
.page-settings .twilio-grid label {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.page-settings .device-row select {
  margin-top: var(--space-2);
}

.page-settings .tab-panel {
  min-width: 0;
  padding-top: 0;
}

.page-settings .profile-grid {
  width: min(100%, 920px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.page-settings .field-row {
  gap: var(--space-4);
}

.page-settings .settings-groups {
  display: grid;
  gap: var(--space-5);
}

.page-settings .settings-group {
  display: grid;
  gap: var(--space-3);
}

.page-settings .settings-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.page-settings .settings-group-head h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 14px;
}

.page-settings .settings-group-head span {
  color: var(--color-text-muted);
  font-size: 11px;
}

.page-settings .metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
}

.page-settings .metric-card {
  min-width: 0;
  min-height: 110px;
  padding: var(--space-3);
  gap: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  box-shadow: none;
}

.page-settings .metric-card:hover {
  border-color: var(--color-border-strong);
  box-shadow: none;
}

.page-settings .metric-card.threshold-active {
  border-color: #bfdbfe;
  background: #fbfdff;
  box-shadow: inset 3px 0 0 var(--color-primary);
}

.page-settings .metric-head {
  gap: var(--space-2);
}

.page-settings .metric-name {
  color: var(--color-text);
  font-size: 12px;
  font-weight: 700;
}

.page-settings .metric-state {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 700;
}

.page-settings .metric-card.threshold-active .metric-state {
  background: var(--color-primary-soft);
  color: #1d4ed8;
}

.page-settings .metric-unit {
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
}

.page-settings .input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
}

.page-settings .notification-stack {
  display: grid;
  gap: var(--space-5);
}

.page-settings .notification-card {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface-subtle);
}

.page-settings .notification-card-title {
  margin: 0;
  color: var(--color-text);
  font-size: 15px;
  font-weight: 800;
}

.page-settings .toggle-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  box-shadow: none;
}

.page-settings .toggle-card.active {
  border-color: #bfdbfe;
  background: #fbfdff;
  box-shadow: none;
}

.page-settings .toggle-card input[type="checkbox"] {
  position: relative;
  width: 40px;
  height: 22px;
  margin: 0;
  appearance: none;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: #cbd5e1;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.page-settings .toggle-card input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
  transition: transform var(--duration-fast) ease;
}

.page-settings .toggle-card input[type="checkbox"]:checked {
  border-color: var(--color-primary);
  background: var(--color-primary);
}

.page-settings .toggle-card input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

.page-settings .toggle-title {
  color: var(--color-text);
  font-size: 13px;
  font-weight: 800;
}

.page-settings .notification-policy-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(360px, 1.3fr) minmax(240px, 0.8fr);
  gap: var(--space-4);
  align-items: start;
}

.page-settings .notification-policy-field,
.page-settings .notification-weekdays,
.page-settings .notification-hours {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: var(--space-2);
  align-content: start;
}

.page-settings .notification-policy-label,
.page-settings .notification-weekdays legend,
.page-settings .notification-hours legend {
  padding: 0;
  color: var(--color-text);
  font-size: 12px;
  font-weight: 800;
}

.page-settings .notification-time-range {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: var(--space-2);
}

.page-settings .notification-time-range label {
  min-width: 0;
  display: grid;
  gap: 4px;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 700;
}

.page-settings .notification-time-range input {
  width: 100%;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.page-settings .notification-time-separator {
  padding-bottom: 12px;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
}

.page-settings .notification-number-control {
  width: max-content;
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(96px, 132px) auto;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
}

.page-settings .notification-number-control input {
  min-width: 0;
  width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.page-settings .weekday-options {
  width: min(100%, 476px);
  display: grid;
  grid-template-columns: repeat(7, minmax(44px, 1fr));
  gap: var(--space-2);
}

.page-settings .weekday-option {
  min-width: 0;
  min-height: 40px;
  padding: 0 var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}

.page-settings .weekday-option:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.page-settings .weekday-option input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--color-primary);
}

.page-settings .weekday-option span {
  font-size: 12px;
  font-weight: 800;
}

.page-settings .weekday-option:nth-child(6) {
  border-color: #bfdbfe;
  background: #f8fbff;
  color: #1d4ed8;
}

.page-settings .weekday-option:nth-child(6) input[type="checkbox"] {
  accent-color: #2563eb;
}

.page-settings .weekday-option:nth-child(7) {
  border-color: #fecaca;
  background: #fffafa;
  color: #b91c1c;
}

.page-settings .weekday-option:nth-child(7):focus-within {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.page-settings .weekday-option:nth-child(7) input[type="checkbox"] {
  accent-color: #dc2626;
}

@media (max-width: 1024px) {
  .page-settings .notification-policy-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 460px) {
  .page-settings .weekday-options {
    grid-template-columns: repeat(4, minmax(48px, 1fr));
  }
}

.page-settings .email-list,
.page-settings .phone-list {
  display: grid;
  gap: var(--space-2);
}

.page-settings .email-row,
.page-settings .phone-row {
  width: min(100%, 760px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
}

.page-settings .remove-email,
.page-settings .remove-phone {
  min-width: 64px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text-muted);
  box-shadow: none;
}

.page-settings .remove-email:hover,
.page-settings .remove-phone:hover {
  border-color: #fecaca;
  background: var(--color-danger-soft);
  color: #b91c1c;
}

.page-settings .twilio-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.page-settings .actions {
  position: sticky;
  bottom: var(--space-3);
  z-index: 20;
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.page-settings .actions .primary {
  min-width: 88px;
}

/* Admin and login */
.page-admin .grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.page-admin .panel {
  padding: var(--space-5);
}

.page-admin .panel form {
  gap: var(--space-3);
}

.page-admin .panel button[type="submit"] {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #ffffff;
}

.page-admin table {
  border-color: var(--color-border);
}

.page-admin th {
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
}

.page-admin .admin-device-name-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 248px;
}

.page-admin .admin-device-name-form input {
  min-width: 0;
  height: 38px;
  margin: 0;
  padding: 0 10px;
}

.page-admin .admin-device-name-form button[type="submit"] {
  width: auto;
  min-width: 56px;
  height: 38px;
  margin: 0;
  padding: 0 12px;
  white-space: nowrap;
}

.page-admin .admin-device-name-form input:focus-visible,
.page-admin .admin-device-name-form button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.page-login {
  background: var(--color-bg);
}

.page-login .login .card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.1);
}

.page-login .visual::before {
  display: none;
}

.page-login .visual h1 {
  color: #ffffff;
  font-size: 32px;
  letter-spacing: 0;
  background: none;
  -webkit-text-fill-color: currentColor;
}

.page-login .login h2 {
  letter-spacing: 0;
}

.page-login .login button[type="submit"] {
  border-radius: var(--radius-control);
  background: var(--color-primary);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.16);
}

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

@media (max-width: 1440px) {
  .shell {
    grid-template-columns: 216px minmax(0, 1fr);
  }

  .sidebar {
    width: 216px;
    padding-inline: var(--space-3);
  }

  .content {
    padding: var(--space-5);
  }

  .page-live .metric-section-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .page-history .panel-actions,
  .page-graph .panel-actions {
    gap: 6px;
  }

  .page-history .record-tab,
  .page-graph .record-tab,
  .page-graph .layout-button {
    padding-inline: 10px;
  }

  .page-settings .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .page-history .panel-toolbar,
  .page-graph .panel-toolbar {
    align-items: flex-start;
  }

  .page-history .panel-actions,
  .page-graph .panel-actions {
    justify-content: flex-start;
  }

  .page-graph .chart-head {
    display: none;
  }

  .page-signage .signage-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-signage .signage-preview-panel {
    position: relative;
    top: auto;
    grid-template-columns: minmax(280px, 420px) minmax(220px, 1fr);
    align-items: center;
  }

  .page-signage .signage-preview-head {
    grid-column: 1 / -1;
  }

  .page-signage .preview-actions {
    grid-column: 2;
  }

  .page-lte .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-settings .twilio-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 960px) {
  body.sidebar-open {
    overflow: hidden;
  }

  body.ui-scroll-locked {
    overflow: hidden;
    overscroll-behavior: none;
  }

  .shell {
    display: block;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, calc(100% - 48px));
    max-width: calc(100% - 48px);
    height: 100dvh;
    z-index: 1000;
    padding: max(var(--space-6), env(safe-area-inset-top)) max(var(--space-4), env(safe-area-inset-right)) max(var(--space-4), env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
    border-right: 1px solid var(--color-border);
    border-bottom: 0;
    transform: translateX(-102%);
    transition: transform 190ms ease;
    overflow-y: auto;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar .sidebar-brand {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 44px 8px 8px;
    text-align: center;
  }

  .sidebar .sidebar-brand-logo {
    width: 100%;
    max-width: 188px;
    flex: 0 0 auto;
  }

  .sidebar .sidebar-brand-user {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav {
    flex-direction: column;
    overflow: visible;
  }

  .side-panel {
    display: block;
  }

  .mobile-nav-toggle {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
    z-index: 900;
    width: 44px;
    height: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-control);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
  }

  .mobile-nav-toggle::before,
  .mobile-nav-toggle::after,
  .mobile-nav-toggle span {
    content: "";
    width: 18px;
    height: 2px;
    position: absolute;
    border-radius: 2px;
    background: currentColor;
    transition: transform var(--duration-fast) ease, opacity var(--duration-fast) ease;
  }

  .mobile-nav-toggle::before { transform: translateY(-6px); }
  .mobile-nav-toggle::after { transform: translateY(6px); }

  body.sidebar-open .mobile-nav-toggle::before { transform: rotate(45deg); }
  body.sidebar-open .mobile-nav-toggle::after { transform: rotate(-45deg); }
  body.sidebar-open .mobile-nav-toggle span { opacity: 0; }

  body.sidebar-open .mobile-nav-toggle {
    z-index: 1100;
  }

  .mobile-app-bar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 850;
    min-width: 0;
    height: calc(68px + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 calc(62px + env(safe-area-inset-left));
    border-bottom: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    backdrop-filter: blur(10px);
  }

  .mobile-product-name {
    flex: 0 0 auto;
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
  }

  .mobile-app-bar strong {
    min-width: 0;
    overflow: hidden;
    color: var(--color-text);
    font-size: 15px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 950;
    border: 0;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.34);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .content,
  .page-history .content,
  .page-graph .content {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
    padding: calc(72px + env(safe-area-inset-top)) max(var(--space-4), env(safe-area-inset-right)) max(var(--space-4), env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left)) !important;
  }

  .page-history,
  .page-graph {
    height: auto;
    overflow-y: auto;
  }

  .page-history .shell,
  .page-graph .shell {
    height: auto;
  }

  .page-history .panel,
  .page-graph .panel {
    min-height: calc(100vh - 84px);
  }

  .topbar {
    min-height: 64px;
  }

  .page-live .content > .topbar > :first-child,
  .page-lte .content > .topbar > :first-child {
    display: none;
  }

  .page-signage .content > .topbar,
  .page-admin .content > .topbar {
    display: none;
  }

  .page-settings .topbar > h1 {
    display: none;
  }

  .page-settings .topbar {
    top: calc(72px + env(safe-area-inset-top));
  }

  .page-settings .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-admin .grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .content,
  .page-history .content,
  .page-graph .content {
    padding: calc(68px + env(safe-area-inset-top)) max(var(--space-3), env(safe-area-inset-right)) max(var(--space-3), env(safe-area-inset-bottom)) max(var(--space-3), env(safe-area-inset-left)) !important;
  }

  .topbar,
  .page-live .topbar,
  .page-lte .topbar,
  .page-settings .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .topbar h1,
  .content h1 {
    font-size: 21px;
  }

  .page-live .topbar-actions,
  .page-lte .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  }

  .page-live .metric {
    min-height: 132px;
    padding: var(--space-3);
  }

  .page-live .metric-value .value,
  .page-live #wind_direction.value,
  .page-live .primary-section .metric-value .value {
    font-size: 32px !important;
  }

  .page-live .live-metric-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    top: calc(76px + env(safe-area-inset-top));
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 88px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }

  .page-history .panel-toolbar,
  .page-graph .panel-toolbar {
    display: grid;
    align-items: stretch;
  }

  .page-history .panel-actions,
  .page-graph .panel-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .page-history .record-tabs,
  .page-graph .record-tabs {
    justify-content: space-between;
  }

  .page-history .date-control,
  .page-graph .date-control,
  .page-history .date-nav,
  .page-graph .date-nav {
    width: 100%;
  }

  .page-history .date-nav,
  .page-graph .date-nav {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .page-history .export-actions,
  .page-graph .export-actions {
    justify-content: flex-end;
  }

  .page-history .metric-tabs,
  .page-graph .metric-tabs {
    left: 12px;
    right: 12px;
    top: calc(76px + env(safe-area-inset-top));
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 88px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }

  .page-signage .background-grid,
  .page-signage .layout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-signage .signage-preview-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-signage .preview-actions {
    grid-column: auto;
  }

  .page-lte .summary-grid,
  .page-lte .details-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-lte .quality-summary {
    padding: var(--space-4);
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-3);
  }

  .page-lte .quality-summary-main {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .page-lte .quality-score strong {
    font-size: 38px;
  }

  .page-lte .signal-raw-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-lte .signal-detail-dialog {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .page-lte .signal-dialog-surface {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .page-lte .signal-dialog-header,
  .page-lte .signal-dialog-body {
    padding: var(--space-4);
  }

  .page-lte .signal-history-panel {
    padding: var(--space-3);
  }

  .page-lte .signal-history-panel .chart-frame {
    height: 280px;
  }

  .page-lte .chart-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-settings .settings-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .page-settings .settings-tab,
  .page-settings .settings-tab.profile-tab,
  .page-settings .settings-tab.alarm-tab,
  .page-settings .settings-tab.notification-tab {
    flex: 1 0 auto;
    padding-inline: var(--space-3);
  }

  .page-settings .device-row,
  .page-settings .profile-grid,
  .page-settings .metric-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-settings .notification-card {
    padding: var(--space-4);
  }

  .page-settings .actions {
    bottom: max(var(--space-2), env(safe-area-inset-bottom));
  }
}

@media (max-width: 768px) {
  .page-login {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  .page-login .login {
    width: 100%;
    min-height: 100dvh;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    overflow-x: clip;
    overflow-y: auto;
  }

  .page-login .login .card {
    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: 32px 24px;
  }

  .page-login .login input,
  .page-login .login button[type="submit"] {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }
}

@media (max-width: 460px) {
  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-signage .background-grid,
  .page-signage .layout-grid,
  .page-signage .preview-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-settings .email-row,
  .page-settings .phone-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Record data mobile toolbar and overflow stabilization */
.mobile-app-identity {
  min-width: 0;
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mobile-app-logo-link {
  flex: 0 0 auto;
  display: block;
  border-radius: 6px;
  line-height: 0;
}

.mobile-app-logo-link:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.mobile-app-logo {
  width: clamp(144px, 47vw, 185px);
  height: 52px;
  max-width: none;
  flex: 0 0 auto;
  object-fit: cover;
  object-position: center;
}

.mobile-page-title {
  min-width: 0;
  overflow: hidden;
  color: var(--color-text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-history .record-toolbar-actions,
.page-graph .record-toolbar-actions {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "primary date-export";
}

.page-history .date-export-row,
.page-graph .date-export-row {
  grid-area: date-export;
  min-width: 0;
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 6px;
}

.page-graph .graph-secondary-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-history .panel-record-tabs .metric-picker-wrap,
.page-graph .panel-record-tabs .metric-picker-wrap {
  order: 0;
}

.page-history .panel-record-tabs .view-mode-toggle,
.page-graph .panel-record-tabs .view-mode-toggle {
  order: 1;
}

.page-graph .column-count-toggle[hidden],
.page-graph .column-count-toggle .layout-button[hidden] {
  display: none !important;
}

.page-history .history-table-scroll {
  min-width: 0;
  max-width: 100%;
  overflow-x: var(--history-overflow-x, auto);
  overflow-y: auto;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  isolation: isolate;
}

@media (max-width: 1160px) {
  .page-history .record-toolbar-actions,
  .page-graph .record-toolbar-actions {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "primary"
      "date-export";
  }

  .page-history .date-export-row,
  .page-graph .date-export-row {
    justify-content: flex-start;
  }
}

@media (max-width: 960px) {
  .mobile-app-bar {
    height: calc(68px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 calc(62px + env(safe-area-inset-left));
  }

  .mobile-nav-toggle {
    top: calc(12px + env(safe-area-inset-top));
  }

  .mobile-app-bar > .mobile-app-identity {
    display: flex;
  }

  .page-history .content,
  .page-graph .content {
    overflow-x: clip;
    padding-top: calc(72px + env(safe-area-inset-top)) !important;
  }

  .page-history .panel,
  .page-graph .panel,
  .page-history .record-toolbar-actions,
  .page-graph .record-toolbar-actions,
  .page-history .toolbar-primary-actions,
  .page-graph .toolbar-primary-actions,
  .page-history .panel-record-tabs,
  .page-graph .panel-record-tabs,
  .page-graph .graph-secondary-actions,
  .page-history .date-export-row,
  .page-graph .date-export-row {
    min-width: 0;
    max-width: 100%;
  }

  .page-history .panel-toolbar,
  .page-graph .panel-toolbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    min-height: 0;
    padding: 10px 0;
    overflow: visible;
  }

  .page-history .record-toolbar-actions,
  .page-graph .record-toolbar-actions {
    order: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "primary"
      "date-export";
    gap: 8px;
  }

  .page-history .record-toolbar-heading,
  .page-graph .record-toolbar-heading {
    order: 2;
    width: 100%;
    min-height: 22px;
    height: auto;
    padding: 0 2px;
  }

  .page-history .summary-pill,
  .page-graph .chart-caption,
  .page-graph .record-toolbar-heading .summary-pill {
    width: 100%;
    min-height: 22px;
    height: auto;
    display: flex;
    align-items: center;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
  }

  .page-history .summary-pill::before,
  .page-graph .record-toolbar-heading .summary-pill::before,
  .page-graph .record-toolbar-heading .legend {
    display: none;
  }

  .page-history .toolbar-primary-actions,
  .page-graph .toolbar-primary-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
  }

  .page-history .panel-record-tabs,
  .page-graph .panel-record-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  .page-history .panel-record-tabs .metric-picker-wrap,
  .page-graph .panel-record-tabs .metric-picker-wrap,
  .page-history .metric-select-toggle,
  .page-graph .metric-select-toggle,
  .page-history .view-mode-toggle,
  .page-graph .view-mode-toggle {
    width: 100%;
    min-width: 0;
  }

  .page-history .metric-select-toggle,
  .page-graph .metric-select-toggle,
  .page-history .record-tab,
  .page-graph .record-tab,
  .page-graph .layout-button,
  .page-graph .advanced-menu-summary {
    min-height: 40px;
    height: 40px;
  }

  .page-history .view-mode-toggle > .record-tab,
  .page-graph .view-mode-toggle > .record-tab {
    min-width: 0;
    padding-inline: 6px;
  }

  .page-graph .graph-secondary-actions {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .page-graph .graph-advanced-menu {
    margin-left: 0;
  }

  .page-history .date-export-row,
  .page-graph .date-export-row {
    width: 100%;
    display: grid;
    grid-template-columns: 40px minmax(108px, 1fr) 40px 44px 44px;
    gap: 4px;
    align-items: center;
  }

  .page-history .date-export-row > .date-control,
  .page-graph .date-export-row > .date-control,
  .page-history .date-export-row .date-nav,
  .page-graph .date-export-row .date-nav,
  .page-history .date-export-row > .export-actions,
  .page-graph .date-export-row > .export-actions {
    display: contents;
  }

  .page-history .date-control-label,
  .page-graph .date-control-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .page-history .date-step,
  .page-graph .date-step,
  .page-history .date-display,
  .page-graph .date-display,
  .page-history .export-button,
  .page-graph .export-button {
    width: 100%;
    min-width: 0;
    height: 42px;
    min-height: 42px;
    padding: 0;
  }

  .page-history .date-display,
  .page-graph .date-display {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-history .date-display > span,
  .page-graph .date-display > span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-history .export-button,
  .page-graph .export-button {
    font-size: 11px;
  }

  .page-history .history-table-scroll {
    width: 100% !important;
    max-width: 100%;
    align-self: stretch;
    overflow-x: auto !important;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  .page-history .history-table-scroll table {
    width: max(100%, var(--history-table-min-width, 820px));
    min-width: var(--history-table-min-width, 820px);
    table-layout: auto;
  }

  .page-history .history-table-scroll th,
  .page-history .history-table-scroll td {
    height: 48px;
  }

  .page-history .history-table-scroll th:first-child,
  .page-history .history-table-scroll td:first-child {
    position: sticky;
    left: 0;
    background: #ffffff;
  }

  .page-history .history-table-scroll th:first-child {
    z-index: 4;
    background: var(--color-surface-subtle);
  }

  .page-history .history-table-scroll td:first-child {
    z-index: 2;
  }
}

/* Shared application chrome: fixed top bar and overlay navigation drawer. */
:root {
  --app-topbar-height: 68px;
  --app-drawer-width: 296px;
}

html.app-shell-document:not(.ui-ready) .sidebar {
  visibility: hidden;
  transform: translateX(-102%) !important;
  transition: none !important;
}

body.has-app-shell {
  overflow-x: clip;
}

body.has-app-shell .shell {
  display: block;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

body.has-app-shell .content,
body.has-app-shell.page-history .content,
body.has-app-shell.page-graph .content {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(var(--app-topbar-height) + var(--space-5)) !important;
}

body.has-app-shell .sidebar {
  position: fixed !important;
  inset: 0 auto 0 0 !important;
  z-index: 1350;
  width: min(var(--app-drawer-width), calc(100vw - 48px)) !important;
  max-width: calc(100vw - 48px);
  height: 100vh !important;
  height: 100dvh !important;
  display: flex;
  padding: calc(var(--app-topbar-height) + var(--space-4)) var(--space-4) max(var(--space-4), env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--color-border);
  background: #ffffff;
  box-shadow: 12px 0 32px rgba(15, 23, 42, 0.12);
  transform: translateX(-102%);
  transition: transform 190ms ease;
}

body.sidebar-open .sidebar {
  transform: translateX(0);
}

body.has-app-shell .sidebar .sidebar-brand {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 8px 10px;
  text-align: center;
}

body.has-app-shell .sidebar .sidebar-brand-logo {
  width: 100%;
  max-width: 188px;
  flex: 0 0 auto;
}

body.has-app-shell .sidebar .sidebar-brand-user {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.has-app-shell .mobile-app-bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1100;
  width: 100%;
  height: calc(var(--app-topbar-height) + env(safe-area-inset-top));
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 calc(140px + env(safe-area-inset-left));
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.98);
  color: var(--color-text);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(12px);
}

body.has-app-shell .mobile-app-identity {
  width: auto;
  min-width: 0;
  height: 52px;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.has-app-shell .mobile-app-logo-link {
  width: 164px;
  height: 48px;
  flex: 0 0 164px;
  display: block;
  border-radius: var(--radius-control);
  background: #ffffff;
  line-height: 0;
}

body.has-app-shell .mobile-app-logo {
  width: 164px;
  height: 48px;
  max-width: 164px;
  padding: 2px 4px;
  border-radius: var(--radius-control);
  background: #ffffff;
  object-fit: contain;
  object-position: center;
}

body.has-app-shell .mobile-page-title {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  color: var(--color-text);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.has-app-shell .app-topbar-company {
  max-width: min(40vw, 440px);
  flex: 0 1 auto;
  overflow: hidden;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.has-app-shell .mobile-nav-toggle {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  z-index: 1250;
  width: 116px;
  height: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: #ffffff;
  color: #273447;
  box-shadow: none;
}

body.has-app-shell .mobile-nav-toggle:hover {
  border-color: #93c5fd;
  background: #f8fbff;
  color: #1d4ed8;
}

body.has-app-shell .mobile-nav-toggle::before,
body.has-app-shell .mobile-nav-toggle::after,
body.has-app-shell .mobile-nav-toggle > span {
  content: "";
  width: 19px;
  height: 2px;
  position: absolute;
  left: 15px;
  border-radius: 2px;
  background: currentColor;
  transition: transform var(--duration-fast) ease, opacity var(--duration-fast) ease;
}

body.has-app-shell .mobile-nav-toggle::before {
  transform: translateY(-6px);
}

body.has-app-shell .mobile-nav-toggle::after {
  transform: translateY(6px);
}

body.has-app-shell .mobile-nav-toggle > b {
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

body.sidebar-open .mobile-nav-toggle {
  z-index: 1450;
}

body.sidebar-open .mobile-nav-toggle::before {
  transform: rotate(45deg);
}

body.sidebar-open .mobile-nav-toggle::after {
  transform: rotate(-45deg);
}

body.sidebar-open .mobile-nav-toggle > span {
  opacity: 0;
}

body.has-app-shell .sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  width: 100%;
  height: 100%;
  display: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: none;
  cursor: default;
  backdrop-filter: blur(1px);
}

body.sidebar-open .sidebar-backdrop {
  display: block;
}

/* The global bar owns the page title; page-level bars keep only their controls. */
.page-live .content > .topbar,
.page-lte .content > .topbar,
.page-settings .content > .topbar {
  min-height: 56px;
  padding: 8px 12px;
  border-color: var(--color-border);
  background: #ffffff;
  color: var(--color-text);
  box-shadow: var(--shadow-card);
}

.page-live .content > .topbar > :first-child,
.page-lte .content > .topbar > :first-child,
.page-settings .content > .topbar > h1 {
  display: none;
}

.page-live .content > .topbar .topbar-actions,
.page-lte .content > .topbar .topbar-actions {
  width: 100%;
}

.admin-device-switch {
  display: inline-grid;
  grid-template-columns: max-content minmax(150px, 220px);
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 40px;
  margin: 0;
}

.admin-device-switch-label {
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.admin-device-switch select {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background-color: #ffffff;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
}

.admin-device-switch select:hover {
  border-color: #94a3b8;
}

.admin-device-switch select:focus {
  border-color: var(--color-primary);
  outline: 3px solid rgba(37, 99, 235, 0.14);
  outline-offset: 0;
}

.admin-device-field {
  min-width: 0;
}

.admin-device-field select {
  width: 100%;
  min-width: 0;
}

.page-admin .content > .topbar,
.page-signage .content > .topbar {
  display: none;
}

.page-settings .content > .topbar {
  position: relative;
  top: auto;
  justify-content: flex-start;
}

.page-settings .content > .topbar .settings-tabs {
  border-color: var(--color-border);
  background: var(--color-surface-subtle);
}

.page-settings .content > .topbar .settings-tab,
.page-settings .content > .topbar .settings-tab.profile-tab,
.page-settings .content > .topbar .settings-tab.alarm-tab,
.page-settings .content > .topbar .settings-tab.notification-tab {
  color: var(--color-text-muted);
}

.page-settings .content > .topbar .settings-tab:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.page-settings .content > .topbar .settings-tab.active {
  border-color: var(--color-primary);
  background: #ffffff;
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

@media (max-width: 720px) {
  :root {
    --app-topbar-height: 68px;
  }

  body.has-app-shell .mobile-app-bar {
    gap: 6px;
    padding-right: calc(8px + env(safe-area-inset-right));
    padding-left: calc(62px + env(safe-area-inset-left));
    border-bottom-color: var(--color-border);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07);
    backdrop-filter: blur(10px);
  }

  body.has-app-shell .mobile-app-identity {
    gap: 6px;
  }

  body.has-app-shell .mobile-app-logo-link,
  body.has-app-shell .mobile-app-logo {
    width: clamp(132px, 39vw, 168px);
    max-width: clamp(132px, 39vw, 168px);
    height: 50px;
    flex-basis: clamp(132px, 39vw, 168px);
  }

  body.has-app-shell .mobile-page-title {
    font-size: 14px;
  }

  body.has-app-shell .app-topbar-company {
    display: none;
  }

  body.has-app-shell .mobile-nav-toggle {
    top: calc(12px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
    width: 44px;
    height: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border-color: var(--color-border-strong);
    color: #1d4ed8;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  }

  body.has-app-shell .mobile-nav-toggle::before,
  body.has-app-shell .mobile-nav-toggle::after,
  body.has-app-shell .mobile-nav-toggle > span {
    left: 12px;
  }

  body.has-app-shell .mobile-nav-toggle > b {
    display: none;
  }

  body.has-app-shell .sidebar {
    width: min(86vw, 320px) !important;
    max-width: min(86vw, 320px);
  }
}

@media (max-width: 360px) {
  body.has-app-shell .mobile-app-logo-link,
  body.has-app-shell .mobile-app-logo {
    width: 126px;
    max-width: 126px;
    flex-basis: 126px;
  }

  body.has-app-shell .mobile-page-title {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.has-app-shell .sidebar {
    transition-duration: 0.01ms;
  }
}

@media (max-width: 340px) {
  .page-history #date_label[data-compact-label],
  .page-graph #date_label[data-compact-label] {
    font-size: 0;
  }

  .page-history #date_label[data-compact-label]::after,
  .page-graph #date_label[data-compact-label]::after {
    content: attr(data-compact-label);
    font-size: 11px;
  }

  .mobile-app-logo {
    width: 132px;
    height: 48px;
    max-width: 132px;
  }

  .mobile-app-identity {
    gap: 4px;
  }

  .mobile-app-bar .mobile-page-title {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Mobile graph/live controls stay available without covering page content. */
.page-graph .graph-sticky-spacer,
.page-live .live-topbar-spacer {
  display: none;
}

@media (max-width: 960px) {
  .page-graph .sticky-header {
    position: fixed !important;
    top: calc(68px + env(safe-area-inset-top)) !important;
    z-index: 800;
    width: auto;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    border-radius: 0;
    background: #ffffff;
    box-shadow: 0 1px 0 var(--color-border), 0 6px 16px -16px rgba(15, 23, 42, 0.45);
  }

  .page-graph .graph-sticky-spacer {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    height: 142px;
    pointer-events: none;
  }

  .page-graph .sticky-header > .panel-toolbar {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
    background: #ffffff;
  }

  .page-live .topbar {
    position: fixed !important;
    top: calc(68px + env(safe-area-inset-top));
    left: max(var(--space-4), env(safe-area-inset-left));
    right: max(var(--space-4), env(safe-area-inset-right));
    z-index: 800;
    display: block !important;
    width: auto;
    min-width: 0;
    min-height: 60px;
    margin: 0;
    padding: 8px !important;
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius-card) var(--radius-card);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 6px 16px -16px rgba(15, 23, 42, 0.45);
  }

  .page-live .topbar-actions {
    display: grid !important;
    grid-template-columns: minmax(78px, 0.8fr) minmax(112px, 1.25fr) minmax(72px, 0.75fr) !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    gap: 4px !important;
    width: 100% !important;
    min-width: 0;
    flex-wrap: nowrap !important;
  }

  .page-live.admin-device-switch-enabled .topbar-actions {
    grid-template-rows: 40px 44px;
  }

  .page-live.admin-device-switch-enabled .admin-device-switch {
    grid-column: 1 / -1;
    grid-row: 1;
    grid-template-columns: max-content minmax(0, 1fr);
    width: 100%;
  }

  .page-live.admin-device-switch-enabled .live-config-button,
  .page-live.admin-device-switch-enabled .test-clock,
  .page-live.admin-device-switch-enabled .status {
    grid-row: 2;
  }

  .page-live .live-config-button,
  .page-live .test-clock,
  .page-live .status {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0;
    padding: 0 6px !important;
    box-sizing: border-box;
  }

  .page-live .live-config-button {
    gap: 4px;
    font-size: 12px;
    box-shadow: none;
  }

  .page-live .live-config-button::before {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
  }

  .page-live .test-clock {
    justify-content: center;
    gap: 4px;
  }

  .page-live .test-clock span:first-child {
    font-size: 10px;
  }

  .page-live .test-clock span:last-child {
    font-size: 13px;
  }

  .page-live .status {
    gap: 5px;
    font-size: 11px;
    white-space: nowrap;
  }

  .page-live .status::before {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
  }

  .page-live .live-topbar-spacer {
    display: block;
    width: 100%;
    height: 68px;
    pointer-events: none;
  }

  .page-live.admin-device-switch-enabled .live-topbar-spacer {
    height: 112px;
  }

  .page-live .live-metric-popover {
    top: calc(136px + env(safe-area-inset-top));
    max-height: calc(100dvh - 148px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .page-live.admin-device-switch-enabled .live-metric-popover {
    top: calc(180px + env(safe-area-inset-top));
    max-height: calc(100dvh - 192px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (max-width: 720px) {
  .page-live .topbar {
    left: max(var(--space-3), env(safe-area-inset-left));
    right: max(var(--space-3), env(safe-area-inset-right));
  }
}

/* Graph workspace: dense, neutral time-series presentation */
.page-graph .panel-toolbar {
  min-height: 88px;
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
}

.page-graph .chart-head {
  min-width: 0;
  padding-top: 0;
}

.page-graph .chart-title {
  color: var(--color-text);
  font-size: 18px;
  line-height: 1.35;
}

.page-graph .chart-caption {
  display: block;
  color: var(--color-text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.page-graph .panel-actions {
  flex: 1 1 760px;
  align-items: flex-end;
}

.page-graph .panel-record-tabs {
  align-items: flex-end;
}

.page-graph .panel-record-tabs .metric-picker-wrap { order: 0; }
.page-graph .panel-record-tabs .view-mode-toggle { order: 1; }

.page-graph .record-tab.active,
.page-graph .layout-button.active {
  border-color: #bfdbfe;
  background: var(--color-primary-soft);
  color: #1d4ed8;
  box-shadow: none;
}

.page-graph .metric-tabs {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.page-graph .metric-tabs[hidden] {
  display: none;
}

.page-graph .metric-tab-controls {
  position: sticky;
  top: 0;
  z-index: 2;
  align-items: center;
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.98);
}

.page-graph .metric-selection-count {
  margin-right: auto;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.page-graph .metric-tab-groups {
  overflow-y: auto;
  min-height: 0;
  padding: var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: #b8c3d1 transparent;
}

.page-graph .metric-tab-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.page-graph .metric-tab-group-title b {
  color: var(--color-text-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.page-graph .metric-tab {
  gap: 7px;
}

.page-graph .metric-tab[data-metric] {
  justify-content: flex-start;
}

.page-history .metric-tab.control[data-action="select-group"],
.page-graph .metric-tab.control[data-action="select-group"] {
  border-color: var(--color-border);
  border-style: solid;
  background: var(--color-surface);
  color: #475569;
}

.page-history .metric-tab.control[data-action="select-group"][data-state="partial"],
.page-graph .metric-tab.control[data-action="select-group"][data-state="partial"] {
  border-color: color-mix(in srgb, var(--group-color, var(--color-primary)) 42%, var(--color-border));
  background: color-mix(in srgb, var(--group-color, var(--color-primary)) 7%, white);
  color: var(--color-text);
}

.page-history .metric-tab.control[data-action="select-group"][data-state="all"],
.page-graph .metric-tab.control[data-action="select-group"][data-state="all"] {
  border-color: color-mix(in srgb, var(--group-color, var(--color-primary)) 66%, var(--color-border));
  background: color-mix(in srgb, var(--group-color, var(--color-primary)) 14%, white);
  color: var(--color-text);
  box-shadow: inset 3px 0 0 var(--group-color, var(--color-primary));
}

.page-graph .metric-tab:focus-visible,
.page-graph .overlay-legend-item:focus-visible,
.page-graph canvas:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 2px;
}

.page-graph .chart-shell {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--color-surface);
}

.page-graph .chart-shell.split-card-mode {
  flex: 0 0 auto;
  height: auto;
  min-height: 0;
  overflow: visible;
  border: 0;
  background: transparent;
}

.page-graph .split-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
  padding: var(--space-4);
}

.page-graph .split-chart-grid[hidden] {
  display: none;
}

.page-graph .split-chart-grid > * {
  min-width: 0;
}

.page-graph .split-chart-grid.is-single .split-chart-card {
  grid-column: 1 / -1;
}

.page-graph .split-chart-card {
  min-width: 0;
  height: 272px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  box-shadow: none;
  outline: none;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.page-graph .split-chart-card:hover,
.page-graph .split-chart-card.is-hovered,
.page-graph .split-chart-card.is-cursor-source {
  border-color: #93b4ef;
  background: #fbfdff;
}

.page-graph .split-chart-card:focus-visible {
  border-color: #6f9ce8;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.page-graph .split-card-header {
  height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #eef2f7;
}

.page-graph .split-card-title-block,
.page-graph .split-card-values {
  min-width: 0;
}

.page-graph .split-card-title-block {
  overflow: hidden;
}

.page-graph .split-card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.page-graph .split-card-title > span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-graph .split-card-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--series-color);
}

.page-graph .split-card-unit {
  margin-left: 5px;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
}

.page-graph .split-card-values {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.page-graph .split-card-current {
  display: inline;
  color: var(--color-text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.page-graph .split-card-current.is-alarm {
  color: #dc2626;
}

.page-graph .split-card-stats {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 0;
  color: var(--color-text-muted);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.page-graph .split-card-plot {
  position: relative;
  height: 218px;
  min-width: 0;
  overflow: hidden;
}

.page-graph .split-card-plot canvas {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: block;
  cursor: crosshair;
}

.page-graph .split-card-cursor {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.page-graph .split-card-empty {
  grid-column: 1 / -1;
  min-height: 280px;
  display: grid;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 700;
}

.page-graph .chart-shell.is-loading .split-chart-card {
  opacity: 0.46;
}

.page-graph .chart-hover-tooltip.split-card-tooltip {
  position: fixed;
  z-index: 120;
  width: min(680px, calc(100% - 24px));
  max-width: min(680px, calc(100% - 24px));
  max-height: min(440px, calc(100dvh - 24px));
}

.page-graph .chart-hover-tooltip.split-card-tooltip,
.page-graph .chart-hover-tooltip.is-multi {
  display: none !important;
}

html.graph-split-card-mode,
html.graph-split-card-mode body.page-graph {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

.graph-split-card-mode .page-graph .shell {
  height: auto;
  min-height: 100vh;
  overflow: visible;
}

.graph-split-card-mode .page-graph .content {
  height: auto;
  min-height: 100vh;
  overflow: visible;
}

.graph-split-card-mode .page-graph .panel {
  flex: 0 0 auto;
  overflow: visible;
}

@media (max-width: 1024px) {
  .page-graph .split-chart-card {
    height: 282px;
  }

  .page-graph .split-card-plot {
    height: 216px;
  }
}

@media (max-width: 560px) {
  .page-graph .split-chart-grid {
    gap: 12px;
    padding: 12px;
  }

  .page-graph .split-card-header {
    height: 50px;
    min-height: 50px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px;
    padding: 7px 9px;
  }

  .page-graph .split-card-values {
    gap: 4px;
    text-align: right;
  }

  .page-graph .split-card-current {
    font-size: 12px;
  }

  .page-graph .split-card-stats {
    gap: 4px;
    margin-top: 0;
    font-size: 8px;
  }

  .page-graph .split-chart-card {
    height: 290px;
  }

  .page-graph .split-card-plot {
    height: 238px;
  }

  .page-graph .chart-hover-tooltip.split-card-tooltip {
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    top: auto !important;
    width: auto;
    max-width: none;
    max-height: 42vh;
    transform: none !important;
  }
}

.page-graph .chart-wrap {
  padding: var(--space-3) var(--space-3) 0;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.page-graph .chart-wrap::-webkit-scrollbar,
.page-graph .metric-tab-groups::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.page-graph .chart-wrap::-webkit-scrollbar-track,
.page-graph .metric-tab-groups::-webkit-scrollbar-track {
  background: transparent;
}

.page-graph .chart-wrap::-webkit-scrollbar-thumb,
.page-graph .metric-tab-groups::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: #cbd5e1;
  background-clip: padding-box;
}

.page-graph .chart-wrap:hover::-webkit-scrollbar-thumb,
.page-graph .metric-tab-groups:hover::-webkit-scrollbar-thumb {
  background: #94a3b8;
  background-clip: padding-box;
}

.page-graph canvas {
  outline: none;
}

.page-graph .chart-cursor-layer {
  position: absolute;
  left: var(--space-3);
  top: var(--space-3);
  z-index: 5;
  width: calc(100% - var(--space-3) * 2);
  height: var(--chart-canvas-height, 100%);
  min-height: 0;
  pointer-events: none;
  cursor: default;
}

.page-graph .overlay-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 92px;
  overflow-y: auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
  scrollbar-width: thin;
}

.page-graph .overlay-legend[hidden] {
  display: none;
}

.page-graph .overlay-legend-item {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: var(--color-surface);
  color: #334155;
  font-size: 10px;
  font-weight: 700;
  box-shadow: none;
}

.page-graph .overlay-legend-item strong {
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.page-graph .overlay-legend-item.is-hidden {
  border-style: dashed;
  background: transparent;
  color: #94a3b8;
  opacity: 0.72;
}

.page-graph .overlay-legend-item.is-hidden .legend-dot {
  background: #cbd5e1;
}

.page-graph .chart-time-axis {
  flex-basis: 40px;
  padding: 0 var(--space-3);
}

.page-graph .chart-time-tick {
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
}

.page-graph .chart-hover-tooltip {
  max-width: min(680px, calc(100% - 32px));
  max-height: min(440px, calc(100% - 24px));
  overflow: hidden;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.11);
}

.page-graph .chart-hover-time {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
  color: #334155;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.page-graph .chart-hover-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  overflow-y: auto;
  max-height: 370px;
}

.page-graph .chart-hover-tooltip[data-count="9"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="10"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="11"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="12"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="13"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="14"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="15"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="16"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="17"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="18"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="19"] .chart-hover-rows {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.page-graph .chart-hover-tooltip[data-count="7"] .chart-hover-rows,
.page-graph .chart-hover-tooltip[data-count="8"] .chart-hover-rows {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}

.page-graph .chart-hover-group {
  min-width: 0;
}

.page-graph .chart-hover-group-title,
.page-graph .tooltip-group-title {
  margin-bottom: 5px;
  color: #64748b;
  font-size: 9px;
  font-weight: 800;
}

.page-graph .chart-hover-group-grid,
.page-graph .tooltip-group-grid {
  display: grid;
  gap: 4px;
}

.page-graph .chart-hover-row {
  min-height: 21px;
  padding-bottom: 3px;
  border-bottom: 1px solid #eef2f7;
  font-variant-numeric: tabular-nums;
}

.page-graph .chart-hover-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-graph .tooltip.all-tooltip {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px 0;
  padding: 12px 16px 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  box-shadow: none;
}

.page-graph .tooltip-panel-header {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 8px;
}

.page-graph .tooltip-time {
  height: auto;
  padding: 0;
  border: 0;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.page-graph .tooltip-collapse {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text-muted);
  box-shadow: none;
}

.page-graph .tooltip-collapse:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-subtle);
  color: var(--color-text);
}

.page-graph .tooltip-collapse:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.24);
  outline-offset: 2px;
}

.page-graph .tooltip-collapse-icon {
  display: block;
  font-size: 17px;
  line-height: 1;
  transition: transform 120ms ease;
}

.page-graph .tooltip-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.page-graph .tooltip-group {
  min-width: 0;
}

.page-graph .tooltip-group-title {
  margin-bottom: 4px;
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.4;
}

.page-graph .tooltip-group-grid {
  grid-template-columns: repeat(var(--value-panel-columns, 4), minmax(0, 1fr));
  column-gap: 16px;
  row-gap: 0;
}

.page-graph .tooltip-row {
  min-width: 0;
  min-height: 30px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid #eef2f7;
  border-radius: 0;
  background: transparent;
}

.page-graph .tooltip-row .tooltip-row-label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.page-graph .tooltip-row-label > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-graph .tooltip-row b {
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  word-break: normal;
  white-space: nowrap;
}

.page-graph .tooltip-row.alarm {
  border-color: #fecaca;
  background: #fff7f7;
}

.page-graph .tooltip.all-tooltip.is-collapsed {
  padding-bottom: 12px;
}

.page-graph .tooltip.all-tooltip.is-collapsed .tooltip-panel-header {
  margin-bottom: 0;
}

.page-graph .tooltip.all-tooltip.is-collapsed .tooltip-metrics {
  display: none;
}

.page-graph .tooltip.all-tooltip.is-collapsed .tooltip-collapse-icon {
  transform: rotate(180deg);
}

.page-graph .chart-loading {
  align-items: stretch;
  justify-content: stretch;
  padding: 18px;
  background: rgba(255, 255, 255, 0.9);
}

.page-graph .chart-loading::before {
  content: "";
  flex: 1;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  background: #f8fafc;
}

.page-graph .chart-loading span {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

@media (max-width: 1024px) {
  .page-graph .tooltip-group-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .page-graph .chart-head {
    display: grid;
    min-width: 160px;
  }

  .page-graph .panel-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  .page-graph .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-graph .date-control {
    flex: 1 1 100%;
    padding-top: 8px;
  }

  .page-graph .chart-hover-tooltip.is-multi {
    position: fixed;
    left: 228px;
    right: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    max-width: none;
    max-height: 42vh;
    transform: none !important;
    background: #ffffff;
  }
}

@media (max-width: 960px) {
  .page-graph .panel-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .page-graph .chart-head {
    min-width: 0;
  }

  .page-graph .panel-actions {
    display: flex;
    justify-content: flex-start;
  }

  .page-graph .chart-hover-tooltip.is-multi {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    max-width: none;
    max-height: 42vh;
    transform: none !important;
  }

  .page-graph .chart-hover-tooltip[data-count] .chart-hover-rows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .page-graph .panel-actions,
  .page-graph .panel-record-tabs {
    width: 100%;
  }

  .page-graph .panel-record-tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  .page-graph .metric-select-toggle,
  .page-graph .view-mode-toggle,
  .page-graph .chart-layout-toggle {
    width: 100%;
  }

  .page-graph .record-tab,
  .page-graph .layout-button {
    flex: 1 1 0;
  }

  .page-graph .metric-tab-controls {
    max-height: 124px;
    overflow-y: auto;
  }

  .page-graph .chart-hover-tooltip[data-count] .chart-hover-rows {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-graph .tooltip.all-tooltip {
    display: block;
    max-height: none;
    overflow: visible;
  }

  .page-graph .tooltip-metrics {
    grid-template-columns: minmax(0, 1fr);
    max-height: min(36vh, 320px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
  }

  .page-graph .tooltip-group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .page-graph .tooltip.all-tooltip {
    width: calc(100% - 24px);
    margin: 10px 12px 0;
    padding: 10px 12px 12px;
  }

  .page-graph .tooltip-group-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-graph .tooltip-metrics {
    max-height: min(34vh, 280px);
  }
}

/* Record data workspace: stable toolbar and responsive card columns */
.page-history .panel-toolbar,
.page-graph .panel-toolbar {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 80px;
  padding: 12px 16px;
}

.page-graph .panel-toolbar {
  grid-template-columns: max-content minmax(0, 1fr);
}

.page-history .record-toolbar-heading,
.page-graph .record-toolbar-heading {
  min-width: 0;
  width: 100%;
  min-height: 44px;
  height: 44px;
  align-items: center;
}

.page-history .record-toolbar-actions,
.page-graph .record-toolbar-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "primary date-export";
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.page-history .toolbar-primary-actions,
.page-graph .toolbar-primary-actions {
  grid-area: primary;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  flex-wrap: nowrap;
}

.page-history .record-toolbar-actions > .date-control,
.page-graph .record-toolbar-actions > .date-control {
  grid-area: date;
  order: initial;
  flex: none;
}

.page-history .record-toolbar-actions > .export-actions,
.page-graph .record-toolbar-actions > .export-actions {
  grid-area: export;
  order: initial;
  flex: none;
}

.page-history .panel-record-tabs,
.page-graph .panel-record-tabs {
  order: initial;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.page-history .column-count-toggle,
.page-graph .column-count-toggle {
  height: 40px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-muted);
  flex: 0 0 auto;
}

.page-history .column-count-toggle,
.page-graph .column-count-toggle {
  width: 132px;
}

.page-history .column-count-toggle .layout-button,
.page-graph .column-count-toggle .layout-button {
  flex: 1 1 0;
  min-width: 0;
}

.page-graph .column-count-toggle.is-suspended {
  opacity: 0.72;
}

.page-history .layout-button,
.page-graph .layout-button {
  height: 32px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.page-history .toolbar-placeholder {
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.page-graph .graph-advanced-menu {
  position: relative;
  flex: 0 0 auto;
}

.page-graph .advanced-menu-summary,
.page-history .advanced-menu-summary {
  width: 82px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

.page-graph .advanced-menu-summary::-webkit-details-marker {
  display: none;
}

.page-graph .advanced-menu-summary:hover,
.page-graph .advanced-menu-summary:focus-visible,
.page-graph .graph-advanced-menu[open] .advanced-menu-summary,
.page-graph .graph-advanced-menu.is-overlay .advanced-menu-summary {
  border-color: #93b4ef;
  background: var(--color-primary-soft);
  color: #1d4ed8;
}

.page-graph .advanced-menu-summary:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.page-graph .advanced-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 2100;
  width: 230px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
}

.page-graph .graph-advanced-menu:not([open]) .advanced-menu-popover {
  display: none;
}

.page-graph .advanced-menu-title {
  padding: 4px 8px 6px;
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 800;
}

.page-graph .advanced-menu-option {
  min-height: 48px;
  display: grid;
  gap: 2px;
  justify-items: start;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.page-graph .advanced-menu-option span {
  font-size: 12px;
  font-weight: 800;
}

.page-graph .advanced-menu-option small {
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
}

.page-graph .advanced-menu-option:hover,
.page-graph .advanced-menu-option:focus-visible {
  border-color: var(--color-border);
  background: var(--color-surface-subtle);
  outline: none;
}

.page-graph .advanced-menu-option.active {
  border-color: #bfdbfe;
  background: var(--color-primary-soft);
  color: #1d4ed8;
}

.page-graph .advanced-menu-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-graph .split-chart-grid[data-effective-columns="1"] {
  grid-template-columns: minmax(0, 1fr);
}

.page-graph .split-chart-grid[data-effective-columns="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.page-graph .split-chart-grid[data-effective-columns="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.page-graph .chart-shell.is-one-column .split-chart-card {
  height: 320px;
}

.page-graph .chart-shell.is-one-column .split-card-plot {
  height: 266px;
}

.page-graph .chart-shell.is-three-column .split-chart-card {
  height: 252px;
}

.page-graph .chart-shell.is-three-column .split-card-header {
  height: 50px;
  gap: 5px;
  padding: 7px 9px;
}

.page-graph .chart-shell.is-three-column .split-card-title {
  font-size: 11px;
}

.page-graph .chart-shell.is-three-column .split-card-unit {
  margin-left: 3px;
  font-size: 9px;
}

.page-graph .chart-shell.is-three-column .split-card-current {
  font-size: 12px;
}

.page-graph .chart-shell.is-three-column .split-card-stats {
  gap: 4px;
  font-size: 8px;
}

.page-graph .chart-shell.is-three-column .split-card-plot {
  height: 200px;
}

@media (max-width: 1200px) {
  .page-graph .panel-toolbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
  }
}

@media (max-width: 1160px) {
  .page-history .record-toolbar-actions,
  .page-graph .record-toolbar-actions {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "primary"
      "date-export";
    align-items: end;
  }

  .page-history .toolbar-primary-actions,
  .page-graph .toolbar-primary-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 1024px) {
  .page-graph .chart-shell.is-one-column .split-chart-card,
  .page-graph .chart-shell.is-two-column .split-chart-card,
  .page-graph .chart-shell.is-three-column .split-chart-card {
    height: 300px;
  }

  .page-graph .chart-shell.is-one-column .split-card-plot,
  .page-graph .chart-shell.is-two-column .split-card-plot,
  .page-graph .chart-shell.is-three-column .split-card-plot {
    height: 248px;
  }
}

@media (max-width: 760px) {
  .page-history .record-toolbar-actions,
  .page-graph .record-toolbar-actions {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "primary"
      "date"
      "export";
  }

  .page-history .toolbar-primary-actions,
  .page-graph .toolbar-primary-actions {
    flex-wrap: wrap;
  }

  .page-history .toolbar-placeholder {
    display: none;
  }

  .page-history .record-toolbar-actions > .export-actions,
  .page-graph .record-toolbar-actions > .export-actions {
    justify-content: flex-end;
  }

  .page-history .panel-record-tabs,
  .page-graph .panel-record-tabs {
    width: 100%;
    display: flex;
  }

  .page-history .panel-record-tabs .metric-picker-wrap,
  .page-graph .panel-record-tabs .metric-picker-wrap,
  .page-history .panel-record-tabs .view-mode-toggle,
  .page-graph .panel-record-tabs .view-mode-toggle {
    flex: 1 1 0;
    width: auto;
  }

  .page-history .metric-select-toggle,
  .page-graph .metric-select-toggle,
  .page-history .view-mode-toggle,
  .page-graph .view-mode-toggle {
    width: 100%;
  }

  .page-graph .column-count-toggle {
    width: auto;
  }
}

@media (max-width: 480px) {
  .page-history .panel-toolbar,
  .page-graph .panel-toolbar {
    padding: 10px 12px;
  }

  .page-history .panel-record-tabs,
  .page-graph .panel-record-tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .page-graph .column-count-toggle {
    flex: 1 1 auto;
  }

  .page-graph .graph-advanced-menu {
    margin-left: auto;
  }
}

/* Mobile stability layer */
@media (max-width: 960px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
  select,
  textarea {
    width: 100%;
    min-width: 0;
    font-size: 16px;
  }

  button,
  .link-button,
  .record-tab,
  .layout-button,
  .settings-tab,
  .export-button,
  .date-step,
  .date-display {
    min-height: 44px;
    touch-action: manipulation;
  }

  .topbar,
  .panel,
  .page-history .panel-toolbar,
  .page-graph .panel-toolbar {
    width: 100%;
    max-width: 100%;
  }

  .page-live .test-clock {
    min-width: 118px;
  }

  .page-live .status,
  .page-lte .status-pill {
    min-width: 88px;
    justify-content: center;
    white-space: nowrap;
  }

  .page-live .metric,
  .page-live .metric-value,
  .page-live .metric-value .value,
  .page-live .unit {
    min-width: 0;
  }

  .page-live .metric-value .value,
  .page-live #wind_direction.value,
  .page-live .unit {
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
  }

  .page-history .table-wrap,
  .page-admin table,
  .settings-tabs,
  .page-lte .chart-legend {
    max-width: 100%;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .page-history .table-wrap {
    width: 100% !important;
    touch-action: pan-x pan-y;
  }

  .page-history table {
    table-layout: fixed;
  }

  .page-history th,
  .page-history td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-history th:first-child,
  .page-history td:first-child {
    background: var(--color-surface);
  }

  .page-history th:first-child {
    background: var(--color-surface-subtle);
  }

  .page-history .date-popover,
  .page-graph .date-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    top: calc(76px + env(safe-area-inset-top));
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 88px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .page-graph .split-chart-grid,
  .page-graph .split-chart-card,
  .page-graph .split-card-plot,
  .page-graph .chart-wrap,
  .page-graph canvas,
  .page-lte .chart-frame,
  .page-lte canvas {
    min-width: 0;
    max-width: 100%;
  }

  .page-graph .split-card-plot,
  .page-graph .chart-wrap,
  .page-lte .chart-frame {
    touch-action: pan-y;
    overscroll-behavior-x: contain;
  }

  .page-settings .panel {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .page-settings .actions {
    width: 100%;
    max-width: 100%;
  }

  .page-admin .panel form,
  .page-admin .panel label,
  .page-admin .panel input,
  .page-admin .panel select,
  .page-admin .panel button[type="submit"] {
    width: 100%;
    min-width: 0;
  }

  .page-admin table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 720px) {
  .page-signage .panel,
  .page-lte .panel,
  .page-settings .panel,
  .page-admin .panel {
    padding: var(--space-4);
  }

  .page-signage .background-option,
  .page-signage .layout-option,
  .page-signage .layout-option[data-layout="1"] {
    min-height: 132px;
  }

  .page-signage .slot-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-signage .preview-actions button {
    width: 100%;
  }

  .page-lte #status_content,
  .page-lte .empty {
    min-height: 280px;
  }

  .page-lte .chart-frame {
    width: 100%;
    height: 300px;
  }

  .page-history .record-toolbar-actions,
  .page-graph .record-toolbar-actions {
    gap: 12px;
  }

  .page-history .toolbar-primary-actions,
  .page-graph .toolbar-primary-actions {
    align-items: stretch;
    gap: 8px;
  }
}

@media (max-width: 460px) {
  .page-login .login {
    width: 100%;
    min-height: 100dvh;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    overflow-y: auto;
  }

  .page-login .login .card {
    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: 32px 24px;
  }

  .page-login .login button[type="submit"] {
    width: 100%;
    min-height: 44px;
  }

  .page-live .topbar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .page-live .live-config-button,
  .page-live .test-clock,
  .page-live .status {
    width: 100%;
  }

  .page-settings .email-row,
  .page-settings .phone-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-settings .remove-email,
  .page-settings .remove-phone {
    width: 100%;
  }
}

/* Record data mobile toolbar: final cascade layer */
@media (max-width: 960px) {
  body.metric-picker-open {
    overflow: hidden !important;
  }

  .page-history .panel-toolbar,
  .page-graph .panel-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-rows: max-content;
    align-content: start !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    gap: 8px !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 10px 12px !important;
    overflow: visible !important;
  }

  .page-history .record-mobile-toolbar,
  .page-graph .record-mobile-toolbar {
    order: 1;
    display: grid !important;
    flex: none !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: none !important;
    grid-auto-rows: max-content;
    align-content: start !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    box-sizing: border-box;
  }

  .page-history .record-mobile-toolbar > *,
  .page-graph .record-mobile-toolbar > *,
  .page-history .record-mobile-toolbar__primary > *,
  .page-graph .record-mobile-toolbar__primary > *,
  .page-graph .record-mobile-toolbar__graph-actions > * {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .page-history .record-mobile-toolbar > .toolbar-primary-actions,
  .page-graph .record-mobile-toolbar > .toolbar-primary-actions {
    display: contents !important;
  }

  .page-history .record-mobile-toolbar .admin-device-switch,
  .page-graph .record-mobile-toolbar .admin-device-switch {
    order: 4;
    grid-template-columns: max-content minmax(0, 1fr);
    width: 100%;
  }

  .page-history .record-mobile-toolbar__primary,
  .page-graph .record-mobile-toolbar__primary {
    order: 1;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(136px, 42%) !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px;
    height: 44px;
    align-items: stretch;
  }

  .page-history .record-mobile-toolbar__date-export,
  .page-graph .record-mobile-toolbar__date-export {
    order: 2;
    display: grid !important;
    grid-area: auto !important;
    grid-template-columns: 40px minmax(0, 1fr) 40px 44px 44px !important;
    gap: 4px !important;
    align-items: center !important;
    justify-content: stretch !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px;
    height: 44px;
    margin: 0 !important;
    padding: 0 !important;
  }

  .page-graph .record-mobile-toolbar__graph-actions {
    order: 3;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
    align-items: stretch !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px !important;
    height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .page-history .record-mobile-toolbar__primary .metric-picker-wrap,
  .page-graph .record-mobile-toolbar__primary .metric-picker-wrap {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .page-history .record-mobile-toolbar .metric-select-toggle,
  .page-graph .record-mobile-toolbar .metric-select-toggle,
  .page-history .record-mobile-toolbar .view-mode-toggle,
  .page-graph .record-mobile-toolbar .view-mode-toggle,
  .page-graph .record-mobile-toolbar .advanced-menu-summary,
  .page-history .record-mobile-toolbar .date-step,
  .page-graph .record-mobile-toolbar .date-step,
  .page-history .record-mobile-toolbar .date-display,
  .page-graph .record-mobile-toolbar .date-display,
  .page-history .record-mobile-toolbar .export-button,
  .page-graph .record-mobile-toolbar .export-button {
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px !important;
    height: 44px !important;
    margin: 0 !important;
    box-sizing: border-box;
    font-size: 13px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    writing-mode: horizontal-tb !important;
  }

  .page-history .record-mobile-toolbar .metric-select-toggle,
  .page-graph .record-mobile-toolbar .metric-select-toggle {
    width: 100% !important;
    padding: 0 10px !important;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
  }

  .page-history .record-mobile-toolbar .view-mode-toggle,
  .page-graph .record-mobile-toolbar .view-mode-toggle {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(64px, 1fr)) !important;
    gap: 2px !important;
    width: 100% !important;
    padding: 3px !important;
  }

  .page-history .record-mobile-toolbar .view-mode-toggle,
  .page-graph .record-mobile-toolbar .view-mode-toggle {
    min-width: 136px !important;
  }

  .page-history .record-mobile-toolbar .view-mode-toggle > .record-tab,
  .page-graph .record-mobile-toolbar .view-mode-toggle > .record-tab {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 36px !important;
    height: 36px !important;
    padding: 0 6px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    writing-mode: horizontal-tb !important;
  }

  .page-graph .record-mobile-toolbar .column-count-toggle[hidden],
  .page-graph .record-mobile-toolbar [hidden] {
    display: none !important;
  }

  .page-graph .record-mobile-toolbar .graph-advanced-menu {
    width: 100% !important;
    min-width: 96px !important;
    max-width: 112px !important;
    height: 44px;
    margin: 0 !important;
  }

  .page-graph .record-mobile-toolbar .advanced-menu-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    padding: 0 8px !important;
  }

  .page-graph .record-mobile-toolbar .advanced-menu-popover {
    left: auto;
    right: 0;
    width: 272px;
    max-width: calc(100% + 160px);
  }

  .page-history .record-mobile-toolbar__date-export > .date-control,
  .page-graph .record-mobile-toolbar__date-export > .date-control,
  .page-history .record-mobile-toolbar__date-export .date-nav,
  .page-graph .record-mobile-toolbar__date-export .date-nav,
  .page-history .record-mobile-toolbar__date-export > .export-actions,
  .page-graph .record-mobile-toolbar__date-export > .export-actions {
    display: contents !important;
    flex: none !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .page-history .record-mobile-toolbar .date-control-label,
  .page-graph .record-mobile-toolbar .date-control-label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  .page-history .record-mobile-toolbar .date-step,
  .page-graph .record-mobile-toolbar .date-step,
  .page-history .record-mobile-toolbar .date-display,
  .page-graph .record-mobile-toolbar .date-display,
  .page-history .record-mobile-toolbar .export-button,
  .page-graph .record-mobile-toolbar .export-button {
    width: 100% !important;
    padding: 0 !important;
  }

  .page-history .record-mobile-toolbar .date-display,
  .page-graph .record-mobile-toolbar .date-display {
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
  }

  .page-history .record-mobile-toolbar .date-display > span,
  .page-graph .record-mobile-toolbar .date-display > span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-history .record-toolbar-heading,
  .page-graph .record-toolbar-heading {
    order: 2;
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 18px !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 2px !important;
  }

  .page-history .summary-pill,
  .page-graph .chart-caption,
  .page-graph .record-toolbar-heading .summary-pill {
    min-height: 18px !important;
    height: auto !important;
    font-size: 11px !important;
    line-height: 18px !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap !important;
  }

  .page-history .metric-tabs,
  .page-graph .metric-tabs {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    top: calc(76px + env(safe-area-inset-top)) !important;
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column;
    overflow: hidden !important;
    overscroll-behavior: contain;
    padding: 0 !important;
  }

  .page-history .item-picker-overlay,
  .page-graph .item-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 1900;
    display: block;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.34);
  }

  .page-history .item-picker-overlay[hidden],
  .page-graph .item-picker-overlay[hidden],
  .page-history .metric-tabs[hidden],
  .page-graph .metric-tabs[hidden] {
    display: none !important;
  }

  .page-history .item-picker-scroll-body,
  .page-graph .item-picker-scroll-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  }

  .page-history .metric-tabs .metric-tab-groups,
  .page-graph .metric-tabs .metric-tab-groups {
    min-height: auto;
    overflow: visible !important;
  }
}

@media (max-width: 839px) {
  .page-graph .record-mobile-toolbar .column-count-toggle {
    display: none !important;
  }
}

@media (min-width: 840px) and (max-width: 960px) {
  .page-graph .record-mobile-toolbar__graph-actions {
    grid-template-columns: 132px !important;
  }
}

@media (max-width: 480px) {
  .page-history .content,
  .page-graph .content {
    padding-right: max(8px, env(safe-area-inset-right)) !important;
    padding-left: max(8px, env(safe-area-inset-left)) !important;
  }

  .page-history .panel-toolbar,
  .page-graph .panel-toolbar {
    padding: 10px 8px !important;
  }
}

/* Plot-only touch ownership while the synchronized cursor is active. */
.page-graph .graph-plot-interaction-layer {
  position: absolute;
  z-index: 6;
  display: block;
  border: 0;
  background: transparent;
  cursor: crosshair;
  pointer-events: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.page-graph .chart-wrap > canvas,
.page-graph .split-card-plot > canvas {
  cursor: default;
}

.page-graph .graph-plot-interaction-layer[hidden] {
  display: none;
}

.page-graph .chart-shell.is-cursor-mode .graph-plot-interaction-layer {
  touch-action: none;
  overscroll-behavior: contain;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.page-graph .split-chart-card.is-pointer-interacting,
.page-graph .chart-wrap.is-pointer-interacting {
  border-color: #93b4ef;
  background: #fbfdff;
}

/* Record item picker: keep the context and close action visible while scrolling. */
.page-history .item-picker-header,
.page-graph .item-picker-header {
  position: relative;
  z-index: 5;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  margin: 0;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
}

.page-history .item-picker-heading,
.page-graph .item-picker-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.page-history .item-picker-heading strong,
.page-graph .item-picker-heading strong {
  color: var(--color-text);
  font-size: 14px;
  font-weight: 800;
}

.page-history .item-picker-heading span,
.page-graph .item-picker-heading span {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.page-history .item-picker-close,
.page-graph .item-picker-close {
  min-width: 92px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: #334155;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.page-history .item-picker-close:hover,
.page-graph .item-picker-close:hover {
  border-color: #94a3b8;
  background: var(--color-surface-subtle);
  color: var(--color-text);
}

.page-history .item-picker-close:focus-visible,
.page-graph .item-picker-close:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.page-history .metric-tab-controls,
.page-graph .metric-tab-controls {
  position: static !important;
}

/* Data exports use a stable semantic color system on both record views. */
.page-history .export-button.export-button--data,
.page-graph .export-button.export-button--data {
  border-color: #16a34a;
  background: #16a34a;
  color: #ffffff;
}

.page-history .export-button.export-button--data:hover:not(:disabled),
.page-graph .export-button.export-button--data:hover:not(:disabled) {
  border-color: #15803d;
  background: #15803d;
  color: #ffffff;
}

.page-history .export-button.export-button--pdf,
.page-graph .export-button.export-button--pdf {
  border-color: #dc2626;
  background: #dc2626;
  color: #ffffff;
}

.page-history .export-button.export-button--pdf:hover:not(:disabled),
.page-graph .export-button.export-button--pdf:hover:not(:disabled) {
  border-color: #b91c1c;
  background: #b91c1c;
  color: #ffffff;
}

.page-history .export-button.export-button--data:focus-visible,
.page-graph .export-button.export-button--data:focus-visible,
.page-history .export-button.export-button--pdf:focus-visible,
.page-graph .export-button.export-button--pdf:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.38);
  outline-offset: 2px;
}

.page-history .export-button:disabled,
.page-graph .export-button:disabled {
  opacity: 0.5;
  filter: saturate(0.65);
  cursor: not-allowed;
}

.page-history.record-view-navigating .view-mode-toggle,
.page-graph.record-view-navigating .view-mode-toggle {
  cursor: progress;
}

.page-history.record-view-navigating .view-mode-toggle a,
.page-graph.record-view-navigating .view-mode-toggle a {
  pointer-events: none;
}

.page-history .history-time-heading-mobile,
.page-history .history-time-mobile {
  display: none;
}

.page-history .history-sticky-stack {
  display: contents;
}

.page-history .history-mobile-column-head {
  display: none;
}

.page-history .history-sticky-spacer {
  display: none;
}

@media (max-width: 960px) {
  .page-graph .record-mobile-toolbar__graph-actions {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .page-history .metric-tabs,
  .page-graph .metric-tabs {
    padding: 0;
  }

  .page-history .item-picker-header,
  .page-graph .item-picker-header {
    position: relative;
    top: auto;
  }
}

@media (min-width: 840px) and (max-width: 960px) {
  .page-graph .record-mobile-toolbar__graph-actions {
    grid-template-columns: 132px !important;
  }
}

@media (max-width: 768px) {
  .page-history .history-time-heading-full,
  .page-history .history-time-full {
    display: none;
  }

  .page-history .history-time-heading-mobile,
  .page-history .history-time-mobile {
    display: inline-flex;
  }

  .page-history .history-time-mobile {
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
  }

  .page-history .history-time-mobile time {
    font-weight: 750;
  }

  .page-history .history-mobile-date-boundary {
    color: var(--color-text-muted);
    font-size: 10px;
    font-weight: 700;
  }

  .page-history .history-table-scroll th:first-child,
  .page-history .history-table-scroll td:first-child {
    width: var(--history-time-col-width, clamp(64px, 17vw, 68px));
    min-width: var(--history-time-col-width, clamp(64px, 17vw, 68px));
    max-width: var(--history-time-col-width, clamp(64px, 17vw, 68px));
  }
}

@media (max-width: 390px) {
  .page-history .item-picker-heading,
  .page-graph .item-picker-heading {
    gap: 5px;
  }

  .page-history .item-picker-heading strong,
  .page-graph .item-picker-heading strong {
    font-size: 13px;
  }

  .page-history .item-picker-heading span,
  .page-graph .item-picker-heading span {
    font-size: 11px;
  }

  .page-history .item-picker-close,
  .page-graph .item-picker-close {
    min-width: 84px;
    padding: 0 10px;
  }
}

/* Mobile record views: the page owns vertical scrolling and graph values stay local. */
html.graph-mobile-cursor-only .page-graph #tooltip {
  display: none !important;
}

@media (max-width: 839px) {
  .page-graph .record-mobile-toolbar__graph-actions {
    display: none !important;
  }
}

@media (max-width: 960px) {
  html.page-history-root {
    height: auto !important;
    min-height: 100%;
    overflow-x: clip;
    overflow-y: auto !important;
  }

  html.page-history-root body.page-history:not(.ui-scroll-locked) {
    height: auto !important;
    min-height: 100dvh;
    overflow-y: visible !important;
  }

  .page-history .shell {
    height: auto !important;
    min-height: 100dvh !important;
    overflow-x: clip !important;
    overflow-y: visible !important;
  }

  .page-history .content {
    height: auto !important;
    min-height: 0 !important;
    overflow-x: clip !important;
    overflow-y: visible !important;
  }

  .page-history .panel {
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow-x: clip !important;
    overflow-y: visible !important;
  }

  .page-history .history-sticky-stack {
    position: fixed;
    top: calc(68px + env(safe-area-inset-top));
    z-index: 800;
    display: block;
    left: 12px;
    right: 12px;
    width: auto;
    min-width: 0;
    background: #ffffff;
    box-shadow: 0 1px 0 var(--color-border), 0 6px 16px -16px rgba(15, 23, 42, 0.45);
  }

  .page-history .history-sticky-spacer {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    height: 186px;
    pointer-events: none;
  }

  .page-history .history-sticky-stack > .panel-toolbar {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
    background: #ffffff;
  }

  .page-history .history-mobile-column-head {
    display: grid;
    grid-template-columns: var(--history-time-col-width, clamp(64px, 17vw, 68px)) minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    height: 44px;
    overflow: hidden;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-subtle);
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 750;
    line-height: 1.2;
  }

  .page-history .history-mobile-column-head__time,
  .page-history .history-mobile-column-head__metric {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 43px;
    padding: 0 5px;
    box-sizing: border-box;
    white-space: nowrap;
  }

  .page-history .history-mobile-column-head__time {
    position: relative;
    z-index: 2;
    border-right: 1px solid var(--color-border);
    background: var(--color-surface-subtle);
    box-shadow: 4px 0 8px -8px rgba(15, 23, 42, 0.42);
  }

  .page-history .history-mobile-column-head__viewport {
    min-width: 0;
    overflow: hidden;
  }

  .page-history .history-mobile-column-head__track {
    display: flex;
    width: max-content;
    height: 43px;
    will-change: transform;
    transition: none !important;
    animation: none;
    backface-visibility: hidden;
  }

  .page-history .history-mobile-column-head__metric {
    flex: 0 0 var(--history-metric-col-width, clamp(96px, 26vw, 106px));
    width: var(--history-metric-col-width, clamp(96px, 26vw, 106px));
    border-right: 1px solid var(--color-border);
    font-variant-numeric: tabular-nums;
  }

  .page-history .history-table-scroll {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    flex: 0 0 auto !important;
    align-self: stretch;
    overflow-x: auto !important;
    overflow-y: visible !important;
    overscroll-behavior-x: none;
    overscroll-behavior-inline: none;
    overscroll-behavior-y: auto;
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: auto;
    scrollbar-gutter: auto;
    isolation: auto;
  }

  .page-history .history-table-scroll table {
    width: max-content !important;
    min-width: max(100%, var(--history-table-min-width, 820px)) !important;
    table-layout: fixed !important;
    transform: none !important;
    filter: none !important;
    perspective: none !important;
  }

  .page-history .history-table-scroll thead {
    display: none;
  }

  .page-history .history-table-scroll th:not(:first-child),
  .page-history .history-table-scroll td:not(:first-child) {
    width: var(--history-metric-col-width, clamp(96px, 26vw, 106px));
    min-width: var(--history-metric-col-width, clamp(96px, 26vw, 106px));
    max-width: var(--history-metric-col-width, clamp(96px, 26vw, 106px));
  }

  .page-history .history-table-scroll th:first-child,
  .page-history .history-table-scroll td:first-child {
    position: sticky;
    left: 0;
    width: var(--history-time-col-width, clamp(64px, 17vw, 68px));
    min-width: var(--history-time-col-width, clamp(64px, 17vw, 68px));
    max-width: var(--history-time-col-width, clamp(64px, 17vw, 68px));
    border-right: 1px solid var(--color-border);
    background: #ffffff;
    box-shadow: 4px 0 8px -8px rgba(15, 23, 42, 0.42);
  }

  .page-history .history-table-scroll th:first-child {
    z-index: 6;
    background: var(--color-surface-subtle);
  }

  .page-history .history-table-scroll td:first-child {
    z-index: 3;
    background: inherit;
  }

  .page-history .history-table-scroll td {
    padding-inline: var(--history-cell-pad-x, 6px);
    font-size: 13px;
  }

  .page-history .history-table-scroll td:first-child {
    padding-inline: 6px;
  }

  .page-history .history-table-scroll .unit {
    margin-left: 2px;
    font-size: 10px;
  }
}

/* Live monitor cards stay dense and scannable on phones. */
@media (max-width: 560px),
       (max-width: 960px) and (max-height: 560px) and (hover: none) and (pointer: coarse) {
  .page-live .metrics {
    gap: 16px;
  }

  .page-live .metric-section {
    gap: 8px;
  }

  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: 120px;
    gap: 8px;
  }

  .page-live .metric,
  .page-live .primary-section .metric {
    min-width: 0;
    min-height: 120px;
    height: 120px;
    padding: 10px 12px;
    gap: 5px;
  }

  .page-live .metric-head,
  .page-live .metric-label {
    min-width: 0;
  }

  .page-live .metric-label {
    overflow: hidden;
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-live .metric-value {
    width: 100%;
    min-height: 36px;
    margin-top: auto;
    padding: 2px 0 0;
    gap: 3px;
  }

  .page-live .metric-value .value,
  .page-live #wind_direction.value,
  .page-live .primary-section .metric-value .value {
    font-size: 28px !important;
    line-height: 1.05;
  }

  .page-live .metric.pressure .metric-value .value,
  .page-live .metric.light .metric-value .value {
    font-size: 26px !important;
  }

  .page-live .unit {
    flex: 0 0 auto;
    font-size: 10px;
    line-height: 1.2;
  }

  .page-live .metric-text-value {
    min-height: 36px;
    margin-top: auto;
    padding-top: 2px;
    overflow: hidden;
    font-size: 27px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-live .sparkline {
    flex-basis: 20px;
    height: 20px;
  }

  .page-live .metric.direction .metric-body {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center !important;
    gap: 4px !important;
    min-width: 0;
  }

  .page-live .metric.direction .metric-value {
    width: auto;
    min-width: 0;
    min-height: 0;
    padding: 0;
  }

  .page-live .metric.direction .compass-wrap {
    min-width: 0;
  }

  .page-live .metric.direction .compass {
    width: 44px;
    height: 44px;
  }

  .page-live #direction_name {
    max-width: 100%;
    overflow: hidden;
    font-size: 10px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 279px) {
  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Desktop live monitor: increase information density without changing mobile cards. */
@media (min-width: 961px) {
  .page-live .metrics {
    gap: 20px;
  }

  .page-live .metric-section {
    gap: 10px;
  }

  .page-live .metric-section-head {
    padding-inline: 4px;
  }

  .page-live .metric-section-title {
    font-size: 14px;
  }

  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-auto-rows: 136px;
    gap: 12px;
  }

  .page-live .metric,
  .page-live .primary-section .metric {
    min-height: 136px;
    height: 136px;
    padding: 14px;
    gap: 6px;
  }

  .page-live .metric-label {
    font-size: 12px;
    line-height: 1.35;
  }

  .page-live .metric-value {
    min-height: 44px;
    padding: 4px 0 0;
    gap: 4px;
  }

  .page-live .metric-value .value,
  .page-live #wind_direction.value {
    font-size: 38px !important;
  }

  .page-live .primary-section .metric-value .value {
    font-size: 42px !important;
  }

  .page-live .metric.pressure .metric-value .value,
  .page-live .metric.light .metric-value .value {
    font-size: 36px !important;
  }

  .page-live .unit {
    font-size: 11px;
  }

  .page-live .metric-text-value {
    min-height: 44px;
    padding-top: 4px;
    font-size: 30px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .page-live .sparkline {
    flex-basis: 26px;
    height: 26px;
  }

  .page-live .metric.direction .metric-body {
    gap: 8px !important;
  }

  .page-live .metric.direction .metric-value {
    min-height: 0;
    padding: 0;
  }

  .page-live .metric.direction .compass {
    width: 56px;
    height: 56px;
  }

  .page-live #direction_name {
    max-width: 100%;
    overflow: hidden;
    font-size: 11px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (min-width: 961px) and (max-width: 1024px) {
  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1025px) and (max-width: 1279px) {
  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) and (max-width: 1459px) {
  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (min-width: 1460px) {
  .page-live .metric-section-grid,
  .page-live .primary-section .metric-section-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* Settings workspace: quiet SaaS hierarchy without changing form behavior. */
body.page-settings {
  background: #edf1f6;
}

.page-settings .content {
  gap: 16px;
  background: #edf1f6;
}

.page-settings .topbar {
  min-height: 72px;
  padding: 14px 20px;
  border-color: #c7d2df;
  background: #e3e9f1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.page-settings .topbar h1 {
  color: #172033;
  font-size: 24px;
  font-weight: 850;
}

.page-settings .settings-tabs {
  gap: 3px;
  padding: 4px;
  border-color: #bac7d6;
  background: #d5dee9;
}

.page-settings .settings-tab,
.page-settings .settings-tab.profile-tab,
.page-settings .settings-tab.alarm-tab,
.page-settings .settings-tab.notification-tab {
  min-height: 36px;
  height: 36px;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  font-weight: 750;
}

.page-settings .settings-tab:hover {
  border-color: #c4cfdb;
  background: #edf2f7;
  color: #172033;
}

.page-settings .settings-tab.active {
  border-color: #1d4ed8;
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(30, 64, 175, 0.22);
}

.page-settings .panel {
  gap: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.page-settings .message {
  border-color: #86d5aa;
  background: #e9f8ef;
}

.page-settings .message.error {
  border-color: #f0aaa8;
  background: #fff0f0;
}

.page-settings .device-row {
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  min-height: 88px;
  padding: 16px 20px;
  border-color: #c4d0de;
  border-left: 4px solid #2563eb;
  background: #e4ebf4;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
}

.page-settings .device-row label {
  color: #334155;
  font-weight: 800;
}

.page-settings .device-row .hint {
  color: #526176;
  font-weight: 500;
}

.page-settings select,
.page-settings input:not([type="checkbox"]):not([type="radio"]) {
  border-color: #b8c5d3;
  background: #ffffff;
  color: #172033;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
}

.page-settings select:hover,
.page-settings input:not([type="checkbox"]):not([type="radio"]):hover {
  border-color: #8fa1b5;
}

.page-settings select:focus,
.page-settings input:not([type="checkbox"]):not([type="radio"]):focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.page-settings form.tab-panel:has(.profile-grid) {
  display: grid;
  gap: 20px;
  padding: 24px;
  border: 1px solid #c9d3df;
  border-radius: 8px;
  background: #ffffff;
}

.page-settings .settings-groups {
  gap: 16px;
}

.page-settings .settings-group {
  gap: 16px;
  padding: 20px;
  border: 1px solid #c9d3df;
  border-radius: 8px;
  background: #ffffff;
}

.page-settings .settings-group-head {
  padding-bottom: 12px;
  border-bottom-color: #cbd5e1;
}

.page-settings .settings-group-head h2 {
  color: #172033;
  font-size: 15px;
}

.page-settings .settings-group-head span {
  color: #64748b;
  font-size: 12px;
}

.page-settings .metric-card {
  border-color: #d3dce7;
  background: #f7f9fc;
}

.page-settings .metric-card:hover {
  border-color: #9eacbc;
  background: #ffffff;
}

.page-settings .metric-card.threshold-active {
  border-color: #9ab9ee;
  background: #edf4ff;
}

.page-settings .notification-stack {
  gap: 0;
  overflow: hidden;
  border: 1px solid #c4cfdb;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.page-settings .notification-card {
  gap: 20px;
  padding: 24px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
}

.page-settings .notification-card + .notification-card {
  border-top: 8px solid #e4eaf1;
}

.page-settings .notification-card-title {
  position: relative;
  min-height: 28px;
  padding: 2px 0 8px 14px;
  border-bottom: 1px solid #cbd5e1;
  color: #172033;
  font-size: 16px;
  font-weight: 850;
}

.page-settings .notification-card-title::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 10px;
  left: 0;
  width: 4px;
  border-radius: 2px;
  background: #2563eb;
}

.page-settings .toggle-card {
  width: 100%;
  padding: 14px 16px;
  border-color: #cbd5e1;
  background: #f1f4f8;
}

.page-settings .toggle-card:hover {
  border-color: #9eacbc;
  background: #edf1f5;
}

.page-settings .toggle-card.active {
  border-color: #8fb2ec;
  background: #eaf2ff;
  box-shadow: inset 3px 0 0 #2563eb;
}

.page-settings .toggle-card > span {
  align-items: center;
  column-gap: 10px;
}

.page-settings .toggle-title {
  color: #172033;
  font-size: 14px;
}

.page-settings .toggle-card .hint {
  color: #526176;
}

.page-settings .notification-policy-grid {
  grid-template-columns: minmax(220px, 0.72fr) minmax(380px, 1.28fr) minmax(240px, 0.8fr);
  gap: 24px;
  margin-inline: -24px;
  padding: 18px 24px;
  border-top: 1px solid #d6dee8;
  border-bottom: 1px solid #d6dee8;
  background: #f3f6fa;
}

.page-settings .notification-policy-label,
.page-settings .notification-weekdays legend,
.page-settings .notification-hours legend,
.page-settings .field-row > label,
.page-settings .twilio-grid label {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.page-settings .notification-policy-field,
.page-settings .notification-weekdays,
.page-settings .notification-hours {
  gap: 9px;
}

.page-settings .notification-hours {
  min-width: 0;
}

.page-settings .notification-weekday-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: min(100%, 360px);
  gap: 4px;
}

.page-settings .notification-weekday-tab {
  min-width: 0;
  height: 40px;
  padding: 0;
  border: 1px solid #c4cfdb;
  border-radius: 6px;
  background: #ffffff;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.page-settings .notification-weekday-tab:hover {
  border-color: #8da4bf;
  background: #f8fafc;
}

.page-settings .notification-weekday-tab:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 1px;
}

.page-settings .notification-weekday-tab.is-active {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}

.page-settings .notification-weekday-tab.is-day-disabled:not(.is-active) {
  border-style: dashed;
  background: #f8fafc;
  color: #94a3b8;
}

.page-settings .notification-weekday-tab[data-weekday-tab="6"]:not(.is-active) {
  color: #2563eb;
}

.page-settings .notification-weekday-tab[data-weekday-tab="7"]:not(.is-active) {
  color: #dc2626;
}

.page-settings .notification-time-range {
  width: min(100%, 360px);
  gap: 8px;
}

.page-settings .notification-time-range label {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.page-settings .notification-time-range input {
  height: 42px;
  padding: 7px 9px;
  border: 1px solid #c4cfdb;
  border-radius: 6px;
  background: #ffffff;
  color: #172033;
  font-size: 13px;
  font-weight: 750;
}

.page-settings .notification-time-range input:focus {
  border-color: #2563eb;
  outline: 3px solid rgba(37, 99, 235, 0.15);
}

.page-settings .notification-time-separator {
  padding-bottom: 12px;
  color: #64748b;
}

.page-settings .notification-metric-selector {
  align-content: start;
}

.page-settings .notification-metric-trigger {
  width: min(100%, 360px);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 8px 14px;
  border: 1px solid #9fb4cf;
  border-radius: 6px;
  background: #ffffff;
  color: #1e4f8f;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.page-settings .notification-metric-trigger:hover {
  border-color: #7295c1;
  background: #f8fbff;
}

.page-settings .notification-metric-trigger:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

.page-settings .notification-metric-trigger[aria-expanded="true"] {
  border-color: #2563eb;
  background: #edf4ff;
  color: #1d4ed8;
}

.page-settings .notification-metric-trigger-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-settings .notification-metric-count {
  flex: 0 0 auto;
  min-width: 48px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #e8eef6;
  color: #475569;
  font-size: 11px;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.page-settings .notification-metric-trigger[aria-expanded="true"] .notification-metric-count {
  background: #dbeafe;
  color: #1d4ed8;
}

.page-settings .notification-zero-count {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  background: #fff1db;
  color: #a24b00;
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.page-settings .notification-zero-count[hidden] {
  display: none !important;
}

.page-settings .notification-metric-trigger.has-zero-cooldown {
  border-color: #e2a857;
  background: #fffaf1;
  color: #8a3f00;
}

.page-settings .notification-metric-panel {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: min(960px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  height: min(760px, calc(100vh - 32px));
  height: min(760px, calc(100dvh - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  margin: auto;
  overflow: hidden;
  overscroll-behavior: contain;
  padding: 0;
  border: 1px solid #b8c6d6;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
}

.page-settings .notification-metric-panel:not([open]) {
  display: none !important;
}

.page-settings .notification-metric-panel::backdrop {
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(2px);
}

.page-settings .notification-metric-panel-head {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid #dbe3ec;
  background: #ffffff;
}

.page-settings .notification-metric-panel-head > div:first-child {
  display: grid;
  gap: 3px;
}

.page-settings .notification-metric-panel-head strong {
  color: #172033;
  font-size: 14px;
}

.page-settings .notification-metric-panel-head span {
  color: #64748b;
  font-size: 11px;
}

.page-settings .notification-metric-actions {
  display: flex;
  gap: 6px;
}

.page-settings .notification-metric-actions button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #c4cfdb;
  border-radius: 5px;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
}

.page-settings .notification-metric-actions button:hover {
  border-color: #8fa1b5;
  background: #f1f5f9;
}

.page-settings .notification-metric-actions [data-metric-close] {
  border-color: #9fb4cf;
  background: #edf4ff;
  color: #1e4f8f;
}

.page-settings .notification-zero-warning {
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid #efb768;
  border-radius: 6px;
  background: #fff7e8;
  color: #8a3f00;
}

.page-settings .notification-zero-warning[hidden] {
  display: none !important;
}

.page-settings .notification-zero-warning strong {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
}

.page-settings .notification-zero-warning span {
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
}

.page-settings .notification-metric-panel-body {
  grid-row: 3;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px 16px;
}

.page-settings .notification-metric-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.page-settings .notification-metric-group {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  margin: 0;
  padding: 10px;
  border: 1px solid #dbe3ec;
  border-radius: 6px;
  background: #f8fafc;
}

.page-settings .notification-metric-group legend {
  padding: 0 5px;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
}

.page-settings .notification-metric-row {
  min-width: 0;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #ffffff;
  color: #64748b;
}

.page-settings .notification-metric-row.is-enabled {
  border-color: #bad0f5;
  background: #f3f7ff;
  color: #1e4f8f;
}

.page-settings .notification-metric-row.has-zero-cooldown {
  border-color: #e9ad5b;
  background: #fff8eb;
  color: #8a3f00;
}

.page-settings .notification-metric-row.has-zero-cooldown .notification-metric-cooldown input {
  border-color: #df9b3f;
  background: #fffdf8;
  color: #8a3f00;
}

.page-settings .notification-metric-choice {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.page-settings .notification-metric-choice input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #2563eb;
}

.page-settings .notification-metric-choice > span {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.page-settings .notification-metric-choice strong {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-settings .notification-metric-choice small {
  flex: 0 0 auto;
  color: #718096;
  font-size: 10px;
  font-weight: 700;
}

.page-settings .notification-metric-cooldown {
  display: grid;
  grid-template-columns: auto 72px auto;
  align-items: center;
  gap: 5px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.page-settings .notification-metric-cooldown input {
  width: 72px;
  min-width: 0;
  height: 32px;
  padding: 4px 7px;
  border: 1px solid #c4cfdb;
  border-radius: 5px;
  background: #ffffff;
  color: #172033;
  font-size: 12px;
  font-weight: 750;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.page-settings .notification-metric-cooldown input:focus {
  border-color: #2563eb;
  outline: 3px solid rgba(37, 99, 235, 0.15);
}

.page-settings .notification-number-control {
  color: #526176;
}

.page-settings .weekday-options {
  width: min(100%, 504px);
  gap: 7px;
}

.page-settings .weekday-option {
  min-height: 42px;
  border-color: #c4cfdb;
  background: #ffffff;
  color: #475569;
}

.page-settings .weekday-option:hover {
  border-color: #8fa1b5;
  background: #f8fafc;
}

.page-settings .weekday-option:has(input:checked) {
  border-color: #7ca4e8;
  background: #e7f0ff;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.page-settings .weekday-option:nth-child(6),
.page-settings .weekday-option:nth-child(7) {
  border-color: #c4cfdb;
  background: #ffffff;
  color: #64748b;
}

.page-settings .weekday-option:nth-child(6):has(input:checked) {
  border-color: #7ca4e8;
  background: #e7f0ff;
  color: #1d4ed8;
}

.page-settings .weekday-option:nth-child(7):has(input:checked) {
  border-color: #e49a9a;
  background: #fff0f0;
  color: #b42318;
}

.page-settings .notification-card > .field-row {
  gap: 10px;
  padding: 2px 0;
}

.page-settings .email-row,
.page-settings .phone-row {
  width: min(100%, 860px);
}

.page-settings .remove-email,
.page-settings .remove-phone {
  border-color: #c4cfdb;
  background: #f8fafc;
  color: #526176;
}

.page-settings button.secondary:not(.test-call) {
  border-color: #9fb4cf;
  background: #eef4fb;
  color: #1e4f8f;
}

.page-settings button.secondary:not(.test-call):hover {
  border-color: #7295c1;
  background: #e3edf9;
}

.page-settings button.test-call {
  border-color: #9eacbc;
  background: #ffffff;
  color: #334155;
}

.page-settings button.test-call:hover {
  border-color: #718096;
  background: #f1f4f7;
}

.page-settings button.primary {
  min-width: 104px;
  border: 1px solid #1d4ed8;
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(30, 64, 175, 0.2);
}

.page-settings button.primary:hover {
  border-color: #1e40af;
  background: #1d4ed8;
}

.page-settings .hint {
  color: #64748b;
}

.page-settings .actions {
  position: static;
  bottom: auto;
  gap: 10px;
  margin-top: 0;
  padding: 12px 14px;
  border-color: #bcc9d7;
  background: #e3e9f1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

@media (max-width: 1280px) {
  .page-settings .notification-policy-grid {
    grid-template-columns: minmax(220px, 0.72fr) minmax(380px, 1.28fr);
  }

  .page-settings .notification-hours {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1024px) {
  .page-settings .device-row,
  .page-settings .notification-policy-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-settings .notification-policy-grid {
    gap: 18px;
  }

  .page-settings .notification-hours {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  body.page-settings,
  .page-settings .content {
    background: #edf1f6;
  }

  .page-settings .topbar {
    gap: 10px;
    padding: 10px 12px;
    background: #e3e9f1;
  }

  .page-settings .settings-tabs {
    padding: 3px;
  }

  .page-settings .settings-tab,
  .page-settings .settings-tab.profile-tab,
  .page-settings .settings-tab.alarm-tab,
  .page-settings .settings-tab.notification-tab {
    min-height: 40px;
    height: 40px;
  }

  .page-settings .device-row {
    gap: 12px;
    min-height: 0;
    padding: 14px;
  }

  .page-settings form.tab-panel:has(.profile-grid),
  .page-settings .settings-group,
  .page-settings .notification-card {
    padding: 16px;
  }

  .page-settings .notification-policy-grid {
    margin-inline: -16px;
    padding: 16px;
  }

  .page-settings .notification-metric-trigger {
    width: 100%;
  }

  .page-settings .notification-time-range {
    width: 100%;
  }

  .page-settings .notification-metric-panel {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 0;
  }

  .page-settings .notification-metric-panel-body {
    padding: 12px;
  }

  .page-settings .notification-metric-groups {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .page-settings .notification-card + .notification-card {
    border-top-width: 6px;
  }

  .page-settings .toggle-card > span {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .page-settings .actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(104px, 1fr);
  }

  .page-settings .actions button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .page-settings .weekday-options {
    grid-template-columns: repeat(4, minmax(48px, 1fr));
  }

  .page-settings .notification-metric-panel-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .page-settings .notification-metric-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .page-settings .notification-zero-warning {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
    margin: 10px 12px 0;
    padding: 9px 10px;
  }

  .page-settings .notification-metric-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .page-settings .notification-metric-cooldown {
    justify-self: end;
  }

}

/* Desktop live/graph pages scroll independently from their fixed navigation. */
@media (min-width: 961px) {
  .page-live .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 232px;
    height: 100vh;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .page-live .content {
    grid-column: 2;
    min-width: 0;
  }
}

@media (min-width: 961px) and (max-width: 1440px) {
  .page-live .sidebar {
    width: 216px;
  }
}

@media (min-width: 1025px) {
  .page-graph .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 232px;
    height: 100vh;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .page-graph .content {
    grid-column: 2;
    min-width: 0;
  }
}

@media (min-width: 1025px) and (max-width: 1440px) {
  .page-graph .sidebar {
    width: 216px;
  }
}

/* Shared management page header */
.page-live .topbar,
.page-lte .topbar,
.page-settings .topbar,
.page-admin .topbar,
.page-signage .topbar {
  border-color: #2f5fa9;
  background: #3b6fc4;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(47, 95, 169, 0.18);
}

.page-live .topbar h1,
.page-lte .topbar h1,
.page-settings .topbar h1,
.page-admin .topbar h1,
.page-signage .topbar h1 {
  color: #ffffff;
}

.page-admin .topbar .subtitle {
  color: #dbeafe;
}

.page-live .topbar .live-config-button {
  border-color: #ffffff;
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14);
}

.page-live .topbar .live-config-button:hover,
.page-live .topbar .live-config-button[aria-expanded="true"] {
  border-color: #dbeafe;
  background: #eff6ff;
  color: #1e40af;
}

.page-live .topbar .test-clock {
  border-color: #ffffff;
  background: #ffffff;
  color: #172033;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14);
}

/* Admin communication settings */
.page-admin .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-admin .admin-tabs {
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  margin-top: var(--space-4);
  padding: 4px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-subtle);
}

.page-admin .admin-tab {
  min-width: 132px;
  height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 800;
  box-shadow: none;
}

.page-admin .admin-tab:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.page-admin .admin-tab.active {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}

.page-admin .admin-tab:focus-visible,
.page-admin .admin-interval-select:focus-visible,
.page-admin .admin-live-duration:focus-visible,
.page-admin .admin-live-button:focus-visible,
.page-admin .admin-apply-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.page-admin .admin-tab-panel[hidden] {
  display: none;
}

.page-admin .admin-communication-panel {
  padding: 0;
  overflow: hidden;
}

.page-admin .admin-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.page-admin .admin-section-heading .note {
  margin: 8px 0 0;
}

.page-admin .admin-plan-label {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.page-admin .admin-control-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: var(--space-4) var(--space-5) 0;
  padding: 11px 13px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-control);
  background: #eff6ff;
  color: #1e3a8a;
}

.page-admin .admin-control-notice > div {
  display: grid;
  gap: 2px;
}

.page-admin .admin-control-notice strong {
  font-size: 13px;
}

.page-admin .admin-control-notice span:not(.admin-control-mark) {
  color: #334e7d;
  font-size: 12px;
  line-height: 1.55;
}

.page-admin .admin-control-mark {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: #2563eb;
}

.page-admin .admin-settings-error {
  margin: var(--space-3) var(--space-5) 0;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: var(--radius-control);
  background: #fff1f2;
  color: #991b1b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.page-admin .admin-device-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 28px;
  margin: var(--space-4) var(--space-5) 0;
  padding: 12px 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 13px;
}

.page-admin .admin-device-summary strong {
  margin-left: 5px;
  color: var(--color-text);
  font-size: 14px;
}

.page-admin .admin-device-table-wrap {
  overflow-x: auto;
  padding: 0 var(--space-5) var(--space-5);
}

.page-admin .admin-device-control-table {
  min-width: 980px;
  margin-top: 0;
  border-top: 0;
  table-layout: auto;
}

.page-admin .admin-device-control-table th,
.page-admin .admin-device-control-table td {
  padding: 12px 10px;
  vertical-align: middle;
}

.page-admin .admin-device-control-table th {
  color: #475569;
  font-size: 12px;
}

.page-admin .admin-device-control-table tbody tr:hover {
  background: #f8fbff;
}

.page-admin .admin-device-name,
.page-admin .admin-device-meta,
.page-admin .admin-traffic-value,
.page-admin .admin-cost-value,
.page-admin .admin-current-mode,
.page-admin .admin-version-meta,
.page-admin .admin-high-traffic-warning {
  display: block;
}

.page-admin .admin-device-name {
  max-width: 220px;
  overflow: hidden;
  color: #172033;
  font-size: 13px;
  text-overflow: ellipsis;
}

.page-admin .admin-device-meta,
.page-admin .admin-cost-value,
.page-admin .admin-current-mode,
.page-admin .admin-version-meta {
  margin-top: 3px;
  color: #64748b;
  font-size: 11px;
}

.page-admin .admin-version-meta {
  line-height: 1.45;
}

.page-admin .admin-high-traffic-warning {
  margin-top: 5px;
  color: #b45309;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.page-admin .admin-high-traffic-warning[hidden] {
  display: none;
}

.page-admin .admin-setting-estimate {
  display: block;
  margin-top: 5px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.page-admin .admin-traffic-value {
  color: #172033;
  font-size: 13px;
}

.page-admin .admin-forecast-caption {
  display: block;
  margin-bottom: 2px;
  color: #64748b;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
}

.page-admin .admin-forecast-caption.is-actual {
  margin-top: 8px;
}

.page-admin .admin-actual-forecast {
  display: block;
  color: #1d4ed8;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
}

.page-admin .admin-soracom-inline {
  display: grid;
  min-width: 150px;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.page-admin .admin-soracom-inline strong {
  color: #1d4ed8;
  font-size: 14px;
  line-height: 1.35;
  white-space: nowrap;
}

.page-admin .admin-soracom-inline span,
.page-admin .admin-soracom-inline small {
  color: #64748b;
  font-size: 10px;
  line-height: 1.45;
  white-space: nowrap;
}

.page-admin .admin-soracom-inline small {
  overflow: hidden;
  max-width: 185px;
  text-overflow: ellipsis;
}

.page-admin .admin-soracom-inline small[data-state="success"] {
  color: #047857;
}

.page-admin .admin-soracom-inline small[data-state="error"] {
  color: #b91c1c;
}

.page-admin .admin-inline-detail-button {
  justify-self: start;
  width: auto;
  min-height: 30px;
  margin-top: 5px;
  padding: 0 9px;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: none;
}

.page-admin .admin-inline-detail-button:hover {
  border-color: #60a5fa;
  background: #dbeafe;
}

.page-admin .admin-field-label {
  display: block;
}

.page-admin .admin-interval-form-anchor {
  display: none;
  margin: 0;
}

.page-admin .admin-interval-select,
.page-admin .admin-live-duration {
  min-width: 88px;
  height: 38px;
  border-color: #cbd5e1;
  background: #ffffff;
  color: #172033;
  font-size: 13px;
  font-weight: 800;
}

.page-admin .admin-live-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
}

.page-admin .admin-live-button,
.page-admin .admin-apply-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #b9c7da;
  border-radius: var(--radius-control);
  background: #ffffff;
  color: #273447;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: none;
}

.page-admin .admin-live-button:hover,
.page-admin .admin-apply-button:hover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.page-admin .admin-live-button.is-active {
  border-color: #dc2626;
  background: #fff1f2;
  color: #b91c1c;
}

.page-admin .admin-apply-button {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}

.page-admin .admin-apply-button:hover {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #ffffff;
}

.page-admin .admin-apply-button:disabled,
.page-admin .admin-live-button:disabled,
.page-admin .admin-live-duration:disabled {
  border-color: #d7dee8;
  background: #eef2f6;
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 1;
}

.page-admin .admin-apply-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.page-admin .admin-apply-status.is-pending {
  border-color: #f5c56b;
  background: #fffaf0;
  color: #92400e;
}

.page-admin .admin-apply-status.is-applied {
  border-color: #86d7ae;
  background: #effbf5;
  color: #047857;
}

.page-admin .admin-apply-status.is-live {
  border-color: #7dd3fc;
  background: #f0f9ff;
  color: #0369a1;
}

.page-admin .admin-apply-status.is-stopped {
  border-color: #d7dee8;
  background: #f1f5f9;
  color: #64748b;
}

.page-admin .admin-empty-row {
  height: 96px;
  color: #64748b;
  text-align: center;
}

.page-admin .admin-soracom-section {
  padding: 0 0 var(--space-5);
  overflow: hidden;
}

.page-admin .admin-soracom-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.page-admin .admin-plan-label.is-ready {
  border-color: #86d7ae;
  background: #effbf5;
  color: #047857;
}

.page-admin .admin-plan-label.is-pending {
  border-color: #f5c56b;
  background: #fffaf0;
  color: #92400e;
}

.page-admin .admin-soracom-notice {
  display: grid;
  gap: 3px;
  margin: var(--space-4) var(--space-5) 0;
  padding: 11px 13px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-control);
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  line-height: 1.55;
}

.page-admin .admin-soracom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: var(--space-4) var(--space-5) 0;
}

.page-admin .admin-soracom-card {
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: #ffffff;
}

.page-admin .admin-soracom-card-header {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, auto) auto 18px;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}

.page-admin .admin-soracom-card-header::-webkit-details-marker {
  display: none;
}

.page-admin .admin-soracom-card-header:hover {
  background: #f8fafc;
}

.page-admin .admin-soracom-card-header:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: -3px;
}

.page-admin .admin-soracom-card[open] .admin-soracom-card-header {
  border-bottom: 1px solid var(--color-border);
  background: #f8fafc;
}

.page-admin .admin-soracom-card-header > div {
  min-width: 0;
}

.page-admin .admin-soracom-card-header h3 {
  margin: 0;
  overflow: hidden;
  color: #172033;
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-admin .admin-soracom-card-header > div:first-child > span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #64748b;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-admin .admin-soracom-summary-metrics {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  font-variant-numeric: tabular-nums;
}

.page-admin .admin-soracom-summary-metrics > span {
  display: grid;
  min-width: 118px;
  gap: 2px;
}

.page-admin .admin-soracom-summary-metrics small {
  color: #64748b;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.3;
}

.page-admin .admin-soracom-summary-metrics strong {
  overflow: hidden;
  color: #172033;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-admin .admin-soracom-summary-metrics > span:first-child strong {
  color: #1d4ed8;
}

.page-admin .admin-soracom-status {
  flex: 0 0 auto;
  min-height: 25px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.page-admin .admin-soracom-expand-icon {
  width: 9px;
  height: 9px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: rotate(45deg);
  transition: transform 150ms ease;
}

.page-admin .admin-soracom-card[open] .admin-soracom-expand-icon {
  transform: rotate(225deg);
}

.page-admin .admin-soracom-card-body {
  padding: 0 14px 14px;
}

.page-admin .admin-soracom-status[data-state="success"] {
  border-color: #86d7ae;
  background: #effbf5;
  color: #047857;
}

.page-admin .admin-soracom-status[data-state="error"] {
  border-color: #fecaca;
  background: #fff1f2;
  color: #991b1b;
}

.page-admin .admin-soracom-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 14px 0 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-border);
}

.page-admin .admin-soracom-metrics > div {
  min-width: 0;
  padding: 10px 11px;
  background: #f8fafc;
}

.page-admin .admin-soracom-metrics > div:last-child {
  grid-column: 1 / -1;
}

.page-admin .admin-soracom-metrics dt {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.4;
}

.page-admin .admin-soracom-metrics dd {
  margin: 4px 0 0;
  overflow: hidden;
  color: #172033;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-admin .admin-soracom-metrics .is-primary dd {
  color: #1d4ed8;
  font-size: 18px;
}

.page-admin .admin-soracom-fetched {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.page-admin .admin-soracom-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.page-admin .admin-soracom-form label {
  min-width: 0;
  color: #475569;
  font-size: 11px;
}

.page-admin .admin-soracom-form label:nth-of-type(3) {
  grid-column: 1 / 2;
}

.page-admin .admin-soracom-form small {
  color: #64748b;
  font-size: 10px;
}

.page-admin .admin-soracom-form input,
.page-admin .admin-soracom-form select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border-color: #cbd5e1;
  font-size: 12px;
}

.page-admin .admin-soracom-form button {
  align-self: end;
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid #2563eb;
  border-radius: var(--radius-control);
  background: #2563eb;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.page-admin .admin-soracom-form input:focus-visible,
.page-admin .admin-soracom-form select:focus-visible,
.page-admin .admin-soracom-form button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.page-admin .admin-soracom-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 28px 12px;
  color: #64748b;
  text-align: center;
}

.page-admin .admin-communication-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.page-admin .admin-usage-refresh {
  width: auto;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-control);
  background: #ffffff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
  box-shadow: none;
}

.page-admin .admin-usage-refresh:hover {
  border-color: #60a5fa;
  background: #eff6ff;
}

.page-admin .admin-usage-refresh:disabled {
  cursor: wait;
  opacity: 0.62;
}

.page-admin .admin-usage-refresh:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.page-admin .admin-integrated-usage-note {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 10px var(--space-5) 0;
  color: #64748b;
  font-size: 11px;
  line-height: 1.45;
}

.page-admin .admin-integrated-usage-note strong {
  color: #334155;
}

.page-admin .admin-device-dialog {
  width: min(900px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
}

.page-admin .admin-device-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(1px);
}

.page-admin .admin-device-dialog-shell {
  display: flex;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.page-admin .admin-device-dialog-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  background: #ffffff;
}

.page-admin .admin-device-dialog-header > div {
  min-width: 0;
}

.page-admin .admin-device-dialog-header h3 {
  margin: 0;
  overflow: hidden;
  color: #172033;
  font-size: 18px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-admin .admin-device-dialog-header p {
  margin: 3px 0 0;
  overflow: hidden;
  color: #64748b;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-admin .admin-device-dialog-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #ffffff;
  color: #475569;
  font-size: 22px;
  line-height: 1;
  box-shadow: none;
}

.page-admin .admin-device-dialog-close:hover {
  border-color: #94a3b8;
  background: #f8fafc;
  color: #172033;
}

.page-admin .admin-device-dialog-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  overscroll-behavior: contain;
}

.page-admin .admin-device-dialog-section {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #ffffff;
}

.page-admin .admin-device-dialog-section + .admin-device-dialog-section {
  margin-top: 12px;
}

.page-admin .admin-device-dialog-section h4 {
  margin: 0;
  color: #172033;
  font-size: 14px;
  line-height: 1.4;
}

.page-admin .admin-device-dialog-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-admin .admin-device-dialog-settings {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  margin-top: 12px;
}

.page-admin .admin-device-dialog-settings .admin-device-dialog-section {
  margin-top: 0;
}

.page-admin .admin-device-dialog-note,
.page-admin .admin-device-dialog-warning {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 11px;
  line-height: 1.55;
}

.page-admin .admin-device-dialog-warning {
  color: #92400e;
}

.page-admin .admin-device-owner-form {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.page-admin .admin-device-owner-form label {
  min-width: 0;
  color: #475569;
  font-size: 11px;
}

.page-admin .admin-device-owner-form select,
.page-admin .admin-device-owner-form button {
  width: 100%;
  min-width: 0;
  height: 38px;
}

.page-admin .admin-device-owner-form button {
  border: 1px solid #2563eb;
  border-radius: var(--radius-control);
  background: #2563eb;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.page-admin .admin-inline-detail-button:focus-visible,
.page-admin .admin-device-dialog-close:focus-visible,
.page-admin .admin-device-owner-form select:focus-visible,
.page-admin .admin-device-owner-form button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .page-admin .admin-tabs {
    width: 100%;
  }

  .page-admin .admin-tab {
    flex: 1 1 0;
    min-width: 0;
  }

  .page-admin .admin-section-heading {
    padding: var(--space-4);
  }

  .page-admin .admin-control-notice,
  .page-admin .admin-settings-error,
  .page-admin .admin-device-summary,
  .page-admin .admin-integrated-usage-note {
    margin-right: var(--space-4);
    margin-left: var(--space-4);
  }

  .page-admin .admin-section-heading,
  .page-admin .admin-device-dialog-settings {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-admin .admin-section-heading {
    flex-direction: column;
  }

  .page-admin .admin-communication-badges {
    justify-content: flex-start;
  }

  .page-admin .admin-device-table-wrap {
    padding: 0 var(--space-4) var(--space-4);
  }

  .page-admin .admin-soracom-notice {
    margin-right: var(--space-4);
    margin-left: var(--space-4);
  }

  .page-admin .admin-soracom-grid {
    padding-right: var(--space-4);
    padding-left: var(--space-4);
  }
}

@media (max-width: 720px) {
  .page-admin .admin-section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .page-admin .admin-plan-label {
    align-self: flex-start;
  }

  .page-admin .admin-soracom-badges {
    justify-content: flex-start;
  }

  .page-admin .admin-control-notice {
    margin-top: var(--space-3);
  }

  .page-admin .admin-device-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .page-admin .admin-device-table-wrap {
    overflow: visible;
  }

  .page-admin .admin-device-control-table {
    display: table;
    min-width: 0;
    border: 0;
  }

  .page-admin .admin-device-control-table thead {
    display: none;
  }

  .page-admin .admin-device-control-table tbody,
  .page-admin .admin-device-control-table tr,
  .page-admin .admin-device-control-table td {
    display: block;
    width: 100%;
  }

  .page-admin .admin-device-control-table tr {
    margin-top: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: #ffffff;
  }

  .page-admin .admin-device-control-table td {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--color-border);
    white-space: normal;
  }

  .page-admin .admin-device-control-table td:last-child {
    border-bottom: 0;
  }

  .page-admin .admin-device-control-table td::before {
    content: attr(data-label);
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
  }

  .page-admin .admin-device-control-table .admin-empty-row {
    display: block;
    padding: 28px 12px;
  }

  .page-admin .admin-device-control-table .admin-empty-row::before {
    display: none;
  }

  .page-admin .admin-device-name {
    max-width: none;
  }

  .page-admin .admin-soracom-card-header {
    grid-template-columns: minmax(0, 1fr) auto 18px;
    gap: 8px 10px;
  }

  .page-admin .admin-soracom-card-header > div:first-child {
    grid-column: 1;
    grid-row: 1;
  }

  .page-admin .admin-soracom-summary-metrics {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .page-admin .admin-soracom-card-header .admin-soracom-status {
    grid-column: 2;
    grid-row: 1 / 3;
  }

  .page-admin .admin-soracom-expand-icon {
    grid-column: 3;
    grid-row: 1 / 3;
  }

  .page-admin .admin-live-controls {
    flex-wrap: wrap;
  }

  .page-admin .admin-live-button,
  .page-admin .admin-apply-button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .page-admin .admin-device-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .page-admin .admin-device-dialog-shell {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .page-admin .admin-device-dialog-header {
    min-height: 60px;
    padding: 10px 12px;
  }

  .page-admin .admin-device-dialog-header h3 {
    font-size: 16px;
  }

  .page-admin .admin-device-dialog-content {
    padding: 10px;
  }

  .page-admin .admin-device-dialog-section {
    padding: 11px;
  }

  .page-admin .admin-soracom-card {
    padding: 0;
  }

  .page-admin .admin-soracom-card-header {
    min-height: 76px;
    padding: 10px 11px;
  }

  .page-admin .admin-soracom-status {
    align-self: center;
  }

  .page-admin .admin-soracom-summary-metrics {
    gap: 12px;
  }

  .page-admin .admin-soracom-summary-metrics > span {
    min-width: 0;
  }

  .page-admin .admin-soracom-summary-metrics strong {
    font-size: 11px;
  }

  .page-admin .admin-soracom-card-body {
    padding: 0 11px 11px;
  }

  .page-admin .admin-soracom-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-admin .admin-soracom-form label:nth-of-type(3) {
    grid-column: auto;
  }
}

.page-live .topbar .test-clock span:first-child {
  color: #1d4ed8;
}

.page-live .topbar .test-clock span:last-child {
  color: #172033;
}

.page-settings .topbar .settings-tabs {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(30, 64, 175, 0.42);
}

.page-settings .topbar .settings-tab,
.page-settings .topbar .settings-tab.profile-tab,
.page-settings .topbar .settings-tab.alarm-tab,
.page-settings .topbar .settings-tab.notification-tab {
  color: #dbeafe;
}

.page-settings .topbar .settings-tab:hover {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.page-settings .topbar .settings-tab.active {
  border-color: #ffffff;
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

@media (max-width: 960px) {
  .mobile-app-bar {
    border-bottom-color: #2f5fa9;
    background: #3b6fc4;
    box-shadow: 0 2px 6px rgba(47, 95, 169, 0.2);
    backdrop-filter: none;
  }

  .mobile-app-bar .mobile-app-identity {
    overflow: hidden;
    padding-right: 8px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
  }

  .mobile-app-bar .mobile-page-title {
    color: #0f172a;
  }

  .mobile-app-bar .mobile-app-logo {
    padding: 2px 4px;
    border-radius: 6px;
    background: #ffffff;
    object-fit: contain;
  }

  .mobile-nav-toggle {
    border-color: #ffffff;
    background: #ffffff;
    color: #1d4ed8;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
  }

  .page-live .topbar {
    border-color: var(--color-border);
    background: #ffffff;
    color: var(--color-text);
    box-shadow: 0 6px 16px -16px rgba(15, 23, 42, 0.45);
  }

  .page-live .topbar .live-config-button,
  .page-live .topbar .test-clock {
    border-color: var(--color-border);
    background: #ffffff;
  }

  body.has-app-shell .mobile-app-identity {
    height: 60px;
    gap: 6px;
  }

  body.has-app-shell .mobile-app-logo-link {
    width: clamp(146px, 48vw, 200px);
    max-width: clamp(146px, 48vw, 200px);
    height: 60px;
    flex-basis: clamp(146px, 48vw, 200px);
    overflow: hidden;
    padding: 0;
  }

  body.has-app-shell .mobile-app-logo {
    width: 100%;
    max-width: 100%;
    height: 60px;
    padding: 0;
    object-fit: contain;
  }
}

@media (max-width: 360px) {
  body.has-app-shell .mobile-app-logo-link {
    width: 172px;
    max-width: 172px;
    flex-basis: 172px;
  }
}

@media (max-width: 330px) {
  body.has-app-shell .mobile-app-logo-link {
    width: 154px;
    max-width: 154px;
    flex-basis: 154px;
  }
}

/* Viewer account management and read-only role */
.viewer-role-badge,
.viewer-readonly-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.nav a[href*="viewer_accounts.php"] .nav-dot {
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M19 8v6M16 11h6'/%3E%3C/g%3E%3C/svg%3E") center / 18px 18px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M19 8v6M16 11h6'/%3E%3C/g%3E%3C/svg%3E") center / 18px 18px no-repeat;
}

.brand-sub .viewer-role-badge {
  margin-left: 6px;
  min-height: 22px;
  padding: 3px 7px;
  font-size: 10px;
}

.page-viewer-accounts {
  background: #f4f7fb;
  color: #172033;
  font-family: "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page-viewer-accounts .viewer-account-content {
  display: grid;
  align-content: start;
  gap: 20px;
  min-width: 0;
  padding: 28px 32px 48px;
}

.page-viewer-accounts .viewer-account-topbar {
  min-height: 88px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-viewer-accounts .settings-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(30, 64, 175, 0.42);
}

.page-viewer-accounts .settings-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #dbeafe;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.page-viewer-accounts .settings-tab:hover {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.page-viewer-accounts .settings-tab.active {
  border-color: #fff;
  background: #fff;
  color: #1d4ed8;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

.viewer-management-panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #fff;
}

.viewer-section-heading,
.viewer-account-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.viewer-section-heading {
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.viewer-section-heading h2,
.viewer-account-summary h3 {
  margin: 0;
  color: #111827;
  letter-spacing: 0;
}

.viewer-section-heading h2 {
  font-size: 20px;
}

.viewer-section-heading p,
.viewer-account-summary p {
  margin: 5px 0 0;
  color: #64748b;
  font-size: 13px;
}

.viewer-create-form,
.viewer-edit-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.viewer-create-form label,
.viewer-edit-form label,
.viewer-password-form label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.viewer-create-form input,
.viewer-create-form select,
.viewer-edit-form input,
.viewer-edit-form select,
.viewer-password-form input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font: inherit;
}

.viewer-create-form input:focus,
.viewer-create-form select:focus,
.viewer-edit-form input:focus,
.viewer-edit-form select:focus,
.viewer-password-form input:focus {
  border-color: #2563eb;
  outline: 3px solid rgba(37, 99, 235, 0.14);
}

.viewer-device-fieldset {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid #dbe3ef;
  border-radius: 6px;
}

.viewer-device-fieldset legend {
  padding: 0 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.viewer-device-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.viewer-device-option {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #dbe3ef;
  border-radius: 6px;
  background: #f8fafc;
  cursor: pointer;
}

.viewer-device-option[hidden] {
  display: none !important;
}

.viewer-device-option input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.viewer-device-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-primary-button,
.viewer-password-form button,
.viewer-delete-form button {
  min-height: 44px;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.viewer-primary-button {
  justify-self: start;
  padding: 10px 18px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
}

.viewer-primary-button:hover {
  background: #1d4ed8;
}

.viewer-primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.viewer-feedback {
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.viewer-feedback.is-success {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.viewer-feedback.is-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.viewer-account-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.viewer-account-card {
  padding: 18px;
  border: 1px solid #dbe3ef;
  border-radius: 6px;
  background: #fff;
}

.viewer-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.viewer-state.is-active {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.viewer-state.is-disabled {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #64748b;
}

.viewer-account-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.viewer-account-meta div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}

.viewer-account-meta dt {
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.viewer-account-meta dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  color: #172033;
  font-size: 13px;
  font-weight: 700;
}

.viewer-account-details {
  margin-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.viewer-account-details summary {
  padding: 14px 0 0;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.viewer-active-toggle {
  display: flex !important;
  align-items: center;
  align-self: end;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
}

.viewer-active-toggle input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.viewer-password-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}

.viewer-password-form button {
  padding: 9px 14px;
  border: 1px solid #94a3b8;
  background: #fff;
  color: #334155;
}

.viewer-delete-form {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.viewer-delete-form button {
  padding: 9px 14px;
  border: 1px solid #fca5a5;
  background: #fff;
  color: #b91c1c;
}

.viewer-empty-state,
.viewer-empty-note {
  color: #64748b;
  font-size: 13px;
}

.viewer-empty-state {
  padding: 28px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #fff;
  text-align: center;
}

.viewer-mode .viewer-empty-state {
  margin: 16px 0;
}

.viewer-mode #csv_export,
.viewer-mode #png_export,
.viewer-mode #pdf_export {
  display: none !important;
}

.page-admin .admin-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid #2563eb;
  border-radius: 6px;
  background: #fff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.page-admin .admin-link-button:hover {
  background: #eff6ff;
}

@media (max-width: 1100px) {
  .viewer-create-form,
  .viewer-edit-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .viewer-device-options,
  .viewer-account-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .page-viewer-accounts .viewer-account-content {
    padding: 16px 14px 32px;
  }

  .page-viewer-accounts .viewer-account-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-viewer-accounts .settings-tabs {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .page-viewer-accounts .settings-tab {
    flex: 1 0 auto;
    min-height: 40px;
    padding-inline: 12px;
  }

  .viewer-management-panel {
    padding: 18px 14px;
  }
}

@media (max-width: 640px) {
  .viewer-create-form,
  .viewer-edit-form,
  .viewer-device-options,
  .viewer-account-meta,
  .viewer-password-form {
    grid-template-columns: 1fr;
  }

  .viewer-password-form button,
  .viewer-primary-button {
    width: 100%;
  }

  .viewer-section-heading {
    align-items: center;
  }
}
