:root {
  --bg: #151c2c;
  --bg-2: #1c2436;
  --card: rgba(255, 255, 255, 0.04);
  --card-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f1f4fa;
  --muted: #a3acbf;
  --dim: #6d778c;
  --blue: #2f6fec;
  --blue-soft: rgba(47, 111, 236, 0.22);
  --home: #2bd47d;
  --away: #f5862a;
  --sleep: #b07cf5;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

/* One gradient on the root, fixed to the viewport, so short pages have no seam where the body ends. */
html {
  min-height: 100%;
  background: var(--bg) linear-gradient(180deg, var(--bg-2), var(--bg)) fixed;
}

html, body {
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { overflow-x: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }

svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.glow { position: fixed; border-radius: 50%; filter: blur(70px); pointer-events: none; z-index: 0; }
.glow-a { width: 220px; height: 220px; top: 40px; left: 60px; background: rgba(110, 70, 220, 0.25); }
.glow-b { width: 260px; height: 260px; bottom: 80px; right: -40px; background: rgba(40, 90, 220, 0.2); }

.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 32px) 20px calc(env(safe-area-inset-bottom) + 40px);
}

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 36px; }
.title {
  margin: 0;
  padding: 10px 26px;
  font-size: 20px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  color: var(--text);
}
.icon-btn.primary { background: var(--blue); border-color: transparent; box-shadow: 0 8px 22px rgba(47, 111, 236, 0.4); }
.icon-btn.small { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.small svg { width: 17px; height: 17px; }
.icon-btn:active { transform: scale(0.96); }

.section-title { margin: 0 0 16px; font-size: 18px; font-weight: 400; }
.section-title.with-icon { display: flex; align-items: center; gap: 10px; }
.section-title .accent { color: #3b8cff; display: inline-flex; }
.section-title .accent svg { width: 20px; height: 20px; }

/* Presets */
.presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 32px; }
.preset {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 12px;
}
.preset svg { width: 24px; height: 24px; margin-bottom: 4px; }
.preset small { color: var(--muted); font-size: 11px; }

/* Days */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; margin-bottom: 28px; }
.day {
  padding: 12px 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  color: var(--text);
}
.day[aria-selected="true"] { background: var(--blue-soft); border-color: rgba(59, 140, 255, 0.5); color: #5fa0ff; }

/* Entries */
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.entry {
  --tint: var(--home);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(90deg, color-mix(in srgb, var(--tint) 9%, transparent), var(--card));
}
.entry.away { --tint: var(--away); }
.entry.sleep { --tint: var(--sleep); }
.entry-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  color: var(--tint);
}
.entry-icon svg { width: 20px; height: 20px; }
.entry-main { flex: 1; min-width: 0; }
.entry-time { font-size: 17px; font-weight: 700; }
.entry-label { font-size: 14px; color: var(--muted); margin-top: 2px; }
.entry-temp { font-size: 19px; font-weight: 700; margin-right: 4px; }
.entry-actions { display: flex; gap: 8px; }

.empty { text-align: center; color: var(--dim); margin: 8px 0 0; }

.fab-wrap { display: flex; justify-content: center; margin: 24px 0 28px; }
.fab {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 0;
  background: var(--blue);
  box-shadow: 0 10px 30px rgba(47, 111, 236, 0.45);
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(0.95); }

/* Overview */
.overview { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.ov-day { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0; border: 0; background: none; }
.ov-day span { font-size: 11px; color: var(--muted); }
.ov-day b {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 0.9;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 11px;
  font-weight: 400;
  color: var(--dim);
}
.ov-day.has b { background: var(--blue-soft); border-color: rgba(59, 140, 255, 0.4); color: #8ab6ff; }

/* Sheet */
.sheet {
  width: min(440px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #1d2538;
  color: var(--text);
}
.sheet::backdrop { background: rgba(5, 8, 15, 0.6); backdrop-filter: blur(4px); }
.sheet h3 { margin: 0 0 20px; font-size: 18px; font-weight: 500; }
.preset-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; border: 0; padding: 0; margin: 0 0 20px; }
.preset-pick legend { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.preset-pick .preset { cursor: pointer; }
.preset-pick .preset[aria-pressed="true"] { border-color: rgba(59, 140, 255, 0.6); background: var(--blue-soft); }

.field { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.field > span { font-size: 14px; color: var(--muted); }
.field input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper .icon-btn { width: 40px; height: 40px; font-size: 20px; }
.stepper output { min-width: 72px; text-align: center; font-size: 20px; font-weight: 700; }

.error { color: #ff8a8a; font-size: 13px; margin: -6px 0 14px; }

.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.btn { padding: 11px 20px; border-radius: 12px; border: 1px solid var(--border); background: var(--card-strong); }
.btn.primary { background: var(--blue); border-color: transparent; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #262f45;
  font-size: 14px;
  z-index: 10;
}
.toast button { border: 0; background: none; color: #5fa0ff; font-weight: 600; }

/* ---------- Main screen ---------- */
body { --mode: #3b7be0; }
body[data-mode="dry"] { --mode: #2bc4d8; }
body[data-mode="heat"] { --mode: #f5862a; }

button:disabled { opacity: 0.4; cursor: default; }

.current-label { margin: 0 0 18px; text-align: center; font-size: 22px; color: var(--mode); transition: color 0.4s; }

.dial { position: relative; width: min(78vw, 300px); aspect-ratio: 1; margin: 0 auto 40px; }
.dial-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.dial-ring circle {
  fill: none;
  stroke: var(--mode);
  stroke-width: 16;
  transition: stroke 0.4s;
}
/* Inset matches the ring's outer edge (r 138 + half of the 16 stroke, in a 300 box). */
.dial::before {
  content: "";
  position: absolute;
  inset: 1.33%;
  border-radius: 50%;
  box-shadow: 0 0 26px color-mix(in srgb, var(--mode) 40%, transparent);
  transition: box-shadow 0.4s;
}
.dial-face {
  position: absolute;
  inset: 11%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: radial-gradient(circle at 50% 30%, #232c40, #171e2d);
  box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.45), 0 12px 34px rgba(0, 0, 0, 0.35);
}
.dial-temp { font-size: clamp(48px, 16vw, 64px); font-weight: 300; letter-spacing: -1px; }

.mode-chips { display: flex; gap: 12px; }
.chip {
  display: grid;
  place-items: center;
  width: 42px;
  height: 32px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  color: #5fa0ff;
}
.chip svg { width: 16px; height: 16px; }
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--mode) 28%, transparent);
  border-color: color-mix(in srgb, var(--mode) 70%, transparent);
  color: var(--text);
}

.steppers { display: flex; justify-content: center; gap: 32px; margin-bottom: 36px; }
.round-btn {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: #5fa0ff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.round-btn svg { width: 26px; height: 26px; }
.round-btn:not(:disabled):active, .chip:active, .toggle:active, .schedule-btn:active { transform: scale(0.96); }

.schedule-btn {
  display: block;
  margin-bottom: 32px;
  padding: 22px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(90deg, #2f6fec, #1f5ad8);
  box-shadow: 0 10px 30px rgba(47, 111, 236, 0.35);
  color: #fff;
  font-size: 18px;
  text-align: center;
  text-decoration: none;
}

.toggles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 32px; }
.toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 12px;
}
.toggle svg { width: 18px; height: 18px; }
.toggle[aria-pressed="true"] {
  background: var(--blue-soft);
  border-color: rgba(59, 140, 255, 0.5);
  color: #5fa0ff;
  box-shadow: 0 8px 24px rgba(47, 111, 236, 0.18);
}

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stat {
  --tint: #3b8cff;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 100px;
  padding: 20px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, color-mix(in srgb, var(--tint) 12%, transparent), var(--card));
}
.stat.outdoor { --tint: #f5862a; }
.stat.humidity { --tint: #2bc4d8; }
.stat.battery { --tint: #2bd47d; }
.stat-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  color: var(--tint);
}
.stat-icon svg { width: 20px; height: 20px; }
.stat.current .stat-icon { color: #a8c4ff; }
.stat-body { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 0; }
.stat-body b { font-size: 18px; }
.stat-body span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.sheet .field .btn { flex: none; margin-left: 12px; }

/* ---------- Shared app chrome ---------- */
body[data-mode="off"] { --mode: #6d778c; }
body[data-mode="auto"] { --mode: #8a7cf5; }

a { color: #5fa0ff; }
.topbar .title { min-width: 0; max-width: calc(100% - 128px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.icon-btn { text-decoration: none; }
.icon-btn[aria-pressed="true"] { background: var(--blue-soft); border-color: rgba(59, 140, 255, 0.5); color: #5fa0ff; }
.app { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: #3a2b14;
  color: #ffd29a;
  font-size: 13px;
}
.offline-banner svg { width: 16px; height: 16px; }

.loading { color: var(--dim); text-align: center; margin: 40px 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.card {
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
}
.card + .card { margin-top: 14px; }
section + section { margin-top: 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head .section-title { margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.badge.blue { color: #8ab6ff; border-color: rgba(59, 140, 255, 0.4); background: var(--blue-soft); }
.badge.warn { color: #ffc27a; border-color: rgba(245, 134, 42, 0.45); background: rgba(245, 134, 42, 0.14); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.online { background: #2bd47d; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; text-decoration: none; color: var(--text); }
.btn svg { width: 18px; height: 18px; }
.btn.danger { color: #ff8a8a; border-color: rgba(255, 110, 110, 0.4); background: rgba(255, 90, 90, 0.08); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; }

/* Stacked form fields */
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-field > span, .form-label { font-size: 13px; color: var(--muted); }
.form-field input, .form-field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.form-field select option { background: #1d2538; }
.form-field input[aria-invalid="true"] { border-color: #ff8a8a; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.form-row .form-field { margin-bottom: 0; }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 16px; }
.sheet .error { margin: 0 0 14px; }

/* ---------- Login ---------- */
.auth { max-width: 420px; padding-top: calc(env(safe-area-inset-top) + 64px); }
.brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 32px; }
.brand img { width: 72px; height: 72px; border-radius: 20px; box-shadow: 0 10px 30px rgba(47, 111, 236, 0.35); }
.brand h1 { margin: 0; font-size: 26px; font-weight: 500; }
.auth .switch { margin-top: 18px; text-align: center; font-size: 14px; color: var(--muted); }
.link-btn { border: 0; background: none; padding: 4px; color: #5fa0ff; font-weight: 600; }

/* ---------- Dashboard ---------- */
.home-select {
  appearance: none;
  -webkit-appearance: none;
  max-width: 100%;
  padding: 10px 34px 10px 22px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3acbf' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px;
  color: var(--text);
  font: inherit;
  font-size: 20px;
  font-weight: 500;
  text-overflow: ellipsis;
}
.home-select option { background: #1d2538; font-size: 16px; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 32px; }
.summary .stat { flex-direction: column; align-items: flex-start; min-height: 0; padding: 14px; }
.summary .stat-body { align-items: flex-start; gap: 4px; }
.summary .stat-body b { font-size: 17px; white-space: nowrap; }
.summary .stat-body span { font-size: 10px; }
.stat.power { --tint: #f5c02a; }

.room + .room { margin-top: 26px; }
.room-title { margin: 0 0 12px; font-size: 13px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.device-card {
  --tint: #3b8cff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(90deg, color-mix(in srgb, var(--tint) 9%, transparent), var(--card));
  color: var(--text);
  text-decoration: none;
}
.device-card[data-type="TemperatureSensor"] { --tint: #f5862a; }
.device-card[data-type="PowerMeter"] { --tint: #f5c02a; }
.device-card.offline { opacity: 0.6; }
.device-card:active { transform: scale(0.99); }
.device-card .entry-icon { color: var(--tint); }
.device-main { flex: 1; min-width: 0; }
.device-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-sub { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.device-sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-value { text-align: right; }
.device-value b { display: block; font-size: 19px; }
.device-value small { font-size: 12px; color: var(--muted); }

.empty-state { padding: 32px 20px; text-align: center; border-radius: var(--radius); border: 1px dashed var(--border); color: var(--muted); }
.empty-state p { margin: 0 0 16px; }

/* ---------- Thermostat extras ---------- */
.status-line { display: flex; justify-content: center; gap: 8px; min-height: 22px; margin: -8px 0 14px; }
.dial-temp.off { color: var(--dim); }
.mode-chips { gap: 8px; }
.chip { width: 38px; }
body[data-mode="off"] .dial-ring circle { stroke-opacity: 0.35; }
.history-link { margin-top: 14px; }

/* ---------- Device history ---------- */
.ranges { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 20px; border-radius: 14px; border: 1px solid var(--border); background: var(--card); }
.ranges button { min-height: 36px; padding: 6px 14px; border-radius: 10px; border: 0; background: none; color: var(--muted); font-size: 14px; }
.ranges button[aria-pressed="true"] { background: var(--blue-soft); color: #8ab6ff; }
.charts { transition: opacity 0.2s; }
.charts.refetching { opacity: 0.5; }
.chart-card { padding: 16px 16px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); }
.chart-card + .chart-card { margin-top: 14px; }
.chart-card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 500; }
.chart-card .chart-sub { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; stroke: none; stroke-width: 1; fill: none; }
.chart .end-label { fill: var(--text); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: #1b2334; stroke-width: 4px; stroke-linejoin: round; }
.chart svg:focus { outline: none; }
.chart:focus-within { outline: 2px solid rgba(95, 160, 255, 0.6); outline-offset: 4px; border-radius: 8px; }
.chart .grid line { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; }
.chart .axis text { fill: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .crosshair { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1; }
.chart .bar.hover { filter: brightness(1.3); }
.chart-empty { padding: 40px 0; text-align: center; color: var(--dim); font-size: 14px; }
.tooltip {
  position: absolute;
  top: 0;
  z-index: 5;
  pointer-events: none;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #262f45;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  white-space: nowrap;
}
.tooltip b { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.tooltip b i { display: inline-block; width: 12px; height: 2px; border-radius: 1px; }
.tooltip span { color: var(--muted); }
.data-table { margin-top: 8px; font-size: 13px; }
.data-table summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.data-table .table-wrap { max-height: 240px; overflow: auto; }
.data-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 6px 4px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.data-table th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: #1c2436; }
.data-table td:last-child, .data-table th:last-child { text-align: right; }

/* ---------- Lists (home, admin) ---------- */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
}
.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.row-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.row-sub { margin-top: 3px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex: none; }
.row-actions .icon-btn { width: 40px; height: 40px; border-radius: 12px; }
.row-actions .icon-btn svg { width: 18px; height: 18px; }
.row .entry-icon { flex: none; }

.key-box { display: flex; gap: 8px; margin-bottom: 12px; }
.key-box input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #121826;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.warning { display: flex; gap: 10px; padding: 12px; margin-bottom: 16px; border-radius: 12px; background: rgba(245, 134, 42, 0.12); color: #ffd29a; font-size: 13px; }
.warning svg { flex: none; width: 18px; height: 18px; }

.danger-zone { border-color: rgba(255, 110, 110, 0.25); }

@media (max-width: 380px) {
  .summary { gap: 8px; }
  .summary .stat { padding: 12px 10px; }
  .summary .stat-body b { font-size: 15px; }
  .row-actions .icon-btn { width: 36px; height: 36px; }
}
.entry.custom { --tint: #3b8cff; }
.entries .loading { list-style: none; }
/* Let row actions drop below the text instead of squeezing it on narrow screens. */
.row { flex-wrap: wrap; }
.row-main { min-width: 140px; }
.row-actions { margin-left: auto; }
.row-title a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.row-title a:hover { text-decoration: underline; }

#tiles { margin-bottom: 24px; }
