/* ============================================================================
   LIQUID GLASS DESIGN SYSTEM — Quindi.ai Brand
   Precision-instrument refinement: same palette, tighter execution.
   The sidebar rail is deliberately always dark (brand anchor); the content
   area follows [data-theme]. Every component color goes through a token so
   both themes stay coherent.
   ========================================================================== */

:root {
    /* Typography */
    --font-display: 'Archivo', 'Hanken Grotesk', sans-serif;
    --font-body: 'Hanken Grotesk', 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'Spline Sans Mono', 'SF Mono', 'Cascadia Code', monospace;

    /* Quindi Brand — Primary: green/teal */
    --primary: #1cd685;
    --primary-light: #51e0cf;
    --primary-dark: #36b084;
    --primary-glow: rgba(28, 214, 133, 0.25);
    --primary-gradient: linear-gradient(120deg, #44e97c, #0bce88, #36b084);
    --primary-ink: #04140c; /* text on solid primary */

    /* Quindi Brand — Secondary: purple */
    --secondary: #985eef;
    --secondary-light: #b07af5;
    --secondary-dark: #371499;
    --secondary-glow: rgba(152, 94, 239, 0.25);

    /* Semantic */
    --success: #1cd685;
    --success-glow: rgba(28, 214, 133, 0.30);
    --danger: #e05151;
    --danger-glow: rgba(224, 81, 81, 0.30);
    --warning: #e5b364;
    --warning-glow: rgba(229, 179, 100, 0.30);
    --info: #51e0cf;
    --info-glow: rgba(81, 224, 207, 0.25);

    /* Quindi Brand — base teal ramp */
    --base-100: #51e0cf;
    --base-200: #469794;
    --base-300: #335b62;
    --base-400: #26444f;
    --base-500: #122730;

    /* Geometry */
    --glass-radius: 14px;
    --glass-radius-sm: 8px;
    --glass-blur: 20px;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    --sidebar-width: 260px;

    /* ---- Dark theme (default) ---------------------------------------- */
    --bg-base: #050505;
    --bg-gradient:
        radial-gradient(ellipse at 18% 8%, rgba(18, 39, 48, 0.55) 0%, transparent 52%),
        radial-gradient(ellipse at 82% 85%, rgba(55, 20, 153, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 15%, rgba(28, 214, 133, 0.05) 0%, transparent 45%),
        #050505;
    --bg-surface-100: #0a0f0f;
    --bg-surface-200: #141919;
    --bg-surface-300: #1f2323;
    --bg-surface-400: #292d2d;

    --text-primary: rgba(255, 255, 255, 0.90);
    --text-secondary: rgba(255, 255, 255, 0.62);
    --text-muted: rgba(255, 255, 255, 0.50); /* ≥4.5:1 on --bg-base */
    --text-bright: #ffffff;

    --glass-bg: rgba(255, 255, 255, 0.045);
    --glass-bg-hover: rgba(255, 255, 255, 0.07);
    --glass-bg-active: rgba(255, 255, 255, 0.11);
    --glass-border: rgba(255, 255, 255, 0.09);
    --glass-border-hover: rgba(255, 255, 255, 0.16);
    --glass-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -8px rgba(0, 0, 0, 0.5);
    --glass-shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --glass-sheen: linear-gradient(90deg, transparent 5%, rgba(81, 224, 207, 0.18), transparent 95%);

    --line-1: rgba(255, 255, 255, 0.055);          /* hairlines: row borders, dividers */
    --line-2: rgba(255, 255, 255, 0.11);           /* control borders */
    --hover-1: rgba(255, 255, 255, 0.06);          /* neutral hover wash */
    --thead-bg: #141919;                           /* opaque: sticky headers must occlude rows */
    --thead-text: rgba(255, 255, 255, 0.55);
    --row-hover: rgba(81, 224, 207, 0.05);
    --row-zebra: rgba(255, 255, 255, 0.015);
    --input-bg: rgba(255, 255, 255, 0.045);
    --input-border: rgba(255, 255, 255, 0.12);
    --option-bg: #141919;
    --option-text: #ffffff;
    --grid-line: rgba(81, 224, 207, 0.022);
    --noise-opacity: 0.05;
    --scrollbar-thumb: rgba(255, 255, 255, 0.10);
    --scrollbar-thumb-hover: rgba(81, 224, 207, 0.35);
}

/* ---- Light theme: real light surfaces, same brand accents -------------- */
[data-theme="light"] {
    --bg-base: #eef1f0;
    --bg-gradient:
        radial-gradient(ellipse at 18% 8%, rgba(81, 224, 207, 0.14) 0%, transparent 52%),
        radial-gradient(ellipse at 82% 85%, rgba(152, 94, 239, 0.08) 0%, transparent 50%),
        #eef1f0;
    --bg-surface-100: #ffffff;
    --bg-surface-200: #f4f7f6;
    --bg-surface-300: #e8edec;
    --bg-surface-400: #dde3e2;

    --text-primary: rgba(10, 26, 22, 0.92);
    --text-secondary: rgba(10, 26, 22, 0.72);
    --text-muted: rgba(10, 26, 22, 0.64); /* ≥4.5:1 on --bg-base */
    --text-bright: #07150f;

    /* Semantic tokens darkened for the light surface: the dark-theme neons sit at
       ~1.4–1.7:1 here; status dots and badges need ≥3:1. Same hexes the light
       text/badge overrides below already use. */
    --success: #157a51;
    --success-glow: rgba(21, 122, 81, 0.30);
    --danger: #b03030;
    --danger-glow: rgba(176, 48, 48, 0.30);
    --warning: #9a6c1f;
    --warning-glow: rgba(154, 108, 31, 0.30);
    --info: #1c7d72;
    --info-glow: rgba(28, 125, 114, 0.25);

    --glass-bg: rgba(255, 255, 255, 0.62);
    --glass-bg-hover: rgba(255, 255, 255, 0.75);
    --glass-bg-active: rgba(255, 255, 255, 0.88);
    --glass-border: rgba(10, 26, 22, 0.10);
    --glass-border-hover: rgba(10, 26, 22, 0.18);
    --glass-shadow: 0 1px 2px rgba(13, 36, 30, 0.05), 0 10px 28px -10px rgba(13, 36, 30, 0.12);
    --glass-shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    --glass-sheen: linear-gradient(90deg, transparent 5%, rgba(28, 214, 133, 0.25), transparent 95%);

    --line-1: rgba(10, 26, 22, 0.07);
    --line-2: rgba(10, 26, 22, 0.14);
    --hover-1: rgba(10, 26, 22, 0.05);
    --thead-bg: #e9efed;
    --thead-text: rgba(10, 26, 22, 0.55);
    --row-hover: rgba(28, 214, 133, 0.07);
    --row-zebra: rgba(10, 26, 22, 0.015);
    --input-bg: rgba(255, 255, 255, 0.85);
    --input-border: rgba(10, 26, 22, 0.16);
    --option-bg: #ffffff;
    --option-text: #07150f;
    --grid-line: rgba(54, 176, 132, 0.05);
    --noise-opacity: 0.03;
    --scrollbar-thumb: rgba(10, 26, 22, 0.18);
    --scrollbar-thumb-hover: rgba(54, 176, 132, 0.55);

    --primary-glow: rgba(28, 214, 133, 0.30);
}

/* === RESET & BASE ======================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scrollbar-gutter: stable; }

body {
    background: var(--bg-base);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Atmosphere: faint engineering grid + photographic grain. Fixed, painted
   behind everything, never intercepting input. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, black 30%, transparent 90%);
    -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, black 30%, transparent 90%);
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: var(--noise-opacity);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

::selection { background: rgba(28, 214, 133, 0.30); color: var(--text-bright); }

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--primary); }
[data-theme="light"] a { color: var(--primary-dark); }
[data-theme="light"] a:hover { color: var(--primary-dark); }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 650;
    line-height: 1.25;
    color: var(--text-bright);
    letter-spacing: -0.01em;
}
h1 { font-size: 1.6rem; font-weight: 700; font-variation-settings: 'wdth' 110; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; }

:focus-visible {
    outline: 2px solid var(--primary-dark);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* === GLASS CARD ========================================================== */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius);
    box-shadow: var(--glass-shadow), var(--glass-shadow-inset);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
    transition: border-color 0.25s ease, background 0.25s ease;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: var(--glass-sheen);
    pointer-events: none;
}

/* Quiet hover: information cards must not jump around — they just sharpen. */
.glass-card:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
}

.glass-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--line-1);
}

.glass-card-header h3 {
    margin: 0;
    color: var(--base-100);
    font-family: var(--font-body);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 650;
}
[data-theme="light"] .glass-card-header h3 { color: var(--primary-dark); }

.glass-card-body { position: relative; }

/* === GLASS SIDEBAR ======================================================= */
/* The rail stays dark in both themes: it anchors the brand and keeps the
   white logo legible. Its colors are therefore fixed, not theme tokens. */
.glass-sidebar {
    background: linear-gradient(180deg, rgba(10, 15, 15, 0.92), rgba(7, 11, 11, 0.96));
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 1.35rem var(--space-lg) 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    position: relative;
}

.sidebar-logo::after {
    content: '';
    position: absolute;
    left: var(--space-lg); right: var(--space-lg); bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, rgba(28, 214, 133, 0.35), transparent 70%);
}

.sidebar-logo svg { flex-shrink: 0; }

.sidebar-nav { flex: 1; padding: var(--space-md) 0.65rem; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.85rem;
    margin-bottom: 2px;
    border-radius: var(--glass-radius-sm);
    color: rgba(255, 255, 255, 0.60);
    font-size: 0.855rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    position: relative;
    transition: background 0.18s ease, color 0.18s ease;
    text-decoration: none;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #ffffff; text-decoration: none; }

.nav-item.active {
    background: linear-gradient(90deg, rgba(28, 214, 133, 0.16), rgba(28, 214, 133, 0.05));
    color: var(--primary-light);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 3px;
    border-radius: 2px;
    background: var(--primary-gradient);
    box-shadow: 0 0 10px var(--primary-glow);
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.55; transition: opacity 0.18s ease; }
.nav-item:hover svg, .nav-item.active svg { opacity: 1; }

.nav-section {
    color: rgba(255, 255, 255, 0.32);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    padding: var(--space-md) 0.85rem var(--space-xs);
}

.sidebar-footer {
    padding: 0.85rem var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.62);
}

.sidebar-footer .status-dot { margin-left: 2px; }

/* === MAIN CONTENT ======================================================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: var(--space-xl) var(--space-2xl) var(--space-2xl);
    overflow-x: hidden;
    max-width: 1680px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.page-header h1 {
    margin: 0;
    position: relative;
    padding-left: 0.9rem;
}

/* Brand tick: every page title carries the gradient mark. */
.page-header h1::before {
    content: '';
    position: absolute;
    left: 0; top: 0.18em; bottom: 0.18em;
    width: 4px;
    border-radius: 2px;
    background: var(--primary-gradient);
    box-shadow: 0 0 12px var(--primary-glow);
}

.page-header-actions { display: flex; gap: var(--space-sm); align-items: center; flex-wrap: wrap; }

/* === GRID LAYOUTS ======================================================== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }

@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .glass-sidebar { transform: translateX(-100%); }
    .glass-sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: var(--space-md); }
}

/* === KPI WIDGET ========================================================== */
.kpi-value {
    font-family: var(--font-mono);
    font-size: 2.05rem;
    font-weight: 600;
    line-height: 1.05;
    margin-top: var(--space-xs);
    color: var(--text-bright);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.kpi-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: var(--space-xs);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.11em;
}

/* === GLASS TABLE ========================================================= */
.glass-table-wrapper {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius);
    overflow: hidden;
    box-shadow: var(--glass-shadow);
}

.glass-table { width: 100%; border-collapse: collapse; }

.glass-table thead th {
    /* Opaque (not the translucent glass tint): a sticky header that scrolling rows pass
       under must fully occlude them, or their text bleeds through and ghosts the header. */
    background: var(--thead-bg);
    padding: 0.6rem var(--space-md);
    text-align: left;
    font-weight: 650;
    color: var(--thead-text);
    text-transform: uppercase;
    font-size: 0.63rem;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--line-2);
    position: sticky;
    top: 0;
    white-space: nowrap;
    /* Paint above tbody rows, whose :hover background + transition create stacking contexts. */
    z-index: 1;
}

.glass-table tbody tr { transition: background 0.12s ease, box-shadow 0.12s ease; }
.glass-table tbody tr:nth-child(even) { background: var(--row-zebra); }
.glass-table tbody tr:hover {
    background: var(--row-hover);
    box-shadow: inset 2px 0 0 var(--primary-dark);
}
.glass-table tbody tr:last-child td { border-bottom: none; }

.glass-table tbody td {
    padding: 0.5rem var(--space-md);
    border-bottom: 1px solid var(--line-1);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* === GLASS BUTTON ======================================================== */
.glass-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: var(--glass-bg-hover);
    border: 1px solid var(--line-2);
    border-radius: var(--glass-radius-sm);
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 550;
    font-size: 0.815rem;
    letter-spacing: 0.01em;
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
    font-family: inherit;
    white-space: nowrap;
}

.glass-btn:hover { background: var(--glass-bg-active); border-color: var(--glass-border-hover); }
.glass-btn:active { filter: brightness(0.92); }
.glass-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.glass-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-glow); border-color: var(--primary-dark); }

/* Primary / success: the one solid call to action on a page. Flat brand fill —
   no gradient, glow or inset gloss — so buttons sit in the page, not above it. */
.glass-btn-primary, .glass-btn-success {
    background: var(--primary);
    border-color: transparent;
    color: var(--primary-ink);
    font-weight: 650;
}
.glass-btn-primary:hover, .glass-btn-success:hover {
    background: var(--primary);
    border-color: transparent;
    filter: brightness(1.08);
}

.glass-btn-danger { background: rgba(224, 81, 81, 0.13); border-color: rgba(224, 81, 81, 0.30); color: var(--danger); }
.glass-btn-danger:hover { background: rgba(224, 81, 81, 0.24); border-color: rgba(224, 81, 81, 0.45); }
.glass-btn-warning { background: rgba(229, 179, 100, 0.13); border-color: rgba(229, 179, 100, 0.30); color: var(--warning); }
.glass-btn-warning:hover { background: rgba(229, 179, 100, 0.24); border-color: rgba(229, 179, 100, 0.45); }

[data-theme="light"] .glass-btn-danger { color: #b03030; }
[data-theme="light"] .glass-btn-warning { color: #9a6c1f; }

.glass-btn-sm { padding: 0.3rem 0.7rem; font-size: 0.74rem; border-radius: 7px; }
.glass-btn-lg { padding: 0.7rem 1.5rem; font-size: 0.95rem; }

/* === GLASS INPUT ========================================================= */
.glass-input, .glass-select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--glass-radius-sm);
    padding: 0.55rem 0.9rem;
    color: var(--text-primary);
    width: 100%;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    outline: none;
    font-family: inherit;
    font-size: 0.875rem;
}

.glass-input:hover, .glass-select:hover { border-color: var(--glass-border-hover); }
.glass-input:focus, .glass-select:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.glass-input::placeholder { color: var(--text-muted); }

.glass-input[type="number"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.glass-select {
    appearance: none;
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%2336b084' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    cursor: pointer;
}

.glass-select option { background: var(--option-bg); color: var(--option-text); }

.form-group { margin-bottom: var(--space-md); }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: var(--space-xs); font-weight: 500; }

/* === STATUS INDICATORS =================================================== */
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    position: relative;
}

.status-dot-lg { width: 11px; height: 11px; }

.status-connected {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(28, 214, 133, 0.14), 0 0 10px var(--success-glow);
}
.status-disconnected {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(224, 81, 81, 0.14), 0 0 10px var(--danger-glow);
}
.status-connecting { background: var(--warning); animation: pulse 1.5s infinite; }
/* A reader that should be reading but is silent: an anomaly, not a healthy green. */
.status-attention {
    background: var(--warning);
    box-shadow: 0 0 0 3px rgba(245, 188, 66, 0.16);
    animation: pulse 1.5s infinite;
}
.status-reading {
    background: var(--info);
    box-shadow: 0 0 0 3px rgba(81, 224, 207, 0.14);
    animation: sonar 1.6s ease-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px currentColor; }
    50% { opacity: 0.35; box-shadow: 0 0 3px currentColor; }
}

/* A reading antenna pings: an expanding ring beats opacity-blinking. */
@keyframes sonar {
    0%   { box-shadow: 0 0 0 0 rgba(81, 224, 207, 0.45); }
    70%  { box-shadow: 0 0 0 7px rgba(81, 224, 207, 0); }
    100% { box-shadow: 0 0 0 0 rgba(81, 224, 207, 0); }
}

/* === RSSI BAR ============================================================ */
.rssi-bar { height: 4px; border-radius: 2px; background: var(--hover-1); overflow: hidden; width: 80px; display: inline-block; vertical-align: middle; }
.rssi-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s ease; }
.rssi-excellent { background: var(--primary); }
.rssi-good { background: var(--base-100); }
.rssi-fair { background: var(--warning); }
.rssi-poor { background: var(--danger); }

/* === BADGE =============================================================== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.66rem;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid transparent;
    font-variant-numeric: tabular-nums;
}
.badge-success { background: rgba(28, 214, 133, 0.12); color: var(--success); border-color: rgba(28, 214, 133, 0.22); }
.badge-danger { background: rgba(224, 81, 81, 0.12); color: var(--danger); border-color: rgba(224, 81, 81, 0.22); }
.badge-warning { background: rgba(229, 179, 100, 0.12); color: var(--warning); border-color: rgba(229, 179, 100, 0.22); }
.badge-info { background: rgba(81, 224, 207, 0.12); color: var(--info); border-color: rgba(81, 224, 207, 0.22); }

[data-theme="light"] .badge-success { color: #157a51; }
[data-theme="light"] .badge-danger { color: #b03030; }
[data-theme="light"] .badge-warning { color: #9a6c1f; }
[data-theme="light"] .badge-info { color: #1c7d72; }

.badge:not([class*="badge-"]) { background: var(--hover-1); color: var(--text-secondary); border-color: var(--line-2); }

/* === TOGGLE ============================================================== */
.toggle-switch { position: relative; width: 44px; height: 24px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--hover-1);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease;
    border: 1px solid var(--line-2);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 2px; top: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.25s ease;
}
.toggle-switch input:checked + .toggle-slider { background: rgba(28, 214, 133, 0.25); border-color: rgba(28, 214, 133, 0.35); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--primary); box-shadow: 0 0 8px var(--primary-glow); }
.toggle-switch input:focus-visible + .toggle-slider { box-shadow: 0 0 0 3px var(--primary-glow); }

/* === SLIDER ============================================================== */
.glass-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--hover-1);
    border-radius: 2px;
    outline: none;
}
.glass-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* === PAGINATION ========================================================== */
.pagination { display: flex; gap: var(--space-xs); align-items: center; justify-content: center; margin-top: var(--space-lg); }
.pagination .glass-btn { font-variant-numeric: tabular-nums; }
.pagination .glass-btn.active { background: var(--primary-glow); border-color: var(--primary-dark); color: var(--text-bright); }

/* === CHART CONTAINER ===================================================== */
.chart-container { position: relative; width: 100%; }
.chart-container canvas { max-width: 100%; }

/* === ANIMATIONS ========================================================== */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 15px var(--primary-glow); }
    50% { box-shadow: 0 0 25px var(--primary-glow); }
}

.glass-card { animation: slideUp 0.3s cubic-bezier(0.2, 0.7, 0.3, 1) both; }

.stagger-1 { animation-delay: 0.04s; }
.stagger-2 { animation-delay: 0.08s; }
.stagger-3 { animation-delay: 0.12s; }
.stagger-4 { animation-delay: 0.16s; }

/* === PIN PAD (login unlock) ============================================== */
/* Sign-in shell: full-viewport flex centering with no sidebar offset (see AuthLayout). */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.auth-card {
    width: 100%;
    max-width: 24rem;
    padding: 2rem;
}

/* Centered brand mark above the heading; currentColor drives the wordmark in both themes. */
.auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.auth-title { text-align: center; margin: 0 0 0.25rem; }
.auth-subtitle { text-align: center; margin: 0 0 1.5rem; }

.pin-card {
    width: 100%;
    max-width: 22rem;
    padding: 2.5rem 2rem;
    text-align: center;
}

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 0.9rem;
    margin-top: 1.75rem;
}

.pin-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 1.5px solid var(--text-secondary);
    transition: background 0.12s ease, border-color 0.12s ease;
}

.pin-dot-filled {
    background: var(--text-primary);
    border-color: var(--text-primary);
}

/* Reserved line so the "wrong PIN" message never shifts the keypad. */
.pin-status {
    min-height: 1.25rem;
    margin: 0.75rem 0 1rem;
    font-size: 0.8rem;
}

.pin-keys {
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: 0.8rem;
    justify-content: center;
}

.pin-key {
    width: 4.25rem;
    height: 4.25rem;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg-hover);
    border: 1px solid var(--line-2);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.16s ease, border-color 0.16s ease, filter 0.16s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.pin-key:hover { background: var(--glass-bg-active); border-color: var(--glass-border-hover); }
.pin-key:active { filter: brightness(0.85); }

.pin-key-digit {
    font-size: 1.45rem;
    font-weight: 550;
    line-height: 1.1;
}

.pin-key-letters {
    font-size: 0.5rem;
    letter-spacing: 0.14em;
    color: var(--text-secondary);
    min-height: 0.65rem;
}

/* Backspace: no glass chrome, like the phone pad's bottom corners. */
.pin-key-plain {
    background: transparent;
    border-color: transparent;
    font-size: 1.3rem;
}

.pin-alt-link {
    display: inline-block;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pin-alt-link:hover { color: var(--text-primary); }

.pin-shake { animation: pinShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

@keyframes pinShake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
}

/* === SCROLLBAR =========================================================== */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); background-clip: padding-box; }

/* === UTILITIES =========================================================== */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
[data-theme="light"] .text-success { color: #157a51 !important; }
[data-theme="light"] .text-danger { color: #b03030 !important; }
[data-theme="light"] .text-warning { color: #9a6c1f !important; }
[data-theme="light"] .text-info { color: #1c7d72 !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-primary-brand { color: var(--primary) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.w-full { width: 100%; }
.overflow-auto { overflow: auto; }
.max-h-400 { max-height: 400px; }
