:root {
  color-scheme: dark;
  --ink: #17130f;
  --ink-2: #211b15;
  --ink-3: #2b231b;
  --line: #443728;
  --line-soft: #32291f;
  --cream: #eee3cf;
  --muted: #a99d8b;
  --gold: #c89435;
  --gold-bright: #e0ad4c;
  --green: #61b985;
  --red: #db705f;
  --blue: #6aa7c9;
  --shadow: 0 20px 60px rgb(0 0 0 / 26%);
  --radius: 18px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background:
    radial-gradient(circle at 85% 8%, rgb(200 148 53 / 8%), transparent 32rem),
    var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 100;
  opacity: 0.035;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold-bright);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

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

.brand > span:last-child {
  display: grid;
  gap: 1px;
}

.brand b {
  font-family: var(--mono);
  font-size: 0.98rem;
  letter-spacing: 0.12em;
}

.brand small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--gold);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--ink), inset 0 0 0 6px var(--gold);
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  width: 42px;
  height: 7px;
  border-right: 4px solid var(--gold);
  border-left: 4px solid var(--gold);
  content: "";
}

.brand-mark::after {
  transform: rotate(90deg);
}

.brand-mark i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
}

/* Login */
.login-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.15fr) minmax(430px, 0.85fr);
}

.login-story {
  position: relative;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(34px, 6vw, 82px);
  border-right: 1px solid var(--line);
  background:
    linear-gradient(125deg, rgb(23 19 15 / 96%), rgb(27 22 17 / 83%)),
    repeating-linear-gradient(135deg, transparent 0 32px, rgb(200 148 53 / 4%) 32px 33px),
    var(--ink-2);
}

.login-story::after {
  position: absolute;
  right: -180px;
  bottom: -190px;
  width: 540px;
  height: 540px;
  border: 1px solid rgb(200 148 53 / 24%);
  border-radius: 50%;
  box-shadow:
    0 0 0 45px rgb(200 148 53 / 3%),
    0 0 0 110px rgb(200 148 53 / 2%);
  content: "";
}

.brand-large .brand-mark {
  width: 46px;
  height: 46px;
}

.brand-large .brand-mark::before,
.brand-large .brand-mark::after {
  width: 54px;
}

.brand-large b {
  font-size: 1.25rem;
}

.login-copy {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.login-copy h1 {
  margin: 0;
  font-size: clamp(3.5rem, 7vw, 7.4rem);
  font-weight: 650;
  letter-spacing: -0.065em;
  line-height: 0.9;
}

.login-copy > p:last-child {
  max-width: 570px;
  margin: 32px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 1.7;
}

.signal-lines {
  position: absolute;
  top: 50%;
  right: clamp(30px, 7vw, 100px);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  opacity: 0.42;
  transform: translateY(-50%);
}

.signal-lines span {
  width: 5px;
  border-radius: 2px;
  background: var(--gold);
}

.signal-lines span:nth-child(1) { height: 18px; }
.signal-lines span:nth-child(2) { height: 33px; }
.signal-lines span:nth-child(3) { height: 52px; }
.signal-lines span:nth-child(4) { height: 75px; }

.build-note {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #766b5d;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.13em;
}

.login-panel {
  display: grid;
  padding: clamp(24px, 6vw, 90px);
  place-items: center;
  background: #130f0c;
}

.login-card {
  width: min(100%, 440px);
}

.mobile-brand {
  display: none;
  margin-bottom: 60px;
}

.login-card h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.045em;
}

.form-intro {
  margin: 12px 0 42px;
  color: var(--muted);
}

.login-card label {
  display: block;
  margin: 20px 0 9px;
  color: #c8bcaa;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.login-card input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--cream);
  background: #1b1611;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-card input:hover,
.login-card input:focus {
  border-color: #8b6933;
  box-shadow: 0 0 0 3px rgb(200 148 53 / 9%);
}

.login-card input::placeholder {
  color: #6f6558;
}

.password-field {
  position: relative;
}

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

.password-field button {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.button {
  display: flex;
  width: 100%;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  margin-top: 30px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.button-primary {
  color: #17110a;
  background: var(--gold);
}

.button-primary:hover {
  background: var(--gold-bright);
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.form-error {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgb(219 112 95 / 45%);
  border-radius: 8px;
  color: #ef9a8d;
  background: rgb(219 112 95 / 8%);
  font-size: 0.85rem;
}

.security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 22px 0 0;
  color: #71675b;
  font-size: 0.72rem;
  text-align: center;
}

.security-note span {
  color: var(--gold);
  font-size: 0.55rem;
}

/* App shell */
.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-areas:
    "topbar topbar"
    "sidebar dashboard";
  grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: 74px 1fr;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  grid-area: topbar;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--line-soft);
  background: rgb(23 19 15 / 92%);
  backdrop-filter: blur(18px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-block {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 8px;
}

.user-block > span:last-child {
  display: grid;
  gap: 1px;
}

.user-block b {
  font-size: 0.78rem;
}

.user-block small {
  color: var(--muted);
  font-size: 0.66rem;
}

.user-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #806330;
  border-radius: 50%;
  color: var(--gold-bright);
  background: rgb(200 148 53 / 8%);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.status-pill i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.status-pill.online { color: var(--green); }
.status-pill.offline { color: var(--red); }
.status-pill.neutral { color: var(--muted); }

.icon-button,
.text-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  font-size: 1.1rem;
}

.icon-button:hover,
.text-button:hover { color: var(--cream); }

.icon-button.loading { animation: spin 900ms linear infinite; }

.text-button {
  padding: 8px;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sidebar {
  position: sticky;
  top: 74px;
  display: flex;
  height: calc(100vh - 74px);
  flex-direction: column;
  grid-area: sidebar;
  padding: 28px 18px 20px;
  border-right: 1px solid var(--line-soft);
  background: #15110e;
}

.sidebar-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.12em;
}

.sidebar-title b {
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  color: var(--gold-bright);
  background: rgb(200 148 53 / 10%);
}

.device-list {
  display: grid;
  gap: 7px;
}

.device-item {
  display: grid;
  width: 100%;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--cream);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.device-item:hover { background: rgb(255 255 255 / 2%); }

.device-item.active {
  border-color: #594529;
  background: linear-gradient(90deg, rgb(200 148 53 / 12%), rgb(200 148 53 / 3%));
}

.device-symbol {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--gold-bright);
  font-family: var(--mono);
}

.device-item span:nth-child(2) {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.device-item b {
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-item small {
  color: var(--muted);
  font-size: 0.62rem;
}

.device-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.device-dot.online { background: var(--green); box-shadow: 0 0 9px var(--green); }
.device-dot.offline { background: var(--red); }

.sidebar-foot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: auto;
  padding: 15px 9px 0;
  border-top: 1px solid var(--line-soft);
  color: #766b5d;
  font-family: var(--mono);
  font-size: 0.57rem;
  letter-spacing: 0.08em;
}

.sidebar-foot b { color: var(--muted); }

.dashboard {
  width: 100%;
  max-width: 1580px;
  grid-area: dashboard;
  justify-self: center;
  padding: clamp(24px, 3vw, 48px);
}

.device-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 28px;
}

.title-line {
  display: flex;
  align-items: center;
  gap: 15px;
}

.title-line h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  letter-spacing: -0.05em;
}

.device-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.last-update {
  display: grid;
  gap: 5px;
  min-width: max-content;
  text-align: right;
}

.last-update span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}

.last-update b {
  font-size: 0.78rem;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr 1fr;
  gap: 14px;
}

.metric-card,
.chart-card,
.detail-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgb(37 30 23 / 94%), rgb(27 22 17 / 96%));
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 186px;
  padding: 20px;
}

.temperature-card {
  position: relative;
  overflow: hidden;
  border-color: #5d482b;
  background:
    radial-gradient(circle at 90% 10%, rgb(200 148 53 / 14%), transparent 50%),
    linear-gradient(145deg, #2a2117, #1c1611);
}

.temperature-card::after {
  position: absolute;
  top: -52px;
  right: -42px;
  width: 150px;
  height: 150px;
  border: 1px solid rgb(200 148 53 / 12%);
  border-radius: 50%;
  content: "";
}

.metric-top {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.metric-icon {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid #5b4932;
  border-radius: 7px;
  color: var(--gold-bright);
  font-size: 0.8rem;
}

.temperature-value {
  display: flex;
  align-items: baseline;
  margin-top: 15px;
}

.temperature-value b {
  font-family: var(--mono);
  font-size: clamp(3rem, 5vw, 4.6rem);
  font-weight: 500;
  letter-spacing: -0.09em;
  line-height: 1;
}

.temperature-value span,
.secondary-value span {
  margin-left: 8px;
  color: var(--gold-bright);
  font-family: var(--mono);
  font-size: 0.88rem;
}

.target-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  margin-top: 17px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.07em;
}

.target-row b { color: var(--cream); font-size: 0.68rem; }

.secondary-value {
  display: flex;
  align-items: baseline;
  margin-top: 27px;
}

.secondary-value b {
  font-family: var(--mono);
  font-size: clamp(2rem, 3.5vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.06em;
}

.metric-caption {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.state-value {
  display: block;
  margin-top: 28px;
  color: var(--gold-bright);
  font-family: var(--mono);
  font-size: 1.12rem;
  letter-spacing: 0.04em;
}

.relay-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 24px;
}

.relay-pill {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #71675a;
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.relay-pill.active-cooling {
  border-color: rgb(106 167 201 / 55%);
  color: #8cc2df;
  background: rgb(106 167 201 / 9%);
}

.relay-pill.active-heating {
  border-color: rgb(219 112 95 / 55%);
  color: #eb9385;
  background: rgb(219 112 95 / 9%);
}

.signal-meter {
  overflow: hidden;
  height: 5px;
  margin-top: 18px;
  border-radius: 99px;
  background: #0e0b09;
}

.signal-meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
  transition: width 400ms ease, background 400ms ease;
}

.chart-card {
  margin-top: 14px;
  padding: clamp(20px, 2.5vw, 30px);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.section-heading.compact { align-items: center; }

.range-control {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #17120e;
}

.range-control button {
  padding: 7px 10px;
  border: 0;
  border-radius: 5px;
  color: #756b5e;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 700;
  cursor: pointer;
}

.range-control button.active {
  color: var(--ink);
  background: var(--gold);
}

.legend {
  display: flex;
  gap: 18px;
  margin: 26px 0 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
}

.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 18px; height: 2px; }
.legend-temp { background: var(--gold-bright); }
.legend-target { border-top: 2px dashed #7a7167; }

.chart-wrap {
  position: relative;
  min-height: 300px;
}

#temperatureChart {
  display: block;
  width: 100%;
  min-width: 700px;
  height: 300px;
  overflow: visible;
}

.chart-wrap {
  overflow-x: auto;
  scrollbar-color: #4e4030 transparent;
}

.chart-line {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.temperature-line {
  stroke: var(--gold-bright);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  filter: drop-shadow(0 0 5px rgb(224 173 76 / 28%));
}

.target-line {
  stroke: #8b8175;
  stroke-dasharray: 7 6;
  stroke-width: 1.5;
}

.chart-grid-line { stroke: #3b3127; stroke-width: 1; }
.chart-grid-text { fill: #71675c; font: 11px var(--mono); }

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.detail-card {
  min-height: 245px;
  padding: 22px;
}

.outline-badge {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.57rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.outline-badge.pending {
  border-color: rgb(224 173 76 / 55%);
  color: var(--gold-bright);
  background: rgb(224 173 76 / 8%);
}

.outline-badge.applied {
  border-color: rgb(97 185 133 / 50%);
  color: var(--green);
  background: rgb(97 185 133 / 8%);
}

.outline-badge.rejected {
  border-color: rgb(219 112 95 / 50%);
  color: var(--red);
  background: rgb(219 112 95 / 8%);
}

.remote-control-card {
  border-color: #5d482b;
  background:
    radial-gradient(circle at 100% 0, rgb(200 148 53 / 10%), transparent 52%),
    linear-gradient(145deg, rgb(42 33 23 / 96%), rgb(27 22 17 / 96%));
}

.remote-control-form {
  margin-top: 24px;
}

.remote-control-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.setpoint-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.temperature-input {
  position: relative;
}

.temperature-input input {
  width: 100%;
  height: 45px;
  padding: 0 42px 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--cream);
  background: #17120e;
  font-family: var(--mono);
}

.temperature-input span {
  position: absolute;
  top: 50%;
  right: 13px;
  color: var(--gold-bright);
  font-family: var(--mono);
  font-size: 0.72rem;
  transform: translateY(-50%);
}

.setpoint-input-row button {
  min-width: 88px;
  padding: 0 13px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  color: #17110a;
  background: var(--gold);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.setpoint-input-row button:hover:not(:disabled) {
  background: var(--gold-bright);
}

.temperature-input input:disabled,
.setpoint-input-row button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.command-status-text {
  min-height: 34px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.5;
}

.data-list {
  display: grid;
  gap: 0;
  margin: 22px 0 0;
}

.data-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.data-list div:last-child { border-bottom: 0; }
.data-list dt { color: var(--muted); font-size: 0.72rem; }
.data-list dd {
  overflow: hidden;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alarm-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 34px;
}

.alarm-summary > span {
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgb(97 185 133 / 40%);
  border-radius: 50%;
  color: var(--green);
  background: rgb(97 185 133 / 8%);
  font-size: 1.2rem;
}

.alarm-summary b { font-size: 0.88rem; }
.alarm-summary p { margin: 5px 0 0; color: var(--muted); font-size: 0.72rem; line-height: 1.5; }

.alarm-card.active {
  border-color: rgb(219 112 95 / 42%);
  background: linear-gradient(145deg, rgb(50 29 23 / 95%), rgb(30 21 17 / 96%));
}

.alarm-card.active .alarm-summary > span {
  border-color: rgb(219 112 95 / 50%);
  color: var(--red);
  background: rgb(219 112 95 / 8%);
}

.dashboard-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 35px;
  padding: 0 4px;
  color: #665c50;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.09em;
}

.toast {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 13px 16px;
  border: 1px solid #665035;
  border-radius: 10px;
  color: var(--cream);
  background: #271f18;
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

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

@media (max-width: 1150px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .login-copy h1 { font-size: clamp(3.4rem, 7vw, 5.6rem); }
}

@media (max-width: 850px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-story { display: none; }
  .login-panel { min-height: 100vh; }
  .mobile-brand { display: flex; }

  .app-shell {
    grid-template-areas: "topbar" "dashboard";
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar { display: none; }
  .user-block > span:last-child,
  .topbar .status-pill { display: none; }
  .dashboard { padding: 24px 16px 36px; }
}

@media (max-width: 640px) {
  .topbar { height: 66px; padding: 0 14px; }
  .topbar .brand small { display: none; }
  .topbar-actions { gap: 6px; }
  .text-button { padding-right: 0; }

  .device-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
  }

  .last-update { text-align: left; }
  .title-line { flex-wrap: wrap; gap: 10px; }
  .metrics-grid,
  .detail-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 170px; }

  .section-heading:not(.compact) {
    align-items: stretch;
    flex-direction: column;
  }

  .range-control { align-self: flex-start; }
  .range-control button { padding-inline: 8px; }
  .chart-card { padding-inline: 16px; }
  .chart-wrap { margin-right: -10px; }
  .dashboard-footer { flex-direction: column; line-height: 1.6; }
}

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