/* ==========================================================================
   PV Plant Monitor — design system
   Strict CSP: no inline styles anywhere; everything lives in this file.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---- Tokens: light ------------------------------------------------------ */
:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --glow: rgba(255, 170, 30, 0.16);
  --surface: #ffffff;
  --surface-2: #f6f5f1;
  --surface-3: #eeece6;
  --line: rgba(20, 22, 26, 0.08);
  --line-strong: rgba(20, 22, 26, 0.14);

  --ink: #14161a;
  --ink-2: #4f5663;
  --ink-3: #868d98;

  --sun-a: #ffbe2e;
  --sun-b: #f57c00;
  --accent: #e98500;
  --accent-ink: #8f4a00;
  --on-accent: #1d1300;

  --ok: #12a26a;
  --warn: #d48300;
  --bad: #dc3f38;
  --info: #3577e6;
  --idle: #8b919b;

  --chart-line: #ef8a00;
  --chart-fill-top: rgba(255, 166, 20, 0.30);
  --chart-fill-bottom: rgba(255, 166, 20, 0.00);
  --chart-bar: rgba(239, 138, 0, 0.38);
  --chart-bar-strong: #ef8a00;
  --chart-grid: rgba(20, 22, 26, 0.06);
  --chart-text: #868d98;
  --tooltip-bg: #14161a;
  --tooltip-ink: #ffffff;

  --shadow-sm: 0 1px 2px rgba(16, 20, 28, 0.04);
  --shadow: 0 1px 2px rgba(16, 20, 28, 0.04), 0 10px 30px -14px rgba(16, 20, 28, 0.16);
  --radius: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --gutter: 16px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---- Tokens: dark ------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0a0d12;
    --glow: rgba(255, 160, 20, 0.10);
    --surface: #12161e;
    --surface-2: #171c25;
    --surface-3: #1f2530;
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.13);

    --ink: #f3f5f8;
    --ink-2: #a7afbc;
    --ink-3: #6e7682;

    --accent: #ffad1f;
    --accent-ink: #ffcd73;

    --ok: #34d399;
    --warn: #fbbf24;
    --bad: #f87171;
    --info: #6ea8ff;
    --idle: #79818d;

    --chart-line: #ffb020;
    --chart-fill-top: rgba(255, 176, 32, 0.28);
    --chart-fill-bottom: rgba(255, 176, 32, 0.00);
    --chart-bar: rgba(255, 176, 32, 0.46);
    --chart-bar-strong: #ffb020;
    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-text: #6e7682;
    --tooltip-bg: #f3f5f8;
    --tooltip-ink: #12161e;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -20px rgba(0, 0, 0, 0.7);
  }
}

@media (min-width: 720px) {
  :root { --gutter: 28px; }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 50% -260px, var(--glow), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
  border-radius: 10px;
}

/* ---- Top bar -------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--sun-a), var(--sun-b));
  box-shadow: 0 6px 18px -8px rgba(245, 124, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.brand-text { min-width: 0; }
.brand-name { font-weight: 680; font-size: 17px; letter-spacing: -0.02em; line-height: 1.2; }
.brand-sub {
  color: var(--ink-3);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
  white-space: nowrap;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--idle);
  position: relative;
}
.live-chip[data-state="live"] .live-dot { background: var(--ok); }
.live-chip[data-state="live"] .live-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--ok);
  opacity: 0.35;
  animation: pulse 2.4s ease-out infinite;
}
.live-chip[data-state="stale"] { color: var(--warn); }
.live-chip[data-state="stale"] .live-dot { background: var(--warn); }
.live-chip[data-state="error"] .live-dot { background: var(--bad); }

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.45; }
  80%, 100% { transform: scale(1.9); opacity: 0; }
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }

/* ---- Layout --------------------------------------------------------------- */
.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px var(--gutter) 8px;
  display: grid;
  gap: 16px;
}
@media (min-width: 720px) { .container { gap: 20px; padding-top: 28px; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 2px 12px;
}
.section-head h2, .panel-head h2 { font-size: 18px; }
.section-meta { color: var(--ink-3); font-size: 13.5px; }

/* ---- Banner --------------------------------------------------------------- */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--ink);
  font-size: 14px;
}
.banner svg { flex: none; color: var(--warn); margin-top: 2px; }

/* ---- Hero ----------------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 22px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--sun-a) 7%, var(--surface)) 0%, var(--surface) 55%);
}
@media (min-width: 720px) { .hero { padding: 34px 36px; } }

.hero-glow {
  position: absolute;
  width: 360px;
  height: 360px;
  right: -120px;
  top: -170px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--sun-a) 30%, transparent), transparent 65%);
  pointer-events: none;
}
.hero-main { position: relative; min-width: 0; }

.eyebrow {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.hero-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 6px 0 8px;
  font-size: clamp(48px, 13vw, 76px);
  font-weight: 680;
  letter-spacing: -0.045em;
  line-height: 1;
}
.hero-unit {
  font-size: 0.34em;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-3);
}
.hero-caption { color: var(--ink-2); font-size: 15px; max-width: 46ch; }

.gauge { position: relative; flex: none; width: 124px; height: 124px; }
.gauge svg { width: 100%; height: 100%; }
@media (min-width: 720px) { .gauge { width: 168px; height: 168px; } }

.gauge-track, .gauge-value {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}
.gauge-track { stroke: var(--surface-3); }
.gauge-value {
  stroke: url(#gauge-grad);
  transition: stroke-dasharray 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.gauge-stop-a { stop-color: var(--sun-a); }
.gauge-stop-b { stop-color: var(--sun-b); }

.gauge-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding-top: 4px;
}
.gauge-pct { font-size: 26px; font-weight: 680; letter-spacing: -0.03em; line-height: 1.1; }
@media (min-width: 720px) { .gauge-pct { font-size: 32px; } }
.gauge-label { font-size: 11.5px; color: var(--ink-3); font-weight: 550; }

/* ---- KPI tiles ------------------------------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; } }

.kpi { padding: 16px 16px 14px; border-radius: var(--radius-md); }
@media (min-width: 720px) { .kpi { padding: 20px 22px 18px; } }
.kpi-label { font-size: 13px; color: var(--ink-3); font-weight: 560; }
.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 6px;
  font-size: clamp(24px, 6.4vw, 30px);
  font-weight: 670;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.kpi-unit { font-size: 0.5em; font-weight: 600; color: var(--ink-3); letter-spacing: 0; }
.kpi-sub { margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }

/* ---- Panels (charts) ------------------------------------------------------ */
.panel { padding: 20px 18px 16px; }
@media (min-width: 720px) { .panel { padding: 26px 28px 22px; } }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 14px;
}
.panel-sub { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }

.chart-box { position: relative; height: 230px; }
@media (min-width: 720px) { .chart-box { height: 300px; } }

.trend-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Select ---------------------------------------------------------------- */
.select { position: relative; display: inline-flex; align-items: center; }
.select select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
  padding: 0 40px 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 560;
  cursor: pointer;
}
.select svg { position: absolute; right: 14px; pointer-events: none; color: var(--ink-3); }

/* ---- Segmented control ---------------------------------------------------- */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  max-width: 100%;
}
.seg-scroll { overflow-x: auto; scrollbar-width: none; }
.seg-scroll::-webkit-scrollbar { display: none; }
.seg button {
  flex: none;
  min-height: 38px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--line);
}
.seg button:disabled { opacity: 0.38; cursor: not-allowed; }

/* ---- Inverter cards ------------------------------------------------------- */
.inv-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 680px) { .inv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1000px) { .inv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.inv { padding: 18px 18px 6px; transition: opacity 0.3s; }
@media (min-width: 720px) { .inv { padding: 22px 22px 8px; } }
.inv.is-offline .inv-power,
.inv.is-offline .inv-stats { opacity: 0.45; }

.inv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.inv-name { font-size: 16.5px; }
.inv-model { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }

.badge {
  --c: var(--idle);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  color: color-mix(in srgb, var(--c) 85%, var(--ink));
  background: color-mix(in srgb, var(--c) 13%, transparent);
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.badge[data-tone="ok"] { --c: var(--ok); }
.badge[data-tone="warn"] { --c: var(--warn); }
.badge[data-tone="bad"] { --c: var(--bad); }
.badge[data-tone="info"] { --c: var(--info); }
.badge[data-tone="idle"] { --c: var(--idle); }

.inv-power {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin: 16px 0 10px;
  font-size: 36px;
  font-weight: 680;
  letter-spacing: -0.04em;
  line-height: 1;
}
.inv-unit { font-size: 15px; font-weight: 600; color: var(--ink-3); letter-spacing: 0; }

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.meter-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sun-a), var(--sun-b));
  transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.inv-meter-cap { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); }

.inv-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 16px 0 14px;
}
.inv-stats dt, .detail-list dt { font-size: 12.5px; color: var(--ink-3); }
.inv-stats dd { margin: 2px 0 0; font-size: 16px; font-weight: 620; letter-spacing: -0.01em; }

.inv-alarm {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--ink);
  background: color-mix(in srgb, var(--bad) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
}

.inv-more { border-top: 1px solid var(--line); margin: 0 -2px; }
.inv-more summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 2px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 560;
  color: var(--ink-2);
}
.inv-more summary::-webkit-details-marker { display: none; }
.inv-more summary svg { transition: transform 0.2s; color: var(--ink-3); }
.inv-more[open] summary svg { transform: rotate(180deg); }

.phase-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 2px 0 14px;
}
.phase-table th, .phase-table td { padding: 7px 4px; text-align: right; }
.phase-table thead th { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.phase-table tbody th { text-align: left; font-weight: 500; color: var(--ink-3); }
.phase-table tbody tr + tr td, .phase-table tbody tr + tr th { border-top: 1px solid var(--line); }
.phase-table td { font-weight: 580; }

.detail-list { margin: 0 0 14px; }
.detail-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px;
  border-top: 1px solid var(--line);
}
.detail-list dd { margin: 0; font-size: 14px; font-weight: 580; text-align: right; }

/* ---- Footer --------------------------------------------------------------- */
.foot {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px var(--gutter) calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 12.5px;
}

/* ---- Loading state -------------------------------------------------------- */
.is-loading .hero-value,
.is-loading .kpi-value { opacity: 0.35; }
.hero-value, .kpi-value { transition: opacity 0.4s; }

/* ==========================================================================
   Login page (rendered by app/auth.py)
   ========================================================================== */
body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(700px 420px at 50% 0%, var(--glow), transparent 70%),
    radial-gradient(500px 300px at 100% 100%, color-mix(in srgb, var(--sun-b) 8%, transparent), transparent 70%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 36px 26px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  text-align: center;
}
@media (min-width: 480px) { .auth-card { padding: 44px 40px 30px; } }

.brand-mark-lg {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 20px;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--sun-a), var(--sun-b));
  box-shadow: 0 12px 30px -12px rgba(245, 124, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.auth-title { font-size: 26px; letter-spacing: -0.03em; }
.auth-sub { margin-top: 4px; color: var(--ink-3); font-size: 15px; }

.auth-error {
  margin: 22px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bad) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
  color: var(--ink);
  font-size: 15px;
  text-align: left;
}

.auth-form { display: grid; gap: 16px; margin-top: 26px; text-align: left; }
.field { display: grid; gap: 7px; }
.field label { font-size: 14.5px; font-weight: 560; color: var(--ink-2); }
.field input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.field input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 56px; }
.pw-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); }
.pw-toggle .eye-closed { display: none; }
.pw-toggle[aria-pressed="true"] .eye-open { display: none; }
.pw-toggle[aria-pressed="true"] .eye-closed { display: block; }

.btn-primary {
  height: 54px;
  margin-top: 6px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--sun-a), var(--sun-b));
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.005em;
  cursor: pointer;
  box-shadow: 0 10px 24px -12px rgba(245, 124, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.1s, filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { filter: saturate(0.6); cursor: progress; }

.auth-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 22px;
  color: var(--ink-3);
  font-size: 12.5px;
}

/* ---- Power limit ------------------------------------------------------------ */
.limit-body { display: grid; gap: 16px; }
.limit.is-locked .limit-body { opacity: 0.5; }

.limit-readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 14px;
}
.limit-value {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
}
.limit-unit { font-size: 20px; font-weight: 620; color: var(--ink-3); letter-spacing: 0; }
.limit-kw { color: var(--ink-2); font-size: 14px; font-weight: 560; }

.limit-slider input[type="range"] {
  --fill: 100%;
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.limit-slider input[type="range"]:disabled { cursor: not-allowed; }
.limit-slider input[type="range"]:focus { outline: none; }
.limit-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--sun-a), var(--sun-b)) 0 0 / var(--fill) 100% no-repeat,
    var(--surface-3);
}
.limit-slider input[type="range"]::-moz-range-track { height: 10px; border-radius: 999px; background: var(--surface-3); }
.limit-slider input[type="range"]::-moz-range-progress {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sun-a), var(--sun-b));
}
.limit-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -9px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line-strong);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
  transition: box-shadow 0.15s;
}
.limit-slider input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line-strong);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
}
.limit-slider input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 35%, transparent), 0 2px 10px rgba(0, 0, 0, 0.22);
}
.limit-slider input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 35%, transparent), 0 2px 10px rgba(0, 0, 0, 0.22);
}
.limit-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.limit-presets { justify-self: start; }
@media (max-width: 460px) {
  .limit-presets { display: flex; width: 100%; }
  .limit-presets button { flex: 1 1 0; padding: 0 4px; }
}

.limit-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.limit-apply {
  flex: 1 1 220px;
  height: 52px;
  margin-top: 0;
  padding: 0 22px;
  font-size: 16px;
}
.limit-apply:disabled { filter: grayscale(1) opacity(0.45); box-shadow: none; cursor: not-allowed; }
.limit-apply.is-confirm {
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.6);
}
.btn-ghost {
  height: 52px;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }

.limit-hint { margin-top: -4px; font-size: 13.5px; color: var(--ink-2); }
.limit-hint:empty { display: none; }

.limit-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 13%, transparent);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
.limit-notice svg { flex: none; margin-top: 1px; color: var(--warn); }
.limit-notice.is-bad { background: color-mix(in srgb, var(--bad) 11%, transparent); }
.limit-notice.is-bad svg { color: var(--bad); }

.limit-inverters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 20px;
  margin: 18px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}
.limit-inverters li { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.limit-inv-name { color: var(--ink-3); }
.limit-inv-val { font-weight: 620; }

/* ---- Motion preferences ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
