/* ============================================================
   Lithifi by Creative Lithium — "Daylight" design system v17
   Light theme, soft pastel backdrop, Creative Lithium brand.
   Liquid-vessel hero: a glowing fluid fills with the charge level;
   sparks fall INTO the liquid while charging, rise OUT while discharging (amber particles flowing out).
   Class contract with app.js preserved exactly (ids, .show, .on,
   .nav-btn, .rtab, .badge, .cell, .mini-btn, .form-ok/.form-error,
   .skeleton, .empty, .gw-pill.offline, .gauge-sub.idle, .toast.show,
   #gauge-card.charging / #gauge-card.discharging)
   ============================================================ */

:root {
  --bg: #f4f7fa;
  --card: #ffffff;
  --card-border: rgba(16, 24, 40, 0.07);
  --on-surface: #16202e;
  --on-surface-dim: #5c6b7e;
  --outline-variant: rgba(16, 24, 40, 0.12);
  --primary: #2f7df6;
  --secondary: #ff7a59;
  --tertiary: #1e9e62;
  --amber: #f59e0b;
  --violet: #8b5cf6;
  --error: #e5484d;
  --ok: #1e9e62;
  --grad-brand: linear-gradient(135deg, #f5a623 0%, #7ac943 55%, #2fbf71 100%);
  --grad-primary: linear-gradient(135deg, #33c98a 0%, #0e9f6e 100%);
  --grad-blue: linear-gradient(135deg, #4da3ff 0%, #2563eb 100%);
  --shadow-card: 0 10px 30px rgba(16, 24, 40, 0.07);
  --r-card: 24px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--on-surface);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------------- Soft pastel backdrop ---------------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1100px 750px at 85% -10%, rgba(51, 201, 138, 0.10), transparent 60%),
    radial-gradient(900px 700px at -10% 20%, rgba(77, 163, 255, 0.10), transparent 55%),
    radial-gradient(700px 600px at 50% 110%, rgba(245, 166, 35, 0.08), transparent 60%),
    var(--bg);
}
.aurora::before, .aurora::after {
  content: "";
  position: absolute;
  width: 60vmax; height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .30;
  will-change: transform;
}
.aurora::before {
  background: radial-gradient(circle at 30% 30%, #9fe8c8, transparent 60%);
  top: -25vmax; left: -15vmax;
  animation: drift1 26s ease-in-out infinite alternate;
}
.aurora::after {
  background: radial-gradient(circle at 70% 70%, #bcd7ff, transparent 60%);
  bottom: -25vmax; right: -18vmax;
  animation: drift2 32s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(9vw, 7vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-8vw, -6vh) scale(1.1); } }

/* soft floating light bokeh */
.aurora i {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: rgba(46, 184, 118, 0.35);
  opacity: 0;
  animation: floatDots 9s ease-in-out infinite;
}
@keyframes floatDots { 0%, 100% { opacity: 0; transform: translateY(0); } 50% { opacity: .7; transform: translateY(-12px); } }

/* ---------------- Header ---------------- */
header { position: sticky; top: 0; z-index: 40; }
.hbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(16, 24, 40, 0.06);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 42px; height: 42px; border-radius: 13px; object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(122, 160, 60, 0.25));
  animation: logoFloat 5s ease-in-out infinite;
}
@keyframes logoFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.brand-sub { font-size: 10.5px; letter-spacing: .09em; color: var(--on-surface-dim); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.live-pill {
  display: none; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; color: var(--tertiary);
  border: 1px solid rgba(30, 158, 98, 0.30);
  background: rgba(51, 201, 138, 0.12);
  padding: 7px 13px; border-radius: 999px;
  backdrop-filter: blur(8px);
}
.live-pill.offline {
  color: var(--error);
  border-color: rgba(229, 72, 77, 0.30);
  background: rgba(229, 72, 77, 0.10);
}
.live-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(51,201,138,.45); }
  70% { box-shadow: 0 0 0 8px rgba(51,201,138,0); }
  100% { box-shadow: 0 0 0 0 rgba(51,201,138,0); }
}

/* ---------------- Layout ---------------- */
main {
  display: flex; flex-direction: column; gap: 14px;
  width: min(100%, 620px); margin: 0 auto;
  padding: 18px 16px 110px;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--r-card);
  padding: 18px;
  box-shadow: var(--shadow-card);
  animation: fadeUp .55s cubic-bezier(.22,.9,.3,1) both;
  transition: transform .25s ease, box-shadow .25s ease;
}
main#app .card:nth-child(1) { animation-delay: .02s; }
main#app .card:nth-child(2) { animation-delay: .07s; }
main#app .card:nth-child(3) { animation-delay: .12s; }
main#app .card:nth-child(4) { animation-delay: .17s; }
main#app .card:nth-child(5) { animation-delay: .22s; }
main#app .card:nth-child(6) { animation-delay: .27s; }
main#app .card:nth-child(7) { animation-delay: .32s; }
main#app .card:nth-child(8) { animation-delay: .37s; }
@media (hover:hover) {
  .card:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(16,24,40,.10); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

h3 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 15.5px; letter-spacing: -0.01em; }
.sub { color: var(--on-surface-dim); font-size: 12.5px; }

/* connectivity row */
.conn { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conn .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.conn .name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn .meta { font-size: 12px; color: var(--on-surface-dim); }

.icon-chip {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(77,163,255,.14), rgba(51,201,138,.12));
  border: 1px solid rgba(16,24,40,.06);
  color: var(--primary);
}
.icon-chip .msr { font-size: 21px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; border-radius: 15px; padding: 13px 16px;
  font: 700 14px var(--font); color: #fff; cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.btn-primary { background: var(--grad-primary); box-shadow: 0 8px 22px rgba(14, 159, 110, 0.30); }
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary:active { transform: scale(.985); }
.btn-secondary {
  background: #fff;
  border: 1px solid var(--outline-variant);
  color: var(--on-surface);
  box-shadow: 0 3px 10px rgba(16,24,40,.05);
}
.btn-secondary:hover { background: #f6f9fc; }
.btn-block { width: 100%; }

.btn-sm {
  border: 1px solid var(--outline-variant); background: #fff;
  color: var(--on-surface); font: 700 12px var(--font);
  border-radius: 999px; padding: 8px 13px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(16,24,40,.05);
  transition: background .18s ease, transform .18s ease;
}
.btn-sm:hover { background: #f1f5f9; }

.mini-btn {
  border: 1px solid var(--outline-variant); background: #fff;
  color: var(--on-surface); font: 700 11px var(--font);
  border-radius: 999px; padding: 4px 11px; cursor: pointer;
}
.mini-btn.danger { color: var(--error); border-color: rgba(229,72,77,.4); background: #fff5f5; }
.mini-btn:hover { background: #f1f5f9; }

/* ---------------- Auth ---------------- */
#auth { align-items: center; text-align: center; padding-top: 7vh; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hero-logo {
  width: 168px; height: auto; object-fit: contain;
  filter: drop-shadow(0 14px 34px rgba(122, 160, 60, 0.30));
  animation: heroPulse 4.5s ease-in-out infinite;
}
@keyframes heroPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 14px 34px rgba(122,160,60,.28)); }
  50% { transform: scale(1.035); filter: drop-shadow(0 20px 46px rgba(122,160,60,.42)); }
}
.hero h1 { font-size: 30px; letter-spacing: -0.03em; margin: 14px 0 4px; }
.hero p { color: var(--on-surface-dim); margin: 0; }
.hero .hero-tag {
  margin-top: 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .16em;
  background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent;
}

.field { text-align: left; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--on-surface-dim); margin: 0 0 6px 2px; }
input, select {
  width: 100%; border: 1px solid var(--outline-variant); border-radius: 14px;
  background: #fbfcfe; color: var(--on-surface);
  padding: 13px 14px; font: 500 15px var(--font); outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input::placeholder { color: #9aa7b8; }
input:focus, select:focus {
  border-color: rgba(30, 158, 98, .55);
  box-shadow: 0 0 0 4px rgba(51, 201, 138, .15);
  background: #fff;
}
#auth .card { width: 100%; max-width: 420px; }


/* manufacturer pages: show ONLY that page's card (beats any inline display set by the poll) */
main.v-devices > section:not(#devices-card) { display: none !important; }
main.v-keys > section:not(#keys-card) { display: none !important; }

/* hCaptcha widget slot — collapses to nothing when captcha is not configured */
.captcha-slot { display: flex; justify-content: center; margin-top: 12px; }
.captcha-slot:empty { display: none; }

/* ---------------- Gauge (liquid vessel hero) ---------------- */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; padding: 10px 0 8px; }
.gauge { position: relative; width: min(78vw, 300px); aspect-ratio: 1 / 1; }

/* progress ring */
.gauge-ring { position: absolute; inset: 0; width: 100%; height: auto; transform: rotate(-90deg); }
.gauge-ring .track { stroke: #e7edf3; }
.gauge-ring .fill {
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(45, 190, 122, .45));
  transition: stroke-dashoffset .9s cubic-bezier(.25, .8, .25, 1), stroke .5s;
}
#gauge-card.charging .gauge-ring .fill   { filter: drop-shadow(0 0 5px rgba(16, 185, 129, .55)); }
#gauge-card.discharging .gauge-ring .fill { filter: drop-shadow(0 0 5px rgba(245, 158, 11, .55)); }

/* liquid vessel */
.gauge-vessel { position: absolute; inset: 0; width: 100%; height: auto; }
.vessel-rim { fill: none; stroke: rgba(255, 255, 255, .16); stroke-width: 1.5; }
.liquid { transition: transform 1.3s cubic-bezier(.25, .8, .25, 1); will-change: transform; }

.wave { fill: url(#liq-idle); }
#gauge-card.charging .wave   { fill: url(#liq-chg); }
#gauge-card.discharging .wave { fill: url(#liq-dis); }
.w1 { animation: waveShift 5.2s linear infinite; }
.w2 { fill: rgba(255, 255, 255, .16) !important; animation: waveShift 8.4s linear infinite reverse; transform: translateY(3px); }
@keyframes waveShift { from { transform: translateX(0); } to { transform: translateX(-64px); } }

/* bubbles rising inside the fluid */
.bubbles circle { fill: currentColor; opacity: 0; animation: bubbleRise 3.6s ease-in infinite; }
.bubbles .b2 { animation-delay: .6s; animation-duration: 4.4s; }
.bubbles .b3 { animation-delay: 1.1s; animation-duration: 3.2s; }
.bubbles .b4 { animation-delay: 1.8s; animation-duration: 4.8s; }
.bubbles .b5 { animation-delay: 2.3s; animation-duration: 3.8s; }
.bubbles .b6 { animation-delay: .3s; animation-duration: 5.2s; }
.bubbles .b7 { animation-delay: 1.5s; animation-duration: 4.1s; }
@keyframes bubbleRise {
  0%   { transform: translateY(26px); opacity: 0; }
  15%  { opacity: .65; }
  80%  { opacity: .4; }
  100% { transform: translateY(-34px); opacity: 0; }
}

/* state colors for bubbles + sparks */
#gauge-card { color: #60a5fa; }
#gauge-card.charging   { color: #34d399; }
#gauge-card.discharging { color: #fbbf24; }

/* charging: sparks fall INTO the liquid (absorbing energy) */
.sparks circle { fill: currentColor; opacity: 0; }
.sparks-in circle { animation: sparkFall 2.1s cubic-bezier(.4, 0, .7, 1) infinite; }
.sparks-in .s2 { animation-delay: .3s; } .sparks-in .s3 { animation-delay: .7s; }
.sparks-in .s4 { animation-delay: 1.1s; } .sparks-in .s5 { animation-delay: .5s; }
.sparks-in .s6 { animation-delay: 1.5s; } .sparks-in .s7 { animation-delay: .9s; }
.sparks-in .s8 { animation-delay: 1.3s; }
@keyframes sparkFall {
  0%   { transform: translateY(-96px); opacity: 0; }
  12%  { opacity: .9; }
  75%  { opacity: .85; }
  100% { transform: translateY(0); opacity: 0; }
}

/* discharging: sparks rise OUT of the liquid (giving energy away) */
.sparks-out circle { animation: sparkRise 2.1s cubic-bezier(.3, .6, .6, 1) infinite; }
.sparks-out .s2 { animation-delay: .4s; } .sparks-out .s3 { animation-delay: .8s; }
.sparks-out .s4 { animation-delay: 1.2s; } .sparks-out .s5 { animation-delay: .6s; }
.sparks-out .s6 { animation-delay: 1.6s; } .sparks-out .s7 { animation-delay: 1s; }
.sparks-out .s8 { animation-delay: 1.4s; }
@keyframes sparkRise {
  0%   { transform: translateY(0); opacity: 0; }
  12%  { opacity: .9; }
  75%  { opacity: .8; }
  100% { transform: translateY(-96px); opacity: 0; }
}

/* center readout: everything sits INSIDE the vessel, nothing touches the ring */
.gauge-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; pointer-events: none;
}
.gauge-num { font-size: 44px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; color: #fff; text-shadow: 0 2px 14px rgba(10, 19, 34, .55); }
.gauge-num small { font-size: 17px; font-weight: 700; color: rgba(255, 255, 255, .75); margin-left: 2px; }
.gauge-label { font-size: 9.5px; letter-spacing: .2em; font-weight: 800; color: rgba(255, 255, 255, .55); text-transform: uppercase; margin-top: 1px; }
/* status pill sits BELOW the vessel — clear of the animation and always readable */
.gauge-sub {
  font-size: 12.5px; font-weight: 800; display: inline-flex; align-items: center; gap: 6px;
  color: #475569; background: #f1f5f9; padding: 6px 14px; border-radius: 999px;
  margin-top: 14px; max-width: 100%; border: 1px solid #e2e8f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .3s, color .3s, border-color .3s;
}
.gauge-sub.idle { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }
.gauge-sub.chg { color: #15803d; background: rgba(45, 190, 122, .13); border-color: rgba(45, 190, 122, .4); }
.gauge-sub.dis { color: #b45309; background: rgba(245, 158, 11, .15); border-color: rgba(245, 158, 11, .45); }

/* offline: calm, still vessel */
#gauge-card:not(.charging):not(.discharging) .sparks circle { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .w1, .w2, .bubbles circle, .sparks circle { animation: none !important; }
}

/* ---------------- Metrics grid ---------------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(100%, 620px); margin: 0 auto; }
.metric {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 20px; padding: 15px 16px;
  box-shadow: var(--shadow-card);
  animation: fadeUp .55s cubic-bezier(.22,.9,.3,1) both;
  transition: transform .22s ease, box-shadow .22s ease;
}
.grid2 .metric:nth-child(1) { animation-delay: .16s; }
.grid2 .metric:nth-child(2) { animation-delay: .21s; }
.grid2 .metric:nth-child(3) { animation-delay: .26s; }
.grid2 .metric:nth-child(4) { animation-delay: .31s; }
.grid2 .metric:nth-child(5) { animation-delay: .36s; }
@media (hover:hover) { .metric:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(16,24,40,.10); } }
.metric .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.metric .lab { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--on-surface-dim); }
.metric .val { font-size: 29px; font-weight: 800; letter-spacing: -0.03em; }
.metric .val small { font-size: 14px; color: var(--on-surface-dim); font-weight: 700; }
.metric .foot { font-size: 11.5px; color: var(--on-surface-dim); margin-top: 3px; }

/* ---------------- Cells ---------------- */
.cells { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 10px; }
.cell {
  background: #f7f9fc; border: 1px solid var(--card-border);
  border-radius: 13px; padding: 9px 12px;
}
.cell.warn { border-color: rgba(229,72,77,.45); background: #fff5f5; animation: warnPulse 1.6s ease-in-out infinite; }
@keyframes warnPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,0); } 50% { box-shadow: 0 0 0 5px rgba(229,72,77,.10); } }
.cell .n { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: var(--on-surface-dim); text-transform: uppercase; }
.cell .v { font-weight: 800; font-size: 15.5px; margin: 1px 0 5px; }
.cell .bar { height: 5px; border-radius: 99px; background: #e7edf3; overflow: hidden; }
.cell .bar i {
  display: block; height: 100%; border-radius: 99px;
  background: var(--grad-primary);
  transition: width 1s cubic-bezier(.25,.8,.25,1);
}
.cell.warn .bar i { background: var(--error); }

/* ---------------- Chips / badges ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-size: 12px; font-weight: 700; color: var(--on-surface);
  background: #f4f7fa; border: 1px solid var(--card-border);
  border-radius: 999px; padding: 7px 13px;
  transition: background .18s ease;
}
.chip:hover { background: #eef3f8; }
.badge {
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
  border-radius: 999px; padding: 5px 11px; white-space: nowrap;
}
.badge.claimed { color: #fff; background: var(--grad-primary); }
.badge.unclaimed { color: var(--on-surface-dim); background: #edf1f6; }
.badge.mut { color: var(--on-surface-dim); background: #f4f7fa; }

/* ---------------- History ---------------- */
.range-tabs { display: flex; gap: 4px; background: #eef2f7; border: 1px solid var(--card-border); border-radius: 999px; padding: 4px; overflow-x: auto; }
.rtab {
  border: 0; background: transparent; color: var(--on-surface-dim);
  font: 800 12px var(--font); padding: 7px 13px; border-radius: 999px; cursor: pointer;
  transition: all .2s ease;
}
.rtab.on { background: var(--grad-primary); color: #fff; box-shadow: 0 4px 12px rgba(14,159,110,.35); }
.rtab:not(.on):hover { color: var(--on-surface); }
.series-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.stab {
  border: 1px solid #e2e8f0; background: #fff; color: var(--on-surface-dim);
  font: 800 12px var(--font); padding: 6px 14px; border-radius: 999px; cursor: pointer;
  transition: all .2s ease;
}
.stab:not(.on):hover { color: var(--on-surface); }
.stab.on[data-s="soc"]     { background: #1E9E62; border-color: #1E9E62; color: #fff; box-shadow: 0 4px 12px rgba(30,158,98,.3); }
.stab.on[data-s="voltage"] { background: #3B82F6; border-color: #3B82F6; color: #fff; box-shadow: 0 4px 12px rgba(59,130,246,.3); }
.stab.on[data-s="current"] { background: #EF4444; border-color: #EF4444; color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,.3); }
.stab.on[data-s="power"]   { background: #8B5CF6; border-color: #8B5CF6; color: #fff; box-shadow: 0 4px 12px rgba(139,92,246,.3); }
.chart-stats { font-size: 11.5px; font-weight: 800; color: var(--on-surface-dim); text-align: right; margin-top: 2px; letter-spacing: .02em; }
.hist-note { display: none; margin: 8px 0 0; font-size: 12px; color: var(--on-surface-dim); }
.hist-note:not(:empty) { display: block; }
.chart { width: 100%; height: 190px; display: block; }

/* ---------------- Empty / skeleton ---------------- */
.empty { text-align: center; padding: 22px 10px; color: var(--on-surface-dim); }
.empty .msr { font-size: 44px; opacity: .4; }
.empty h3 { justify-content: center; color: var(--on-surface); }
.skeleton {
  border-radius: 13px;
  background: linear-gradient(100deg, #eef2f7 40%, #f8fafc 50%, #eef2f7 60%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------- Admin ---------------- */
.admin-list { display: grid; gap: 10px; margin-top: 12px; }
.admin-list > div {
  display: flex; justify-content: space-between; gap: 10px; align-items: flex-start;
  background: #f7f9fc; border: 1px solid var(--card-border);
  border-radius: 16px; padding: 13px 14px;
  animation: fadeUp .4s ease both;
}
.admin-list .meta { font-size: 11.5px; color: var(--on-surface-dim); }
.key-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700; font-size: 14px; word-break: break-all;
  background: rgba(51, 201, 138, .10); border: 1px dashed rgba(30, 158, 98, .45);
  color: #157a4c; border-radius: 14px; padding: 12px;
}

/* ---------------- Bottom nav ---------------- */
.bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(244,247,250,.96), rgba(244,247,250,.6) 70%, transparent);
  pointer-events: none;
}
.navbar {
  pointer-events: auto;
  display: flex; gap: 4px;
  width: min(100%, 620px); margin: 0 auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--card-border);
  border-radius: 22px; padding: 7px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 14px 36px rgba(16, 24, 40, 0.12);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: transparent; cursor: pointer;
  color: var(--on-surface-dim); font: 700 10.5px var(--font);
  border-radius: 16px; padding: 8px 4px;
  transition: color .2s ease, background .25s ease, transform .2s cubic-bezier(.34,1.56,.64,1);
}
.nav-btn .msr { font-size: 22px; transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.nav-btn.on {
  color: #fff;
  background: var(--grad-primary);
  box-shadow: 0 6px 16px rgba(14, 159, 110, .35);
}
.nav-btn.on .msr { transform: translateY(-2px) scale(1.12); }
.nav-btn:not(.on):active { transform: scale(.94); }

/* ---------------- Modals ---------------- */
.modal-back {
  position: fixed; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, 0.38);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0;
}
.modal-back.show { display: flex; animation: backIn .28s ease both; }
@keyframes backIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(100%, 430px); max-height: 86vh; overflow-y: auto;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 26px; padding: 22px;
  box-shadow: 0 30px 80px rgba(16, 24, 40, 0.25);
  animation: modalIn .38s cubic-bezier(.22,1.2,.36,1) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(22px) scale(.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal p { color: var(--on-surface-dim); }

/* QR containers get a light plate for scannability */
.qr-plate { background: #fff; border-radius: 16px; padding: 12px; display: inline-block; border: 1px solid var(--card-border); }

/* ---------------- Toast ---------------- */
#toast {
  position: fixed; left: 50%; bottom: 92px; z-index: 100;
  transform: translate(-50%, 26px);
  background: #16202e;
  border: 1px solid rgba(51, 201, 138, .5);
  color: #fff;
  font-weight: 700; font-size: 13.5px;
  border-radius: 16px; padding: 13px 20px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.30);
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease, transform .38s cubic-bezier(.22,1.2,.36,1);
  max-width: min(90vw, 420px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Form feedback ---------------- */
.form-error { color: var(--error); font-size: 13px; font-weight: 600; }
.form-ok { color: var(--ok); font-size: 13px; font-weight: 600; }

/* ---------------- Misc ---------------- */
.msr { font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal;
  display: inline-block; line-height: 1; letter-spacing: normal; text-transform: none;
  white-space: nowrap; direction: ltr; -webkit-font-feature-settings: "liga"; font-variation-settings: "liga"; }
a { color: var(--primary); }

#boot-error { color: var(--error); background: #fff; }

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

/* ---------------- Boot splash ---------------- */
#boot-splash {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--bg);
  transition: opacity .5s ease;
}
#boot-splash.hide { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .5s ease, visibility 0s .5s; }
#boot-splash img {
  width: 104px; height: auto; object-fit: contain;
  animation: heroPulse 3.2s ease-in-out infinite;
  filter: drop-shadow(0 12px 30px rgba(122, 160, 60, 0.35));
}
.splash-name { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.splash-sub { display: flex; gap: 6px; margin-top: 2px; }
.splash-sub span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--grad-primary); opacity: .35;
  animation: splashDot 1.2s ease-in-out infinite;
}
.splash-sub span:nth-child(2) { animation-delay: .18s; }
.splash-sub span:nth-child(3) { animation-delay: .36s; }
@keyframes splashDot { 50% { opacity: 1; transform: translateY(-4px); } }


/* ============================================================
   Responsive — tablets and desktops
   ============================================================ */
@media (min-width: 760px) {
  .hbar { justify-content: space-between; }
  .hbar .brand { margin-left: auto; margin-right: auto; }
  .hbar .live-pill { margin-left: 0; }
  .hbar { padding: 14px 22px; }
  header .hbar { max-width: 648px; margin: 0 auto; }
  .brand-name { font-size: 18px; }
  .grid2 { grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 652px; }
  .cells { grid-template-columns: 1fr 1fr; }
  .gauge { width: 300px; }
  .gauge-num { font-size: 48px; }
  main { padding-top: 24px; }
  .navbar { border-radius: 999px; }
  .nav-btn { flex-direction: row; gap: 8px; padding: 11px 18px; font-size: 13px; }
  #toast { bottom: 104px; }
}

@media (min-width: 1080px) {
  main { width: min(100%, 780px); }
  header .hbar { max-width: 808px; }
  .grid2 { grid-template-columns: repeat(5, 1fr); max-width: 812px; }
  .metric .val { font-size: 26px; }
  .cells { grid-template-columns: repeat(2, 1fr); }
  .gauge { width: 330px; }
  .gauge-num { font-size: 54px; }
  .chart { height: 240px; }
  .modal { width: min(100%, 470px); }
  .aurora::before { width: 44vmax; height: 44vmax; }
  .aurora::after { width: 40vmax; height: 40vmax; }
}

/* very narrow phones: keep the header airy */
@media (max-width: 400px) {
  .brand-sub { display: none; }
}

/* small phones */
@media (max-width: 350px) {
  .grid2 { grid-template-columns: 1fr; }
  .gauge-num { font-size: 40px; }
  .brand-sub { max-width: 130px; }
}
