/* ═══════════════════════════════════════════════════════════════════════════
   XRC Dashboard — Dark Theme Stylesheet
   Modern IoT dashboard with glass-morphism, smooth animations, and
   responsive card-based layout.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ───────────────────────────────────────────────────────── */

:root {
    /* Colors */
    --bg:               #0c0c1d;
    --bg-gradient:      linear-gradient(145deg, #0c0c1d 0%, #111128 50%, #0d1117 100%);
    --surface:          #161629;
    --surface-raised:   #1c1c36;
    --surface-border:   rgba(255, 255, 255, 0.07);
    --surface-hover:    rgba(255, 255, 255, 0.04);

    --accent:           #4a9eff;
    --accent-glow:      rgba(74, 158, 255, 0.25);
    --accent-subtle:    rgba(74, 158, 255, 0.12);
    --secondary:        #7c5cff;
    --secondary-glow:   rgba(124, 92, 255, 0.25);

    --success:          #22c55e;
    --success-bg:       rgba(34, 197, 94, 0.12);
    --warning:          #f59e0b;
    --warning-bg:       rgba(245, 158, 11, 0.12);
    --danger:           #ef4444;
    --danger-bg:        rgba(239, 68, 68, 0.12);
    --info:             #3b82f6;
    --info-bg:          rgba(59, 130, 246, 0.12);

    --text:             #e4e4e7;
    --text-secondary:   #a1a1aa;
    --text-muted:       #71717a;
    --text-inverse:     #0c0c1d;

    /* Typography */
    --font:             'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono:        'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Spacing */
    --space-1:          4px;
    --space-2:          8px;
    --space-3:          12px;
    --space-4:          16px;
    --space-5:          20px;
    --space-6:          24px;
    --space-8:          32px;
    --space-10:         40px;
    --space-12:         48px;

    /* Radii */
    --radius-sm:        6px;
    --radius:           10px;
    --radius-lg:        16px;
    --radius-xl:        24px;
    --radius-full:      9999px;

    /* Shadows */
    --shadow-sm:        0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow:           0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg:        0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow:      0 0 24px var(--accent-glow);

    /* Transitions */
    --ease:             cubic-bezier(0.4, 0, 0.2, 1);
    --transition:       150ms var(--ease);
    --transition-slow:  300ms var(--ease);

    /* Layout */
    --navbar-h:         56px;
    --max-width:        1400px;
}


/* ── Reset & Base ────────────────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    background: var(--bg-gradient);
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: #6cb3ff; }

::selection { background: var(--accent-subtle); color: var(--text); }

input, button, textarea, select { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }


/* ── Navbar ──────────────────────────────────────────────────────────────── */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-h);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    background: rgba(12, 12, 29, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--surface-border);
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
}

.brand-text { color: var(--text); }
.brand-accent { color: var(--accent); }
.logo { flex-shrink: 0; }

.navbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.connection-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-4);
    border-radius: var(--radius-full);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition-slow);
}

.status-dot--connected { background: var(--success); box-shadow: 0 0 8px rgba(34, 197, 94, 0.6); }
.status-dot--connecting { background: var(--warning); animation: pulse 1.5s infinite; }
.status-dot--error { background: var(--danger); }
.status-dot--waiting { background: var(--text-muted); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.navbar-actions { display: flex; align-items: center; gap: var(--space-3); }


/* ── User Menu ───────────────────────────────────────────────────────────── */

.user-menu { position: relative; }

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
}

.user-menu-btn:hover {
    background: var(--surface-hover);
    border-color: var(--surface-border);
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
}

.username {
    font-size: 13px;
    font-weight: 500;
}

.chevron {
    transition: transform var(--transition);
    color: var(--text-muted);
}

.user-menu.open .chevron { transform: rotate(180deg); }

.dropdown-menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: 180px;
    background: var(--surface-raised);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: var(--space-1) 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition);
    z-index: 200;
}

.user-menu.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    color: var(--text);
    font-size: 13px;
    transition: background var(--transition);
}

.dropdown-item:hover { background: var(--surface-hover); color: var(--text); }
.dropdown-item--danger { color: var(--danger); }
.dropdown-item--danger:hover { background: var(--danger-bg); color: var(--danger); }

.dropdown-divider {
    height: 1px;
    background: var(--surface-border);
    margin: var(--space-1) 0;
}

.dropdown-label {
    display: block;
    padding: var(--space-1) var(--space-4);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
}


/* ── Main Content ────────────────────────────────────────────────────────── */

.main-content {
    padding-top: calc(var(--navbar-h) + var(--space-6));
    padding-left: var(--space-6);
    padding-right: var(--space-6);
    padding-bottom: var(--space-8);
    max-width: var(--max-width);
    margin: 0 auto;
}


/* ── Flash Messages ──────────────────────────────────────────────────────── */

.flash-messages {
    margin-bottom: var(--space-6);
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    margin-bottom: var(--space-2);
    font-size: 13px;
    animation: slideDown 0.3s var(--ease);
}

.flash--success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.flash--danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.flash--warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.flash--info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(59,130,246,0.2); }

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    padding: 0 var(--space-1);
    opacity: 0.6;
    transition: opacity var(--transition);
}
.flash-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ── Connection Panel ────────────────────────────────────────────────────── */

.connection-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - var(--navbar-h) - var(--space-12));
}

.connection-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    padding: var(--space-10);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.connection-icon {
    margin-bottom: var(--space-6);
    animation: radar 3s ease-in-out infinite;
}

@keyframes radar {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

.connection-card h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
}

.connection-subtitle {
    color: var(--text-muted);
    margin-bottom: var(--space-8);
    font-size: 14px;
}

.connection-form {
    text-align: left;
}


/* ── Forms ────────────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: var(--space-5);
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control,
.connection-form input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-raised);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    transition: all var(--transition);
    outline: none;
}

.form-control:focus,
.connection-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-control::placeholder,
.connection-form input::placeholder {
    color: var(--text-muted);
}

.form-error {
    display: block;
    color: var(--danger);
    font-size: 12px;
    margin-top: var(--space-1);
}

.form-hint {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: var(--space-1);
}

.optional { color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }


/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    white-space: nowrap;
    text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn--primary:hover {
    background: #5dadff;
    border-color: #5dadff;
    box-shadow: var(--shadow-glow);
}

.btn--outline {
    background: transparent;
    color: var(--text);
    border-color: var(--surface-border);
}
.btn--outline:hover {
    background: var(--surface-hover);
    border-color: var(--text-muted);
}

.btn--danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}
.btn--danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
}

.btn--sm { padding: var(--space-1) var(--space-3); font-size: 12px; }
.btn--lg { padding: var(--space-3) var(--space-6); font-size: 15px; }
.btn--full { width: 100%; }
.btn--icon { padding: var(--space-2); }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}


/* ── Dashboard ───────────────────────────────────────────────────────────── */

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.dashboard-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.dashboard-actions {
    display: flex;
    gap: var(--space-3);
}

.plugin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-6);
}


/* ── Plugin Cards ────────────────────────────────────────────────────────── */

.plugin-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-slow);
    animation: cardEnter 0.4s var(--ease) both;
}

.plugin-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow);
}

@keyframes cardEnter {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--surface-border);
}

.card-icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-raised);
    border-radius: var(--radius);
}

.card-title-group { flex: 1; min-width: 0; }

.card-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.card-status { flex-shrink: 0; }

.card-body {
    padding: var(--space-5);
}


/* ── Sensor Card ─────────────────────────────────────────────────────────── */

.sensor-readings {
    display: flex;
    gap: var(--space-6);
    justify-content: center;
}

.sensor-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.gauge-svg {
    width: 120px;
    height: 120px;
}

.gauge-fill {
    transition: stroke-dashoffset 0.8s var(--ease), stroke 0.8s var(--ease);
}

.gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    margin-top: -4px;
}

.gauge-number {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    display: block;
    line-height: 1;
    transition: color var(--transition-slow);
}

.gauge-unit {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.gauge-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: var(--space-2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sensor-footer {
    text-align: center;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--surface-border);
}

.last-update {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Temperature color coding */
.temp-cold .gauge-number  { color: #60a5fa; }
.temp-cool .gauge-number  { color: #22d3ee; }
.temp-warm .gauge-number  { color: var(--warning); }
.temp-hot  .gauge-number  { color: var(--danger); }


/* ── Servo Card ──────────────────────────────────────────────────────────── */

.servo-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5);
}

.steering-wheel-container {
    position: relative;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.steering-wheel-container:active { cursor: grabbing; }

.steering-wheel {
    filter: drop-shadow(0 0 12px var(--accent-glow));
    transition: filter var(--transition);
}

.steering-wheel:hover {
    filter: drop-shadow(0 0 20px var(--accent-glow));
}

.servo-arc {
    /* No CSS transition — arc length is set via setAttribute (SVG attr),
       which doesn't trigger CSS transitions. This keeps the arc endpoint
       perfectly in sync with the indicator line (also set via setAttribute). */
}

.knob-indicator {
    /* No CSS transition — rotation is driven via SVG setAttribute('transform','rotate(a cx cy)')
       which doesn't trigger CSS transitions. CSS transform-box quirks on zero-width <line>
       elements are avoided entirely by using the SVG attribute instead. */
}

.servo-value-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.servo-position {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent);
}

.servo-info {
    width: 100%;
}

.servo-range {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.range-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.range-value {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

/* Custom range slider */
.servo-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--surface-border);
    border-radius: var(--radius-full);
    outline: none;
    transition: background var(--transition);
}

.servo-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 3px solid var(--surface);
    box-shadow: 0 0 8px var(--accent-glow);
    transition: all var(--transition);
}

.servo-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 16px var(--accent-glow);
}

.servo-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 3px solid var(--surface);
    box-shadow: 0 0 8px var(--accent-glow);
}


/* ── Chat Card ───────────────────────────────────────────────────────────── */

.chat-card { min-height: 400px; display: flex; flex-direction: column; }
.chat-card .card-body { flex: 1; display: flex; flex-direction: column; padding: 0; }

.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-5);
    max-height: 300px;
    scroll-behavior: smooth;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    color: var(--text-muted);
    gap: var(--space-2);
}

.chat-bubble {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius) var(--radius) var(--radius) var(--space-1);
    margin-bottom: var(--space-2);
    background: var(--surface-raised);
    animation: bubbleIn 0.2s var(--ease);
}

.chat-bubble--self {
    align-self: flex-end;
    background: var(--accent-subtle);
    border-radius: var(--radius) var(--radius) var(--space-1) var(--radius);
}

.chat-bubble-sender {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2px;
}

.chat-bubble--self .chat-bubble-sender {
    color: var(--text-muted);
    text-align: right;
}

.chat-bubble-text {
    font-size: 13px;
    word-break: break-word;
}

.chat-bubble-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: var(--space-1);
    font-family: var(--font-mono);
}

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-input-form {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--surface-border);
}

.chat-input {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    background: var(--surface-raised);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
}

.chat-input:focus {
    border-color: var(--accent);
}

.chat-send-btn {
    flex-shrink: 0;
}


/* ── Camera Card ─────────────────────────────────────────────────────────── */

.camera-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--surface-raised);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-3);
}

.camera-stream {
    display: none;   /* shown by JS when frames arrive */
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    color: var(--text-muted);
}

.camera-placeholder-text {
    font-size: 13px;
}

.camera-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.camera-resolution {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.camera-fullscreen-btn:hover { color: var(--accent); }


/* ── Toast Notifications ─────────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-2);
    z-index: 300;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    background: var(--surface-raised);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    pointer-events: all;
    animation: toastIn 0.3s var(--ease);
    min-width: 260px;
    max-width: 400px;
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--info    { border-left: 3px solid var(--info); }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-text { flex: 1; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}


/* ── Auth Pages ──────────────────────────────────────────────────────────── */

.auth-page {
    background: var(--bg-gradient);
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: var(--space-6);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    padding: var(--space-10);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.auth-logo { margin-bottom: var(--space-4); }

.auth-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-1);
}

.auth-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-form .form-group { margin-bottom: var(--space-5); }

.auth-form .btn { margin-top: var(--space-3); }

.auth-footer {
    text-align: center;
    margin-top: var(--space-6);
    font-size: 13px;
    color: var(--text-muted);
}


/* ── Settings Page ───────────────────────────────────────────────────────── */

.settings-page { max-width: 900px; margin: 0 auto; }

.settings-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.settings-topbar .page-title { margin-bottom: 0; }

.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: var(--space-6);
    letter-spacing: -0.02em;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: var(--space-6);
}

.settings-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--surface-border);
}

.settings-card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.settings-card-body {
    padding: var(--space-5);
}

.settings-form h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: var(--space-6) 0 var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--surface-border);
}

.settings-form h3:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.profile-name { font-weight: 600; font-size: 15px; }
.profile-meta { font-size: 12px; color: var(--text-muted); }


/* ── Badges ──────────────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-3);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge--default  { background: var(--surface-raised); color: var(--text-muted); }
.badge--primary  { background: var(--accent-subtle);  color: var(--accent); }
.badge--accent   { background: var(--secondary-glow); color: var(--secondary); }
.badge--success  { background: var(--success-bg);     color: var(--success); }


/* ── Scrollbar ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }


/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .navbar { padding: 0 var(--space-3); }
    .username { display: none; }
    .main-content { padding-left: var(--space-3); padding-right: var(--space-3); }
    .plugin-grid { grid-template-columns: 1fr; }
    .sensor-readings { flex-direction: column; align-items: center; }
    .connection-card { padding: var(--space-6); }
    .settings-grid { grid-template-columns: 1fr; }
    .dashboard-header { flex-direction: column; gap: var(--space-3); align-items: flex-start; }
}

@media (max-width: 480px) {
    .auth-card { padding: var(--space-6); }
    .connection-card { max-width: 100%; border-radius: var(--radius-lg); }
}


/* ══════════════════════════════════════════════════════════════════════════
   MULTI-SERVER PANEL
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Servers section ────────────────────────────────────────────────────── */
.servers-panel {
    padding: var(--space-4) 0 var(--space-6);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-6);
}

.servers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.servers-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── Add / Edit form panel ──────────────────────────────────────────────── */
.server-form-panel {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
}

.server-form-panel h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-4) 0;
}

.server-form-grid {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.server-form-grid .form-group {
    margin-bottom: 0;
}

.server-form-full {
    margin-bottom: var(--space-4);
}

.server-form-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

.server-form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.server-form-check label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

/* ── Connections list ───────────────────────────────────────────────────── */
.connections-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.connections-empty {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.connections-empty p:first-child {
    font-size: 1.5rem;
    margin-bottom: var(--space-2);
}

/* ── Connection row ─────────────────────────────────────────────────────── */
.connection-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-raised);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: border-color 0.15s ease, background 0.15s ease;
    position: relative;
    overflow: hidden;
}

.connection-row:hover {
    border-color: var(--border-strong, rgba(255,255,255,0.18));
    background: var(--surface-overlay, rgba(255,255,255,0.04));
}

.connection-row.conn-connected {
    border-color: rgba(34, 197, 94, 0.35);
}

.conn-color-bar {
    width: 3px;
    border-radius: 999px;
    align-self: stretch;
    min-height: 36px;
    flex-shrink: 0;
}

.conn-row-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conn-row-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conn-row-host {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conn-row-status {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    flex-shrink: 0;
}

.conn-row-status.status-connected {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success, #22c55e);
}

.conn-row-status.status-connecting {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.conn-row-status.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error, #ef4444);
}

.conn-row-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-shrink: 0;
}

.conn-row-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.conn-row-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    min-width: 0;
}

/* ── Ghost / danger-hover buttons ───────────────────────────────────────── */
.btn--ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    line-height: 1.4;
}

.btn--ghost:hover {
    background: rgba(255,255,255,0.06);
    border-color: var(--border-strong, rgba(255,255,255,0.18));
    color: var(--text-primary);
}

.btn--ghost.btn--danger-hover:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--error, #ef4444);
}

.btn--ghost:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Server badge on plugin cards ───────────────────────────────────────── */
.server-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px 3px 6px;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    font-size: 0.68rem;
    font-weight: 500;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.server-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.server-badge-name {
    color: rgba(255,255,255,0.75);
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* ── Plugin card server-badge placement ─────────────────────────────────── */
.card .server-badge,
.plugin-card .server-badge {
    margin-top: var(--space-3);
}

/* ── Plugin grid empty state ────────────────────────────────────────────── */
.plugins-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-10, 3.5rem) var(--space-4);
    color: var(--text-muted);
    text-align: center;
}

.plugins-empty-icon {
    font-size: 2.5rem;
    line-height: 1;
    opacity: 0.5;
}

.plugins-empty p {
    font-size: 0.875rem;
    max-width: 280px;
    line-height: 1.5;
    margin: 0;
}

/* ── Dashboard section heading ──────────────────────────────────────────── */
.dashboard-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.dashboard-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── Responsive overrides ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    .server-form-grid { grid-template-columns: 1fr 1fr; }
    .conn-row-actions { opacity: 1; }
}

@media (max-width: 560px) {
    .server-form-grid { grid-template-columns: 1fr; }
    .connection-row { flex-wrap: wrap; }
    .conn-row-actions { width: 100%; justify-content: flex-end; }
}
