@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    --bg-page: #080a0e;
    --bg-surface: #101319;
    --bg-surface-elevated: #161a22;
    --bg-surface-inset: #0c0e13;
    
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-medium: rgba(255, 255, 255, 0.12);
    --border-highlight: rgba(255, 255, 255, 0.22);
    
    --accent-cyan: #00e5ff;
    --accent-cyan-dim: rgba(0, 229, 255, 0.12);
    --accent-cyan-border: rgba(0, 229, 255, 0.3);
    
    --accent-emerald: #10b981;
    --accent-emerald-dim: rgba(16, 185, 129, 0.12);
    --accent-emerald-border: rgba(16, 185, 129, 0.3);
    
    --accent-amber: #f59e0b;
    --accent-amber-dim: rgba(245, 158, 11, 0.12);
    --accent-amber-border: rgba(245, 158, 11, 0.3);
    
    --accent-crimson: #ef4444;
    --accent-crimson-dim: rgba(239, 68, 68, 0.12);
    --accent-crimson-border: rgba(239, 68, 68, 0.3);

    --text-primary: #f0f3f6;
    --text-secondary: #9aa4b2;
    --text-tertiary: #5d6778;
    
    --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Roboto Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: var(--font-ui);
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background Atmosphere */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1200px;
    max-width: 100vw;
    height: 480px;
    background: radial-gradient(50% 50% at 50% 0%, rgba(0, 229, 255, 0.05) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

/* ==========================================================================
   PORTAL HEADER (Sleek High-Tech Bar)
   ========================================================================== */
.portal-header {
    background: rgba(13, 16, 21, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.85rem 1.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.portal-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.brand-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(16, 185, 129, 0.1));
    border: 1px solid var(--accent-cyan-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-cyan);
    font-size: 1.05rem;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
    flex-shrink: 0;
}

.brand-titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.brand-title .brand-tag {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan-border);
}

.brand-subtitle {
    font-size: 0.74rem;
    color: var(--text-tertiary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.meta-pill.link-online {
    color: var(--accent-emerald);
    border-color: var(--accent-emerald-border);
    background: var(--accent-emerald-dim);
}

.meta-pill.link-offline {
    color: var(--accent-crimson);
    border-color: var(--accent-crimson-border);
    background: var(--accent-crimson-dim);
}

.status-dot-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: breathingGlow 2s infinite ease-in-out;
    flex-shrink: 0;
}

.status-dot-pulse.offline {
    background-color: var(--accent-crimson);
    box-shadow: 0 0 8px var(--accent-crimson);
    animation: none;
}

@keyframes breathingGlow {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.4; }
}

/* ==========================================================================
   MAIN DASHBOARD CONTAINER
   ========================================================================== */
main.dashboard-container {
    max-width: 1280px;
    width: 100%;
    margin: 1.5rem auto 3.5rem;
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==========================================================================
   DIGITAL TWIN STAGE: 3D CAD MODEL & REMOTE DISPLAY
   ========================================================================== */
.digital-twin-stage {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}

/* Twin View Selector Bar */
.twin-view-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 0.45rem 0.65rem;
    gap: 0.75rem;
    flex-wrap: wrap;
    width: 100%;
}

.selector-tabs {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.selector-tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 0.45rem 0.95rem;
    border-radius: 9px;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.2s ease;
}

.selector-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.selector-tab.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan-border);
}

.selector-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.btn-tool-mini {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.35rem 0.7rem;
    border-radius: 7px;
    font-family: var(--font-ui);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.btn-tool-mini:hover, .btn-tool-mini.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-medium);
}

/* ==========================================================================
   CASE HERO STAGE (Interactive 3D Powerbank & Integrated Remote Display)
   ========================================================================== */
.case-hero-stage {
    position: relative;
    width: 100%;
    height: 620px;
    background: radial-gradient(circle at 50% 45%, #181d28 0%, #07090c 100%);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.case-hero-stage.mode-display {
    min-height: 420px;
    height: auto;
    padding: 2.5rem 1.5rem;
    background: radial-gradient(circle at 50% 50%, #131720 0%, #080a0e 100%);
}

#case-3d-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
    z-index: 5;
    transition: none !important;
}

#case-3d-stage:active {
    cursor: grabbing;
}

#case-3d-stage canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    transition: none !important;
}

.case-display-viewport {
    position: relative;
    width: min(100%, 720px);
    aspect-ratio: 320 / 170;
    margin: 0 auto;
    z-index: 20;
    transition: opacity 0.3s ease;
}

.case-display-viewport.docked-offscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 320px !important;
    height: 170px !important;
    opacity: 0.001 !important;
    pointer-events: none !important;
    z-index: -999 !important;
}

.case-hint-badge {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    padding: 0.3rem 0.85rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    z-index: 10;
    transition: all 0.25s ease;
}

.case-hint-badge.badge-active {
    background: rgba(10, 25, 47, 0.88);
    border-color: rgba(56, 189, 248, 0.5);
    color: #38bdf8;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
}

.twin-exit-focus-btn {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #38bdf8;
    padding: 0.45rem 0.95rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 15;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.twin-exit-focus-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.35);
}

/* IMMERSIVE 3D POWERBANK FULLSCREEN OVERLAY (Fills physical display, covers dashboard) */
.case-hero-stage.twin-immersive-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2000 !important;
    background: radial-gradient(circle at 50% 45%, #0e1524 0%, #05070a 100%) !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    transition: none !important;
}

.case-hero-stage.twin-immersive-fullscreen #case-3d-stage {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    transition: none !important;
}

.case-hero-stage.twin-immersive-fullscreen #case-3d-stage canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    transition: none !important;
}

.case-hero-stage.twin-immersive-fullscreen .twin-exit-focus-btn,
.case-hero-stage.twin-immersive-fullscreen #display-back-to-case-btn,
.case-hero-stage.twin-immersive-fullscreen .display-back-btn,
.twin-exit-focus-btn,
.display-back-btn,
#display-back-to-case-btn,
#twin-exit-focus-btn {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.case-hero-stage.twin-immersive-fullscreen .case-hint-badge {
    position: fixed !important;
    top: 24px !important;
    bottom: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 2150 !important;
    font-size: 0.88rem !important;
    padding: 10px 24px !important;
    border-radius: 9999px !important;
    background: rgba(15, 23, 42, 0.90) !important;
    border-color: rgba(56, 189, 248, 0.35) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8) !important;
}

/* Floating Back Button for Fullscreen Remote Display */
.display-back-btn {
    position: fixed !important;
    top: 24px !important;
    left: 24px !important;
    z-index: 3200 !important;
    background: rgba(15, 23, 42, 0.92) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border: 1px solid rgba(56, 189, 248, 0.5) !important;
    color: #f8fafc !important;
    padding: 10px 22px !important;
    border-radius: 9999px !important;
    font-size: 0.90rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.6rem !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85), 0 0 18px rgba(56, 189, 248, 0.3) !important;
}

.display-back-btn:hover {
    background: rgba(30, 41, 59, 0.98) !important;
    border-color: #38bdf8 !important;
    color: #38bdf8 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.9), 0 0 24px rgba(56, 189, 248, 0.45) !important;
}

/* ==========================================================================
   DISPLAY POCKET & EXACT MATHEMATICAL CORNER RADIUS
   LVGL C++ Hardware Spec: 21px corner radius on 320x170px display.
   Horizontal ratio: 21 / 320 = 0.065625 (6.5625%)
   Vertical ratio:   21 / 170 = 0.1235294 (12.3529%)
   Since aspect-ratio is locked at 320 / 170, W * (21/320) == H * (21/170).
   This guarantees a 100% TRUE CIRCULAR CORNER RADIUS of 21px * (W / 320)
   at EVERY size (small, embedded, fullscreen, desktop, mobile)!
   ========================================================================== */
.display-stage-wrap {
    width: 100%;
    height: 100%;
    background-color: #000;
    aspect-ratio: 320 / 170;
    border-radius: 6.5625% / 12.3529% !important;
    border: 2px solid #1c222c;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.85),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 0 14px rgba(0, 0, 0, 0.95);
    overflow: hidden;
    position: relative;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.display-stage-wrap:hover {
    border-color: rgba(0, 229, 255, 0.5);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.9),
        0 0 18px rgba(0, 229, 255, 0.25),
        inset 0 0 14px rgba(0, 0, 0, 0.95);
}

/* Remote LVGL Device Display Canvas inside Pocket */
.device-display {
    width: 100%;
    height: 100%;
    background-color: #000;
    border-radius: 6.5625% / 12.3529% !important;
    position: relative;
    overflow: hidden;
}

#display-click-overlay {
    border-radius: 6.5625% / 12.3529% !important;
}

.device-display iframe {
    border-radius: 6.5625% / 12.3529% !important;
}

/* ==========================================================================
   BENTO GRID ARCHITECTURE (Hero Telemetry & Diagnostics)
   ========================================================================== */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.25rem;
    width: 100%;
}

.bento-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.005) 100%), var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.6);
    position: relative;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease;
}

.bento-card:hover {
    border-color: var(--border-medium);
}

.bento-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    pointer-events: none;
}

/* Card Header */
.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.15rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card-title-group {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.card-icon-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.icon-cyan {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan-border);
}

.icon-emerald {
    background: var(--accent-emerald-dim);
    color: var(--accent-emerald);
    border: 1px solid var(--accent-emerald-border);
}

.icon-amber {
    background: var(--accent-amber-dim);
    color: var(--accent-amber);
    border: 1px solid var(--accent-amber-border);
}

.icon-purple {
    background: rgba(168, 85, 247, 0.12);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.card-heading {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subheading {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status Pill */
.card-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-pill.good {
    background: var(--accent-emerald-dim);
    color: var(--accent-emerald);
    border: 1px solid var(--accent-emerald-border);
}

.card-pill.info {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan-border);
}

.card-pill.warn {
    background: var(--accent-amber-dim);
    color: var(--accent-amber);
    border: 1px solid var(--accent-amber-border);
}

.card-pill.bad {
    background: var(--accent-crimson-dim);
    color: var(--accent-crimson);
    border: 1px solid var(--accent-crimson-border);
}

.card-pill.neutral {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   CARD 1: HERO BATTERY & ENERGY FLOW (Span 7 cols)
   ========================================================================== */
.card-battery-hero {
    grid-column: span 7;
}

.hero-energy-layout {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 1.35rem;
    align-items: center;
    height: 100%;
}

.soc-dial-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-inset);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 1.25rem 1rem;
    position: relative;
    overflow: hidden;
}

.soc-large-val {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.soc-percent-symbol {
    font-size: 1.15rem;
    color: var(--accent-cyan);
    font-weight: 600;
}

.soc-state-pill {
    margin-top: 0.65rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    white-space: nowrap;
}

.soc-state-pill.charging {
    background: var(--accent-emerald-dim);
    color: var(--accent-emerald);
    border: 1px solid var(--accent-emerald-border);
}

.soc-state-pill.discharging {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan-border);
}

.soc-state-pill.standby {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.soc-track-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    margin-top: 0.85rem;
    overflow: hidden;
}

.soc-fill-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-emerald));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.hero-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
}

.metric-tile {
    background: var(--bg-surface-inset);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: border-color 0.2s ease;
    min-width: 0;
}

.metric-tile:hover {
    border-color: var(--border-medium);
}

.metric-caption {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric-number {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.35rem 0 0.15rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.metric-unit {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 2px;
}

.metric-footer {
    font-size: 0.66rem;
    color: var(--text-tertiary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   CARD 2: ZELL-BALANCE & SYMMETRIE (Span 5 cols)
   ========================================================================== */
.card-cell-balance {
    grid-column: span 5;
}

.balance-content {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    height: 100%;
    justify-content: space-between;
}

.cells-compare-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.75rem;
    align-items: center;
}

.cell-box {
    background: var(--bg-surface-inset);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.cell-header-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.cell-voltage {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-progress {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.cell-progress-fill {
    height: 100%;
    background: var(--accent-cyan);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.delta-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0 0.15rem;
    flex-shrink: 0;
}

.delta-tag {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--accent-emerald);
    background: var(--accent-emerald-dim);
    border: 1px solid var(--accent-emerald-border);
    padding: 0.35rem 0.55rem;
    border-radius: 8px;
    white-space: nowrap;
}

.delta-tag.warn {
    color: var(--accent-amber);
    background: var(--accent-amber-dim);
    border-color: var(--accent-amber-border);
}

.balance-status-footer {
    background: var(--bg-surface-inset);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.74rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.balance-status-footer span {
    color: var(--text-secondary);
}

/* ==========================================================================
   CARD 3: THERMISCHES MANAGEMENT (Span 6 cols)
   ========================================================================== */
.card-thermal {
    grid-column: span 6;
}

.thermal-matrix {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
}

.thermal-sensor-card {
    background: var(--bg-surface-inset);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 0.8rem 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.sensor-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.sensor-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sensor-meta {
    font-size: 0.68rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sensor-readout {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
}

.temp-val-display {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.temp-val-display.good { color: var(--accent-emerald); }
.temp-val-display.info { color: var(--accent-cyan); }
.temp-val-display.warn { color: var(--accent-amber); }
.temp-val-display.bad  { color: var(--accent-crimson); }

.thermal-bar {
    width: 55px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.thermal-bar-fill {
    height: 100%;
    background: var(--accent-cyan);
    border-radius: 2px;
}

.thermal-bar-fill.warn { background: var(--accent-amber); }
.thermal-bar-fill.bad { background: var(--accent-crimson); }

/* ==========================================================================
   CARD 4: DUAL-CONTROLLER ARCHITEKTUR (Span 6 cols)
   ========================================================================== */
.card-dual-controller {
    grid-column: span 6;
}

.controller-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.controller-col {
    background: var(--bg-surface-inset);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 0.8rem 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
}

.controller-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.5rem;
    gap: 0.4rem;
}

.ctrl-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctrl-title i {
    color: var(--accent-cyan);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.controller-stat-rows {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.74rem;
    gap: 0.4rem;
}

.stat-k {
    color: var(--text-tertiary);
    font-weight: 500;
    white-space: nowrap;
}

.stat-v {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-v.highlight {
    color: var(--accent-emerald);
}

/* ==========================================================================
   CARD 5: OTA FIRMWARE DOCK (Span 12 cols)
   ========================================================================== */
.card-ota-dock {
    grid-column: span 12;
}

.ota-form-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.15rem;
    align-items: center;
}

.ota-drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    background: var(--bg-surface-inset);
    padding: 1.15rem 1.35rem;
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1.15rem;
    transition: all 0.25s ease;
    min-width: 0;
}

.ota-drop-zone:hover, .ota-drop-zone.has-file {
    border-color: var(--accent-cyan-border);
    background: var(--accent-cyan-dim);
}

.ota-file-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--accent-cyan);
    flex-shrink: 0;
}

.ota-file-texts {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ota-main-msg {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ota-sub-msg {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ota-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.btn-flash-firmware {
    background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
    color: #fff;
    border: none;
    padding: 0.9rem 1.65rem;
    border-radius: 12px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: 0 8px 20px -4px rgba(0, 114, 255, 0.5);
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-flash-firmware:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px -4px rgba(0, 114, 255, 0.7);
    filter: brightness(1.1);
}

.btn-flash-firmware:disabled {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-tertiary);
    cursor: not-allowed;
    box-shadow: none;
    border: 1px solid var(--border-subtle);
}

.ota-toast {
    grid-column: span 2;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.4rem;
}

.ota-toast.success {
    background: var(--accent-emerald-dim);
    color: var(--accent-emerald);
    border: 1px solid var(--accent-emerald-border);
}

.ota-toast.error {
    background: var(--accent-crimson-dim);
    color: var(--accent-crimson);
    border: 1px solid var(--accent-crimson-border);
}

/* ==========================================================================
   EXACT CORNER RADIUS & RESPONSIVE SCALING ON ALL DEVICES
   ========================================================================== */

/* Tablet & Smaller Laptops (<= 1024px) */
@media (max-width: 1024px) {
    .card-battery-hero { grid-column: span 12; }
    .card-cell-balance { grid-column: span 12; }
    .card-thermal { grid-column: span 12; }
    .card-dual-controller { grid-column: span 12; }
    
    .desktop-only {
        display: none !important;
    }
}

/* Tablets & Large Phones (<= 768px) */
@media (max-width: 768px) {
    .portal-header {
        padding: 0.65rem 1rem;
    }
    
    .portal-header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.55rem;
    }

    .header-meta {
        width: 100%;
        justify-content: space-between;
    }

    main.dashboard-container {
        margin: 1rem auto 2.5rem;
        padding: 0 0.75rem;
        gap: 1.15rem;
    }

    .twin-view-selector {
        padding: 0.35rem 0.5rem;
        gap: 0.5rem;
    }

    .selector-tab {
        padding: 0.35rem 0.65rem;
        font-size: 0.74rem;
    }

    .case-hero-stage.mode-twin,
    .case-hero-stage.mode-3d {
        height: 520px;
    }

    .case-hero-stage.mode-twin .case-display-viewport {
        top: 19%;
        left: 0;
        right: 0;
        margin-left: auto;
        margin-right: auto;
        width: clamp(200px, 46vw, 250px);
    }

    .hero-energy-layout {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .hero-metrics-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
    }

    .thermal-matrix {
        grid-template-columns: 1fr;
        gap: 0.55rem;
    }

    .controller-split {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .ota-form-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .btn-flash-firmware {
        width: 100%;
        justify-content: center;
    }

    .ota-toast {
        grid-column: span 1;
    }
}

/* Standard Mobile Phones (<= 480px) */
@media (max-width: 480px) {
    main.dashboard-container {
        margin: 0.65rem auto 2rem;
        padding: 0 0.5rem;
        gap: 0.85rem;
    }

    .case-hero-stage.mode-twin,
    .case-hero-stage.mode-3d {
        height: 480px;
    }

    .case-hero-stage.mode-twin .case-display-viewport {
        top: 18%;
        left: 0;
        right: 0;
        margin-left: auto;
        margin-right: auto;
        width: clamp(185px, 62vw, 235px);
    }

    .bento-card {
        padding: 0.95rem 0.85rem;
        border-radius: 14px;
    }

    .card-top {
        margin-bottom: 0.85rem;
    }

    .card-heading {
        font-size: 0.86rem;
    }

    .card-subheading {
        font-size: 0.66rem;
    }

    .card-icon-badge {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .card-pill {
        font-size: 0.66rem;
        padding: 0.25rem 0.5rem;
    }

    /* Metric Tiles on Small Screen */
    .hero-metrics-grid {
        gap: 0.45rem;
    }

    .metric-tile {
        padding: 0.6rem 0.45rem;
        border-radius: 10px;
        text-align: center;
    }

    .metric-caption {
        font-size: 0.58rem;
        justify-content: center;
    }

    .metric-caption i {
        display: none;
    }

    .metric-number {
        font-size: 1.1rem;
        margin: 0.2rem 0;
    }

    .metric-unit {
        font-size: 0.7rem;
    }

    .metric-footer {
        font-size: 0.54rem;
    }

    /* Cell Balance */
    .cells-compare-row {
        gap: 0.4rem;
    }

    .cell-box {
        padding: 0.65rem 0.5rem;
        border-radius: 9px;
    }

    .cell-header-line {
        font-size: 0.62rem;
    }

    .cell-voltage {
        font-size: 1.1rem;
    }

    .delta-tag {
        font-size: 0.78rem;
        padding: 0.25rem 0.45rem;
        border-radius: 6px;
    }

    .balance-status-footer {
        flex-direction: column;
        align-items: flex-start;
        font-size: 0.68rem;
        gap: 0.35rem;
    }

    /* Thermal Card */
    .thermal-sensor-card {
        padding: 0.65rem 0.75rem;
        border-radius: 9px;
    }

    .sensor-name {
        font-size: 0.76rem;
    }

    .sensor-meta {
        font-size: 0.62rem;
    }

    .temp-val-display {
        font-size: 1.05rem;
    }

    /* Controller Card */
    .controller-col {
        padding: 0.7rem 0.75rem;
        border-radius: 9px;
    }

    .ctrl-title {
        font-size: 0.76rem;
    }

    .stat-item {
        font-size: 0.7rem;
    }

    /* OTA Card */
    .ota-drop-zone {
        padding: 0.85rem 0.95rem;
        gap: 0.75rem;
        border-radius: 10px;
    }

    .ota-file-icon {
        width: 36px;
        height: 36px;
        font-size: 1.15rem;
    }

    .ota-main-msg {
        font-size: 0.8rem;
    }

    .ota-sub-msg {
        font-size: 0.64rem;
    }

    .btn-flash-firmware {
        padding: 0.75rem 1rem;
        font-size: 0.84rem;
        border-radius: 10px;
    }
}

/* Very Small Mobile Phones (<= 360px) */
@media (max-width: 360px) {
    .brand-title {
        font-size: 0.92rem;
    }
    
    .soc-large-val {
        font-size: 2rem;
    }

    .metric-number {
        font-size: 0.98rem;
    }

    .cell-voltage {
        font-size: 1rem;
    }
}

/* ==========================================================================
   ZOOMED 2D DISPLAY ON CASE (Native Crisp LVGL Canvas with Zero Reflections)
   ========================================================================== */
.device-display.zoomed-on-case {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) scale(1) !important;
    width: min(76vw, calc(70vh * (320 / 170))) !important;
    height: calc(min(76vw, calc(70vh * (320 / 170))) * (170 / 320)) !important;
    z-index: 2500 !important;
    border-radius: 20px !important;
    border: 2px solid rgba(56, 189, 248, 0.45) !important;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.95), 0 0 25px rgba(56, 189, 248, 0.25) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    display: block !important;
    overflow: hidden !important;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.device-display.zoomed-on-case iframe {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    display: block !important;
    border-radius: 18px !important;
    pointer-events: auto !important;
}

#screen-zoom-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2450 !important;
    background: transparent !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

#screen-zoom-backdrop.active {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* ==========================================================================
   BATTERY CELL EXTRACTION HUD CARD (Live Telemetry next to 3D Cell)
   ========================================================================== */
.cell-hud-card {
    position: fixed;
    z-index: 2300;
    width: 320px;
    background: rgba(13, 18, 30, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 20px;
    padding: 1.25rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 24px rgba(56, 189, 248, 0.2);
    color: #f8fafc;
    opacity: 0;
    transform: translateY(-50%) scale(0.92);
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    user-select: none;
}

.cell-hud-card.active {
    opacity: 1;
    transform: translateY(-50%) scale(1);
    pointer-events: auto;
}

.cell-hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.cell-hud-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 9999px;
    padding: 0.25rem 0.65rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #38bdf8;
    text-transform: uppercase;
}

.cell-hud-badge .cell-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
}

.cell-hud-close-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.cell-hud-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ffffff;
}

.cell-hud-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0 0 0.2rem 0;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cell-hud-status {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 1.1rem;
}

.cell-hud-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-bottom: 1.1rem;
}

.cell-hud-item {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.65rem 0.75rem;
}

.cell-hud-item.highlight {
    grid-column: span 2;
    background: linear-gradient(135deg, rgba(14, 28, 48, 0.85) 0%, rgba(10, 18, 30, 0.85) 100%);
    border-color: rgba(56, 189, 248, 0.35);
}

.cell-hud-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.cell-hud-item.highlight .cell-hud-label {
    color: #38bdf8;
}

.cell-hud-val {
    font-size: 1.25rem;
    font-weight: 800;
    color: #f8fafc;
}

.cell-hud-val .unit {
    font-size: 0.75rem;
    font-weight: 500;
    color: #94a3b8;
}

.cell-hud-bar-wrap {
    margin-top: 0.45rem;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.cell-hud-bar {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #10b981);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.cell-dock-btn {
    width: 100%;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #38bdf8;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    transition: all 0.2s ease;
}

.cell-dock-btn:hover {
    background: rgba(56, 189, 248, 0.24);
    border-color: #38bdf8;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}


/* Positioning for Left and Right extracted battery cell HUDs */
.cell-hud-card.side-left {
    left: clamp(24px, 5vw, 70px) !important;
    right: auto !important;
    top: 50% !important;
}

.cell-hud-card.side-right {
    right: clamp(24px, 5vw, 70px) !important;
    left: auto !important;
    top: 50% !important;
}

/* Ensure no click overlay intercepts touches on zoomed 2D display */
.device-display.zoomed-on-case #display-click-overlay {
    display: none !important;
    pointer-events: none !important;
}


/* ==========================================================================
   AUTHENTICATION GATE & USER PROFILE (Glassmorphism Cyber Theme)
   ========================================================================== */
.auth-gate-wrapper {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: radial-gradient(circle at 50% 30%, #0d1b2a 0%, #050811 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: rgba(13, 22, 38, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 24px;
    padding: 2.2rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 0 35px rgba(56, 189, 248, 0.15);
    color: #f8fafc;
    animation: authFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.8rem;
}

.auth-brand .brand-icon-box.large {
    width: 64px;
    height: 64px;
    font-size: 1.8rem;
    margin: 0 auto 1rem auto;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(16, 185, 129, 0.15));
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
}

.auth-brand h2 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 0.3rem 0;
    background: linear-gradient(135deg, #ffffff 40%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-brand p {
    font-size: 0.85rem;
    color: #94a3b8;
    margin: 0;
}

.auth-tabs {
    display: flex;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 0.3rem;
    margin-bottom: 1.5rem;
    gap: 0.3rem;
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.auth-tab.active {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    box-shadow: 0 2px 10px rgba(56, 189, 248, 0.15);
}

.auth-alert {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}

.auth-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #6ee7b7;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    text-align: left;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.form-group input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    padding: 0.75rem 0.95rem;
    border-radius: 12px;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
}

.form-group input:focus {
    border-color: #38bdf8;
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.form-hint {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 0.15rem;
}

.form-hint code {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

.btn-auth-submit {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border: 1px solid rgba(56, 189, 248, 0.5);
    color: #ffffff;
    padding: 0.85rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin-top: 0.5rem;
    box-shadow: 0 4px 18px rgba(2, 132, 199, 0.35);
    transition: all 0.2s ease;
}

.btn-auth-submit:hover:not(:disabled) {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    box-shadow: 0 6px 24px rgba(56, 189, 248, 0.45);
    transform: translateY(-1px);
}

.btn-auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-footer-text {
    text-align: center;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 0.8rem;
}

.auth-footer-text a {
    color: #38bdf8;
    text-decoration: none;
    font-weight: 600;
}

.auth-footer-text a:hover {
    text-decoration: underline;
}

/* User Profile Pill in Header */
.user-profile-pill {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 9999px;
    padding: 0.3rem 0.75rem 0.3rem 0.45rem;
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #0284c7, #10b981);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #ffffff;
}

.user-info-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.1;
}

.user-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: #f8fafc;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role-badge {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #38bdf8;
}

.user-role-badge.admin {
    color: #f59e0b;
}

.btn-user-action {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    padding: 0.35rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.btn-user-action:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    color: #ffffff;
}

.btn-user-action.logout:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #fca5a5;
}

/* Device Pair Banner */
.device-pair-banner {
    max-width: 1400px;
    margin: 1rem auto;
    padding: 0 1.5rem;
}

.pair-card {
    background: linear-gradient(135deg, rgba(14, 28, 48, 0.95), rgba(10, 18, 30, 0.95));
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 18px;
    padding: 1.25rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.15);
}

.pair-icon {
    width: 48px;
    height: 48px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #38bdf8;
    flex-shrink: 0;
}

.pair-info {
    flex: 1;
    text-align: left;
}

.pair-info h3 {
    margin: 0 0 0.2rem 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}

.pair-info p {
    margin: 0;
    font-size: 0.85rem;
    color: #94a3b8;
}

.btn-pair-open {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    border: 1px solid rgba(56, 189, 248, 0.45);
    color: #ffffff;
    padding: 0.65rem 1.25rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
    transition: all 0.2s ease;
}

.btn-pair-open:hover {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    transform: translateY(-1px);
}

/* Modal Backdrop & Card */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: authFadeIn 0.25s ease;
}

.modal-card {
    width: 100%;
    max-width: 420px;
    background: rgba(13, 22, 38, 0.95);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 20px;
    padding: 1.75rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
    color: #f8fafc;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #ffffff;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.3rem;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #ffffff;
}

.modal-desc {
    font-size: 0.82rem;
    color: #94a3b8;
    margin: 0 0 1.2rem 0;
    text-align: left;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.4rem;
}

.btn-modal-cancel {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-modal-submit {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #ffffff;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}


/* ==========================================================================
   HAMBURGER BUTTON, SIDE MENU DRAWER & SERVER DIAGNOSTICS MODAL
   ========================================================================== */
.btn-hamburger {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #38bdf8;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.btn-hamburger:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    color: #ffffff;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
    transform: scale(1.05);
}

/* Side Menu Backdrop */
.side-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

/* Side Menu Drawer */
.side-menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 85vw);
    z-index: 9999;
    background: rgba(10, 16, 28, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid rgba(56, 189, 248, 0.25);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.side-menu-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.1rem;
    font-weight: 800;
    color: #ffffff;
}

.drawer-close-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.drawer-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ffffff;
}

.drawer-user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 16px;
    padding: 0.9rem;
    margin: 1.2rem 0;
}

.drawer-avatar {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #0284c7, #10b981);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #ffffff;
    flex-shrink: 0;
}

.drawer-user-details {
    overflow: hidden;
    text-align: left;
}

.drawer-user-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-user-email {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex: 1;
    overflow-y: auto;
}

.drawer-nav-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: #e2e8f0;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.drawer-nav-item:hover, .drawer-nav-item.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    transform: translateX(4px);
    color: #ffffff;
}

.nav-item-icon {
    width: 36px;
    height: 36px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    font-size: 1rem;
    flex-shrink: 0;
}

.nav-item-icon.icon-server {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.nav-item-icon.icon-pair {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.nav-item-title {
    font-size: 0.9rem;
    font-weight: 700;
}

.nav-item-sub {
    font-size: 0.72rem;
    color: #94a3b8;
}

.drawer-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-drawer-logout {
    width: 100%;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-drawer-logout:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #ffffff;
}

/* SERVER MODAL */
.server-modal-card {
    max-width: 640px !important;
    padding: 2rem !important;
}

.server-modal-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-align: left;
}

.server-icon-badge {
    width: 44px;
    height: 44px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #10b981;
    font-size: 1.25rem;
}

.server-sub {
    font-size: 0.78rem;
    color: #94a3b8;
}

.server-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
    margin-top: 1.2rem;
    text-align: left;
}

.server-stat-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1rem 1.15rem;
}

.server-stat-card.highlight {
    background: linear-gradient(135deg, rgba(14, 28, 48, 0.85) 0%, rgba(10, 18, 30, 0.85) 100%);
    border-color: rgba(56, 189, 248, 0.35);
}

.server-stat-card.span-2 {
    grid-column: span 2;
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stat-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    border: 1px solid transparent;
}

.stat-badge.good {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.stat-badge.warn {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.stat-badge.bad {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.stat-badge.info {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.3);
    color: #38bdf8;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: #ffffff;
}

.stat-value .unit {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 600;
}

.stat-sub {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 0.2rem;
}

.stat-bar-wrap {
    margin-top: 0.55rem;
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #10b981);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.server-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

.meta-label {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 600;
}

.meta-val {
    font-size: 0.88rem;
    font-weight: 700;
    color: #ffffff;
    margin-top: 0.15rem;
}

.text-good {
    color: #10b981 !important;
}

/* Docker list */
.docker-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.docker-item {
    display: flex;
    align-items: center;
    background: rgba(10, 16, 28, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    gap: 0.65rem;
    font-size: 0.78rem;
}

.docker-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    flex-shrink: 0;
}

.docker-name {
    font-weight: 700;
    color: #f8fafc;
    font-family: monospace;
}

.docker-role {
    color: #94a3b8;
    flex: 1;
    font-size: 0.72rem;
}

.docker-status {
    color: #10b981;
    font-weight: 600;
    font-size: 0.7rem;
}

.server-loading {
    padding: 3rem 1rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.95rem;
}

@media (max-width: 600px) {
    .server-grid {
        grid-template-columns: 1fr;
    }
    .server-stat-card.span-2 {
        grid-column: span 1;
    }
    .server-meta-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }
}
