/* Private Echo portal — component styles.
 *
 * Each component has its own block, prefixed with its component
 * name as a comment. Phase 1 ships only the minimum to keep
 * existing Sprint 8 pages legible while the redesign is in
 * flight; Phase 2 fills in the rest of the component library.
 *
 * Naming: BEM-light. Block class is `.pe-<name>`. Modifiers use
 * `--<modifier>` suffix (e.g. `.pe-pill--success`).
 */

/* ------------------------------------------------------- transitional layout */

/* Holds the page while individual page templates haven't been
 * redesigned yet. Replaced by sidebar+topbar layout in Phase 2. */
.pe-page {
  max-width: var(--pe-content-max);
  margin: 0 auto;
  padding: var(--pe-space-6) var(--pe-space-8);
}

/* Topbar (transitional, Phase 1 only). Phase 2 replaces with full
 * component including breadcrumb, theme toggle, user avatar. */
.pe-topbar-legacy {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--pe-border);
  padding-bottom: var(--pe-space-3);
  margin-bottom: var(--pe-space-6);
}
.pe-topbar-legacy .pe-brand {
  font-weight: 500;
  font-size: var(--pe-font-size-lg);
  color: var(--pe-text-primary);
}
.pe-topbar-legacy nav {
  display: flex;
  gap: var(--pe-space-4);
}

/* ------------------------------------------------------------------- buttons */

.pe-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--pe-space-2);
  padding: var(--pe-space-2) var(--pe-space-4);
  border-radius: var(--pe-radius-md);
  font-size: var(--pe-font-size-sm);
  font-weight: 500;
  line-height: 1;
  border: 1px solid var(--pe-border);
  background: var(--pe-bg-surface);
  color: var(--pe-text-primary);
  cursor: pointer;
  transition: background var(--pe-transition-fast), border-color var(--pe-transition-fast);
  text-decoration: none;
}
.pe-btn:hover { background: var(--pe-bg-hover); border-color: var(--pe-border-strong); text-decoration: none; }
.pe-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pe-btn--primary {
  background: var(--pe-accent);
  border-color: var(--pe-accent);
  color: var(--pe-accent-text);
}
.pe-btn--primary:hover { background: var(--pe-accent-strong); border-color: var(--pe-accent-strong); color: var(--pe-accent-text); }

.pe-btn--danger {
  background: var(--pe-danger-bg);
  border-color: transparent;
  color: var(--pe-danger);
}
.pe-btn--danger:hover { background: var(--pe-danger); color: var(--pe-text-inverse); }

.pe-btn--ghost { background: transparent; border-color: transparent; }
.pe-btn--ghost:hover { background: var(--pe-bg-hover); }

.pe-btn--sm { padding: var(--pe-space-1) var(--pe-space-2); font-size: var(--pe-font-size-xs); }

/* -------------------------------------------------------------------- pills */

.pe-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--pe-space-1);
  padding: 2px 10px;
  border-radius: var(--pe-radius-pill);
  font-size: var(--pe-font-size-xs);
  font-weight: 500;
  line-height: 1.6;
  background: var(--pe-neutral-bg);
  color: var(--pe-neutral-text);
}
.pe-pill--success { background: var(--pe-success-bg); color: var(--pe-success); }
.pe-pill--warning { background: var(--pe-warning-bg); color: var(--pe-warning); }
.pe-pill--danger  { background: var(--pe-danger-bg);  color: var(--pe-danger);  }
.pe-pill--info    { background: var(--pe-info-bg);    color: var(--pe-info);    }
.pe-pill--accent  { background: var(--pe-accent-bg);  color: var(--pe-accent-strong); }
[data-theme="dark"] .pe-pill--accent { color: var(--pe-accent); }

.pe-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.85;
}

/* ------------------------------------------------------------------- cards */

.pe-card {
  background: var(--pe-bg-surface);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-lg);
  padding: var(--pe-space-6);
  box-shadow: var(--pe-shadow-sm);
}
.pe-card--flat { box-shadow: none; }
.pe-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--pe-space-4);
}
.pe-card__title {
  font-size: var(--pe-font-size-md);
  font-weight: 500;
  color: var(--pe-text-primary);
  margin: 0;
}

/* ------------------------------------------------------------------ flash */

.pe-flash {
  padding: var(--pe-space-3) var(--pe-space-4);
  border-radius: var(--pe-radius-md);
  margin-bottom: var(--pe-space-4);
  font-size: var(--pe-font-size-sm);
}
.pe-flash--ok { background: var(--pe-success-bg); color: var(--pe-success); }
.pe-flash--error { background: var(--pe-danger-bg); color: var(--pe-danger); }
.pe-flash--warning { background: var(--pe-warning-bg); color: var(--pe-warning); }

/* ----------------------------------------------- force-password banner */

.pe-force-password {
  background: var(--pe-warning-bg);
  border: 1px solid var(--pe-warning);
  color: var(--pe-warning);
  padding: var(--pe-space-3) var(--pe-space-4);
  border-radius: var(--pe-radius-md);
  margin-bottom: var(--pe-space-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--pe-space-4);
}

/* ----------------------------------------------------------- form fields */

.pe-field { display: flex; flex-direction: column; gap: var(--pe-space-1); margin-bottom: var(--pe-space-4); }
.pe-field label { font-size: var(--pe-font-size-sm); color: var(--pe-text-secondary); font-weight: 500; }
.pe-field input,
.pe-field select,
.pe-field textarea {
  padding: var(--pe-space-2) var(--pe-space-3);
  border: 1px solid var(--pe-border-strong);
  border-radius: var(--pe-radius-md);
  background: var(--pe-bg-surface);
  color: var(--pe-text-primary);
  font-size: var(--pe-font-size-base);
}
.pe-field input:focus,
.pe-field select:focus,
.pe-field textarea:focus {
  outline: 2px solid var(--pe-accent);
  outline-offset: -1px;
  border-color: var(--pe-accent);
}
.pe-field__hint { font-size: var(--pe-font-size-xs); color: var(--pe-text-tertiary); }
.pe-field__error { font-size: var(--pe-font-size-xs); color: var(--pe-danger); }

/* ------------------------------------------------------------ theme toggle */

.pe-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--pe-radius-md);
  border: 1px solid var(--pe-border);
  background: var(--pe-bg-surface);
  color: var(--pe-text-secondary);
  cursor: pointer;
  transition: background var(--pe-transition-fast);
}
.pe-theme-toggle:hover { background: var(--pe-bg-hover); color: var(--pe-text-primary); }
.pe-theme-toggle .ti { font-size: 16px; }

/* ============================================================== sidebar */

.pe-sidebar {
  position: sticky;
  top: 0;
  width: var(--pe-sidebar-width);
  height: 100vh;
  background: var(--pe-bg-surface);
  border-right: 1px solid var(--pe-border);
  display: flex;
  flex-direction: column;
  padding: var(--pe-space-4) var(--pe-space-3);
  flex-shrink: 0;
}
.pe-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--pe-space-2);
  padding: var(--pe-space-2) var(--pe-space-3);
  font-size: var(--pe-font-size-md);
  margin-bottom: var(--pe-space-4);
}
.pe-sidebar__brand .ti { font-size: 22px; }
.pe-sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.pe-sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--pe-space-3);
  padding: var(--pe-space-2) var(--pe-space-3);
  border-radius: var(--pe-radius-md);
  color: var(--pe-text-secondary);
  text-decoration: none;
  font-size: var(--pe-font-size-sm);
  transition: background var(--pe-transition-fast), color var(--pe-transition-fast);
}
.pe-sidebar__item:hover { background: var(--pe-bg-hover); color: var(--pe-text-primary); text-decoration: none; }
.pe-sidebar__item.is-active {
  background: var(--pe-accent-bg);
  color: var(--pe-accent-strong);
}
[data-theme="dark"] .pe-sidebar__item.is-active { color: var(--pe-accent); }
.pe-sidebar__item .ti { font-size: 18px; flex-shrink: 0; }
.pe-sidebar__footer {
  margin-top: auto;
  padding-top: var(--pe-space-3);
  border-top: 1px solid var(--pe-border);
}

/* ============================================================== topbar */

.pe-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--pe-space-4) var(--pe-space-6);
  border-bottom: 1px solid var(--pe-border);
  background: var(--pe-bg-surface);
  gap: var(--pe-space-4);
}
.pe-topbar__left { display: flex; align-items: flex-start; gap: var(--pe-space-3); flex: 1; min-width: 0; }
.pe-topbar__title { font-size: var(--pe-font-size-xl); font-weight: 500; }
.pe-topbar__right { display: flex; align-items: center; gap: var(--pe-space-2); }
.pe-topbar__actions { display: flex; align-items: center; gap: var(--pe-space-2); }

/* ============================================================== breadcrumb */

.pe-breadcrumb ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: var(--pe-space-1);
  font-size: var(--pe-font-size-xs);
  color: var(--pe-text-tertiary);
}
.pe-breadcrumb li { display: inline-flex; align-items: center; gap: var(--pe-space-1); }
.pe-breadcrumb a { color: var(--pe-text-secondary); }
.pe-breadcrumb a:hover { color: var(--pe-accent-strong); text-decoration: none; }
.pe-breadcrumb [aria-current="page"] { color: var(--pe-text-primary); }

/* ============================================================== layout shell */

.pe-shell {
  display: flex;
  min-height: 100vh;
  background: var(--pe-bg-page);
}
.pe-shell__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow children to overflow correctly */
}
.pe-shell__content {
  flex: 1;
  padding: var(--pe-space-6) var(--pe-space-8);
  max-width: var(--pe-content-max);
  width: 100%;
  margin: 0 auto;
}

/* ============================================================== metric card */

.pe-metric {
  display: flex;
  flex-direction: column;
  gap: var(--pe-space-2);
  padding: var(--pe-space-5);
  background: var(--pe-bg-surface);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-lg);
  box-shadow: var(--pe-shadow-sm);
}
.pe-metric--success { border-left: 3px solid var(--pe-success); }
.pe-metric--warning { border-left: 3px solid var(--pe-warning); }
.pe-metric--danger { border-left: 3px solid var(--pe-danger); }
.pe-metric--info { border-left: 3px solid var(--pe-info); }
.pe-metric__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pe-metric__label { font-size: var(--pe-font-size-xs); color: var(--pe-text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; }
.pe-metric__icon { color: var(--pe-text-tertiary); font-size: 16px; }
.pe-metric__value {
  display: flex; align-items: baseline; gap: var(--pe-space-1);
  font-size: var(--pe-font-size-3xl); font-weight: 500;
  color: var(--pe-text-primary); font-family: var(--pe-font-mono);
  line-height: 1;
}
.pe-metric__unit { font-size: var(--pe-font-size-md); color: var(--pe-text-tertiary); font-family: var(--pe-font-sans); }
.pe-metric__trend {
  display: inline-flex; align-items: center; gap: var(--pe-space-1);
  font-size: var(--pe-font-size-xs);
}
.pe-metric__trend--up { color: var(--pe-success); }
.pe-metric__trend--down { color: var(--pe-danger); }
.pe-metric__trend--flat { color: var(--pe-text-tertiary); }

/* ============================================================== event item */

.pe-event {
  display: flex;
  gap: var(--pe-space-3);
  padding: var(--pe-space-3) var(--pe-space-4);
  border-bottom: 1px solid var(--pe-border);
  list-style: none;
}
.pe-event:last-child { border-bottom: 0; }
.pe-event__icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.pe-event--success .pe-event__icon { color: var(--pe-success); }
.pe-event--warning .pe-event__icon { color: var(--pe-warning); }
.pe-event--danger .pe-event__icon { color: var(--pe-danger); }
.pe-event--info .pe-event__icon { color: var(--pe-info); }
.pe-event--neutral .pe-event__icon { color: var(--pe-text-tertiary); }
.pe-event__title { font-size: var(--pe-font-size-sm); color: var(--pe-text-primary); }
.pe-event__meta { font-size: var(--pe-font-size-xs); color: var(--pe-text-tertiary); margin-top: 2px; }
.pe-event__details { font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); margin-top: var(--pe-space-1); font-family: var(--pe-font-mono); }

/* ============================================================== modal */

.pe-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pe-space-4);
}
.pe-modal {
  background: var(--pe-bg-surface);
  border-radius: var(--pe-radius-lg);
  box-shadow: var(--pe-shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - var(--pe-space-8));
  overflow-y: auto;
}
.pe-modal--lg { max-width: 720px; }
.pe-modal--xl { max-width: 960px; }
.pe-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--pe-space-4) var(--pe-space-5);
  border-bottom: 1px solid var(--pe-border);
}
.pe-modal__title { font-size: var(--pe-font-size-lg); font-weight: 500; }
.pe-modal__body { padding: var(--pe-space-5); }
.pe-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--pe-space-2);
  padding: var(--pe-space-4) var(--pe-space-5);
  border-top: 1px solid var(--pe-border);
}

/* ============================================================== map panel */

.pe-map-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pe-bg-elevated);
  border-radius: var(--pe-radius-lg);
  padding: var(--pe-space-4);
  min-height: 360px;
}
.pe-map-panel__svg {
  width: 100%;
  height: auto;
  max-height: 480px;
}
.pe-map-panel__regions path {
  fill: var(--pe-bg-surface);
  stroke: var(--pe-border-strong);
  stroke-width: 0.6;
  transition: fill var(--pe-transition-base);
}
[data-theme="dark"] .pe-map-panel__regions path {
  fill: var(--pe-bg-elevated);
  stroke: var(--pe-border);
}
.pe-map-pin__halo {
  fill: var(--pe-accent);
  opacity: 0.18;
}
.pe-map-pin__dot {
  fill: var(--pe-accent);
  stroke: var(--pe-bg-surface);
  stroke-width: 1;
}
.pe-map-pin--online .pe-map-pin__halo { fill: var(--pe-success); opacity: 0.20; }
.pe-map-pin--online .pe-map-pin__dot { fill: var(--pe-success); }
.pe-map-pin--offline .pe-map-pin__halo { fill: var(--pe-danger); opacity: 0.20; }
.pe-map-pin--offline .pe-map-pin__dot { fill: var(--pe-danger); }
.pe-map-pin--neutral .pe-map-pin__halo { fill: var(--pe-text-tertiary); opacity: 0.16; }
.pe-map-pin--neutral .pe-map-pin__dot { fill: var(--pe-text-tertiary); }
.pe-map-panel__empty-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--pe-space-2);
  padding: var(--pe-space-6);
  text-align: center;
  background: color-mix(in srgb, var(--pe-bg-elevated) 78%, transparent);
  backdrop-filter: blur(2px);
  border-radius: var(--pe-radius-lg);
  pointer-events: none;
}
.pe-map-panel__empty-overlay .ti {
  font-size: 32px;
  color: var(--pe-text-tertiary);
}
.pe-map-panel__empty-title {
  margin: 0;
  font-weight: 500;
  color: var(--pe-text-primary);
}
.pe-map-panel__empty-message {
  margin: 0;
  font-size: var(--pe-font-size-sm);
  max-width: 32ch;
}

/* ============================================================== chart panel */

.pe-chart-panel {
  background: var(--pe-bg-surface);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-lg);
  padding: var(--pe-space-4);
}
.pe-chart-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--pe-space-3);
}
.pe-chart-panel__title { font-size: var(--pe-font-size-sm); font-weight: 500; color: var(--pe-text-secondary); }
.pe-chart-panel__canvas { width: 100%; }

/* ============================================================== empty state */

.pe-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--pe-space-12) var(--pe-space-6);
  text-align: center;
  color: var(--pe-text-secondary);
  gap: var(--pe-space-3);
}
.pe-empty-state__icon { font-size: 48px; color: var(--pe-text-tertiary); }
.pe-empty-state__title { font-size: var(--pe-font-size-md); font-weight: 500; color: var(--pe-text-primary); }
.pe-empty-state__message { max-width: 360px; font-size: var(--pe-font-size-sm); }

/* ============================================================== pagination */

.pe-pagination {
  display: flex;
  align-items: center;
  gap: var(--pe-space-1);
  justify-content: center;
  margin-top: var(--pe-space-6);
}
.pe-pagination .pe-btn { min-width: 32px; justify-content: center; }
.pe-pagination [aria-current="page"] { pointer-events: none; }

/* ============================================================== card body */

.pe-card__body { /* slot */ }
.pe-card__actions { display: inline-flex; gap: var(--pe-space-2); align-items: center; }

/* ============================================================== misc */

/* For full-width nav lists without table chrome. */
.pe-list-bare { list-style: none; padding: 0; margin: 0; }
.pe-list-bare > li { padding: var(--pe-space-2) 0; border-bottom: 1px solid var(--pe-border); }
.pe-list-bare > li:last-child { border-bottom: 0; }

/* ============================================================== mobile (<= 768px) */

/* Default state in components above is desktop. Below 768px we
 * collapse the sidebar into a slide-over and shift the content area
 * to full width. The sidebar's `data-mobile-open` attribute (driven by
 * Alpine x-data { open: bool }) toggles visibility. */

@media (max-width: 768px) {
  .pe-sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    bottom: 0;
    width: 232px;
    z-index: 200;
    transition: left var(--pe-transition-base);
    box-shadow: var(--pe-shadow-lg);
  }
  .pe-sidebar[data-mobile-open="true"] { left: 0; }

  .pe-shell { flex-direction: column; }
  .pe-shell__main { width: 100%; }
  .pe-shell__content {
    padding: var(--pe-space-4) var(--pe-space-4);
    padding-bottom: 80px; /* tab-bar clearance */
  }

  .pe-topbar {
    padding: var(--pe-space-3) var(--pe-space-4);
  }
  .pe-topbar__title { font-size: var(--pe-font-size-lg); }

  /* Tables become horizontally scrollable rather than wrap-and-look-bad. */
  .pe-table { display: block; overflow-x: auto; white-space: nowrap; }

  /* KPIs: 2-up on mobile */
  .pe-kpi-grid { grid-template-columns: repeat(2, 1fr); }

  /* Hero stacks */
  .pe-hero { flex-direction: column; align-items: flex-start; gap: var(--pe-space-3); }

  /* Filter bar: stacks */
  .pe-filter-bar { flex-direction: column; align-items: stretch; }
  .pe-filter-bar .pe-field { width: 100%; }

  /* Modal: full screen on mobile */
  .pe-modal { max-width: 100% !important; max-height: 100vh; border-radius: 0; }
  .pe-modal-backdrop { padding: 0; }
}

@media (min-width: 769px) {
  /* Belt-and-braces: hide the mobile sidebar overlay state on desktop. */
  .pe-sidebar { left: 0 !important; }
}

/* Spinner used by WiFi modal + wizard status */
@keyframes pe-spin { to { transform: rotate(360deg); } }
.pe-spin { display: inline-block; animation: pe-spin 1s linear infinite; }

/* ============================================================== mobile tab bar */

.pe-tab-bar {
  display: none;
}
@media (max-width: 768px) {
  .pe-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--pe-bg-surface);
    border-top: 1px solid var(--pe-border);
    z-index: 90;
    padding: var(--pe-space-1) 0;
    justify-content: space-around;
  }
  .pe-tab-bar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--pe-space-1) var(--pe-space-2);
    color: var(--pe-text-tertiary);
    text-decoration: none;
    font-size: var(--pe-font-size-xs);
    flex: 1;
  }
  .pe-tab-bar__item .ti { font-size: 20px; }
  .pe-tab-bar__item.is-active { color: var(--pe-accent-strong); }
  [data-theme="dark"] .pe-tab-bar__item.is-active { color: var(--pe-accent); }
}

/* ============================================================== dashboard */

.pe-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--pe-space-5) var(--pe-space-6);
  gap: var(--pe-space-4);
}
.pe-hero__time { white-space: nowrap; }

.pe-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--pe-space-4);
}

.pe-dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--pe-space-4);
}
@media (max-width: 1024px) {
  .pe-dashboard-grid { grid-template-columns: 1fr; }
}

/* ============================================================== filter bar */

.pe-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--pe-space-3);
  padding: var(--pe-space-4) var(--pe-space-5);
  background: var(--pe-bg-surface);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-lg);
  margin-bottom: var(--pe-space-4);
}
.pe-filter-bar .pe-field { margin-bottom: 0; min-width: 160px; }

/* ============================================================== data table */

.pe-table {
  width: 100%;
  background: var(--pe-bg-surface);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-lg);
  overflow: hidden;
}
.pe-table th {
  background: var(--pe-bg-elevated);
  text-transform: uppercase;
  font-size: var(--pe-font-size-xs);
  letter-spacing: 0.04em;
}
.pe-table td { font-size: var(--pe-font-size-sm); }
.pe-table tr:last-child td { border-bottom: 0; }
.pe-table tbody tr { transition: background var(--pe-transition-fast); }
.pe-table tbody tr:hover { background: var(--pe-bg-hover); }
.pe-table .pe-num { font-family: var(--pe-font-mono); font-variant-numeric: tabular-nums; }

/* ============================================================== device-detail (Sprint 21)
 * The Sprint 9 state strip (.pe-state-strip / .pe-state-cell) is gone:
 * its value colour was overridden by its own rule. See .pe-status below. */

.pe-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--pe-space-4);
}
@media (max-width: 1024px) {
  .pe-detail-grid { grid-template-columns: 1fr; }
}

/* ============================================================== WiFi modal extras */

.pe-wifi-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-md);
  max-height: 280px;
  overflow-y: auto;
}
.pe-wifi-list > li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--pe-space-2) var(--pe-space-3);
  border-bottom: 1px solid var(--pe-border);
  cursor: pointer;
  transition: background var(--pe-transition-fast);
}
.pe-wifi-list > li:last-child { border-bottom: 0; }
.pe-wifi-list > li:hover { background: var(--pe-bg-hover); }
.pe-wifi-list > li.is-selected { background: var(--pe-accent-bg); }
.pe-wifi-list .signal { font-family: var(--pe-font-mono); font-size: var(--pe-font-size-xs); color: var(--pe-text-tertiary); }

.pe-bandwidth-meter {
  background: var(--pe-bg-elevated);
  border-radius: var(--pe-radius-md);
  padding: var(--pe-space-3);
  margin-top: var(--pe-space-3);
}
.pe-bandwidth-meter__bar {
  height: 6px;
  background: var(--pe-border-strong);
  border-radius: var(--pe-radius-pill);
  overflow: hidden;
}
.pe-bandwidth-meter__fill {
  height: 100%;
  background: var(--pe-accent);
  transition: width var(--pe-transition-base);
}
.pe-bandwidth-meter__fill--warning { background: var(--pe-warning); }
.pe-bandwidth-meter__fill--danger { background: var(--pe-danger); }

/* ── Mini-EQ visual (Sprint Portal-EQ visual) ─────────────────────
   Room-map corner panels with a vertical trim slider + a live SVG
   response curve. Geometry constants (viewBox, dB window, tick
   positions) are coupled with CURVE in voicing-inline.js and the
   static gridlines in devices/detail.html — change them together. */
.pe-eq-corner {
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-md);
  background: var(--pe-bg-elevated);
  padding: var(--pe-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--pe-space-2);
}
.pe-eq-trim-readout {
  font-family: var(--pe-font-mono, monospace);
  font-size: var(--pe-font-size-xs);
  color: var(--pe-text-secondary);
}
.pe-eq-body {
  display: flex;
  gap: var(--pe-space-2);
  align-items: stretch;
  height: 120px;
}
/* Vertical range input: modern writing-mode path (Chrome 119+ / FF /
   Safari 18+) + the legacy WebKit fallback. direction:rtl puts max at
   the TOP, matching the dB axis of the curve next to it. */
.pe-eq-vslider {
  writing-mode: vertical-lr;
  direction: rtl;
  -webkit-appearance: slider-vertical;
  appearance: auto;
  width: 1.25rem;
  height: 100%;
  margin: 0;
  accent-color: var(--pe-accent);
}
.pe-eq-curve {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: var(--pe-bg-surface);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-sm);
}
.pe-eq-grid { stroke: var(--pe-border); stroke-width: 1; }
.pe-eq-zero { stroke: var(--pe-border-strong); stroke-width: 1; stroke-dasharray: 4 3; }
.pe-eq-tick {
  fill: var(--pe-text-tertiary);
  font-size: 9px;
  font-family: var(--pe-font-mono, monospace);
}
.pe-eq-line {
  fill: none;
  stroke: var(--pe-accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.pe-eq-line--inverted { stroke-dasharray: 6 4; }
.pe-eq-row {
  display: flex;
  align-items: center;
  gap: var(--pe-space-2);
  font-size: var(--pe-font-size-sm);
}
.pe-eq-row-label {
  min-width: 2.6rem;
  font-size: var(--pe-font-size-xs);
  color: var(--pe-text-tertiary);
}
.pe-eq-unit { font-size: var(--pe-font-size-xs); color: var(--pe-text-tertiary); }
.pe-eq-num-hz { max-width: 5.5rem; }
.pe-eq-num-db { max-width: 4.5rem; }
/* Sotto il breakpoint mobile la mappa-stanza collassa a colonna
   singola: i pannelli restano leggibili, la geometria fisica è
   comunicata dall'ordine (ant. sx, ant. dx, post. sx, post. dx). */
@media (max-width: 768px) {
  .pe-eq-corner { padding: var(--pe-space-2); }
}

/* ============================================================== Sprint 21 — classi usate e mai definite
 *
 * Raccolte dalla guardia `test_sprint21_css_class_guard.py`: ogni classe
 * `pe-*` usata in un template o in un file JS deve avere una regola qui o
 * in base.css, oppure stare nella lista di eccezioni motivata del test.
 * Qui le definizioni minime per le classi già in uso nelle altre pagine
 * (nessun restyling: solo quello che il markup si aspettava). */

.pe-input,
.pe-select {
  box-sizing: border-box;
  padding: var(--pe-space-2) var(--pe-space-3);
  border: 1px solid var(--pe-border-strong);
  border-radius: var(--pe-radius-md);
  background: var(--pe-bg-surface);
  color: var(--pe-text-primary);
  font-size: var(--pe-font-size-sm);
  line-height: var(--pe-line-base);
  min-width: 0;
}
.pe-input:focus,
.pe-select:focus {
  outline: 2px solid var(--pe-accent);
  outline-offset: -1px;
  border-color: var(--pe-accent);
}
.pe-input:disabled,
.pe-select:disabled { opacity: 0.55; cursor: not-allowed; }
.pe-input--sm { padding: 2px var(--pe-space-2); font-size: var(--pe-font-size-xs); height: 30px; }
.pe-input--mono { font-family: var(--pe-font-mono); }
.pe-input[aria-invalid="true"] { border-color: var(--pe-danger); }

.pe-checkbox { accent-color: var(--pe-accent); width: 16px; height: 16px; margin: 0; }

.pe-btn--secondary { background: var(--pe-bg-surface); border-color: var(--pe-border); color: var(--pe-text-primary); }
.pe-btn--warning { background: var(--pe-warning-bg); border-color: transparent; color: var(--pe-warning); }
.pe-btn--warning:hover { background: var(--pe-warning); color: var(--pe-text-inverse); }
.pe-btn--icon { width: 28px; height: 28px; padding: 0; justify-content: center; }

.pe-flash--info { background: var(--pe-info-bg); color: var(--pe-info); }

.pe-form { margin: 0; }
.pe-wifi-diagnostic, .pe-wifi-scan, .pe-wifi-saved { margin: 0; }

/* ============================================================== Sprint 21 — avviso in linea (FOLLOWUPS §23)
 * `pe-alert` esisteva solo nei template. Varianti per tono; l'icona sta
 * a sinistra, il testo può andare a capo. */

.pe-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--pe-space-3);
  padding: var(--pe-space-3) var(--pe-space-4);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-md);
  background: var(--pe-bg-elevated);
  color: var(--pe-text-secondary);
  font-size: var(--pe-font-size-sm);
}
.pe-alert > .ti { flex: none; font-size: 16px; margin-top: 1px; }
.pe-alert p { margin: 0; }
.pe-alert--success { background: var(--pe-success-bg); border-color: transparent; color: var(--pe-success); }
.pe-alert--warning { background: var(--pe-warning-bg); border-color: transparent; color: var(--pe-warning); }
.pe-alert--danger  { background: var(--pe-danger-bg);  border-color: transparent; color: var(--pe-danger); }
.pe-alert--info    { background: var(--pe-info-bg);    border-color: transparent; color: var(--pe-info); }
.pe-alert--neutral { background: var(--pe-bg-elevated); color: var(--pe-text-secondary); }
.pe-alert--inline { padding: var(--pe-space-2) var(--pe-space-3); font-size: var(--pe-font-size-xs); }

/* ============================================================== Sprint 21 — card di stato a celle
 *
 * Una card, cinque celle divise da una linea (gap 1px sul colore del
 * bordo). Ogni cella: etichetta con icona, valore mono preceduto dal
 * pallino di stato, riga secondaria. Il TONO vive sulla cella
 * (`data-tone`) e colora pallino + valore con specificità maggiore di
 * quella del valore: così il colore si vede davvero (il vecchio
 * `.pe-state-cell__value` annullava `pe-text-warning`). */

.pe-status {
  background: var(--pe-bg-surface);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-lg);
  box-shadow: var(--pe-shadow-sm);
  overflow: hidden;
}
.pe-status__notice {
  display: flex;
  align-items: center;
  gap: var(--pe-space-2);
  padding: 10px var(--pe-space-5);
  background: var(--pe-danger-bg);
  color: var(--pe-danger);
  font-size: var(--pe-font-size-sm);
}
.pe-status__notice .ti { flex: none; font-size: 16px; }
.pe-status__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--pe-border);
}
.pe-status__cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: var(--pe-space-4) var(--pe-space-5);
  background: var(--pe-bg-surface);
  transition: opacity var(--pe-transition-base);
}
.pe-status__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--pe-font-size-sm);
  color: var(--pe-text-secondary);
}
.pe-status__label .ti { font-size: 14px; }
.pe-status__main { display: flex; align-items: center; gap: var(--pe-space-2); min-height: 24px; }
.pe-status__dot {
  width: 8px; height: 8px; flex: none;
  border-radius: 50%;
  background: var(--pe-text-tertiary);
}
.pe-status__value {
  font-family: var(--pe-font-mono);
  font-size: var(--pe-font-size-lg);
  font-weight: 500;
  line-height: var(--pe-line-tight);
  color: var(--pe-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pe-status__sub {
  display: flex; align-items: center; gap: var(--pe-space-2);
  min-height: 18px;
  font-size: var(--pe-font-size-sm);
  color: var(--pe-text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pe-status__cell[data-tone="success"] .pe-status__dot { background: var(--pe-success); }
.pe-status__cell[data-tone="warning"] .pe-status__dot { background: var(--pe-warning); }
.pe-status__cell[data-tone="warning"] .pe-status__value { color: var(--pe-warning); }
.pe-status__cell[data-tone="danger"] .pe-status__dot { background: var(--pe-danger); }
.pe-status__cell[data-tone="danger"] .pe-status__value { color: var(--pe-danger); }
.pe-status__cell[data-tone="neutral"] .pe-status__dot { background: var(--pe-text-tertiary); }
/* Device offline: celle attenuate e pallini grigi, qualunque fosse il tono. */
.pe-status--offline .pe-status__cell { opacity: 0.7; }
.pe-status.pe-status--offline .pe-status__cell .pe-status__dot { background: var(--pe-text-tertiary); }
.pe-status.pe-status--offline .pe-status__cell .pe-status__value { color: var(--pe-text-primary); }

/* ============================================================== Sprint 21 — riquadri delle impostazioni
 *
 * `<button>` a tutta card: icona, nome, valore corrente, aiuto, freccia.
 * Tre colonne con l'equalizzatore largo due; due colonne sotto i 1024 px;
 * sotto i 768 px una lista compatta dentro una sola card (il corpo ricco
 * si nasconde e resta la riga di riepilogo). */

.pe-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: var(--pe-space-4);
}
.pe-tile {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  min-width: 0;
  padding: var(--pe-space-5);
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--pe-bg-surface);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-lg);
  box-shadow: var(--pe-shadow-sm);
  cursor: pointer;
  transition: border-color var(--pe-transition-fast), box-shadow var(--pe-transition-fast);
}
.pe-tile:hover { border-color: var(--pe-border-strong); box-shadow: var(--pe-shadow-md); }
.pe-tile:disabled { cursor: not-allowed; opacity: 0.55; box-shadow: var(--pe-shadow-sm); border-color: var(--pe-border); }
.pe-tile--wide { grid-column: span 2; }
.pe-tile__head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pe-tile__icon {
  display: inline-flex; flex: none; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--pe-radius-md);
  background: var(--pe-accent-bg);
  color: var(--pe-accent-strong);
}
[data-theme="dark"] .pe-tile__icon { color: var(--pe-accent); }
.pe-tile__icon .ti { font-size: 18px; }
.pe-tile__title { flex: 1; min-width: 0; font-weight: 500; }
.pe-tile__title--fixed { flex: none; }
.pe-tile__spacer { flex: 1; }
.pe-tile__chevron { flex: none; color: var(--pe-text-tertiary); font-size: 16px; }
.pe-tile__body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pe-tile__summary { display: none; }
.pe-tile__help { font-size: var(--pe-font-size-sm); color: var(--pe-text-secondary); }
.pe-tile__big {
  display: flex; align-items: baseline; gap: var(--pe-space-2);
}
.pe-tile__big-value { font-family: var(--pe-font-mono); font-size: var(--pe-font-size-2xl); font-weight: 500; line-height: 1; }
.pe-tile__big-unit { font-size: var(--pe-font-size-sm); color: var(--pe-text-secondary); }
.pe-tile__bar { display: block; height: 6px; border-radius: var(--pe-radius-pill); background: var(--pe-bg-elevated); overflow: hidden; }
.pe-tile__bar-fill { display: block; height: 100%; border-radius: var(--pe-radius-pill); background: var(--pe-accent); transition: width var(--pe-transition-base); }
.pe-tile__chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--pe-space-2); }
.pe-tile__chips--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; min-height: 56px; align-content: start; }
.pe-tile__chip {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: var(--pe-space-2) var(--pe-space-3);
  border-radius: var(--pe-radius-md);
  background: var(--pe-bg-elevated);
}
.pe-tile__chip--label { padding: 4px 10px; border-radius: var(--pe-radius-sm); font-family: var(--pe-font-mono); font-size: var(--pe-font-size-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.pe-tile__chip-name { font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-tile__chip-value { font-family: var(--pe-font-mono); font-size: var(--pe-font-size-md); font-weight: 500; }
.pe-tile__row { display: flex; align-items: center; gap: var(--pe-space-3); min-height: 56px; }
.pe-tile__primary { font-size: var(--pe-font-size-md); font-weight: 500; }
.pe-tile__mono { font-family: var(--pe-font-mono); font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); }

/* Glifo dell'orientamento: un rettangolo con un punto che segna il fondo
 * dello schermo. La rotazione la fa `data-orientation`. */
.pe-orient {
  position: relative; display: block; flex: none;
  box-sizing: border-box;
  width: 26px; height: 42px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}
.pe-orient::after {
  content: ""; position: absolute;
  width: 4px; height: 4px; margin: -2px 0 0 -2px;
  border-radius: 50%; background: currentColor;
  left: 50%; top: 86%;
}
.pe-orient[data-orientation="90"], .pe-orient[data-orientation="270"] { width: 42px; height: 26px; }
.pe-orient[data-orientation="90"]::after { left: 88%; top: 50%; }
.pe-orient[data-orientation="180"]::after { left: 50%; top: 14%; }
.pe-orient[data-orientation="270"]::after { left: 12%; top: 50%; }
.pe-orient--lg { width: 30px; height: 48px; }
.pe-orient--lg[data-orientation="90"], .pe-orient--lg[data-orientation="270"] { width: 48px; height: 30px; }

/* Griglia delle quattro opzioni di orientamento nella modale Schermo. */
.pe-choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--pe-space-2); }
.pe-choice {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
  min-height: 124px; padding: var(--pe-space-3) var(--pe-space-2);
  border: 1px solid var(--pe-border-strong);
  border-radius: var(--pe-radius-md);
  background: var(--pe-bg-surface);
  color: var(--pe-text-primary);
  font: inherit; cursor: pointer;
}
.pe-choice__glyph { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; }
.pe-choice__value { font-family: var(--pe-font-mono); font-size: var(--pe-font-size-sm); font-weight: 500; }
.pe-choice__label { font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); text-align: center; line-height: 1.3; }
.pe-choice[aria-pressed="true"] { border-color: var(--pe-accent); box-shadow: inset 0 0 0 1px var(--pe-accent); background: var(--pe-accent-bg); }
.pe-choice:disabled { opacity: 0.55; cursor: not-allowed; }

/* ============================================================== Sprint 21 — modale su <dialog>
 *
 * Il browser dà focus intrappolato, Esc (evento `cancel`) e sfondo inerte.
 * Il pannello è una colonna: intestazione fissa, corpo che scorre, piè
 * fisso. Larghezze: 480 (default), 560 (`--md`), 720 (`--lg`), 960
 * (`--xl`). Sotto i 768 px a tutto schermo (regola nel blocco mobile più
 * in basso; `.pe-modal{max-width:100% !important}` del primo blocco
 * mobile resta valida e compatibile). */

dialog.pe-modal {
  box-sizing: border-box;
  width: min(480px, calc(100vw - 32px));
  max-width: 480px;
  max-height: calc(100vh - 64px);
  margin: 32px auto auto;
  padding: 0;
  border: 0;
  border-radius: var(--pe-radius-lg);
  background: var(--pe-bg-surface);
  color: var(--pe-text-primary);
  box-shadow: var(--pe-shadow-lg);
  overflow: hidden;
}
dialog.pe-modal::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog.pe-modal--md { width: min(560px, calc(100vw - 32px)); max-width: 560px; }
dialog.pe-modal--lg { width: min(720px, calc(100vw - 32px)); max-width: 720px; }
dialog.pe-modal--xl { width: min(960px, calc(100vw - 32px)); max-width: 960px; }
.pe-modal__panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 64px);
  min-height: 0;
}
.pe-modal__header {
  display: flex;
  align-items: center;
  gap: var(--pe-space-3);
  padding: var(--pe-space-4) var(--pe-space-5);
  border-bottom: 1px solid var(--pe-border);
  flex: none;
}
.pe-modal__title { flex: none; font-size: var(--pe-font-size-lg); font-weight: 500; margin: 0; }
.pe-modal__header-extra { display: flex; align-items: center; gap: var(--pe-space-2); flex: 1; min-width: 0; }
.pe-modal__close { margin-left: auto; }
.pe-modal__note {
  display: flex; align-items: flex-start; gap: var(--pe-space-2);
  padding: 10px var(--pe-space-5);
  border-bottom: 1px solid var(--pe-border);
  background: var(--pe-bg-page);
  font-size: var(--pe-font-size-sm);
  color: var(--pe-text-secondary);
  flex: none;
}
.pe-modal__note .ti { flex: none; margin-top: 2px; }
.pe-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: var(--pe-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--pe-space-4);
}
.pe-modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--pe-space-3);
  padding: var(--pe-space-4) var(--pe-space-5);
  border-top: 1px solid var(--pe-border);
  flex: none;
  flex-wrap: wrap;
}
.pe-modal__footer-note { font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); min-width: 0; flex: 1; }
.pe-modal__footer-note--danger { color: var(--pe-danger); }
.pe-modal__footer-note--warning { color: var(--pe-warning); }
.pe-modal__actions { display: flex; gap: var(--pe-space-2); margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.pe-modal__section { display: flex; flex-direction: column; gap: 10px; }
.pe-modal__section-title { margin: 0; font-size: var(--pe-font-size-sm); font-weight: 500; }
.pe-modal__divider { width: 100%; height: 1px; margin: 0; border: 0; background: var(--pe-border); }
.pe-modal__hint { margin: 0; font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); }
.pe-modal__error { margin: 0; font-size: var(--pe-font-size-xs); color: var(--pe-danger); }
/* Lista chiave → valore (Dettagli tecnici). */
.pe-kv { margin: 0; }
.pe-kv__row {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--pe-space-3);
  padding: 7px 0; border-bottom: 1px solid var(--pe-border);
  font-size: var(--pe-font-size-sm);
}
.pe-kv__row--stack { flex-direction: column; align-items: stretch; gap: 2px; }
.pe-kv__row dt { color: var(--pe-text-secondary); flex: none; }
.pe-kv__row dd { margin: 0; min-width: 0; text-align: right; }
.pe-kv__row--stack dd { text-align: left; display: flex; align-items: center; justify-content: space-between; gap: var(--pe-space-2); }
.pe-kv__mono { font-family: var(--pe-font-mono); font-size: var(--pe-font-size-xs); }
.pe-kv__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pe-space-5) var(--pe-space-8); align-items: start; }
.pe-kv__col { display: flex; flex-direction: column; gap: var(--pe-space-5); min-width: 0; }
.pe-kv__truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Riga di azione (Manutenzione): icona, titolo + aiuto, controllo a destra. */
.pe-action-row { display: flex; align-items: flex-start; gap: var(--pe-space-3); }
.pe-action-row__icon {
  display: inline-flex; flex: none; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--pe-radius-md);
  background: var(--pe-bg-elevated); color: var(--pe-text-secondary);
}
.pe-action-row__icon--danger { background: var(--pe-danger-bg); color: var(--pe-danger); }
.pe-action-row__icon .ti { font-size: 18px; }
.pe-action-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pe-action-row__title { font-weight: 500; }
.pe-action-row__help { font-size: var(--pe-font-size-sm); color: var(--pe-text-secondary); }
.pe-action-row__help--danger { color: var(--pe-danger); }
.pe-action-row__controls { display: flex; align-items: center; flex-wrap: wrap; gap: var(--pe-space-2); margin-top: var(--pe-space-2); }
.pe-action-row__aside { flex: none; }

/* ============================================================== Sprint 21 — interruttore
 * `<input type="checkbox" role="switch" class="pe-switch">`: la casella
 * nativa sparisce, resta la pill con la manopola. Space la commuta. */
.pe-switch {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none;
  width: 36px; height: 20px; margin: 0;
  border: 0; border-radius: var(--pe-radius-pill);
  background: var(--pe-text-tertiary);
  cursor: pointer;
  transition: background var(--pe-transition-fast);
}
.pe-switch::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 18, 25, 0.24);
  transition: transform var(--pe-transition-fast);
}
.pe-switch:checked { background: var(--pe-accent); }
.pe-switch:checked::before { transform: translateX(16px); }
.pe-switch:disabled { opacity: 0.55; cursor: not-allowed; }
.pe-switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--pe-space-3); font-size: var(--pe-font-size-sm); }
.pe-switch-row__text { display: flex; flex-direction: column; gap: 2px; }
.pe-switch-row__help { font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); }

/* ============================================================== Sprint 21 — controllo a segmenti */
.pe-segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  gap: 2px; padding: 3px;
  border-radius: 10px;
  background: var(--pe-bg-elevated);
}
.pe-segmented__item {
  height: 36px; padding: 0 4px;
  border: 0; border-radius: var(--pe-radius-md);
  background: transparent; color: var(--pe-text-secondary);
  font: inherit; font-size: var(--pe-font-size-xs); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.pe-segmented__item[aria-pressed="true"] { background: var(--pe-bg-surface); color: var(--pe-text-primary); box-shadow: var(--pe-shadow-sm); }
.pe-segmented--mono .pe-segmented__item { font-family: var(--pe-font-mono); font-weight: 400; }
.pe-segmented--tall .pe-segmented__item { height: 44px; }

/* ============================================================== Sprint 21 — cursore con traccia disegnata
 *
 * Chromium con il solo `accent-color` rende una traccia scura che si legge
 * male in tema chiaro. Qui traccia e riempimento sono disegnati: il
 * riempimento è `--pe-range-fill` (percentuale), aggiornato da Alpine a
 * ogni input. Variante verticale per l'equalizzatore. */
.pe-range {
  --pe-range-fill: 0%;
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 24px; margin: 0; padding: 0;
  background: transparent;
  cursor: pointer;
}
.pe-range:disabled { cursor: not-allowed; opacity: 0.55; }
.pe-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: var(--pe-radius-pill);
  background: linear-gradient(to right, var(--pe-accent) 0 var(--pe-range-fill), var(--pe-border-strong) var(--pe-range-fill) 100%);
}
.pe-range::-moz-range-track { height: 6px; border-radius: var(--pe-radius-pill); background: var(--pe-border-strong); }
.pe-range::-moz-range-progress { height: 6px; border-radius: var(--pe-radius-pill); background: var(--pe-accent); }
.pe-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin-top: -6px;
  border-radius: 50%;
  background: var(--pe-accent);
  border: 2px solid var(--pe-bg-surface);
  box-shadow: 0 1px 3px rgba(15, 18, 25, 0.24);
}
.pe-range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--pe-accent);
  border: 2px solid var(--pe-bg-surface);
  box-shadow: 0 1px 3px rgba(15, 18, 25, 0.24);
}
.pe-range:focus-visible { outline: none; }
.pe-range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--pe-accent); outline-offset: 2px; }
.pe-range:focus-visible::-moz-range-thumb { outline: 2px solid var(--pe-accent); outline-offset: 2px; }
.pe-range--vertical {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 24px; height: 100%;
}
.pe-range--vertical::-webkit-slider-runnable-track {
  width: 6px; height: 100%;
  background: linear-gradient(to top, var(--pe-accent) 0 var(--pe-range-fill), var(--pe-border-strong) var(--pe-range-fill) 100%);
}
.pe-range--vertical::-moz-range-track { width: 6px; height: 100%; }
.pe-range--vertical::-webkit-slider-thumb { margin-top: 0; margin-left: -6px; }
.pe-range-scale { display: flex; justify-content: space-between; font-family: var(--pe-font-mono); font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); }
.pe-range-row { display: flex; flex-direction: column; gap: var(--pe-space-2); }
.pe-range-row__head { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--pe-font-size-sm); }
.pe-range-row__label { color: var(--pe-text-secondary); }
.pe-range-row__value { font-family: var(--pe-font-mono); }
.pe-range-row--muted { opacity: 0.45; }
.pe-stepper { display: flex; align-items: center; gap: var(--pe-space-3); }
.pe-stepper__btn {
  display: inline-flex; flex: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--pe-border-strong); border-radius: 10px;
  background: var(--pe-bg-surface); color: var(--pe-text-primary);
  cursor: pointer;
}
.pe-stepper__btn .ti { font-size: 18px; }

/* ============================================================== Sprint 21 — toast
 * In alto al centro della colonna principale, sopra la pagina. I successi
 * spariscono da soli; avvisi ed errori restano finché non si chiudono. */
.pe-shell__main { position: relative; }
.pe-toast-stack {
  position: absolute;
  top: 72px; left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: var(--pe-space-2);
  width: max-content; max-width: calc(100% - 32px);
  pointer-events: none;
}
.pe-toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: var(--pe-space-2) var(--pe-space-2) var(--pe-space-2) 14px;
  background: var(--pe-bg-surface);
  border: 1px solid var(--pe-border);
  border-radius: var(--pe-radius-md);
  box-shadow: var(--pe-shadow-lg);
  font-size: var(--pe-font-size-sm);
  color: var(--pe-text-primary);
  max-width: 100%;
}
.pe-toast > .ti { flex: none; font-size: 16px; }
.pe-toast--success > .ti { color: var(--pe-success); }
.pe-toast--warning > .ti { color: var(--pe-warning); }
.pe-toast--danger  > .ti { color: var(--pe-danger); }
.pe-toast--info    > .ti { color: var(--pe-info); }
.pe-toast--warning { border-color: var(--pe-warning); }
.pe-toast--danger  { border-color: var(--pe-danger); }
.pe-toast__text { min-width: 0; }

/* ============================================================== Sprint 21 — riga di testa + stream */
.pe-device-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--pe-space-3); }
.pe-device-head__left { display: flex; align-items: center; flex-wrap: wrap; gap: var(--pe-space-3); min-width: 0; }
.pe-device-head__right { display: flex; align-items: center; gap: var(--pe-space-2); }
.pe-stream-note { display: inline-flex; align-items: center; gap: 6px; font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); }
.pe-stream-note--danger { color: var(--pe-danger); }
.pe-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--pe-space-3); margin-top: var(--pe-space-3); }
.pe-section-head__title { margin: 0; font-size: var(--pe-font-size-lg); font-weight: 500; }
.pe-section-head__note { font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); }

/* ============================================================== Sprint 21 — equalizzatore in modale
 * Angoli 2×2 (anteriori sopra, posteriori sotto), SUB in una colonna a
 * destra alta due righe. Le etichette degli assi stanno FUORI dall'SVG
 * (che è stirato con preserveAspectRatio=none). */
.pe-eq-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--pe-space-3); }
.pe-eq-panel {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: var(--pe-space-3);
  border: 1px solid var(--pe-border); border-radius: var(--pe-radius-md);
  background: var(--pe-bg-elevated);
}
.pe-eq-panel--sub { grid-column: 3; grid-row: 1 / span 2; }
.pe-eq-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--pe-space-2); }
.pe-eq-panel__title { margin: 0; font-size: var(--pe-font-size-sm); font-weight: 500; display: flex; align-items: center; gap: var(--pe-space-2); }
.pe-eq-panel__trim { display: flex; align-items: center; gap: 6px; font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); }
.pe-eq-plot { display: flex; gap: var(--pe-space-2); height: 96px; }
.pe-eq-panel--sub .pe-eq-plot { height: 280px; }
.pe-eq-plot__box {
  flex: 1; min-width: 0; height: 100%; box-sizing: border-box; overflow: hidden;
  border: 1px solid var(--pe-border); border-radius: var(--pe-radius-sm);
  background: var(--pe-bg-surface);
}
.pe-eq-curve { display: block; width: 100%; height: 100%; }
.pe-eq-axis {
  position: relative; height: 14px; margin-left: 32px;
  font-family: var(--pe-font-mono); font-size: 10px; line-height: 14px;
  color: var(--pe-text-secondary);
}
.pe-eq-axis > span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.pe-eq-axis--full { margin-left: 0; }
.pe-eq-field { display: flex; align-items: center; gap: 6px; font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); }
.pe-eq-field__label { width: 32px; flex: none; }
.pe-eq-field .pe-select { flex: 1; min-width: 0; }
.pe-eq-mobile { display: none; }
.pe-eq-trim-big { font-family: var(--pe-font-mono); font-size: var(--pe-font-size-2xl); font-weight: 500; line-height: 1; white-space: nowrap; }

/* ============================================================== Sprint 21 — WiFi in modale */
.pe-wifi-summary { display: flex; flex-direction: column; gap: 14px; padding: var(--pe-space-4); border-radius: var(--pe-radius-md); background: var(--pe-bg-elevated); }
.pe-wifi-summary__head { display: flex; align-items: center; gap: var(--pe-space-3); }
.pe-wifi-summary__icon { display: inline-flex; flex: none; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: var(--pe-radius-md); background: var(--pe-bg-surface); color: var(--pe-accent-strong); }
[data-theme="dark"] .pe-wifi-summary__icon { color: var(--pe-accent); }
.pe-wifi-summary__icon .ti { font-size: 20px; }
.pe-wifi-summary__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pe-wifi-summary__name { display: flex; align-items: center; gap: var(--pe-space-2); font-size: var(--pe-font-size-md); font-weight: 500; }
.pe-wifi-summary__signal { font-family: var(--pe-font-mono); font-size: var(--pe-font-size-md); font-weight: 500; white-space: nowrap; }
.pe-wifi-summary__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--pe-space-3); margin: 0; }
.pe-wifi-summary__grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pe-wifi-summary__grid dt { font-size: var(--pe-font-size-xs); color: var(--pe-text-secondary); }
.pe-wifi-summary__grid dd { margin: 0; font-family: var(--pe-font-mono); font-size: var(--pe-font-size-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-wifi-empty { margin: 0; padding: 14px var(--pe-space-4); border: 1px dashed var(--pe-border-strong); border-radius: var(--pe-radius-md); font-size: var(--pe-font-size-sm); color: var(--pe-text-secondary); text-align: center; }
.pe-wifi-list--static > li { cursor: default; }
.pe-wifi-list--static > li:hover { background: transparent; }
.pe-wifi-confirm { display: flex; align-items: center; justify-content: space-between; gap: var(--pe-space-3); padding: var(--pe-space-3); border-radius: var(--pe-radius-md); background: var(--pe-warning-bg); color: var(--pe-warning); font-size: var(--pe-font-size-sm); }

/* ============================================================== Sprint 21 — responsive (≤1024 e ≤768)
 * Blocco mobile SEPARATO dal primo `@media (max-width: 768px)` di questo
 * file: test_mobile_responsive legge i 1.500 caratteri dopo quello. */
@media (max-width: 1024px) {
  .pe-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pe-status__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pe-kv__grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .pe-status__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pe-status__cell--span { grid-column: span 2; }
  .pe-status__cell { padding: 14px var(--pe-space-4); }
  .pe-device-head__right { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pe-device-head__right .pe-btn { justify-content: center; height: 44px; }
  /* Lista compatta: una card, righe con icona + titolo + riepilogo + freccia. */
  .pe-tiles {
    display: flex; flex-direction: column; gap: 0;
    background: var(--pe-bg-surface);
    border: 1px solid var(--pe-border);
    border-radius: var(--pe-radius-lg);
    box-shadow: var(--pe-shadow-sm);
    overflow: hidden;
  }
  .pe-tile {
    flex-direction: row; align-items: center; gap: var(--pe-space-3);
    min-height: 64px; padding: 10px var(--pe-space-3) 10px 14px;
    border: 0; border-bottom: 1px solid var(--pe-border); border-radius: 0; box-shadow: none;
  }
  .pe-tile:last-child { border-bottom: 0; }
  .pe-tile:hover { box-shadow: none; border-color: var(--pe-border); }
  .pe-tile__head { flex: 1; min-width: 0; display: grid; grid-template-columns: 36px minmax(0, 1fr) 18px; align-items: center; }
  .pe-tile__icon { width: 36px; height: 36px; }
  .pe-tile__icon .ti { font-size: 20px; }
  .pe-tile__head > .pe-pill { display: none; }
  .pe-tile__spacer { display: none; }
  .pe-tile__title { display: flex; flex-direction: column; }
  .pe-tile__summary { display: block; font-size: var(--pe-font-size-sm); font-weight: 400; color: var(--pe-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pe-tile__body { display: none; }
  .pe-tile__chevron { font-size: 18px; }
  /* Modali a tutto schermo. */
  dialog.pe-modal, dialog.pe-modal--md, dialog.pe-modal--lg, dialog.pe-modal--xl {
    width: 100vw; height: 100vh; max-height: 100vh; margin: 0; border-radius: 0;
  }
  .pe-modal__panel { height: 100vh; max-height: 100vh; }
  .pe-modal__header { padding: 6px var(--pe-space-4) 6px var(--pe-space-2); min-height: 56px; }
  .pe-modal__body { padding: var(--pe-space-4); }
  .pe-modal__footer { padding: var(--pe-space-3) var(--pe-space-4); }
  .pe-modal__footer .pe-btn { height: 44px; }
  .pe-modal__actions { width: 100%; margin-left: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pe-modal__actions .pe-btn { justify-content: center; }
  .pe-toast-stack { position: fixed; top: 64px; }
  .pe-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pe-choice { min-height: 108px; }
  .pe-wifi-summary__grid { grid-template-columns: 1fr; }
  /* Equalizzatore: un canale per volta. */
  .pe-eq-grid { display: flex; flex-direction: column; gap: var(--pe-space-4); }
  .pe-eq-panel { display: none; padding: 0; border: 0; background: transparent; }
  .pe-eq-panel.is-mobile-active { display: flex; }
  .pe-eq-panel__head { display: none; }
  .pe-eq-plot { height: 170px; }
  .pe-eq-panel--sub .pe-eq-plot { height: 170px; }
  .pe-eq-plot .pe-range--vertical { display: none; }
  .pe-eq-axis { margin-left: 0; }
  .pe-eq-mobile { display: flex; flex-direction: column; gap: var(--pe-space-3); }
  .pe-eq-field .pe-input, .pe-eq-field .pe-select { height: 44px; font-size: var(--pe-font-size-base); }
}

/* ============================================================== Sprint 21 — movimento ridotto */
@media (prefers-reduced-motion: reduce) {
  .pe-tile, .pe-switch, .pe-switch::before, .pe-tile__bar-fill, .pe-status__cell, .pe-spin {
    transition: none !important;
    animation: none !important;
  }
}

/* ============================================================== Sprint 21 — rifiniture usate dai parziali */
.pe-modal__big { display: flex; align-items: baseline; gap: var(--pe-space-1); font-family: var(--pe-font-mono); font-weight: 500; }
.pe-modal__big-value { font-size: 40px; line-height: 1; }
.pe-modal__big-unit { font-size: var(--pe-font-size-xl); line-height: 1; color: var(--pe-text-secondary); }
/* Asse delle frequenze fuori dall'SVG: x(100 Hz)=23.3 %, x(1 kHz)=56.6 %,
 * x(10 kHz)=90 % della larghezza del grafico (log 20 Hz → 20 kHz). */
.pe-eq-axis__100 { left: 23.3%; }
.pe-eq-axis__1k { left: 56.6%; }
.pe-eq-axis__10k { left: 90%; }
/* Pallino di stato riusato fuori dalle celle (NTP nei Dettagli tecnici). */
.pe-status__dot--success { background: var(--pe-success); }
.pe-status__dot--warning { background: var(--pe-warning); }
.pe-status__dot--danger { background: var(--pe-danger); }
.pe-status__dot--neutral { background: var(--pe-text-tertiary); }

/* ============================================================== Sprint 21 — classi usate altrove e mai definite
 * Definizioni minime, nessun restyling delle altre pagine (guardia
 * test_sprint21_css_class_guard.py). */
.pe-container { max-width: var(--pe-content-max); margin: 0 auto; padding: 0 var(--pe-space-8); }
.pe-empty-state__action { margin-top: var(--pe-space-2); }
.pe-event__body { flex: 1; min-width: 0; }
.pe-field--error input, .pe-field--error select, .pe-field--error textarea { border-color: var(--pe-danger); }
.pe-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.pe-map-panel__pins { pointer-events: none; }
.pe-map-pin { pointer-events: auto; }
.pe-pl-4 { padding-left: var(--pe-space-4); }
.pe-text-2xl { font-size: var(--pe-font-size-2xl); }
.pe-uppercase { text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- Sprint 21: one screen even with the alerting banner ----------------
   base.html renders the "Allarmi non configurati" banner ABOVE .pe-shell.
   With `min-height: 100vh` on the shell and `height: 100vh` on the sticky
   sidebar, every page scrolled by exactly the banner's height (59 px at
   1440×900) even when its content fitted. The body becomes a column and
   the shell takes what is left; on desktop the sidebar stretches with the
   shell and is capped at the viewport, so it still sticks on long pages. */
body:has(> .pe-shell) { display: flex; flex-direction: column; }
body:has(> .pe-shell) > .pe-shell { flex: 1 1 auto; min-height: 0; }
@media (min-width: 769px) {
  .pe-shell > .pe-sidebar { height: auto; max-height: 100vh; align-self: stretch; }
}

/* ---- Sprint 21: short desktop viewports (1366×768 with the banner) ------
   The page must stay one screen on the 1366×768 reference too: with the
   alerting banner it was 10 px over. Below 820 px of height the content
   breathes a little less (paddings and the tiles' inner gap). */
@media (min-width: 769px) and (max-height: 820px) {
  .pe-shell__content { padding-top: var(--pe-space-4); padding-bottom: var(--pe-space-4); }
  .pe-section-head { margin-top: var(--pe-space-2); }
  .pe-tile { padding: var(--pe-space-4) var(--pe-space-5); gap: 10px; }
  .pe-tile__body { gap: 10px; }
}
