:root {
  --bg: #12100f;
  --bg-raise: #1b1817;
  --card: #201d1b;
  --card-hi: #272321;
  --line: #332e2b;
  --text: #f3ede6;
  --muted: #9a908780;
  --muted-solid: #9a9087;
  --accent: #ff9130;
  --accent-soft: #ff913022;
  --on: #ffcf6b;
  --cool: #6bb5ff;
  --good: #57d9a3;
  --bad: #ff6b6b;
  --radius: 20px;
  --shadow: 0 12px 40px -18px #000000cc;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 80% -10%, #ff913015, transparent 60%),
    radial-gradient(900px 500px at -10% 10%, #6bb5ff0f, transparent 55%),
    var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 380px at 12% 16%, #ff913026, transparent 62%),
    radial-gradient(620px 400px at 88% 10%, #6bb5ff20, transparent 62%),
    radial-gradient(600px 420px at 74% 92%, #57d9a31c, transparent 62%),
    radial-gradient(520px 360px at 22% 88%, #b06bff1a, transparent 62%);
  animation: aurora 18s ease-in-out infinite alternate;
}

@keyframes aurora {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.75;
  }
  100% {
    transform: translate3d(0, -18px, 0) scale(1.06);
    opacity: 1;
  }
}

main,
.energy,
.topbar,
.controls {
  position: relative;
  z-index: 1;
}

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  padding-top: calc(18px + env(safe-area-inset-top));
  background: #12100fcc;
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: conic-gradient(from 140deg, var(--accent), var(--on), var(--cool), var(--accent));
  animation: markPulse 3.5s ease-in-out infinite, spin 12s linear infinite;
}

@keyframes markPulse {
  0%,
  100% {
    box-shadow: 0 0 18px -4px var(--accent);
  }
  50% {
    box-shadow: 0 0 30px 0 var(--accent), 0 0 12px 0 var(--cool);
  }
}

.brand h1 {
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 0;
  background: linear-gradient(100deg, var(--accent), var(--on) 45%, var(--cool));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradientShift 7s ease-in-out infinite;
}

@keyframes gradientShift {
  0%,
  100% {
    background-position: 0% center;
  }
  50% {
    background-position: 100% center;
  }
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 3px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--muted-solid);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 30px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--on));
  color: #1a1207;
  box-shadow: 0 0 16px -2px var(--accent);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted-solid);
  font-weight: 500;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-hi, #ffffff0d);
  color: var(--muted-solid);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.refresh-btn:hover {
  color: var(--text);
  border-color: var(--on, #ff9130);
}
.refresh-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.refresh-btn.spinning svg {
  animation: spin 0.6s linear infinite;
}

.status .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted-solid);
  box-shadow: 0 0 0 0 transparent;
}

.status[data-state="connected"] {
  color: var(--good);
}
.status[data-state="connected"] .dot {
  background: var(--good);
  animation: ringPulse 2.2s ease-out infinite;
}

@keyframes ringPulse {
  0% {
    box-shadow: 0 0 0 0 #57d9a366, 0 0 10px 1px var(--good);
  }
  70% {
    box-shadow: 0 0 0 8px #57d9a300, 0 0 10px 1px var(--good);
  }
  100% {
    box-shadow: 0 0 0 0 #57d9a300, 0 0 10px 1px var(--good);
  }
}
.status[data-state="error"] {
  color: var(--bad);
}
.status[data-state="error"] .dot {
  background: var(--bad);
}
.status[data-state="connecting"] .dot {
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* ---- Controls bar ---- */
.controls {
  position: sticky;
  top: 61px;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: #12100fd8;
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.controls[hidden] {
  display: none;
}

.search {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--muted-solid);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.search input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px 10px 36px;
  outline: none;
  transition: border-color 0.15s;
}

.search input:focus {
  border-color: #ff913066;
}

.search input::placeholder {
  color: var(--muted-solid);
}

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted-solid);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  color: var(--text);
}

.chip.active {
  background: linear-gradient(135deg, var(--accent), var(--on));
  border-color: var(--accent);
  color: #1a1207;
  box-shadow: 0 0 14px -3px var(--accent);
}

.diag-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted-solid);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.diag-toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

/* ---- Main ---- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}

.room {
  margin-bottom: 34px;
}

.room-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 4px 14px;
  cursor: pointer;
  user-select: none;
}

.room-head .chevron {
  width: 16px;
  height: 16px;
  stroke: var(--muted-solid);
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}

.room.collapsed .chevron {
  transform: rotate(-90deg);
}

.room.collapsed .grid {
  display: none;
}

.room-head h2 {
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.01em;
  margin: 0;
}

.room-head .count {
  font-size: 13px;
  color: var(--muted-solid);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

/* ---- Card ---- */
.card {
  position: relative;
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 116px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.2s, transform 0.12s, box-shadow 0.2s;
}

.card.active {
  border-color: #ff913055;
  box-shadow: 0 0 0 1px #ff913022, 0 18px 40px -24px var(--accent);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #ffffff08;
  border: 1px solid var(--line);
  flex-shrink: 0;
  line-height: 1;
  color: var(--muted-solid);
}

.card-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card.active .card-icon {
  background: var(--accent-soft);
  border-color: #ff913044;
  color: var(--on);
}

.fav-star {
  flex-shrink: 0;
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s, transform 0.1s;
}
.fav-star.on {
  color: var(--on);
  text-shadow: 0 0 10px var(--on);
}
.fav-star:hover {
  color: var(--on);
  transform: scale(1.18);
}
/* A favourite's star is a static indicator (removal lives inside edit) */
.fav-star.static {
  cursor: default;
}
.fav-star.static:hover {
  transform: none;
}
.fav-remove {
  flex-shrink: 0;
  align-self: flex-start;
  background: none;
  border: 1px solid var(--bad, #ff6b6b);
  color: var(--bad, #ff6b6b);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
}
.fav-remove:hover {
  background: var(--bad, #ff6b6b);
  color: #2a0606;
}
/* Whole toggle-card is tappable on mobile */
.card.tappable {
  cursor: pointer;
}

.fav-rename {
  flex-shrink: 0;
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s;
}
.fav-rename:hover {
  color: var(--accent);
}
.fav-rename-input {
  width: 100%;
  background: var(--bg-raise);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 5px 8px;
  outline: none;
}

.room-head.static {
  cursor: default;
}
.fav-hd {
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--on);
}

.card-name {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-value {
  font-size: 13px;
  color: var(--muted-solid);
  font-weight: 500;
}

.card-value .big {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 26px;
  color: var(--text);
  font-weight: 500;
}

.card-value .unit {
  font-size: 14px;
  color: var(--muted-solid);
  margin-left: 2px;
}

/* Toggle */
.toggle {
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: #00000030;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
  padding: 0;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--muted-solid);
  transition: transform 0.2s, background 0.2s;
}

.toggle[aria-checked="true"] {
  background: linear-gradient(135deg, var(--accent), var(--on));
  border-color: var(--accent);
  box-shadow: 0 0 14px -2px var(--accent);
}

.toggle[aria-checked="true"]::after {
  transform: translateX(20px);
  background: #fff;
}

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--on));
  background-size: var(--fill, 50%) 100%;
  background-repeat: no-repeat;
  background-color: #00000040;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 8px #0008;
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: #fff;
}

/* Buttons for scenes / covers / locks */
.btn-row {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  border: 1px solid var(--line);
  background: #ffffff08;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--accent-soft);
  border-color: #ff913055;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1207;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stepper button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff08;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.stepper button:active {
  background: var(--accent-soft);
}

/* ---- Empty / states ---- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 90px 20px;
  color: var(--muted-solid);
  text-align: center;
}

.empty h2 {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  margin: 0;
}

.empty code {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--on);
  font-size: 13px;
}

.empty .steps {
  max-width: 440px;
  text-align: left;
  line-height: 1.7;
  font-size: 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

/* ---- Energy view ---- */
.energy {
  max-width: 1000px;
  margin: 0 auto;
  padding: 26px 20px 70px;
}

/* EV charging cost — recent sessions list */
.ev-sessions {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
}
.ev-sess {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.ev-sess:last-child { border-bottom: 0; }
.ev-sess-when {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ev-sess-split { font-size: 11px; color: var(--muted); }
.ev-sess-kwh { color: var(--muted); min-width: 74px; text-align: right; }
.ev-sess-price { color: var(--muted); min-width: 92px; text-align: right; }
.ev-sess-cost { color: #ff9a3d; font-weight: 600; min-width: 88px; text-align: right; }

/* Faint dollar-sign watermark behind the Økonomi page */
#economy {
  position: relative;
}
#economy::before {
  content: "$";
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
  font-size: min(80vh, 60vw);
  font-weight: 700;
  line-height: 1;
  color: var(--good);
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
  text-shadow: 0 0 60px currentColor;
}
#economy > * {
  position: relative;
  z-index: 1;
}

.energy-hero {
  background:
    radial-gradient(120% 90% at 50% 0%, #ff91300f, transparent 60%),
    linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 26px 20px 30px;
  margin-bottom: 22px;
  box-shadow: 0 24px 60px -40px var(--accent), inset 0 1px 0 #ffffff08;
}

.flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  margin: 4px auto 0;
}

.flow-mid {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.flow-node {
  width: 122px;
  min-height: 96px;
  flex-shrink: 0;
  padding: 12px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  z-index: 2;
}

.flow-node .n-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 2px;
}

.flow-node .n-label {
  font-size: 11.5px;
  color: var(--muted-solid);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.flow-node .n-value {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.05;
}

.flow-node .n-value .u {
  font-size: 12px;
  color: var(--muted-solid);
  margin-left: 2px;
  font-family: "Inter", sans-serif;
}

.flow-node .n-sub {
  font-size: 11.5px;
  color: var(--muted-solid);
  font-weight: 500;
}

.n-solar .n-icon {
  stroke: var(--on);
}
.n-home {
  background: var(--card-hi);
}
.n-home .n-icon {
  stroke: var(--text);
}
.n-batt .n-icon {
  stroke: var(--good);
}
.n-grid .n-icon {
  stroke: var(--cool);
}

/* connectors */
.flow-vline,
.flow-hline {
  position: relative;
  background: var(--line);
  border-radius: 3px;
}
.flow-vline {
  width: 3px;
  height: 42px;
}
.flow-hline {
  flex: 1;
  max-width: 90px;
  height: 3px;
}
.flow-vline.idle,
.flow-hline.idle {
  opacity: 0.45;
}
.flow-vline.solar {
  background: color-mix(in srgb, var(--on) 50%, transparent);
}
.flow-hline.batt {
  background: color-mix(in srgb, var(--good) 50%, transparent);
}
.flow-hline.grid {
  background: color-mix(in srgb, var(--cool) 50%, transparent);
}

.flow-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 8px 1px currentColor;
}
.flow-vline .flow-dot {
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--on);
  background: var(--on);
  animation: flowV 1.4s linear infinite;
}
.flow-hline .flow-dot {
  top: 50%;
  transform: translate(-50%, -50%);
  animation: flowH 1.4s linear infinite;
}
.flow-hline.batt .flow-dot {
  color: var(--good);
  background: var(--good);
}
.flow-hline.grid .flow-dot {
  color: var(--cool);
  background: var(--cool);
}
.flow-dot.rev {
  animation-direction: reverse;
}

@keyframes flowV {
  from {
    top: 0;
  }
  to {
    top: 100%;
  }
}
@keyframes flowH {
  from {
    left: 0;
  }
  to {
    left: 100%;
  }
}

/* SOC bar inside battery node */
.soc-bar {
  width: 74px;
  height: 5px;
  border-radius: 4px;
  background: #00000040;
  overflow: hidden;
  margin-top: 3px;
}
.soc-bar > i {
  display: block;
  height: 100%;
  background: var(--good);
  border-radius: 4px;
}

/* stat tiles */
.section-title {
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 600;
  font-size: 18px;
  margin: 4px 4px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 3px;
  background: linear-gradient(var(--accent), var(--on));
  box-shadow: 0 0 10px -1px var(--accent);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.tile {
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
}
.tile:hover {
  transform: translateY(-2px);
  border-color: #ffffff1f;
  box-shadow: 0 14px 32px -20px #000, 0 0 0 1px #ffffff08;
}
.tile .t-label {
  font-size: 12px;
  color: var(--muted-solid);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tile .t-label .swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.tile .t-value {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 26px;
  font-weight: 700;
  margin-top: 8px;
  text-shadow: 0 0 22px color-mix(in srgb, currentColor 45%, transparent);
}
.tile .t-value .u {
  font-size: 13px;
  color: var(--muted-solid);
  margin-left: 3px;
  font-family: "Inter", sans-serif;
}

/* Graphic energy scene (house + flow) */
.escene {
  padding: 14px 16px 8px;
}
.scene-svg {
  width: 100%;
  max-width: 600px;
  height: auto;
  display: block;
  margin: 0 auto;
}
.scene-val {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  fill: var(--text);
}
.scene-lbl {
  font-size: 9.5px;
  fill: var(--muted-solid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.escene .flow-base {
  fill: none;
  stroke: var(--line);
  stroke-width: 3;
  opacity: 0.5;
}
.escene .flow-path {
  fill: none;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-dasharray: 1.5 9;
  animation: flowdash 1s linear infinite;
}
@keyframes flowdash {
  to {
    stroke-dashoffset: -10.5;
  }
}
.escene .flow-path.rev {
  animation-direction: reverse;
}
.escene .flow-path.idle {
  animation: none;
  opacity: 0.18;
}
.escene .fp-sun {
  stroke: var(--on);
}
.escene .fp-bat {
  stroke: var(--good);
}
.escene .fp-grid {
  stroke: var(--cool);
}
.escene .fp-ev {
  stroke: var(--good);
}
.escene .tesla {
  transition: opacity 0.4s;
}
.escene .tesla.charging {
  filter: drop-shadow(0 0 5px var(--good));
}
.escene .sun {
  opacity: 0.45;
  transition: opacity 0.4s;
}
.escene .sun.lit {
  opacity: 1;
}
.escene .sun.lit circle {
  filter: drop-shadow(0 0 6px var(--on));
}

/* Illustrated farmhouse scene */
.scene-illus {
  position: relative;
  padding: 0;
  overflow: hidden;
  background: none;
  border: 1px solid var(--line);
  box-shadow: 0 26px 70px -46px #000;
}
.scene-bg {
  display: block;
  width: 100%;
  height: auto;
}
.scene-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.wire-base {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: miter;
  opacity: 0.6;
}
.wire-flow {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: miter;
  stroke-dasharray: 4 16;
  animation: wiretravel 1s linear infinite;
}
.wire-flow.rev {
  animation-direction: reverse;
}
@keyframes wiretravel {
  to {
    stroke-dashoffset: -20;
  }
}
.batt-badge-t {
  font-size: 20px;
  font-weight: 800;
}
.scene-illus .clouds {
  animation: cloudDrift 40s ease-in-out infinite alternate;
}
@keyframes cloudDrift {
  to {
    transform: translateX(30px);
  }
}
.scene-illus .sun {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0.9;
}
.scene-illus .sun.lit {
  opacity: 1;
}
.scene-illus .sun.lit circle {
  filter: drop-shadow(0 0 14px #ffce46);
}
.scene-illus .rays {
  transform-box: fill-box;
  transform-origin: 150px 96px;
  animation: spin 60s linear infinite;
}
.scene-wire {
  fill: none;
  stroke: #ffd23f;
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.22;
}
.scene-wire.on {
  opacity: 1;
  stroke-dasharray: 2 11;
  filter: drop-shadow(0 0 4px #ffd23f);
  animation: wireflow 1s linear infinite;
}
@keyframes wireflow {
  to {
    stroke-dashoffset: -13;
  }
}
.scene-badge {
  font-size: 22px;
  font-weight: 800;
}
.scene-info {
  font-size: 16px;
  font-weight: 700;
}
.tesla {
  transition: opacity 0.4s;
}
.tesla.charging {
  filter: drop-shadow(0 0 6px #3ecf8e);
}

/* Status pills */
.scene-pills {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 70%;
  z-index: 2;
}
.spill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffffe8;
  color: #1a2230;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  box-shadow: 0 6px 16px -8px #0009;
}
.spill b {
  font-weight: 400;
  font-size: 14px;
}
.spill-active {
  background: #3ecf8e;
  color: #08301f;
}
.spill-warn {
  background: #ffb454;
  color: #3a2405;
}
.spill-idle {
  background: #ffffffcc;
  color: #55606e;
}
.spill-sell {
  background: #3ecf8e;
  color: #08301f;
}
.spill-buy {
  background: #ff6b6b;
  color: #3a0808;
}

/* 24-panel wall */
.panel-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}
.panel {
  position: relative;
  aspect-ratio: 1 / 1.5;
  border-radius: 6px;
  border: 1px solid #0b1a2b;
  overflow: hidden;
  background-color: #14273e;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 32%, #00000038 32% 34%),
    repeating-linear-gradient(90deg, transparent 0 46%, #00000038 46% 48%);
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 34%, var(--on), transparent 70%);
  opacity: var(--lit, 0);
}
.panel.bad {
  border-color: var(--bad);
  box-shadow: inset 0 0 0 1px var(--bad);
}
.panel.bad .panel-w {
  color: var(--bad);
}
.panel-id {
  position: absolute;
  top: 3px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 8.5px;
  color: #cfe0ffaa;
  text-shadow: 0 1px 2px #000;
}
.panel-w {
  position: absolute;
  bottom: 3px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px #000;
}
.panel-w span {
  font-size: 8.5px;
  opacity: 0.8;
  margin-left: 1px;
}

.energy-note {
  font-size: 13px;
  color: var(--muted-solid);
  line-height: 1.6;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 8px;
}

@media (max-width: 560px) {
  .flow-node {
    width: 96px;
    min-height: 84px;
  }
  .flow-node .n-value {
    font-size: 19px;
  }
}

/* ---- Plan view: price chart ---- */
.pchart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
}
.pday {
  width: 2px;
  align-self: stretch;
  background: repeating-linear-gradient(var(--line) 0 4px, transparent 4px 8px);
  margin: 0 4px;
  flex-shrink: 0;
}
.pcol {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 15px;
  flex: 1;
}
.pbar {
  width: 100%;
  max-width: 22px;
  border-radius: 3px 3px 0 0;
  transition: opacity 0.2s, filter 0.15s, transform 0.1s;
  position: relative;
  cursor: pointer;
}
.pbar:hover {
  filter: brightness(1.15);
}
.pbar.past {
  opacity: 0.32;
}
.pbar.now {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}
.pbar.sel {
  outline: 2px solid #fff;
  outline-offset: 1px;
  filter: brightness(1.25) drop-shadow(0 0 6px currentColor);
  opacity: 1;
}

/* Tap-a-bar price readout above the chart */
.pread {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-height: 26px;
  margin-bottom: 12px;
  font-size: 13px;
}
.pread-hint { color: var(--muted-solid); font-style: italic; }
.pread-when { color: var(--text); font-weight: 600; }
.pread-val {
  color: var(--on);
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.pread-val::after { content: " kr/kWh"; font-size: 12px; font-weight: 500; color: var(--muted-solid); }
.pread-unit { color: var(--muted-solid); }
.ptick {
  font-size: 10px;
  color: var(--muted-solid);
  margin-top: 4px;
  height: 12px;
}
.plegend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted-solid);
}
.plegend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}

/* recommendation cards */
.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.rec-card {
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  padding: 15px 16px;
}
.rec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
}
.rec-badge {
  font-size: 11.5px;
  color: var(--muted-solid);
  background: #ffffff08;
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}
.rec-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.pchips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.pchip {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--line);
}
.pchip.good {
  color: var(--good);
  border-color: #57d9a355;
}
.pchip.bad {
  color: var(--bad);
  border-color: #ff6b6b55;
}

/* Deye time-of-use table */
.tou-wrap {
  overflow-x: auto;
}
.tou-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tou-table th {
  text-align: left;
  color: var(--muted-solid);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 10px 8px;
}
.tou-table td {
  padding: 5px 10px;
  border-top: 1px solid var(--line);
}
.tou-table input[type="time"],
.tou-table input[type="number"] {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  width: 92px;
  outline: none;
}
.tou-table input:focus {
  border-color: #ff913066;
}
.tou-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.tou-pow {
  color: var(--muted-solid);
}

.auto-subtoggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}

/* Battery SOC history chart */
.batt-chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart-lbl {
  fill: var(--muted-solid);
  font-size: 11px;
}
.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted-solid);
}
.chart-legend i {
  display: inline-block;
  width: 12px;
  height: 4px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: 2px;
}
.chart-toggle {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
}
.chart-toggle .ptg {
  padding: 4px 12px;
  font-size: 12px;
}
.hp-now {
  margin-left: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-solid);
  white-space: nowrap;
}
.hp-now.on {
  color: #ff7e6b;
}

/* Energi shortcut pills (Autopilot / Oplad elbil nu) */
.energy-ctl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.ap-pill {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted-solid);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.15s;
}
.ap-pill:hover {
  color: var(--text);
  border-color: #ffffff22;
}
.ap-pill.on {
  background: linear-gradient(135deg, var(--accent), var(--on));
  border-color: var(--accent);
  color: #1a1207;
  box-shadow: 0 0 16px -3px var(--accent);
}
.ap-pill.ev-now.on {
  background: linear-gradient(135deg, var(--good), #7cf0b5);
  border-color: var(--good);
  color: #08301f;
  box-shadow: 0 0 16px -3px var(--good);
}
.ap-pill.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.ap-pill .pill-sub {
  font-weight: 500;
  opacity: 0.8;
}

/* Autopilot master card */
.autopilot-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #ff91301a, var(--card));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: box-shadow 0.25s, border-color 0.25s;
}
.autopilot-card.on {
  border-color: #ff913066;
  box-shadow: 0 0 26px -6px var(--accent), inset 0 0 0 1px #ff913022;
}
.ap-left {
  flex: 1;
}
.ap-title {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ap-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #08301f;
  background: var(--good);
  padding: 2px 9px;
  border-radius: 20px;
}
.ap-desc {
  font-size: 13px;
  color: var(--muted-solid);
  line-height: 1.55;
  margin-top: 5px;
}
.toggle-lg {
  width: 62px;
  height: 36px;
  border-radius: 36px;
  flex-shrink: 0;
}
.toggle-lg::after {
  width: 28px;
  height: 28px;
  top: 3px;
  left: 3px;
}
.toggle-lg[aria-checked="true"]::after {
  transform: translateX(26px);
}
.rec-grid.ap-managed {
  opacity: 0.55;
  pointer-events: none;
}

/* auto-control log */
.auto-log {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text);
}
.auto-log div {
  display: flex;
  gap: 8px;
}
.auto-log span {
  color: var(--muted-solid);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.auto-log-empty {
  font-size: 13px;
  color: var(--muted-solid);
  margin: 2px 4px 24px;
}

/* settings form */
.settings {
  margin-top: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.settings > summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
}
.settings > summary::-webkit-details-marker {
  display: none;
}
.set-body {
  padding: 4px 16px 18px;
  border-top: 1px solid var(--line);
}
.set-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-solid);
  margin: 16px 0 8px;
  font-weight: 600;
}
.set-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}
.set-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted-solid);
  flex: 1;
  min-width: 110px;
}
.set-row input,
.set-row select {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
}
.set-row input:focus,
.set-row select:focus {
  border-color: #ff913066;
}
.set-chk {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  color: var(--text) !important;
  font-size: 13px;
  min-width: 150px;
}
.set-chk input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
.set-hint {
  color: var(--muted-solid);
  font-size: 10.5px;
}

/* Spot / Total price toggle */
.price-toggle {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-bottom: 12px;
}
.ptg {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted-solid);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}
.ptg.active {
  background: linear-gradient(135deg, var(--accent), var(--on));
  border-color: var(--accent);
  color: #1a1207;
}

/* ---- Økonomi ---- */
.econ-rescan-btn {
  flex: none;
  margin-left: auto;
  max-width: 160px;
  padding: 6px 14px;
  font-size: 13px;
}
.econ-scope {
  margin-left: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  outline: none;
}
.econ-scope:focus {
  border-color: #ff913066;
}
.econ-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.econ-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.econ-bar-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.econ-bar-label {
  color: var(--muted-solid);
  text-transform: capitalize;
}
.econ-bar-row.clickable {
  cursor: pointer;
  border-radius: 8px;
  padding: 3px 6px;
  margin: 0 -6px;
  transition: background 0.12s;
}
.econ-bar-row.clickable:hover {
  background: #ffffff0a;
}
.econ-bar-row.open .econ-bar-label {
  color: var(--text);
  font-weight: 600;
}
.econ-bar-detail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 12px 8px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}
.econ-detail-rec {
  display: grid;
  grid-template-columns: 56px 1fr auto auto auto auto;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.econ-detail-period {
  color: var(--muted-solid);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 680px) {
  .econ-detail-rec {
    grid-template-columns: auto 1fr auto;
    row-gap: 3px;
  }
  .econ-detail-period {
    grid-column: 2 / 4;
  }
}
.econ-bar-track {
  height: 12px;
  background: #00000038;
  border-radius: 6px;
  overflow: hidden;
}
.econ-bar-track > i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--on));
}
.econ-bar-val {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.econ-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.econ-rec {
  display: grid;
  grid-template-columns: 56px 1fr auto auto auto auto auto auto;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.econ-rec.warn {
  border-color: #ffb45455;
}
.econ-rec.warn .econ-rec-period {
  color: #ffb454;
}
.econ-rec-kind {
  font-weight: 700;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 20px;
  text-align: center;
}
.econ-rec-kind.buy {
  color: var(--bad);
  border: 1px solid #ff6b6b55;
}
.econ-rec-kind.sell {
  color: var(--good);
  border: 1px solid #57d9a355;
}
.econ-rec-period {
  color: var(--muted-solid);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.econ-rec-fig {
  color: var(--text);
  font-weight: 500;
}
.econ-rec-pdf {
  color: var(--cool);
  text-decoration: none;
  font-weight: 600;
}
.econ-rec-del,
.econ-rec-edit {
  background: none;
  border: none;
  color: var(--muted-solid);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 4px;
}
.econ-rec-del:hover {
  color: var(--bad);
}
.econ-rec-edit:hover {
  color: var(--accent);
}

/* inline edit row */
.econ-rec.editing {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.econ-rec.editing select,
.econ-rec.editing input {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 9px;
  outline: none;
}
.econ-rec.editing input:focus,
.econ-rec.editing select:focus {
  border-color: #ff913066;
}
.econ-rec.editing input[type="date"] {
  width: 140px;
}
.econ-rec.editing input[type="number"] {
  width: 92px;
}
.econ-rec.editing input[type="text"] {
  flex: 1;
  min-width: 90px;
}
.econ-rec.editing .btn {
  max-width: 92px;
  padding: 7px 12px;
}
@media (max-width: 680px) {
  .econ-rec {
    grid-template-columns: auto 1fr auto;
    grid-auto-rows: auto;
    row-gap: 4px;
  }
  .econ-rec-period {
    grid-column: 2 / 4;
  }
}

/* ---- Mobile ---- */
@media (max-width: 680px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
  }
  .brand {
    gap: 9px;
  }
  .brand h1 {
    font-size: 18px;
  }
  .status {
    order: 2;
    font-size: 12px;
  }
  .tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .tab {
    flex: 1;
    text-align: center;
  }
  .controls {
    position: static;
    padding: 10px 12px;
  }
  .topbar {
    position: static;
  }

  main {
    padding: 16px 12px 50px;
  }
  .energy {
    padding: 14px 12px 50px;
  }

  /* Big, full-bleed hero illustration */
  .scene-illus {
    margin: 0 -12px 16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    aspect-ratio: 3 / 2;
  }
  .scene-bg {
    height: 100%;
    object-fit: cover;
    object-position: center;
  }
  .scene-pills {
    top: 10px;
    right: 10px;
    gap: 6px;
    max-width: 82%;
  }
  .spill {
    font-size: 12px;
    padding: 5px 10px;
  }

  .section-title {
    font-size: 17px;
  }
  .tiles {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: var(--bad);
  color: #ffd7d7;
}

/* --- Tesla control view --------------------------------------------------- */
.tesla-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #1a1a1c 0%, #0a0a0b 70%, #000 100%);
  border: 1px solid var(--line);
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.tesla-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: filter 0.4s, opacity 0.4s;
}
.tesla-img.sleeping { filter: grayscale(0.5) brightness(0.6); opacity: 0.75; }
.tesla-overlay {
  position: absolute;
  inset: 0;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.tesla-soc { max-width: 240px; }
.tesla-soc-num { font-family: "Fraunces", serif; font-size: 44px; font-weight: 600; line-height: 1; }
.tesla-soc-bar {
  margin-top: 8px; height: 8px; border-radius: 5px;
  background: #ffffff1f; overflow: hidden; max-width: 200px;
}
.tesla-soc-bar i { display: block; height: 100%; border-radius: 5px; transition: width 0.5s; }
.tesla-range { margin-top: 8px; color: #d8d2cb; font-size: 14px; font-weight: 600; }
.tesla-pills { position: static; justify-content: flex-start; flex-wrap: wrap; }

.tesla-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.tbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.tbtn:hover { background: var(--card-hi); }
.tbtn:active { transform: scale(0.96); }
.tbtn-ic {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: #ffffff0d; color: var(--text);
}
.tbtn-svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tbtn.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tbtn.active .tbtn-ic { background: var(--accent-soft); color: var(--accent); }
.tbtn.danger.armed, .tbtn.armed { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad) inset; }
.tbtn.armed .tbtn-ic { background: #ff6b6b22; color: var(--bad); }
.tbtn-lb { text-align: center; line-height: 1.2; }

.tesla-charge-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 14px;
}
.tesla-charge-row .tbtn { flex-direction: row; padding: 12px 18px; }
.tesla-charge-row .tbtn-ic { width: 32px; height: 32px; }
.tesla-limit { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted-solid); flex: 1; min-width: 180px; }
.tesla-limit b { color: var(--text); }
.tesla-limit input[type="range"] { width: 100%; accent-color: var(--good); }
