/* ============================================================
   LuCI · Apple Liquid Glass — one free commercial typeface
   ============================================================ */
/* MiSans (Xiaomi, free for commercial use) loads via fonts/misans.css */}

:root {
  --ease-spring: cubic-bezier(.22, 1.2, .32, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
}

/* ---------- light ---------- */
:root,
html[data-theme="light"] {
  --canvas: #e6eaf2;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-2: rgba(255, 255, 255, 0.9);
  --surface-3: rgba(120, 120, 128, 0.14);
  --glass-border: rgba(255, 255, 255, 0.9);
  --ring: rgba(15, 23, 42, 0.05);
  --hairline: rgba(60, 60, 67, 0.12);
  --ink: #16171a;
  --ink-muted: #3c3d42;
  --ink-subtle: #6b6d75;
  --ink-tertiary: #767880;
  --primary: #0a84ff;
  --primary-press: #0066cc;
  --success: #1a9e45;
  --success-bg: rgba(48, 209, 88, 0.16);
  --warning: #b26a00;
  --warning-bg: rgba(255, 159, 10, 0.16);
  --danger: #d92b2b;
  --danger-bg: rgba(255, 69, 58, 0.12);
  --accent-bg: rgba(10, 132, 255, 0.12);
  --shadow-card: 0 24px 50px -32px rgba(28, 38, 72, 0.5), 0 1px 2px rgba(28, 38, 72, 0.06);
  --shadow-hover: 0 30px 60px -30px rgba(28, 38, 72, 0.55), 0 2px 6px rgba(28, 38, 72, 0.08);
  --inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.95);
  --input-bg: rgba(255, 255, 255, 0.9);
  --glow-1: #7cc4ff;
  --glow-2: #ffb8dd;
  --glow-3: #c3b2ff;
  --glow-4: #9fe8d3;
  --blob-opacity: .55;
  --vignette: rgba(20, 28, 46, 0.18);
}
/* ---------- dark ---------- */
html[data-theme="dark"] {
  --canvas: #05060a;
  --surface: rgba(36, 37, 43, 0.6);
  --surface-2: rgba(58, 59, 66, 0.76);
  --surface-3: rgba(130, 130, 140, 0.26);
  --glass-border: rgba(255, 255, 255, 0.14);
  --ring: rgba(255, 255, 255, 0.06);
  --hairline: rgba(255, 255, 255, 0.09);
  --ink: #f5f5f7;
  --ink-muted: #d2d3d8;
  --ink-subtle: #9a9ca4;
  --ink-tertiary: #83858e;
  --primary: #0a84ff;
  --primary-press: #3f9bff;
  --success: #30d158;
  --success-bg: rgba(48, 209, 88, 0.18);
  --warning: #ff9f0a;
  --warning-bg: rgba(255, 159, 10, 0.16);
  --danger: #ff453a;
  --danger-bg: rgba(255, 69, 58, 0.16);
  --accent-bg: rgba(10, 132, 255, 0.2);
  --shadow-card: 0 30px 70px -40px rgba(0, 0, 0, 1);
  --shadow-hover: 0 40px 90px -40px rgba(0, 0, 0, 1);
  --inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.09);
  --input-bg: rgba(20, 21, 25, 0.85);
  --glow-1: #2f6bff;
  --glow-2: #a855f7;
  --glow-3: #06b6d4;
  --glow-4: #ec4899;
  --blob-opacity: .34;
  --vignette: rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font-family: "MiSans", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  letter-spacing: -.003em;
  font-variant-numeric: tabular-nums;
  transition: background .4s var(--ease-out), color .4s var(--ease-out);
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; }
/* unified typeface: same family for headings, numbers and body */
.widget-main b, .row-val, .mem-row b { font-variant-numeric: tabular-nums; }
::selection { background: rgba(10, 132, 255, 0.26); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

/* slim Apple-style scrollbars */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120, 120, 128, 0.34); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(120, 120, 128, 0.55); border: 3px solid transparent; background-clip: content-box; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border: 3px solid transparent; background-clip: content-box; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); border: 3px solid transparent; background-clip: content-box; }

/* ============================================================
   BACKGROUND — layered aurora, animated
   ============================================================ */
.wallpaper { position: fixed; inset: -8%; z-index: 0; overflow: hidden; pointer-events: none; }
.wallpaper::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(1200px 700px at 50% -10%, color-mix(in srgb, var(--glow-1) 26%, transparent), transparent 62%),
    radial-gradient(900px 600px at 100% 100%, color-mix(in srgb, var(--glow-2) 20%, transparent), transparent 60%),
    var(--canvas);
}
.wallpaper i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: var(--blob-opacity); will-change: transform; }
.wallpaper .b1 { width: 44vw; height: 44vw; left: -8vw; top: -12vw; background: radial-gradient(circle at 40% 40%, var(--glow-1), transparent 68%); animation: float1 28s var(--ease-in-out) infinite; }
.wallpaper .b2 { width: 38vw; height: 38vw; right: -8vw; top: -6vw; background: radial-gradient(circle at 55% 45%, var(--glow-2), transparent 68%); animation: float2 36s var(--ease-in-out) infinite; }
.wallpaper .b3 { width: 42vw; height: 42vw; left: 12vw; bottom: -22vw; background: radial-gradient(circle at 50% 50%, var(--glow-3), transparent 68%); animation: float3 32s var(--ease-in-out) infinite; }
.wallpaper .b4 { width: 30vw; height: 30vw; right: 4vw; bottom: -14vw; background: radial-gradient(circle at 50% 50%, var(--glow-4), transparent 68%); animation: float4 40s var(--ease-in-out) infinite; }
html[data-theme="dark"] .wallpaper i { filter: blur(110px); }
@keyframes float1 { 0%,100% { transform: translate3d(0,0,0) scale(1); } 33% { transform: translate3d(4vw,3vh,0) scale(1.12); } 66% { transform: translate3d(-2vw,6vh,0) scale(.94); } }
@keyframes float2 { 0%,100% { transform: translate3d(0,0,0) scale(1.05); } 40% { transform: translate3d(-5vw,4vh,0) scale(.92); } 70% { transform: translate3d(-2vw,-3vh,0) scale(1.1); } }
@keyframes float3 { 0%,100% { transform: translate3d(0,0,0) scale(.98); } 35% { transform: translate3d(3vw,-4vh,0) scale(1.08); } 65% { transform: translate3d(-4vw,-1vh,0) scale(1.02); } }
@keyframes float4 { 0%,100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(-3vw,-5vh,0) scale(1.14); } }
.grain { position: absolute; inset: 0; opacity: .045; mix-blend-mode: overlay; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E"); }
.wallpaper::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, transparent 45%, var(--vignette) 100%);
}

/* ============================================================
   GLASS — rim light + specular + spotlight
   ============================================================ */
.glass, .cbi-section, .widget, .menu, .login-card {
  position: relative; isolation: isolate;
  background:
    radial-gradient(520px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, 0.1), transparent 45%),
    var(--surface);
  border: 1px solid var(--glass-border);
  box-shadow: var(--inset-top), var(--shadow-card), 0 0 0 1px var(--ring);
  backdrop-filter: blur(28px) saturate(185%);
  -webkit-backdrop-filter: blur(28px) saturate(185%);
  transition: box-shadow .45s var(--ease-out), transform .45s var(--ease-out), border-color .3s, background-color .45s var(--ease-out);
}
.glass::before, .cbi-section::before, .widget::before, .menu::before, .login-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; z-index: 2;
  background: linear-gradient(145deg, rgba(255,255,255,.85), rgba(255,255,255,.06) 28%, rgba(255,255,255,.03) 62%, rgba(255,255,255,.42));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
  opacity: .55; transition: opacity .4s;
}
html[data-theme="dark"] .glass::before, html[data-theme="dark"] .cbi-section::before,
html[data-theme="dark"] .widget::before, html[data-theme="dark"] .menu::before, html[data-theme="dark"] .login-card::before {
  background: linear-gradient(145deg, rgba(255,255,255,.42), rgba(255,255,255,.04) 30%, rgba(255,255,255,.02) 65%, rgba(255,255,255,.18));
  opacity: .8;
}
.glass::after, .cbi-section::after, .widget::after, .menu::after, .login-card::after {
  content: ""; position: absolute; left: 12%; right: 12%; top: 0; height: 1px; border-radius: 999px; z-index: 2;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.9), transparent);
  opacity: .75; pointer-events: none;
}
html[data-theme="dark"] .glass::after, html[data-theme="dark"] .cbi-section::after,
html[data-theme="dark"] .widget::after, html[data-theme="dark"] .menu::after, html[data-theme="dark"] .login-card::after {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); opacity: .6;
}
@media (hover: hover) and (pointer: fine) {
  .glass:hover, .cbi-section:hover, .widget:hover { box-shadow: var(--inset-top), var(--shadow-hover), 0 0 0 1px var(--ring); }
  .glass:hover::before, .cbi-section:hover::before, .widget:hover::before { opacity: .95; }
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--canvas) 55%, transparent);
  backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
  animation: dropDown .5s var(--ease-out) both;
  transition: box-shadow .3s var(--ease-out);
}
.header.scrolled { box-shadow: 0 12px 30px -26px rgba(20, 28, 46, 0.55); }
html[data-theme="dark"] .header.scrolled { box-shadow: 0 12px 30px -22px rgba(0, 0, 0, 0.9); }
.header::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--hairline) 18%, var(--hairline) 82%, transparent); pointer-events: none; }
@keyframes dropDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.header-inner { max-width: 1180px; margin: 0 auto; height: 60px; padding: 0 26px; display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 20px; height: 20px; stroke: url(#brandGrad); stroke-width: 1.8; filter: drop-shadow(0 0 10px rgba(10,132,255,.4)); transition: transform .4s var(--ease-spring); }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.08); }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.02em; }
.brand-sub { font-size: 11px; font-weight: 500; letter-spacing: .08em; color: var(--ink-tertiary); margin-left: 2px; transition: opacity .3s var(--ease-out), max-width .35s var(--ease-out); overflow: hidden; max-width: 90px; white-space: nowrap; }
.header.scrolled .brand-sub { opacity: 0; max-width: 0; }

.tabs { position: relative; display: flex; gap: 2px; margin: 0 auto; padding: 3px; border-radius: 9999px; background: var(--surface-3); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; z-index: 1; border: 0; background: none; color: var(--ink-subtle); font-size: 13px; font-weight: 500; padding: 6px 13px; border-radius: 9999px; white-space: nowrap; transition: color .25s var(--ease-out); }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); }
.tab-indicator { position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; width: 0; border-radius: 9999px; background: var(--surface-2); box-shadow: 0 1px 3px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.6); transition: transform .45s var(--ease-spring), width .35s var(--ease-out); }
html[data-theme="dark"] .tab-indicator { box-shadow: 0 1px 4px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08); }

.tools { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--glass-border); background: var(--surface); border-radius: 50%; color: var(--ink-muted); transition: transform .25s var(--ease-spring), color .2s, background .2s; }
.icon-btn:hover { color: var(--ink); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.9); }
.icon-btn .icon { transition: transform .45s var(--ease-spring), opacity .2s; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="light"] .icon-moon { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #fff; border: 0; padding: 0; cursor: pointer; background: linear-gradient(160deg, #5ac8fa, #0a84ff 55%, #5e5ce6); box-shadow: 0 4px 14px -4px rgba(10,132,255,.8), inset 0 1px 0 rgba(255,255,255,.55); transition: transform .25s var(--ease-spring); }
.avatar:hover { transform: scale(1.06); }

/* ============================================================
   LAYOUT
   ============================================================ */
.layout { position: relative; z-index: 1; display: flex; gap: 22px; max-width: 1180px; margin: 0 auto; padding: 20px 26px 80px; }
.menu { position: sticky; top: 80px; align-self: flex-start; width: 232px; flex: 0 0 232px; padding: 10px; border-radius: 22px; max-height: calc(100vh - 104px); overflow: auto; animation: slideIn .5s var(--ease-out) both; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.menu::-webkit-scrollbar { width: 0; }
.menu-group { padding: 12px 10px 5px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-tertiary); }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; color: var(--ink-muted); text-decoration: none; transition: background .2s, transform .2s var(--ease-out); }
.menu-item:hover { background: var(--surface-3); transform: translateX(2px); }
.menu-item.active { background: var(--surface-2); box-shadow: var(--inset-top), 0 1px 3px rgba(0,0,0,.08); }
.menu-item.active .mi-label { color: var(--ink); font-weight: 600; }

.mi-icon { --tile: #8e8e93; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: 0 0 28px; background: linear-gradient(180deg, color-mix(in srgb, var(--tile) 86%, #fff), var(--tile)); box-shadow: inset 0 1px 0 rgba(255,255,255,.38), 0 1px 3px rgba(0,0,0,.18); transition: transform .3s var(--ease-spring); }
.menu-item:hover .mi-icon { transform: scale(1.1) rotate(-3deg); }
.mi-icon .icon { width: 16px; height: 16px; stroke-width: 2.2; filter: drop-shadow(0 1px 1px rgba(0,0,0,.16)); }
.t-blue { --tile: #0a84ff; }
.t-blue2 { --tile: #5e5ce6; }
.t-teal { --tile: #30b0c7; }
.t-green { --tile: #30d158; }
.t-purple { --tile: #bf5af2; }
.t-orange { --tile: #ff9f0a; }
.t-red { --tile: #ff453a; }
.t-gray { --tile: #8e8e93; }
.mi-label { flex: 1; font-size: 13.5px; }
.mi-chev { width: 12px; height: 12px; color: var(--ink-tertiary); opacity: 0; transform: translateX(-4px); transition: opacity .2s, transform .3s var(--ease-out); }
.menu-item:hover .mi-chev, .menu-item.active .mi-chev { opacity: 1; transform: none; }

.content { flex: 1; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 20px; }
.page-head h1 { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.022em; }
.page-head p { margin: 6px 0 0; font-size: 13px; color: var(--ink-subtle); }

.view { display: none; }
.view.active { display: block; }
body.boot .view.active { animation: viewIn .55s var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================================================
   WIDGETS
   ============================================================ */
.widgets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; align-items: stretch; }
.grid-2.top { align-items: start; }
.grid-2 > .cbi-section { margin-bottom: 0; min-width: 0; display: flex; flex-direction: column; }
.grid-2 .hint { margin-top: auto; }
.grid-2 .actions { margin-top: auto; }
.widget { border-radius: 20px; padding: 16px 18px; overflow: hidden; }
.widget-top { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 500; color: var(--ink-subtle); }
.widget-pill { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 9999px; background: var(--surface-3); color: var(--ink-subtle); transition: background .3s, color .3s; }
.widget-pill.ok { color: var(--success); background: var(--success-bg); }
.widget-pill.warn { color: var(--warning); background: var(--warning-bg); }
.widget-main { display: flex; align-items: baseline; gap: 3px; margin: 10px 0 12px; }
.widget-main b { font-size: 34px; line-height: 1; font-weight: 700; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.widget-main span { font-size: 13px; font-weight: 500; color: var(--ink-tertiary); }
.widget-bar { position: relative; height: 5px; border-radius: 9999px; background: var(--surface-3); overflow: hidden; }
.widget-bar i { display: block; height: 100%; border-radius: 9999px; background: var(--primary); transform-origin: left; }
.widget-bar.warm i { background: linear-gradient(90deg, #ffd60a, #ff9f0a); }

.widget-foot { margin-top: 9px; font-size: 11px; color: var(--ink-tertiary); }

/* ============================================================
   SECTIONS / ROWS
   ============================================================ */
.cbi-section { border-radius: 20px; padding: 18px 20px; margin-bottom: 14px; }
.cbi-section-title { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.cbi-section-title span { font-size: 10.5px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-tertiary); }

.list { display: flex; flex-direction: column; margin: 0 -8px; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; row-gap: 6px; min-height: 42px; padding: 8px; border-radius: 10px; position: relative; transition: background .2s; }
.row + .row::before { content: ""; position: absolute; left: 8px; right: 8px; top: 0; height: 1px; background: var(--hairline); }
.row:hover { background: var(--surface-3); }
.row-key { flex: 0 0 34%; font-size: 13px; color: var(--ink-subtle); }
.row-val { font-size: 13px; color: var(--ink-muted); text-align: right; word-break: break-word; }
.row-key + .row-val { margin-left: auto; }
.row-val.strong { color: var(--ink); font-weight: 600; }
.row-grow { flex: 1; min-width: 0; font-size: 13px; }
.row-grow b { display: block; font-size: 13px; font-weight: 500; color: var(--ink); }
.row-grow small { display: block; font-size: 11.5px; color: var(--ink-tertiary); margin-top: 1px; }

.zonebadge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 9999px; background: var(--surface-3); color: var(--ink-muted); flex: 0 0 auto; transition: transform .2s var(--ease-spring); }
.zonebadge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.zonebadge.wan { color: var(--warning); background: var(--warning-bg); }
.zonebadge.lan { color: var(--primary); background: var(--accent-bg); }
.badge { font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 9999px; background: var(--surface-3); color: var(--ink-subtle); white-space: nowrap; }
.tag { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 7px; white-space: nowrap; }
.tag.ok { color: var(--success); background: var(--success-bg); }
.tag.danger { color: var(--danger); background: var(--danger-bg); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-tertiary); flex: 0 0 8px; position: relative; }
.dot.ok { background: var(--success); }
.dot.live::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--success); opacity: 0; animation: ping 2.4s var(--ease-out) infinite; }
.dot.warn { background: var(--warning); }
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 70%,100% { transform: scale(1.6); opacity: 0; } }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 12.5px; }
.kv + .kv { border-top: 1px solid var(--hairline); }
.kv span { color: var(--ink-subtle); }
.kv b { color: var(--ink); font-weight: 500; }
.kv b.warn { color: var(--warning); }

.mem-row { display: grid; grid-template-columns: 52px 1fr 100px; align-items: center; gap: 12px; padding: 8px 0; font-size: 12.5px; }
.mem-row + .mem-row { border-top: 1px solid var(--hairline); }
.mem-row > span { color: var(--ink-subtle); }
.mem-row b { font-size: 12px; font-weight: 400; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.progress { position: relative; height: 6px; background: var(--surface-3); border-radius: 9999px; overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 9999px; background: var(--primary); transform-origin: left; }
.progress i.dim { background: var(--ink-tertiary); }
.progress i.ok { background: var(--success); }

/* loading replay (JS toggles .bars-in) */
.bars-in .progress i, .bars-in .widget-bar i { animation: growBar 1.25s var(--ease-out) both; }
@keyframes growBar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.progress::after, .widget-bar::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 45%; border-radius: inherit; background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent); opacity: 0; pointer-events: none; }
.bars-in .progress::after, .bars-in .widget-bar::after { animation: sweep 1.4s var(--ease-out) .1s 1 both; }
@keyframes sweep { 0% { transform: translateX(-130%); opacity: 0; } 25% { opacity: .85; } 100% { transform: translateX(340%); opacity: 0; } }
.hint { margin-top: 12px; font-size: 11.5px; color: var(--ink-tertiary); }

.iface-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ifacebox { border: 1px solid transparent; border-radius: 16px; background: rgba(120, 120, 128, 0.1); overflow: hidden; box-shadow: none; transition: background .25s, transform .3s var(--ease-out); }
.ifacebox:hover { background: rgba(120, 120, 128, 0.14); transform: translateY(-2px); }
.ifacebox-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid var(--hairline); }
.ifacebox-body { padding: 8px 14px 10px; }

.radio-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.radio-card { border: 1px solid transparent; border-radius: 16px; background: rgba(120, 120, 128, 0.1); padding: 14px; box-shadow: none; transition: background .25s, transform .3s var(--ease-out); }
.radio-card:hover { background: rgba(120, 120, 128, 0.14); transform: translateY(-2px); }
.radio-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.radio-head b { font-size: 14px; font-weight: 600; }

.log { font-size: 11.5px; background: var(--surface-3); border-radius: 14px; padding: 12px 14px; font-variant-numeric: tabular-nums; overflow-x: auto; scrollbar-width: none; }
.log::-webkit-scrollbar { height: 0; }
.log div { display: flex; gap: 10px; padding: 3px 0; color: var(--ink-muted); white-space: nowrap; }
.log div + div { border-top: 1px solid var(--hairline); }
.log time { color: var(--ink-tertiary); flex: 0 0 auto; }
.log span { overflow: hidden; text-overflow: ellipsis; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-subtle); margin-bottom: 6px; }
.cbi-input-text, .cbi-input-select { width: 100%; height: 44px; padding: 0 14px; background: var(--input-bg); border: 1px solid var(--glass-border); border-radius: 12px; color: var(--ink); font-size: 14px; outline: none; box-shadow: inset 0 1px 2px rgba(0,0,0,.04); transition: border-color .2s, box-shadow .25s var(--ease-out), background .2s; }
.cbi-input-text:focus, .cbi-input-select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(10,132,255,.18); }
.actions { display: flex; gap: 10px; margin-top: 16px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--glass-border); background: var(--surface-2); color: var(--ink); font-size: 14px; font-weight: 600; transition: transform .2s var(--ease-spring), background .2s, box-shadow .3s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.96); }
.btn.secondary {
  background: linear-gradient(180deg, #ffffff 0%, #e6e7ec 100%);
  border-color: rgba(60, 60, 67, 0.18);
  color: var(--ink);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(20, 28, 46, 0.08), 0 10px 22px -18px rgba(20, 28, 46, 0.5);
}
html[data-theme="dark"] .btn.secondary {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 2px rgba(0, 0, 0, 0.45);
}
.btn.secondary:hover { filter: brightness(1.04); box-shadow: inset 0 1px 0 #ffffff, 0 2px 4px rgba(20, 28, 46, 0.08), 0 14px 28px -18px rgba(20, 28, 46, 0.55); }
html[data-theme="dark"] .btn.secondary:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 5px rgba(0, 0, 0, 0.5); filter: brightness(1.08); }
.btn.secondary:active { box-shadow: inset 0 1px 3px rgba(20, 28, 46, 0.12); }
.btn.primary { background: linear-gradient(180deg, #2b9bff, var(--primary)); border-color: transparent; color: #fff; box-shadow: 0 10px 24px -10px rgba(10,132,255,.8), inset 0 1px 0 rgba(255,255,255,.4); }
.btn.primary:hover { box-shadow: 0 14px 30px -10px rgba(10,132,255,.9), inset 0 1px 0 rgba(255,255,255,.5); }
.btn.sm { height: 32px; padding: 0 14px; font-size: 12.5px; border-radius: 10px; }
.btn.sm .icon { width: 15px; height: 15px; }
.btn.block { width: 100%; height: 46px; }
.ripple { position: absolute; border-radius: 50%; transform: scale(0); background: rgba(255,255,255,.45); pointer-events: none; animation: ripple .6s var(--ease-out) forwards; }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }

/* ============================================================
   SWITCH
   ============================================================ */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--surface-3); border-radius: 9999px; cursor: pointer; transition: background .3s var(--ease-out); }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.25); transition: transform .35s var(--ease-spring); }
.switch input:checked + i { background: var(--success); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:active + i::after { transform: scale(.92); }
.switch input:checked:active + i::after { transform: translateX(18px) scale(.92); }

/* ============================================================
   LOGIN — single smooth entrance, no stagger
   ============================================================ */
.login-view {
  display: flex; position: fixed; inset: 0; z-index: 60; align-items: center; justify-content: center; padding: 24px;
  background: color-mix(in srgb, var(--canvas) 8%, transparent);
  backdrop-filter: blur(26px) saturate(170%); -webkit-backdrop-filter: blur(26px) saturate(170%);
  visibility: hidden; opacity: 0; pointer-events: none;
  transition: opacity .32s var(--ease-out), visibility .32s;
}
.login-view.active { visibility: visible; opacity: 1; pointer-events: auto; }
/* let the wallpaper colours come through so the card reads as glass */
body.login-open .wallpaper i { opacity: .68; }
html[data-theme="dark"] body.login-open .wallpaper i { opacity: .6; }
.login-card {
  width: 100%; max-width: 392px; border-radius: 28px; padding: 34px 30px 28px;
  opacity: 0; transform: translateY(22px);
  transition: opacity .42s var(--ease-out), transform .55s var(--ease-out), box-shadow .45s var(--ease-out), border-color .3s;
}
html[data-theme="dark"] .login-card {
  background:
    radial-gradient(520px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, 0.1), transparent 45%),
    radial-gradient(420px circle at 12% 0%, rgba(90, 140, 255, 0.14), transparent 62%),
    rgba(30, 31, 37, 0.4);
  border-color: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(40px) saturate(210%);
  -webkit-backdrop-filter: blur(40px) saturate(210%);
}
.login-view.active .login-card { opacity: 1; transform: none; transition-delay: .05s; }
.login-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--glass-border); background: var(--surface-3); color: var(--ink-subtle); display: grid; place-items: center; transition: transform .2s var(--ease-spring), color .2s, background .2s; }
.login-close:hover { color: var(--ink); transform: scale(1.06); }
.login-close:active { transform: scale(.92); }
.login-close .icon { width: 14px; height: 14px; }
body.login-open { overflow: hidden; }

.login-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 22px; }
.login-card h2 { margin: 0 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -.022em; }
.login-sub { margin: 0 0 22px; font-size: 12px; color: var(--ink-subtle); }
.login-fields { background: var(--surface-3); border-radius: 14px; overflow: hidden; margin-bottom: 18px; }
.login-row { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 48px; }
.login-row + .login-row { border-top: 1px solid var(--hairline); }
.login-ico { color: var(--ink-tertiary); display: grid; place-items: center; }
.login-ico .icon { width: 16px; height: 16px; }
.login-row .cbi-input-text { border: 0; background: transparent; height: 46px; padding: 0; box-shadow: none; font-size: 15px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 11px; color: var(--ink-tertiary); }

/* ============================================================
   TOAST
   ============================================================ */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px) scale(.96); background: var(--surface-2); border: 1px solid var(--glass-border); color: var(--ink); font-size: 13px; font-weight: 500; padding: 10px 18px; border-radius: 9999px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .45s var(--ease-spring); backdrop-filter: blur(22px) saturate(180%); box-shadow: 0 20px 50px -20px rgba(0,0,0,.5); z-index: 90; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ============================================================
   MOBILE TAB BAR
   ============================================================ */
.tabbar { display: none; }
@media (max-width: 900px) {
  .tabs { display: none; }
  .tabbar {
    display: flex; position: fixed; left: 12px; right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 45;
    padding: 7px 6px; border-radius: 22px;
    background: var(--surface-2); border: 1px solid var(--glass-border);
    box-shadow: var(--inset-top), var(--shadow-card);
    backdrop-filter: blur(26px) saturate(180%); -webkit-backdrop-filter: blur(26px) saturate(180%);
  }
  .tabbar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; color: var(--ink-tertiary); font-size: 10px; font-weight: 500; padding: 6px 0 4px; border-radius: 14px; transition: color .2s, background .2s; }
  .tabbar-item .icon { width: 20px; height: 20px; }
  .tabbar-item.active { color: var(--primary); background: var(--accent-bg); }
  .content { padding-bottom: 140px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  body::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 132px; background: linear-gradient(180deg, transparent, var(--canvas) 78%); pointer-events: none; z-index: 44; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1060px) { .iface-grid, .radio-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 901px) and (max-width: 1060px) { .widgets .widget:last-child { grid-column: span 2; } }
@media (max-width: 900px) {
  .layout { padding: 16px 16px 80px; }
  .menu { display: none; }
  .widgets { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .iface-grid, .radio-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 28px; }
  .header-inner { padding: 0 16px; gap: 10px; }
  .brand-sub { display: none; }
  .tools { margin-left: auto; }
  .widget { padding: 14px 16px; border-radius: 18px; }
  .widget-main b { font-size: 30px; }
  .content { padding-bottom: 130px; }
}
@media (max-width: 560px) {
  .widgets { grid-template-columns: 1fr; }
  .page-head p { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .view.active > * { filter: none; }
}

/* hide top tabs (match router) */
.tabs { display: none !important; }

/* demo: hide mobile tabbar, push tools right */
.header-inner .tools { margin-left: auto; }
.tabbar { display: none !important; }

/* ===== updated from design spec ===== */
.chart { width: 100%; height: auto; display: block; margin-top: 10px; border-radius: 14px; background: var(--surface-3); padding: 8px; }
.chart .grid { stroke: var(--hairline); stroke-width: 1; }
.chart .axis { fill: var(--ink-tertiary); font-size: 9px; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .line2 { fill: none; stroke: var(--success); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.demo-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.demo-table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--ink-tertiary); padding: 8px 10px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.demo-table td { padding: 9px 10px; border-bottom: 1px solid var(--hairline); color: var(--ink-muted); overflow-wrap: anywhere; }
.demo-table tr:hover td { background: rgba(120,120,128,.08); }
.demo-table .empty-cell { text-align: center; color: var(--ink-tertiary); padding: 22px; }
.alert-message { border-radius: 14px; padding: 13px 15px; margin-bottom: 14px; background: var(--warning-bg); border: 1px solid color-mix(in srgb, var(--warning) 32%, transparent); }
.alert-message h4 { margin: 0 0 3px; font-size: 14px; font-weight: 650; }
.alert-message p { margin: 0; font-size: 12px; color: var(--ink-subtle); }
.logbox { margin: 10px 0 0; padding: 12px 14px; border-radius: 12px; background: #0f1115; color: #d7dae0; font-size: 11.5px; line-height: 1.65; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 200px; overflow: auto; }

.traffic-card { padding: 18px 20px 14px; }
.traffic-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.traffic-legend { display: flex; align-items: center; gap: 14px; font-size: 11.5px; color: var(--ink-subtle); }
.traffic-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.traffic-legend .dot-rx { background: var(--primary); }
.traffic-legend .dot-tx { background: var(--success); }
.pill.live { font-size: 10.5px; font-weight: 600; color: var(--success); background: var(--success-bg); padding: 3px 9px; border-radius: 9999px; }
.traffic-stats { display: flex; gap: 32px; margin: 2px 0 4px; }
.traffic-stats small { display: block; font-size: 11px; color: var(--ink-tertiary); margin-bottom: 2px; }
.traffic-stats b { font-size: 24px; font-weight: 700; letter-spacing: -.025em; color: var(--ink); }
.traffic-stats b span { font-size: 11px; font-weight: 500; color: var(--ink-tertiary); margin-left: 3px; }
.traffic-svg { width: 100%; height: auto; background: none !important; padding: 0 !important; margin-top: 6px; border-radius: 0; }
.traffic-svg .grid line { stroke: var(--hairline); stroke-dasharray: 2 5; }
.traffic-svg .axis { fill: var(--ink-tertiary); font-size: 9.5px; }
.traffic-svg .xaxis text { fill: var(--ink-tertiary); font-size: 9.5px; }
.traffic-svg .line { fill: none; stroke: var(--primary); stroke-width: 2.2; stroke-linecap: round; }
.traffic-svg .line2 { fill: none; stroke: var(--success); stroke-width: 1.6; stroke-linecap: round; opacity: .9; }

.traffic-xaxis { display: flex; justify-content: space-between; padding: 0 2px; margin-top: 6px; font-size: 11px; font-weight: 400; color: var(--ink-tertiary); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.traffic-svg .axis { font-size: 11px; font-weight: 400; fill: var(--ink-tertiary); font-variant-numeric: tabular-nums; }
.traffic-svg text { font-family: inherit; }

.traffic-plot { position: relative; }
.traffic-yaxis { position: absolute; left: 2px; top: 0; bottom: 0; width: 30px; font-size: 11px; font-weight: 400; color: var(--ink-tertiary); font-variant-numeric: tabular-nums; letter-spacing: .01em; pointer-events: none; }
.traffic-yaxis span { position: absolute; left: 0; transform: translateY(-50%); }

.traffic-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.traffic-head .seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9999px; background: var(--surface-3); }
.traffic-head .seg button { border: 0; background: none; cursor: pointer; font: inherit; font-size: 11.5px; color: var(--ink-subtle); padding: 5px 11px; border-radius: 9999px; transition: background .2s, color .2s; }
.traffic-head .seg button:hover { color: var(--ink); }
.traffic-head .seg button.active { background: var(--surface-2); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.6); }
.traffic-kpis { display: flex; align-items: flex-end; gap: 40px; margin-bottom: 12px; }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-subtle); margin-bottom: 2px; }
.kpi-label i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.kpi-label .dot-rx { background: var(--primary); }
.kpi-label .dot-tx { background: var(--success); }
.kpi-val { display: flex; align-items: baseline; gap: 3px; }
.kpi-val b { font-size: 26px; font-weight: 700; letter-spacing: -.03em; line-height: 1.05; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-val span { font-size: 11px; color: var(--ink-tertiary); }
.kpi.peak .kpi-val b { color: var(--ink-muted); font-size: 18px; }
.kpi.peak .kpi-val span { font-size: 10.5px; }

.traffic-plot { padding-left: 38px; }
.traffic-yaxis { z-index: 2; }
.traffic-xaxis { padding-left: 38px; }
