:root {
  --bg: #060913;
  --surface: rgba(15, 23, 42, 0.68);
  --surface-strong: rgba(20, 30, 54, 0.88);
  --surface-2: rgba(30, 41, 68, 0.65);
  --border: rgba(148, 163, 184, 0.16);
  --border-hi: rgba(255, 255, 255, 0.14);
  --text: #f8fafc;
  --text-sub: #94a3b8;
  --text-dim: #64748b;

  --cyan: #38bdf8;
  --teal: #2dd4bf;
  --green: #22c55e;
  --amber: #fbbf24;
  --orange: #fb923c;
  --red: #f43f5e;

  --aura-primary: rgba(56, 189, 248, 0.22);
  --aura-secondary: rgba(45, 212, 191, 0.16);
  --thermal-color: #22c55e;

  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow-card: 0 20px 50px rgba(2, 6, 23, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

body[data-thermal="cold"] {
  --aura-primary: rgba(56, 189, 248, 0.28);
  --aura-secondary: rgba(99, 102, 241, 0.2);
  --thermal-color: #38bdf8;
}
body[data-thermal="normal"] {
  --aura-primary: rgba(34, 197, 94, 0.2);
  --aura-secondary: rgba(56, 189, 248, 0.18);
  --thermal-color: #22c55e;
}
body[data-thermal="near"] {
  --aura-primary: rgba(251, 191, 36, 0.24);
  --aura-secondary: rgba(251, 146, 60, 0.16);
  --thermal-color: #fbbf24;
}
body[data-thermal="high"] {
  --aura-primary: rgba(251, 146, 60, 0.28);
  --aura-secondary: rgba(244, 63, 94, 0.2);
  --thermal-color: #fb923c;
}
body[data-thermal="over"],
body[data-thermal="fault"] {
  --aura-primary: rgba(244, 63, 94, 0.34);
  --aura-secondary: rgba(251, 146, 60, 0.22);
  --thermal-color: #f43f5e;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* Dynamic Ambient Aurora */
.aurora-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.aurora-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  transition: background 1.2s ease;
  animation: floatOrb 16s ease-in-out infinite alternate;
}

.orb-1 {
  width: 520px;
  height: 520px;
  top: -140px;
  left: -100px;
  background: var(--aura-primary);
}

.orb-2 {
  width: 460px;
  height: 460px;
  bottom: -140px;
  right: -80px;
  background: var(--aura-secondary);
  animation-delay: -6s;
}

.orb-3 {
  width: 340px;
  height: 340px;
  top: 40%;
  left: 48%;
  background: rgba(99, 102, 241, 0.12);
  animation-delay: -11s;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at 50% 30%, black 35%, transparent 90%);
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(35px, -25px) scale(1.07); }
  100% { transform: translate(-20px, 30px) scale(0.96); }
}

/* Glass Surface */
.glass {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}

/* Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  border-radius: var(--radius-xl);
  margin-bottom: 18px;
  position: sticky;
  top: calc(10px + env(safe-area-inset-top));
  z-index: 20;
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(45, 212, 191, 0.08));
  border: 1px solid rgba(56, 189, 248, 0.35);
  flex-shrink: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.brand-name {
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #f8fafc, #7dd3fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-gen {
  font-weight: 800;
  font-size: 0.78rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-chip {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(45, 212, 191, 0.12);
  color: var(--teal);
  border: 1px solid rgba(45, 212, 191, 0.25);
}

.brand-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--text-sub);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px currentColor;
  animation: pulseDot 1.6s infinite;
}

.status-pill.is-live {
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
}
.status-pill.is-live .pulse-dot { background: var(--green); }

.status-pill.is-demo {
  color: var(--cyan);
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.12);
}
.status-pill.is-demo .pulse-dot { background: var(--cyan); }

.status-pill.is-offline {
  color: var(--red);
  border-color: rgba(244, 63, 94, 0.35);
  background: rgba(244, 63, 94, 0.12);
}
.status-pill.is-offline .pulse-dot { background: var(--red); animation: none; }

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.5; }
}

.icon-pill-btn, .install-btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.icon-pill-btn { padding: 0 12px; }
.install-btn {
  padding: 0 13px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(45, 212, 191, 0.18));
  border-color: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}
.icon-btn {
  width: 36px;
  justify-content: center;
  padding: 0;
}

.icon-pill-btn:hover, .install-btn:hover, .icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.55);
}
.icon-pill-btn:active, .install-btn:active, .icon-btn:active {
  transform: scale(0.95);
}
.icon-pill-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* Alert Banner */
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, rgba(244, 63, 94, 0.26), rgba(251, 146, 60, 0.16));
  border: 1px solid rgba(244, 63, 94, 0.55);
  box-shadow: 0 0 30px rgba(244, 63, 94, 0.2);
  animation: alertPulse 1.8s infinite;
}

@keyframes alertPulse {
  0%, 100% { box-shadow: 0 0 22px rgba(244, 63, 94, 0.2); }
  50% { box-shadow: 0 0 38px rgba(244, 63, 94, 0.42); }
}

.alert-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-pulse-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.alert-left p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: #ffe4e6;
}

.mute-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: white;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

/* Bento Grid */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr 1.18fr;
  gap: 18px;
}

.card {
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.chart-card {
  grid-column: 1 / -1;
}

.fade-in-up {
  animation: fadeInUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--delay, 0s);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.eyebrow {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--cyan);
}

.card-head h2 {
  margin: 2px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
}

/* Thermal Badge */
.thermal-badge {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: var(--thermal-color);
  border: 1px solid currentColor;
  transition: all 0.35s ease;
}

/* Radial Gauge */
.gauge-wrap {
  position: relative;
  width: 100%;
  max-width: 310px;
  margin: 6px auto 12px;
}

.radial-gauge {
  width: 100%;
  height: auto;
  display: block;
}

.gauge-ring-bg {
  stroke: rgba(148, 163, 184, 0.08);
  stroke-width: 1;
  stroke-dasharray: 3 7;
}

#gaugeProgress {
  transition: stroke-dasharray 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.sp-marker {
  transition: cx 0.4s ease, cy 0.4s ease;
  stroke: #060913;
  stroke-width: 2;
}
.sp-marker.sp-off { fill: var(--cyan); }
.sp-marker.sp-on { fill: var(--orange); }

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 14px;
  pointer-events: none;
}

.temp-readout-row {
  display: flex;
  align-items: flex-start;
  line-height: 1;
}

.temp-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 3.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--thermal-color);
  text-shadow: 0 0 28px color-mix(in srgb, var(--thermal-color) 45%, transparent);
  transition: color 0.35s ease;
}

.temp-unit {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-sub);
  margin: 6px 0 0 4px;
}

.temp-delta {
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--text-sub);
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
}

.gauge-scale-labels {
  width: 62%;
  display: flex;
  justify-content: space-between;
  margin-top: 30px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Mini Metrics */
.mini-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.metric-tile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.56);
  border: 1px solid var(--border);
}

.metric-tile small {
  display: block;
  font-size: 0.65rem;
  color: var(--text-sub);
}

.metric-tile strong {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.92rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-orange { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.dot-cyan { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.dot-green { background: var(--green); box-shadow: 0 0 8px var(--green); }

.device-meta-bar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  color: var(--text-dim);
  flex-wrap: wrap;
}

/* Mode Switcher */
.mode-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 14px;
  background: rgba(10, 15, 30, 0.85);
  border: 1px solid var(--border);
  width: 196px;
}

.mode-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), #0ea5e9);
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.35);
  transition: transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1), background 0.3s ease;
}

.mode-switch.is-auto .mode-thumb {
  transform: translateX(100%);
  background: linear-gradient(135deg, var(--amber), var(--orange));
  box-shadow: 0 4px 18px rgba(251, 146, 60, 0.35);
}

.mode-btn {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  color: var(--text-sub);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 8px 10px;
  cursor: pointer;
  transition: color 0.25s ease;
}

.mode-btn.active {
  color: #060913;
}

.control-panel {
  display: none;
  animation: panelFade 0.28s ease;
}
.control-panel.active {
  display: block;
}

@keyframes panelFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.quick-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.quick-hint {
  font-size: 0.76rem;
  color: var(--text-sub);
}

.quick-btns {
  display: flex;
  gap: 6px;
}

.chip-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: transform 0.15s ease, background 0.2s ease;
}
.chip-btn:active { transform: scale(0.95); }
.chip-green:hover { background: rgba(34, 197, 94, 0.18); border-color: var(--green); color: var(--green); }
.chip-red:hover { background: rgba(244, 63, 94, 0.18); border-color: var(--red); color: var(--red); }

/* Fan Cards */
.fan-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fan-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-radius: var(--radius-lg);
  background: rgba(15, 23, 42, 0.56);
  border: 1px solid var(--border);
  transition: border-color 0.28s ease, background 0.28s ease, box-shadow 0.28s ease, transform 0.2s ease;
  overflow: hidden;
}

.fan-card:hover {
  transform: translateY(-1px);
}

.fan-card.is-on {
  background: rgba(16, 42, 38, 0.45);
  border-color: rgba(34, 197, 94, 0.48);
  box-shadow: 0 8px 26px rgba(34, 197, 94, 0.12);
}

.fan-card.is-seq-active {
  border-color: rgba(251, 191, 36, 0.65);
  box-shadow: 0 8px 28px rgba(251, 191, 36, 0.18);
}

.fan-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.fan-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(30, 41, 68, 0.72);
  border: 1px solid var(--border);
  color: var(--text-sub);
  transition: color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.fan-card.is-on .fan-icon-box {
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.26);
}

.fan-svg {
  transition: transform 0.6s ease;
}

.fan-card.is-on .fan-svg {
  animation: fanSpin 0.58s linear infinite;
}

@keyframes fanSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.fan-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.fan-status-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-sub);
}

.fan-card.is-on .fan-status-tag {
  background: rgba(34, 197, 94, 0.16);
  color: var(--green);
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(10, 15, 30, 0.65);
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}
.timer-pill:hover {
  border-color: var(--cyan);
}
.timer-pill:active { transform: scale(0.96); }

.edit-tag {
  font-family: "Plus Jakarta Sans", "Noto Sans Thai", sans-serif;
  font-size: 0.68rem;
  color: var(--text-sub);
  border-left: 1px solid var(--border);
  padding-left: 6px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 62px;
  height: 34px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(30, 41, 68, 0.9);
  border: 1px solid var(--border);
  transition: background 0.28s ease, border-color 0.28s ease;
}

.toggle-knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text-sub);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s ease;
}

.toggle-switch input:checked + .toggle-track {
  background: linear-gradient(135deg, #22c55e, #10b981);
  border-color: #34d399;
}

.toggle-switch input:checked + .toggle-track .toggle-knob {
  transform: translateX(28px);
  background: #ffffff;
}

.seq-progress-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: transparent;
}
.seq-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--orange));
  transition: width 0.5s linear;
}

/* Sequence Pipeline */
.seq-pipeline {
  margin-top: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-lg);
  background: rgba(15, 23, 42, 0.62);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.seq-pipeline.is-running {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(66, 44, 12, 0.34);
}

.seq-meta strong {
  font-size: 0.85rem;
}

.seq-steps {
  display: flex;
  align-items: center;
  gap: 6px;
}

.seq-node {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-sub);
  transition: all 0.25s ease;
}
.seq-node.active {
  background: var(--amber);
  color: #060913;
  border-color: var(--amber);
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.55);
  transform: scale(1.1);
}
.seq-node.done {
  background: var(--green);
  color: #060913;
  border-color: var(--green);
}

.seq-line {
  width: 18px;
  height: 2px;
  background: var(--border);
}

.seq-action-btn {
  padding: 10px 18px;
  border-radius: 12px;
  border: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--green), #10b981);
  color: #060913;
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.28);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.seq-action-btn.is-stop {
  background: linear-gradient(135deg, var(--red), #e11d48);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(244, 63, 94, 0.32);
}
.seq-action-btn:active { transform: scale(0.96); }

/* Auto Panel */
.auto-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.setpoint-card {
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(15, 23, 42, 0.58);
  border: 1px solid var(--border);
}

.sp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sp-header strong {
  font-size: 0.82rem;
  margin-left: 6px;
}
.sp-header p {
  margin: 4px 0 0;
  font-size: 0.72rem;
  color: var(--text-sub);
}

.sp-val-box {
  font-family: "JetBrains Mono", monospace;
  white-space: nowrap;
}
.sp-val {
  font-size: 1.45rem;
  font-weight: 700;
}
.sp-val-box small {
  color: var(--text-sub);
  margin-left: 2px;
}

.sp-slider {
  width: 100%;
  margin: 14px 0 12px;
  accent-color: var(--orange);
  cursor: pointer;
}
.sp-slider.slider-cyan { accent-color: var(--cyan); }

.stepper-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.step-btn {
  padding: 8px 4px;
  border-radius: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.14s ease, background 0.2s ease;
}
.step-btn:active { transform: scale(0.94); }
.step-btn.neg {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.35);
  color: #fda4af;
}
.step-btn.pos {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.hysteresis-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--text-sub);
  flex-wrap: wrap;
}
.hysteresis-info strong {
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
}

.auto-hero-btn {
  width: 100%;
  padding: 15px 18px;
  border-radius: 16px;
  border: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, #22c55e, #10b981);
  color: #060913;
  box-shadow: 0 10px 28px rgba(34, 197, 94, 0.28);
  transition: transform 0.18s ease, box-shadow 0.25s ease;
}
.auto-hero-btn.is-running {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(244, 63, 94, 0.34);
}
.auto-hero-btn:active { transform: scale(0.98); }

/* Chart */
.chart-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-sub);
}
.stat-pill b { color: var(--text); margin-left: 4px; }

.chart-stage {
  position: relative;
  height: 220px;
  width: 100%;
  border-radius: var(--radius-lg);
  background: rgba(8, 13, 26, 0.6);
  border: 1px solid var(--border);
  overflow: hidden;
}

.trend-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.thresh-line {
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
  opacity: 0.72;
}
.thresh-on { stroke: var(--orange); }
.thresh-off { stroke: var(--cyan); }

.hover-line {
  stroke: rgba(248, 250, 252, 0.35);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}
.hover-dot {
  fill: var(--cyan);
  stroke: #ffffff;
  stroke-width: 2;
}

.chart-tooltip {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.45);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  pointer-events: none;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 18px;
  animation: fadeModal 0.2s ease;
}

@keyframes fadeModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

.hidden { display: none !important; }

.modal-card {
  width: 100%;
  max-width: 430px;
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  background: var(--surface-strong);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.08rem;
}

.close-x {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.timer-display {
  text-align: center;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(8, 13, 26, 0.7);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.timer-display span {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 2.3rem;
  font-weight: 700;
  color: var(--cyan);
}
.timer-display small {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

.modal-step-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.modal-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.btn-primary, .btn-secondary {
  padding: 11px 14px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #0ea5e9);
  color: #060913;
}
.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.full-w { width: 100%; margin-bottom: 14px; }

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-form label span {
  display: block;
  font-size: 0.76rem;
  color: var(--text-sub);
  margin-bottom: 5px;
}
.settings-form input[type="text"],
.settings-form input[type="url"],
.settings-form input[type="password"],
.settings-form select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(8, 13, 26, 0.8);
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
}
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.check-row span { margin: 0 !important; }

.install-steps {
  font-size: 0.84rem;
  color: var(--text-sub);
}
.os-guide {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(8, 13, 26, 0.6);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.os-guide h4 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 0.86rem;
}
.os-guide ol {
  margin: 0;
  padding-left: 18px;
  line-height: 1.65;
}

/* Toasts */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 15px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mobile Dock */
.mobile-dock {
  display: none;
}

@media (max-width: 960px) {
  .bento-grid {
    grid-template-columns: 1fr;
  }
  .auto-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: calc(10px + env(safe-area-inset-top)) 12px calc(92px + env(safe-area-inset-bottom));
  }
  .top-header {
    padding: 10px 12px;
  }
  .brand-sub { display: none; }
  .install-btn span { display: none; }
  .install-btn { width: 36px; padding: 0; justify-content: center; }
  .icon-pill-btn span { display: none; }
  .icon-pill-btn { width: 36px; padding: 0; justify-content: center; }

  .mobile-dock {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px;
    border-radius: 20px;
  }
  .dock-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    border: 0;
    background: transparent;
    color: var(--text-sub);
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 14px;
    transition: color 0.2s ease, background 0.2s ease;
  }
  .dock-btn.active {
    color: var(--cyan);
    background: rgba(56, 189, 248, 0.12);
  }
  .toast-stack {
    bottom: calc(84px + env(safe-area-inset-bottom));
    right: 12px;
    left: 12px;
  }
}
