/* IRIS Gateway Manager - Firmware Hub inspired design */

:root {
    --bg-primary: #09151a;
    --bg-secondary: #15262d;
    --bg-tertiary: #1c3641;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent: #00d2ff;
    --accent-secondary: #3a7bd5;
    --accent-hover: #00e5ff;
    --accent-dim: rgba(0, 210, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border: rgba(255, 255, 255, 0.1);
    --success: #2ed573;
    --warning: #ffa502;
    --error: #ff4757;
    --info: #3b82f6;
}

/* Light Theme */
body.light-theme {
    --bg-primary: #f0f4f8;
    --bg-secondary: #e2e8f0;
    --bg-tertiary: #cbd5e1;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --glass-border: rgba(0, 0, 0, 0.1);
    --accent: #0088cc;
    --accent-secondary: #2563eb;
    --accent-hover: #0099dd;
    --accent-dim: rgba(0, 136, 204, 0.1);
    --text-primary: #1e293b;
    --text-secondary: rgba(30, 41, 59, 0.8);
    --text-muted: rgba(30, 41, 59, 0.5);
    --border: rgba(0, 0, 0, 0.1);
}

body.light-theme {
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary), var(--bg-tertiary));
}

body.light-theme .bg-animation {
    opacity: 0.3;
}

body.light-theme .gateway-card {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

body.light-theme header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
}

body.light-theme .btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(0, 0, 0, 0.15);
}

body.light-theme .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    border-color: rgba(0, 0, 0, 0.2);
}

/* ============================================
   BASE UTILITY CLASSES
   Konsolidierte Basis-Klassen für wiederverwendbare Styles
   ============================================ */

/* Flex Utilities */
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; }
.flex-column { display: flex; flex-direction: column; }
.flex-wrap { display: flex; flex-wrap: wrap; }

/* Gap Utilities */
.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }
.gap-lg { gap: 1rem; }
.gap-xl { gap: 2rem; }

/* Padding Utilities */
.pad-sm { padding: 0.5rem; }
.pad-md { padding: 0.75rem 1rem; }
.pad-lg { padding: 1rem 1.5rem; }
.pt-sm { padding-top: 0.5rem; }

/* Margin Utilities */
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 0.75rem; }
.mt-lg { margin-top: 1rem; }

/* Text Utilities */
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-bold { font-weight: 600; }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }

/* Alignment Utilities */
.flex-center-all { display: flex; align-items: center; justify-content: center; }

/* Mobile Responsive Utilities */
@media (max-width: 768px) {
    .flex-wrap-mobile { flex-wrap: wrap; }
}

/* ============================================
   BASE COMPONENT CLASSES
   Gemeinsame Styles für Section-Container und -Header
   ============================================ */

/* Base Container - für alle Section-Container */
.section-container-base,
.firmware-container,
.pdolog-container,
.coredump-container,
.documents-container,
.kanban-container,
.modbus-container,
.help-container,
.notifications-container,
.admin-container,
.groups-container,
.influxdb-container,
.server-logs-container,
.mail-settings-container,
.users-container,
.system-info-container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

/* Base Header - für alle Section-Header */
.section-header-base,
.firmware-header,
.pdolog-header,
.coredump-header,
.documents-header,
.kanban-header,
.modbus-header,
.help-header,
.notifications-header,
.admin-header,
.groups-header,
.influxdb-header,
.server-logs-header,
.mail-settings-header,
.users-header,
.system-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

/* Base Header Title */
.section-header-base h2,
.firmware-header h2,
.pdolog-header h2,
.coredump-header h2,
.documents-header h2,
.kanban-header h2,
.modbus-header h2,
.help-header h2,
.notifications-header h2,
.admin-header h2,
.groups-header h2,
.influxdb-header h2,
.server-logs-header h2,
.mail-settings-header h2,
.users-header h2,
.system-info-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Base Item/Card - für Listen-Elemente */
.item-base {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: background 0.2s ease;
}

.item-base:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Base Input Focus State */
.input-focus-base:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.1);
}

/* ============================================
   END BASE CLASSES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary), var(--bg-tertiary));
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

/* Animated Chip Background */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

/* Chip/Microcontroller SVG Styles */
.chip-element {
    position: absolute;
    opacity: 0.12;
}

.chip-element svg {
    width: 100%;
    height: 100%;
}

.chip-element .chip-outline {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.5;
}

.chip-element .chip-inner {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1;
}

.chip-element .chip-pins {
    stroke: var(--accent);
    stroke-width: 1.5;
    stroke-linecap: round;
}

.chip-element .chip-arrow {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chip-element .orbit-ring {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1;
}

.chip-element .orbit-dot {
    fill: var(--accent);
}

.chip-element .circuit-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1;
    stroke-linecap: round;
}

/* Chip 1 - Large main chip top-left */
.chip-1 {
    top: 5%;
    left: 3%;
    width: 280px;
    height: 280px;
    animation: float-chip 25s infinite ease-in-out, pulse-glow 8s infinite ease-in-out;
}

/* Chip 2 - Medium chip bottom-right */
.chip-2 {
    bottom: 10%;
    right: 5%;
    width: 220px;
    height: 220px;
    animation: float-chip 30s infinite ease-in-out reverse, pulse-glow 10s infinite ease-in-out 2s;
}

/* Chip 3 - Small chip with rotating orbit top-right */
.chip-3 {
    top: 15%;
    right: 10%;
    width: 180px;
    height: 180px;
    animation: rotate-slow 40s infinite linear;
}

/* Chips 4-6 removed to reduce visual clutter */

/* Data flow particles */
.data-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.4;
    box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent);
    animation: data-flow 8s infinite linear;
}

/* 3 chips + 3 data particles = children 4, 5, 6 */
.data-particle:nth-child(4) { left: 5%; top: 30%; animation-delay: 0s; }
.data-particle:nth-child(5) { left: 15%; top: 60%; animation-delay: 1s; }
.data-particle:nth-child(6) { right: 20%; top: 25%; animation-delay: 2s; }

/* Circuit trace lines (reduced to 3) */
.circuit-trace {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.15;
    animation: trace-pulse 4s infinite ease-in-out;
}

.trace-1 { top: 20%; left: 0; width: 30%; animation-delay: 0s; }
.trace-2 { top: 40%; right: 0; width: 25%; animation-delay: 1s; }
.trace-3 { bottom: 30%; left: 0; width: 35%; animation-delay: 2s; }

@keyframes float-chip {
    0%, 100% { transform: translateY(0) translateX(0); }
    25% { transform: translateY(-15px) translateX(8px); }
    50% { transform: translateY(-8px) translateX(-12px); }
    75% { transform: translateY(-20px) translateX(5px); }
}

@keyframes rotate-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.1; filter: drop-shadow(0 0 5px transparent); }
    50% { opacity: 0.18; filter: drop-shadow(0 0 15px rgba(0, 210, 255, 0.3)); }
}

@keyframes data-flow {
    0% { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
    10% { opacity: 0.6; }
    50% { transform: translateY(-150px) translateX(80px) scale(0.8); opacity: 0.4; }
    90% { opacity: 0.6; }
    100% { transform: translateY(-300px) translateX(160px) scale(0.5); opacity: 0; }
}

@keyframes trace-pulse {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.25; }
}

/* ============================================
   Header - Komplett neu
   ============================================ */
header {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

/* Logo - immer links */
.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    flex-shrink: 0;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
    flex-shrink: 0;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

/* Navigation - Mitte, zentriert sich selbst */
.header-content .main-nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* Status-Bar mit User-Menu - immer rechts */
.status-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    margin-left: auto;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Header Mobile */
@media (max-width: 768px) {
    .header-content {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .logo-text {
        display: none;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .logo-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* Main Content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
    overflow-x: hidden;
}

.intro-section {
    text-align: center;
    margin-bottom: 3rem;
}

.intro-section h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.intro-section p {
    color: var(--text-secondary);
    font-size: 1.125rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Gateways Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Gateway toolbar - desktop: single row */
.gateway-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.gateway-toolbar .search-box {
    min-width: 140px;
    max-width: 200px;
}

.gateway-toolbar .view-toggle {
    margin-left: auto;
}

/* Status Toggle (Multi-Switch) */
.status-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2px;
    gap: 2px;
}

.status-toggle-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.status-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.status-toggle-btn.active {
    background: var(--accent);
    color: #000;
    box-shadow: 0 2px 4px rgba(0, 210, 255, 0.3);
}

.light-theme .status-toggle-btn.active {
    color: #fff;
}

/* Toolbar select styling */
.toolbar-select {
    height: 34px;
    padding: 0 1.75rem 0 0.5rem;
    font-size: 0.8125rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c7086' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.toolbar-select option {
    background-color: #1e1e2e;
    color: #cdd6f4;
    padding: 0.5rem;
}

.light-theme .toolbar-select option {
    background-color: #ffffff;
    color: #4c4f69;
}

.toolbar-select:hover {
    border-color: var(--accent);
}

.toolbar-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.1);
}

/* Select actions compact */
.gateway-toolbar .select-actions {
    display: flex;
    gap: 0.25rem;
}

.gateway-toolbar .select-actions .btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    height: 34px;
    min-width: 34px;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.gateway-count {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* View Toggle Buttons */
.view-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.view-btn {
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.view-btn.active {
    background: var(--accent);
    color: #fff;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.375rem 0.75rem;
    min-width: 200px;
    max-width: 300px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.1);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    min-width: 0;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.125rem;
    border-radius: 0.25rem;
    transition: color 0.2s ease, background 0.2s ease;
}

.search-clear:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Filter Buttons */
.filter-group {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.25rem;
    border-radius: 0.5rem;
    border: 1px solid var(--glass-border);
}

.filter-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--glass-border);
}

.filter-btn.active {
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent));
    color: #ffffff;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 210, 255, 0.2);
}

/* Online/Offline specific filter button styles */
.filter-btn[data-filter="online"].active {
    background: linear-gradient(90deg, var(--success), rgba(16, 185, 129, 0.5));
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.filter-btn[data-filter="offline"].active {
    background: linear-gradient(90deg, var(--error), rgba(239, 68, 68, 0.5));
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
}

/* Group Filter Dropdown */
.group-filter-wrapper {
    position: relative;
}

.group-filter-select {
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-size: 0.875rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a6adc8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    min-width: 140px;
}

.group-filter-select:hover {
    border-color: var(--accent);
    background-color: rgba(255, 255, 255, 0.06);
}

.group-filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.2);
}

.group-filter-select option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.5rem;
}

/* Select Actions */
.select-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Gateway Sort Group */
.gateway-sort-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--glass-border);
}

.gateway-sort-group .sort-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 0.25rem;
}

.gateway-sort-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gateway-sort-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--glass-border);
}

.gateway-sort-btn.active {
    background: rgba(0, 210, 255, 0.15);
    color: var(--accent);
    border-color: var(--accent);
}

.gateway-sort-btn .sort-icon {
    opacity: 0.5;
    transition: opacity 0.2s;
}

.gateway-sort-btn.active .sort-icon {
    opacity: 1;
}

/* Bulk Action Bar */
.bulk-action-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0, 210, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--accent);
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    animation: slideDown 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 210, 255, 0.1);
}

.bulk-action-bar.active {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bulk-action-bar #selectedCount {
    font-weight: 500;
    color: var(--accent);
}

.bulk-actions {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.bulk-actions .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.gateway-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Gateway Table View */
.gateway-table-container {
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: visible;
}

.gateway-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.gateway-table thead {
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.gateway-table th {
    padding: 0.5rem 0.625rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: 0.8rem;
}

.gateway-table th.th-select {
    width: 40px;
    text-align: center;
}

.gateway-table th.th-sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.gateway-table th.th-sortable:hover {
    color: var(--accent);
}

.gateway-table th.th-sortable::after {
    content: '';
    display: inline-block;
    margin-left: 0.5rem;
    opacity: 0.3;
}

.gateway-table th.th-sortable.sort-asc::after {
    content: '▲';
    opacity: 1;
    color: var(--accent);
}

.gateway-table th.th-sortable.sort-desc::after {
    content: '▼';
    opacity: 1;
    color: var(--accent);
}

/* Table Filter Row */
.gateway-table .th-filters th {
    padding: 0.35rem 0.5rem;
    background: var(--bg-tertiary);
}

.gateway-table .th-filters input,
.gateway-table .th-filters select {
    width: 100%;
    padding: 0.375rem 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    color: var(--text-primary);
    font-size: 0.75rem;
}

.gateway-table .th-filters input:focus,
.gateway-table .th-filters select:focus {
    outline: none;
    border-color: var(--accent);
}

.gateway-table .th-filters input::placeholder {
    color: var(--text-muted);
}

.gateway-table .th-filters select {
    cursor: pointer;
}

/* Select2 styling for table filters */
.gateway-table .th-filters .select2-container {
    width: 100% !important;
}

.gateway-table .th-filters .select2-container--default .select2-selection--single {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    height: auto;
    min-height: 28px;
}

.gateway-table .th-filters .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary);
    font-size: 0.75rem;
    line-height: 26px;
    padding-left: 0.5rem;
    padding-right: 2.5rem;
}

.gateway-table .th-filters .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--text-muted);
}

.gateway-table .th-filters .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 26px;
    right: 4px;
}

.gateway-table .th-filters .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--text-muted) transparent transparent transparent;
}

.gateway-table .th-filters .select2-container--default .select2-selection--single .select2-selection__clear {
    color: var(--text-muted);
    font-size: 1rem;
    position: absolute;
    right: 45px;
    top: 50%;
    transform: translateY(-50%);
}

.gateway-table .th-filters .select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: var(--error);
}

.gateway-table .th-filters .select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--accent);
}

/* OTA indicator in table */
.table-ota-indicator {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent);
    color: white;
    animation: pulse-ota 1.5s ease-in-out infinite;
}

.table-ota-indicator.success {
    background: var(--success);
    animation: none;
}

.table-ota-indicator.error {
    background: var(--error);
    animation: none;
}

.table-ota-indicator.rebooting {
    background: var(--warning);
    animation: spin-ota 1s linear infinite;
}

@keyframes pulse-ota {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes spin-ota {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ota-cell {
    text-align: center;
    white-space: nowrap;
}

.gateway-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}

.gateway-table tbody tr:hover {
    background: var(--bg-secondary);
}

.gateway-table tbody tr.selected {
    background: rgba(0, 210, 255, 0.1);
}

.gateway-table tbody tr.offline {
    opacity: 0.7;
}

.gateway-table td {
    padding: 0.5rem 0.625rem;
    vertical-align: middle;
    font-size: 0.8rem;
}

.gateway-table td.td-select {
    text-align: center;
}

.gateway-table .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
}

.gateway-table .status-badge.online,
.gateway-table .status-badge.status-online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.gateway-table .status-badge.offline,
.gateway-table .status-badge.status-offline {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.gateway-table .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.gateway-table .status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.gateway-table .status-dot.offline {
    background: var(--error);
}

.gateway-table .mac-address {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.gateway-table .mac-col {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.gateway-table .ip-link {
    color: var(--accent);
    text-decoration: none;
}

.gateway-table .ip-link:hover {
    text-decoration: underline;
}

.gateway-table .version-cell {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
}

.gateway-table .version-cell.outdated {
    color: var(--warning);
}

.gateway-table .actions-cell {
    display: flex;
    gap: 0.375rem;
}

.gateway-table .actions-cell .btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
}

.gateway-table .alias-cell {
    max-width: 150px;
}

.gateway-table .alias-input {
    width: 100%;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 0.25rem;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.gateway-table .alias-input:focus {
    border-color: var(--accent);
    outline: none;
}

.gateway-table .alias-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Numeric columns */
.gateway-table th.th-numeric {
    text-align: right;
}

.gateway-table .numeric-col {
    text-align: right;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* SOC value colors */
.gateway-table .soc-value {
    font-weight: 600;
}

/* Power indicators */
.gateway-table .power-charge {
    color: var(--success);
}

.gateway-table .power-discharge {
    color: var(--warning);
}

/* Temperature indicators */
.gateway-table .temp-cold {
    color: #3b82f6;
}

.gateway-table .temp-hot {
    color: var(--error);
}

/* OTA column */
.gateway-table .ota-col {
    width: 40px;
    text-align: center;
}

/* Alias input in table */
.gateway-table .alias-input-table {
    width: 100%;
    min-width: 80px;
    max-width: 120px;
    padding: 0.2rem 0.375rem;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 0.25rem;
    color: var(--text-primary);
    font-size: 0.75rem;
    transition: border-color 0.2s ease;
}

.gateway-table .alias-input-table:focus {
    border-color: var(--accent);
    outline: none;
}

.gateway-table .alias-input-table::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: 1rem;
    border: 2px dashed var(--border);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.empty-state span {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Gateway View Title */
.gateway-view-title {
    margin-bottom: 1rem;
}

.gateway-view-title h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gateway-view-title h2::before {
    content: '';
    width: 4px;
    height: 1.25rem;
    background: var(--accent);
    border-radius: 2px;
}

/* Gateway Card */
.gateway-card {
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 1rem;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Online/Offline status indicator - top gradient bar */
.gateway-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--error), rgba(239, 68, 68, 0.3));
    transition: background 0.3s ease;
}

.gateway-card[data-online="true"]::before {
    background: linear-gradient(90deg, var(--success), rgba(16, 185, 129, 0.3));
}

/* OTA Update in progress - orange gradient bar (overrides online/offline) */
.gateway-card.ota-active::before {
    background: linear-gradient(90deg, var(--warning), rgba(245, 158, 11, 0.3));
}

.gateway-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 210, 255, 0.15);
}

.gateway-card.selected {
    border-color: var(--accent);
    background: rgba(0, 210, 255, 0.08);
}

.gateway-card.highlight-pulse {
    animation: card-highlight-pulse 0.5s ease-out 3;
    border-color: var(--accent);
}

@keyframes card-highlight-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(0, 210, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0);
    }
}

/* Stale gateway card - last update > 5 minutes */
.gateway-card.stale {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.08);
}

.gateway-card.stale::before {
    background: linear-gradient(90deg, var(--warning), rgba(245, 158, 11, 0.3)) !important;
}

/* Last seen display in card header */
.gateway-last-seen {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.gateway-last-seen svg {
    opacity: 0.7;
}

.gateway-last-seen.stale {
    color: var(--warning);
}

.gateway-last-seen.stale svg {
    opacity: 1;
}

/* Gateway Selection Checkbox */
.gateway-select-checkbox {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    cursor: pointer;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.gateway-select-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.gateway-select-checkbox .checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gateway-select-checkbox:hover .checkmark {
    border-color: var(--accent);
}

.gateway-select-checkbox input:checked ~ .checkmark {
    background: var(--accent);
    border-color: var(--accent);
}

.gateway-select-checkbox input:checked ~ .checkmark::after {
    content: '';
    width: 5px;
    height: 10px;
    border: solid var(--bg-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.gateway-card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    position: relative;
}

/* Position checkbox absolutely so text starts at left edge */
.gateway-card-header .gateway-select-checkbox {
    position: absolute;
    right: 1rem;
    top: 0.85rem;
    margin-right: 0;
}

.gateway-card-header .gateway-info {
    flex: 1;
}

.gateway-card-header .gateway-status {
    margin-left: auto;
}

/* Activity Ping Indicator */
.gateway-activity-ping {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    margin-left: 0.5rem;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.gateway-activity-ping.ping {
    animation: activity-ping 0.8s ease-out;
}

@keyframes activity-ping {
    0% {
        background: #22c55e;
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
        transform: scale(1.2);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
        transform: scale(1);
    }
    100% {
        background: var(--border);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
        transform: scale(1);
    }
}

/* Alias display (double-click to edit) */
.gateway-alias-row {
    margin-bottom: 0.1rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.alias-display {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.1rem 0;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.alias-display:hover {
    border-bottom-color: var(--accent);
}

.alias-display.no-alias {
    color: var(--text-muted);
    font-weight: 400;
    font-style: italic;
}

.alias-edit-icon {
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.gateway-alias-row:hover .alias-edit-icon {
    opacity: 0.6;
}

.alias-edit-icon:hover {
    color: var(--accent);
    opacity: 1 !important;
}

/* Table alias display */
.alias-table-display {
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.alias-table-display:hover {
    background: rgba(0, 210, 255, 0.1);
}

.alias-table-display.no-alias {
    color: var(--text-muted);
    font-style: italic;
}

/* MAC and IP row */
.gateway-mac-ip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
}

.gateway-mac-ip .mac-address {
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
}

.gateway-mac-ip .ip-address {
    color: var(--accent);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
}

/* Small update badge in header */
.update-badge-small {
    background: var(--warning);
    color: #000;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: update-pulse 2s ease-in-out infinite;
}

@keyframes update-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Version display (kept for detail modal) */
.gateway-versions {
    display: flex;
    justify-content: space-between;
    margin-top: 0;
}

.gateway-versions .version-item {
    font-size: 0.7rem;
    font-family: 'Monaco', 'Menlo', monospace;
    color: var(--text-muted);
    padding: 0.15rem 0.4rem;
    background: var(--bg-tertiary);
    border-radius: 0.25rem;
    transition: all 0.3s ease;
}

.gateway-versions .version-item.outdated {
    color: #fff;
    background: #cc7a00;
    animation: version-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 8px 2px rgba(255, 149, 0, 0.5);
}

@keyframes version-pulse {
    0%, 100% {
        box-shadow: 0 0 8px 2px rgba(255, 149, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 14px 4px rgba(255, 149, 0, 0.7);
    }
}

.gateway-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-family: 'Monaco', 'Menlo', monospace;
}

.gateway-info .ip {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.gateway-info .ip-link {
    color: var(--accent);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.gateway-info .ip-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.gateway-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
    position: static;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-badge.online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge.offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.status-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.gateway-version {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.gateway-card-body {
    padding: 1.25rem;
}

.gateway-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.stat {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.stat:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.03);
}

.stat.active {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.stat.active .stat-icon,
.stat.active .stat-value {
    color: var(--success);
}

.stat.inactive {
    border-color: var(--border);
    opacity: 0.7;
}

.stat.inactive .stat-icon {
    color: var(--text-muted);
}

.stat-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat.ethernet {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.stat.ethernet .stat-icon,
.stat.ethernet .stat-value {
    color: var(--success);
}

.stat.wifi {
    border-color: var(--accent);
    background: rgba(0, 210, 255, 0.1);
}

.stat.wifi .stat-icon,
.stat.wifi .stat-value {
    color: var(--accent);
}

.stat.offline {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    opacity: 0.7;
}

.stat.offline .stat-icon,
.stat.offline .stat-value {
    color: var(--error);
}

.stat-content {
    display: none;
}

.stat-value {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

/* RSSI Signal Indicator */
.rssi-indicator {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.rssi-bar {
    display: inline-block;
    width: 4px;
    min-height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 1px;
    transition: background 0.2s ease;
}

/* Active bar color is set via inline style in JavaScript */

/* Status Widgets (Battery & Inverter) */
.gateway-status-widgets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.15);
}

.status-widget {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    min-height: 70px;
}

.status-widget:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

.battery-widget {
    cursor: pointer;
}

.battery-widget:hover {
    border-color: var(--accent);
}

/* Battery widget icon column layout - icon above status indicators */
.widget-icon-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.widget-icon-column .widget-status-icons {
    margin-top: 0;
    justify-content: center;
}

.widget-icon {
    flex-shrink: 0;
    color: var(--accent);
    opacity: 0.9;
}

.widget-icon svg {
    display: block;
}

.widget-content {
    flex: 1;
    min-width: 0;
}

.widget-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.widget-values {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.widget-value-primary {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.widget-value-secondary {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.widget-status {
    font-size: 0.65rem;
    margin-top: 0.25rem;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    display: inline-block;
    max-width: 100%;
    line-height: 1.3;
    word-break: break-word;
    white-space: normal;
}

.widget-status-icons {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

/* Status icons in battery widget */
.status-icon {
    font-size: 0.875rem;
    line-height: 1;
}

.status-icon.status-ok {
    color: var(--success);
}

.status-icon.status-power {
    color: var(--warning);
}

.status-icon.status-warning {
    color: var(--warning);
}

.status-icon.status-error {
    color: var(--error);
}

.status-icon.status-offline {
    color: var(--error);
}

/* Relay Widget */
.relay-widget {
    cursor: pointer;
}

.relay-widget:hover {
    border-color: var(--accent);
}

.relay-icon {
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.relay-icon.active {
    color: var(--success);
}

.relay-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.relay-switch {
    width: 36px;
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    position: relative;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

.relay-switch.on {
    background: var(--success);
    border-color: var(--success);
}

.relay-switch-handle {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 1px;
    left: 1px;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.relay-switch.on .relay-switch-handle {
    left: 17px;
}

.relay-state {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Relay disabled state (offline gateway) */
.relay-widget.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.relay-widget.disabled:hover {
    border-color: var(--border);
}

/* Relay loading state */
.relay-widget.loading {
    pointer-events: none;
}

.relay-switch.loading {
    opacity: 0.6;
}

.relay-switch.loading .relay-switch-handle {
    animation: relay-pulse 1s ease-in-out infinite;
}

@keyframes relay-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Temperature Widget */
.temp-widget {
    background: var(--bg-secondary);
}

.temp-icon {
    color: var(--warning);
    transition: all 0.3s ease;
}

.temp-values {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.temp-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.temp-label {
    color: var(--text-secondary);
    font-size: 0.65rem;
    min-width: 50px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.temp-label:hover {
    color: var(--accent);
}

.temp-value span:last-child {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

/* MQTT Widget */
.mqtt-widget {
    cursor: pointer;
}

.mqtt-widget:hover {
    border-color: var(--accent);
}

.mqtt-icon {
    color: var(--accent);
    transition: all 0.3s ease;
}

.mqtt-timestamps {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    margin-top: 0.25rem;
}

.mqtt-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.mqtt-time:first-child {
    color: var(--success);
}

.mqtt-time:last-child {
    color: var(--warning);
}

/* Automation Widget */
.automation-widget {
    cursor: pointer;
}

.automation-widget:hover {
    border-color: var(--accent);
}

.automation-icon {
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.automation-icon.success {
    color: var(--success);
}

.automation-icon.failed {
    color: var(--error);
}

.automation-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    margin-top: 0.25rem;
}

.automation-name {
    font-size: 0.75rem;
    color: var(--text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}

.automation-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
}

.automation-status.success {
    color: var(--success);
}

.automation-status.failed {
    color: var(--error);
}

.automation-none {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.bms-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
}

.bms-status-icon.operational {
    background: var(--success);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.bms-status-icon.power {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    padding: 0.2rem;
}

.bms-status-icon.power svg {
    display: block;
}

.bms-status-icon.estop-ok {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    padding: 0.2rem;
}

.bms-status-icon.estop-ok svg {
    display: block;
}

.bms-status-icon.estop-active {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
    padding: 0.2rem;
    animation: pulse-error 1s infinite;
}

.bms-status-icon.estop-active svg {
    display: block;
}

@keyframes pulse-error {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text-short {
    font-size: 0.6rem;
    color: var(--text-muted);
    padding: 0.125rem 0.25rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.widget-status.status-ok {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.widget-status.status-warning {
    background: rgba(249, 115, 22, 0.15);
    color: var(--warning);
}

.widget-status.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.widget-status.status-unknown {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

/* OTA Update Indicator - Centered Overlay */
.ota-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.25rem 2rem;
    background: rgba(0, 136, 170, 0.95);
    border-radius: inherit;
    font-size: 1.8rem;
    animation: ota-pulse 2s ease-in-out infinite;
    white-space: nowrap;
    z-index: 50;
    pointer-events: none; /* Allow scrolling through the indicator */
}


@keyframes ota-pulse {
    0%, 100% {
        background: rgba(0, 136, 170, 0.95);
    }
    50% {
        background: rgba(0, 160, 200, 0.98);
    }
}

.ota-indicator-type {
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    font-size: 1rem;
    letter-spacing: 2px;
}

.ota-indicator-progress {
    font-weight: 700;
    color: #fff;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 2.4rem;
}

.ota-indicator-bar {
    width: 120px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.ota-indicator-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Rebooting indicator */
.ota-indicator.rebooting {
    background: rgba(100, 100, 100, 0.95);
    border-color: var(--text-secondary);
    box-shadow: 0 0 20px 5px rgba(150, 150, 150, 0.4);
    animation: none;
}

.ota-indicator-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ota-spin 1s linear infinite;
}

@keyframes ota-spin {
    to { transform: rotate(360deg); }
}

/* Gateway Card Reboot Overlay */
.gateway-card-reboot-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 100;
    border-radius: 1rem;
    opacity: 0;
    animation: reboot-overlay-fade-in 0.3s ease forwards;
}

@keyframes reboot-overlay-fade-in {
    to { opacity: 1; }
}

.gateway-card-reboot-overlay .reboot-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ota-spin 1s linear infinite;
}

.gateway-card-reboot-overlay .reboot-text {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
}

.gateway-card-reboot-overlay .reboot-subtext {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
}

/* Table row reboot overlay */
.gateway-table-row-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    z-index: 10;
}

.gateway-table-row-overlay .reboot-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ota-spin 1s linear infinite;
}

.gateway-table-row-overlay .reboot-text {
    color: #fff;
    font-size: 0.8rem;
}

/* OTA Table Row Overlay */
.gateway-table-row-ota-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
    padding: 0 1rem;
}

.gateway-table-row-ota-overlay .ota-progress-bar {
    flex: 1;
    max-width: 200px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.gateway-table-row-ota-overlay .ota-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #00f0c0);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.gateway-table-row-ota-overlay .ota-progress-text {
    color: #fff;
    font-size: 0.8rem;
    white-space: nowrap;
}

tr.ota-active {
    position: relative;
}

/* ============================================
   Gateway AG Grid Styles
   ============================================ */

#gatewayGridContainer.ag-theme-alpine-dark {
    height: calc(100vh - 280px);
    min-height: 400px;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border);
    --ag-background-color: var(--bg-card);
    --ag-header-background-color: var(--bg-secondary);
    --ag-odd-row-background-color: var(--bg-secondary);
    --ag-row-hover-color: var(--bg-hover);
    --ag-border-color: var(--border);
    --ag-header-foreground-color: var(--text-secondary);
    --ag-foreground-color: var(--text-primary);
    --ag-secondary-foreground-color: var(--text-muted);
    --ag-input-focus-border-color: var(--accent);
    --ag-range-selection-border-color: var(--accent);
    --ag-selected-row-background-color: rgba(0, 210, 255, 0.15);
    --ag-font-size: 0.8rem;
    --ag-row-height: 44px;
    --ag-header-height: 44px;
}

#gatewayGridContainer .ag-root-wrapper {
    border-radius: 0.75rem;
}

#gatewayGridContainer .ag-header {
    border-bottom: 2px solid var(--border);
}

#gatewayGridContainer .ag-header-cell {
    padding: 0 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

#gatewayGridContainer .ag-header-cell:hover {
    background: var(--bg-tertiary);
}

#gatewayGridContainer .ag-header-cell-label {
    font-weight: 600;
    font-size: 0.75rem;
}

/* Floating filter inputs */
#gatewayGridContainer .ag-floating-filter-input input,
#gatewayGridContainer .ag-floating-filter-body input {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px;
    color: var(--text-primary) !important;
    padding: 4px 8px;
    font-size: 0.7rem;
}

#gatewayGridContainer .ag-floating-filter-input input::placeholder {
    color: var(--text-muted);
}

#gatewayGridContainer .ag-floating-filter-input input:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.2);
}

/* Row styling */
#gatewayGridContainer .ag-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#gatewayGridContainer .ag-row:hover {
    background: var(--bg-hover) !important;
}

#gatewayGridContainer .ag-row-selected {
    background: rgba(0, 210, 255, 0.15) !important;
}

/* Cell styling */
#gatewayGridContainer .ag-cell {
    padding: 0 10px;
    line-height: var(--ag-row-height);
}

/* Status badge */
#gatewayGridContainer .status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.7rem;
    font-weight: 500;
}

#gatewayGridContainer .status-badge.status-online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

#gatewayGridContainer .status-badge.status-offline {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* Power colors */
#gatewayGridContainer .power-charge {
    color: var(--success);
}

#gatewayGridContainer .power-discharge {
    color: var(--warning);
}

/* Temperature colors */
#gatewayGridContainer .temp-cold {
    color: #3b82f6;
}

#gatewayGridContainer .temp-hot {
    color: var(--error);
}

/* SOC value */
#gatewayGridContainer .soc-value {
    font-weight: 600;
}

/* Alias display */
#gatewayGridContainer .alias-table-display {
    cursor: text;
}

#gatewayGridContainer .alias-table-display.no-alias {
    color: var(--text-muted);
    font-style: italic;
}

/* OTA indicator in grid */
#gatewayGridContainer .ota-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#gatewayGridContainer .ota-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 210, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#gatewayGridContainer .ota-indicator span {
    font-size: 0.7rem;
    color: var(--accent);
}

/* Details button */
#gatewayGridContainer .grid-details-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}

/* Checkbox styling */
#gatewayGridContainer .ag-checkbox-input-wrapper {
    background: var(--bg-secondary);
    border-radius: 4px;
}

#gatewayGridContainer .ag-checkbox-input-wrapper.ag-checked {
    background: var(--accent);
}

/* Scrollbar styling */
#gatewayGridContainer ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#gatewayGridContainer ::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 4px;
}

#gatewayGridContainer ::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

#gatewayGridContainer ::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Light theme overrides */
body.light-theme #gatewayGridContainer.ag-theme-alpine-dark {
    --ag-background-color: var(--bg-card);
    --ag-header-background-color: #e2e8f0;
    --ag-odd-row-background-color: rgba(0, 0, 0, 0.02);
    --ag-row-hover-color: rgba(0, 136, 204, 0.1);
    --ag-border-color: rgba(0, 0, 0, 0.1);
    --ag-header-foreground-color: var(--text-secondary);
    --ag-foreground-color: var(--text-primary);
}

body.light-theme #gatewayGridContainer .ag-header-cell {
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-theme #gatewayGridContainer .ag-row {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Mobile responsive */
@media (max-width: 768px) {
    #gatewayGridContainer.ag-theme-alpine-dark {
        --ag-row-height: 48px;
        --ag-font-size: 0.75rem;
        height: calc(100vh - 320px);
    }

    #gatewayGridContainer .ag-header-cell,
    #gatewayGridContainer .ag-cell {
        padding: 0 6px;
    }
}

/* ============================================
   View Loading Overlay (Lazy Loading)
   ============================================ */

.view-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 100;
    border-radius: inherit;
}

.view-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.view-loading-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.view-error-icon {
    font-size: 3rem;
    color: var(--warning);
}

.view-error-details {
    color: var(--text-muted);
    font-size: 0.8rem;
    max-width: 300px;
    text-align: center;
    margin-bottom: 0.5rem;
}

/* OTA Error Modal */
.ota-error-modal {
    max-width: 500px;
}

.ota-error-modal .modal-header.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(185, 28, 28, 0.1));
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
}

.ota-error-modal .modal-header.error h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--error);
}

.ota-error-modal .modal-header.error svg {
    flex-shrink: 0;
}

.ota-error-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ota-error-row {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.ota-error-row:last-child {
    border-bottom: none;
}

.ota-error-row.error-message {
    flex-direction: column;
    gap: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    margin: 0.5rem -1rem -0.5rem -1rem;
    padding: 1rem;
    border-radius: 0 0 0.5rem 0.5rem;
    border-bottom: none;
}

.ota-error-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-width: 100px;
    flex-shrink: 0;
}

.ota-error-value {
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-all;
}

.ota-error-value.mac {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
}

.ota-error-value.url {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    color: var(--accent);
}

.ota-error-value.error {
    color: var(--error);
    font-weight: 600;
}

/* Enhanced OTA Error Modal Styles */
.ota-error-modal {
    max-width: 550px;
}

.ota-error-alert {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 1.25rem;
}

.ota-error-alert-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.2);
    border-radius: 50%;
    color: var(--error);
}

.ota-error-alert-content {
    flex: 1;
}

.ota-error-alert-title {
    font-weight: 600;
    color: var(--error);
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.ota-error-alert-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.ota-error-details {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.ota-error-details-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
}

.ota-error-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.ota-error-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ota-error-detail-item.full-width {
    grid-column: 1 / -1;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.ota-error-detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.ota-error-detail-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

.ota-error-detail-value.mac {
    font-family: 'Monaco', 'Menlo', monospace;
}

.ota-error-detail-value.url {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    color: var(--accent);
    word-break: break-all;
}

.ota-error-detail-code {
    display: block;
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: 0.375rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    color: var(--error);
    word-break: break-all;
    margin-top: 0.25rem;
}

.ota-error-suggestion {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.ota-error-suggestion svg {
    flex-shrink: 0;
    color: var(--accent);
    margin-top: 0.125rem;
}

.ota-error-modal .modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.ota-error-modal .modal-footer .btn-primary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gateway-card-actions {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    flex: 1;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(30%);
}

.btn-primary {
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent));
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Active toggle button state (for Statistics/Chart buttons) */
.btn-secondary.active {
    background: rgba(0, 210, 255, 0.15);
    color: var(--accent);
    border-color: rgba(0, 210, 255, 0.3);
}

.btn-secondary.active:hover {
    background: rgba(0, 210, 255, 0.25);
    color: var(--accent);
    border-color: rgba(0, 210, 255, 0.4);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: white;
}

.btn-warning {
    background: rgba(234, 179, 8, 0.1);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.btn-warning:hover {
    background: var(--warning);
    color: #000;
}

.btn-icon {
    padding: 0.5rem;
    flex: 0;
}

.btn-link {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: color 0.2s ease;
    flex: 0;
}

.btn-link:hover {
    color: var(--accent);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.modal {
    background: rgba(21, 38, 45, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 1.25rem;
    border: 1px solid var(--glass-border);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-wide {
    max-width: 80vw;
    width: 80vw;
}

/* Config Modal - wider for peripherals tab */
#configModal.modal-wide {
    max-width: 900px;
    width: 95vw;
}

/* Large data modals (BMS, Inverter, CAN) */
.modal-data {
    max-width: 80vw;
    width: 80vw;
    max-height: 80vh;
}

/* BMS PDO Log Modal - Large */
#bmsPdoLogModal {
    max-width: 95vw;
    width: 95vw;
    max-height: 90vh;
    height: 90vh;
}

#bmsPdoLogModal .modal-content {
    height: calc(90vh - 60px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* BMS PDO Log Modal Styles */
.pdo-log-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.pdo-log-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.pdo-log-tab:hover {
    color: var(--text-primary);
}

.pdo-log-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Error sub-tabs (within the Fehler tab) */
.pdo-error-subtabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pdo-error-subtab {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.pdo-error-subtab:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.pdo-error-subtab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.pdo-error-subtab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdo-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 0;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.pdo-log-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdo-log-search {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.pdo-log-search input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.pdo-log-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.pdo-log-search input::placeholder {
    color: var(--text-muted);
}

.pdo-log-entries {
    flex: 1;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.pdo-log-entry {
    display: flex;
    gap: 1rem;
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.pdo-log-entry:hover {
    background: var(--bg-secondary);
}

.pdo-log-entry.trigger {
    background: rgba(255, 193, 7, 0.2);
    border-left: 3px solid var(--warning);
}

.pdo-log-time {
    color: var(--text-muted);
    white-space: nowrap;
}

.pdo-log-status {
    min-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdo-log-status.ok {
    color: var(--success);
}

.pdo-log-status.warning {
    color: var(--warning);
}

.pdo-log-data {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdo-log-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

.pdo-snapshot-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.pdo-snapshot-item:hover {
    background: var(--bg-tertiary);
}

.pdo-snapshot-status {
    font-weight: 600;
    color: var(--warning);
}

.pdo-snapshot-time {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pdo-snapshot-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.pdo-log-snapshot-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.pdo-log-snapshot-header > span {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* PDO Log Table Styles */
.pdo-log-table {
    width: 100%;
    border-collapse: collapse;
    font-family: monospace;
    font-size: 0.8rem;
}

.pdo-log-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 1;
}

.pdo-log-table th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.pdo-log-table td {
    padding: 0.35rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.pdo-log-table tbody tr:hover {
    background: var(--bg-secondary);
}

.pdo-log-table .trigger-row {
    background: rgba(255, 193, 7, 0.2);
    border-left: 3px solid var(--warning);
}

.pdo-log-table .trigger-row:hover {
    background: rgba(255, 193, 7, 0.3);
}

.pdo-log-table .pdo-col-date {
    white-space: nowrap;
    color: var(--text-muted);
}

.pdo-log-table .pdo-col-time {
    white-space: nowrap;
    color: var(--text-muted);
}

.pdo-log-table .pdo-col-status {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdo-log-table .pdo-col-status.ok {
    color: var(--success);
}

.pdo-log-table .pdo-col-status.warning {
    color: var(--warning);
}

.pdo-log-table .pdo-col-node {
    text-align: center;
    color: var(--accent);
    font-weight: 500;
}

.pdo-log-table .pdo-col-ts {
    text-align: right;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.pdo-log-table .pdo-col-voltage,
.pdo-log-table .pdo-col-current,
.pdo-log-table .pdo-col-soc,
.pdo-log-table .pdo-col-temp {
    text-align: right;
    white-space: nowrap;
}

.pdo-log-table .pdo-col-data {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.pdo-log-table .pdo-col-data code {
    background: transparent;
    padding: 0;
    font-size: inherit;
}

/* Undecodable Table Columns */
.pdo-log-table .pdo-col-reason {
    max-width: 200px;
    color: var(--warning);
}

.pdo-log-table .pdo-col-raw {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.undecodable-table tbody tr:hover .pdo-col-raw {
    white-space: normal;
    word-break: break-all;
}

/* Full height entries container (for tabs without detail panel) */
.pdo-log-entries-full {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 350px);
}

/* PDO Log Header Buttons */
.pdo-log-header-buttons {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.pdo-log-header-buttons .btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.pdo-log-header-buttons label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-right: 0.25rem;
}

.pdo-log-header-buttons select {
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 160px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2300d2ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 14px;
    transition: all 0.2s ease;
}

.pdo-log-header-buttons select:hover {
    border-color: var(--accent);
    background-color: var(--bg-secondary);
}

.pdo-log-header-buttons select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.15);
}

.pdo-log-header-buttons select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.5rem;
}

/* Datetime Picker Group */
.datetime-picker-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.datetime-picker-group input[type="datetime-local"],
.datetime-picker-group input[type="date"] {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    color-scheme: dark;
}

.datetime-picker-group input[type="datetime-local"]:focus,
.datetime-picker-group input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Date/time inputs dark theme support */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
    color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.light-theme input[type="date"],
.light-theme input[type="datetime-local"],
.light-theme input[type="time"] {
    color-scheme: light;
}

.light-theme input[type="date"]::-webkit-calendar-picker-indicator,
.light-theme input[type="datetime-local"]::-webkit-calendar-picker-indicator,
.light-theme input[type="time"]::-webkit-calendar-picker-indicator {
    filter: none;
}

.datetime-picker-group span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* PDO Log Statistics */
.pdo-log-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.pdo-stat-card {
    background: var(--bg-primary);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.pdo-stat-card h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pdo-stat-values {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    font-family: monospace;
}

.pdo-stat-item {
    text-align: center;
}

.pdo-stat-item .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
}

.pdo-stat-item .value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pdo-stat-item .value.min { color: var(--info); }
.pdo-stat-item .value.max { color: var(--warning); }
.pdo-stat-item .value.avg { color: var(--success); }

/* Status Counts */
.pdo-stat-status {
    background: var(--bg-primary);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    grid-column: span 2;
}

.pdo-stat-status h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pdo-status-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pdo-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.8rem;
}

.pdo-status-badge.ok {
    background: rgba(46, 204, 113, 0.2);
    color: var(--success);
}

.pdo-status-badge.warning {
    background: rgba(255, 193, 7, 0.2);
    color: var(--warning);
}

.pdo-status-badge.error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.pdo-status-badge.info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

.pdo-status-badge .count {
    font-weight: 600;
    background: var(--bg-primary);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

/* PDO Log Chart Container */
.pdo-log-chart-container {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-sizing: border-box;
}

/* Chart wrapper - this is what Chart.js uses for sizing */
.pdo-log-chart-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Chart area with fixed height for Chart.js */
.pdo-chart-wrapper {
    position: relative;
    width: 100%;
    height: 280px;
}

/* PDO Chart Controls */
.pdo-chart-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.pdo-chart-control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pdo-chart-control-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.pdo-chart-controls select {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 140px;
}

/* Multi-source dropdown */
.pdo-source-dropdown-wrapper {
    position: relative;
}

.pdo-source-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 140px;
}

.pdo-source-dropdown-btn:hover {
    border-color: var(--accent);
}

.pdo-source-dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    min-width: 280px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    margin-top: 0.25rem;
    padding: 0.5rem;
}

.pdo-source-multiselect {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pdo-source-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pdo-source-group-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

.pdo-source-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.pdo-source-checkbox {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.75rem;
}

.pdo-source-checkbox:hover {
    background: var(--bg-tertiary);
}

.pdo-source-checkbox input[type="checkbox"] {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid var(--source-color, var(--accent));
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.pdo-source-checkbox input[type="checkbox"]:checked {
    background: var(--source-color, var(--accent));
}

.pdo-source-checkbox input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: white;
    font-weight: bold;
}

.pdo-source-label {
    color: var(--text-secondary);
    white-space: nowrap;
}

.pdo-source-count {
    color: var(--text-primary);
}

/* PDO Loading Animation */
.pdo-log-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.pdo-loading-animation {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 32px;
}

.pdo-loading-bar {
    width: 6px;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    animation: pdoLoadingBar 1s ease-in-out infinite;
}

.pdo-loading-bar:nth-child(1) {
    animation-delay: 0s;
}

.pdo-loading-bar:nth-child(2) {
    animation-delay: 0.2s;
}

.pdo-loading-bar:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pdoLoadingBar {
    0%, 100% {
        transform: scaleY(0.3);
        opacity: 0.5;
    }
    50% {
        transform: scaleY(1);
        opacity: 1;
    }
}

.pdo-loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: pdoSpin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes pdoSpin {
    to {
        transform: rotate(360deg);
    }
}

.pdo-chart-controls select:hover {
    border-color: var(--accent);
}

.pdo-chart-controls select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.pdo-chart-controls select optgroup {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.pdo-chart-controls select option {
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
}

.pdo-chart-info {
    margin-left: auto;
}

.pdo-chart-point-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.25rem 0.625rem;
    border-radius: 1rem;
}

/* Responsive chart controls */
@media (max-width: 768px) {
    .pdo-chart-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .pdo-chart-control-group {
        width: 100%;
    }

    .pdo-chart-controls select {
        flex: 1;
        min-width: 0 !important;
    }

    .pdo-chart-info {
        margin-left: 0;
        width: 100%;
        text-align: right;
    }
}

@media (max-width: 1200px) {
    .pdo-log-main-area {
        flex-direction: column;
    }

    .pdo-log-detail-panel {
        width: 100%;
        min-width: auto;
        max-height: 400px;
    }
}

/* Mobile PDO Chart - Better responsive handling */
@media (max-width: 768px) {
    .pdo-log-chart-container {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .pdo-chart-wrapper {
        height: 250px;
    }

    .pdo-chart-controls {
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .pdo-chart-control-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .pdo-chart-control-group label {
        font-size: 0.7rem;
    }

    .pdo-chart-controls select {
        width: 100%;
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }

    .pdo-chart-source-select {
        min-width: auto !important;
    }

    .pdo-chart-point-count {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .pdo-log-chart-container {
        padding: 0.5rem;
        border-radius: 6px;
    }

    .pdo-chart-wrapper {
        height: 220px;
    }

    .pdo-chart-controls {
        gap: 0.375rem;
        flex-wrap: wrap;
    }

    .pdo-chart-control-group label {
        font-size: 0.65rem;
    }

    .pdo-chart-controls select {
        padding: 0.3rem 0.4rem;
        font-size: 0.7rem;
        max-width: 100%;
    }
}

/* Legacy selector support */
.pdo-chart-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.pdo-chart-selector label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pdo-chart-selector select {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
}

.pdo-chart-selector select:hover {
    border-color: var(--accent);
}

.pdo-chart-selector select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* PDO Filter Row - Hidden, using AG Grid header filters now */
.pdo-log-filters {
    display: none; /* Header filters in table columns replace this */
}

.pdo-log-filters .pdo-log-search {
    margin-bottom: 0.5rem;
}

.pdo-filter-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Node Filter */
.pdo-node-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.pdo-node-filter > label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.pdo-node-checkboxes {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pdo-node-checkboxes label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
}

.pdo-node-checkboxes input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

.btn-tiny {
    padding: 0.2rem 0.4rem;
    font-size: 0.65rem;
}

.pdo-filter-row select,
.pdo-filter-row input[type="number"] {
    padding: 0.35rem 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.75rem;
}

.pdo-filter-row select {
    min-width: 140px;
    max-width: 200px;
}

.pdo-filter-row input[type="number"] {
    width: 70px;
}

.pdo-filter-row select:focus,
.pdo-filter-row input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

.pdo-filter-row .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
}

/* PDO Main Area with Detail Panel */
.pdo-log-main-area {
    display: flex;
    gap: 1rem;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    height: 100%;
}

.pdo-log-main-area .pdo-log-entries {
    flex: 1;
    overflow-y: auto;
}

/* PDO Detail Panel - Full Height */
.pdo-log-detail-panel {
    width: 350px;
    min-width: 300px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    max-height: calc(100vh - 300px);
}

.pdo-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.875rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.pdo-detail-header h4 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.pdo-detail-header .btn {
    padding: 0.2rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
}

.pdo-detail-content {
    padding: 0.875rem;
    overflow-y: auto;
    flex: 1;
    font-size: 0.8rem;
}

.pdo-detail-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.pdo-detail-actions .btn {
    flex: 1;
}

.pdo-detail-section {
    margin-bottom: 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.pdo-detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.pdo-detail-section h5 {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.4rem;
    letter-spacing: 0.05em;
}

.pdo-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.75rem;
}

.pdo-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.pdo-detail-item .label {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.pdo-detail-item .value {
    font-family: monospace;
    font-weight: 500;
}

.pdo-detail-item.full-width {
    grid-column: span 2;
}

.pdo-detail-raw {
    background: var(--bg-primary);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.65rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
}

/* Selectable Table Row */
.pdo-log-table tbody tr {
    cursor: pointer;
}

.pdo-log-table tbody tr.selected {
    background: rgba(59, 130, 246, 0.2);
    border-left: 3px solid var(--accent);
}

.pdo-log-table tbody tr.selected:hover {
    background: rgba(59, 130, 246, 0.3);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* BMS Modal Header - NMI Button in der Mitte */
.modal-header.bms-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header.bms-header h3 {
    flex: 1;
    margin-right: auto;
}

/* BMS Header Buttons - einheitliches Design */
.modal-header.bms-header .bms-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.modal-header.bms-header .bms-header-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--text-secondary);
}

.modal-header.bms-header .bms-header-btn.active {
    background: rgba(96, 165, 250, 0.15);
    border-color: rgba(96, 165, 250, 0.4);
    color: #60a5fa;
}

.modal-header.bms-header .bms-header-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* NMI Button - Warning-Farbe */
.modal-header.bms-header .bms-nmi-btn {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #f59e0b;
}

.modal-header.bms-header .bms-nmi-btn:hover {
    background: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.6);
    color: #fbbf24;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content {
    padding: 1.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.modal-footer .btn {
    min-width: 100px;
}

/* Config Loading Indicator */
.config-loading-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    color: var(--accent);
    font-size: 0.875rem;
}

.config-loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 210, 255, 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Config Timeout Warning */
.config-timeout-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    color: var(--warning);
}

.config-timeout-warning svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.config-timeout-warning div {
    flex: 1;
}

.config-timeout-warning strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--warning);
}

.config-timeout-warning p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.config-timeout-warning button {
    flex-shrink: 0;
    padding: 0.4rem 0.75rem;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid var(--warning);
    border-radius: 0.375rem;
    color: var(--warning);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.config-timeout-warning button:hover {
    background: rgba(245, 158, 11, 0.3);
}

/* Config Fields Success */
.config-fields-success {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    color: var(--success);
    font-size: 0.8rem;
}

.config-fields-success svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Config Fields Warning */
.config-fields-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    overflow: hidden;
}

.config-fields-warning-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--warning);
}

.config-fields-warning-header svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.config-fields-warning-header div {
    flex: 1;
}

.config-fields-warning-header strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
}

.config-fields-warning-header p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.config-fields-warning-header button {
    flex-shrink: 0;
    padding: 0.3rem 0.6rem;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid var(--warning);
    border-radius: 0.375rem;
    color: var(--warning);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.config-fields-warning-header button:hover {
    background: rgba(245, 158, 11, 0.3);
}

.config-fields-missing-list {
    display: none;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(245, 158, 11, 0.2);
}

.config-fields-missing-list.expanded {
    display: flex;
}

.missing-field-tag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Custom Checkbox / Toggle Switch */
.form-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.form-group input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.form-group input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.form-group input[type="checkbox"]:checked::before {
    transform: translateX(20px);
    background: white;
}

.form-group input[type="checkbox"]:hover {
    border-color: var(--text-muted);
}

.form-group input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Checkbox label alignment */
.form-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

/* Custom Select Styling */
.form-group select {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
}

.form-group select:hover {
    border-color: var(--text-muted);
    background-color: var(--bg-tertiary);
}

.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2300d4ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.form-group select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.5rem;
}

.form-group select option:hover,
.form-group select option:focus,
.form-group select option:checked {
    background: var(--accent);
    color: var(--bg-primary);
}

.form-group select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-tertiary);
}

/* Select with description */
.select-with-description {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.select-with-description select {
    flex: 1;
    min-width: 180px;
}

.select-description {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    max-width: 300px;
    opacity: 0;
    transform: translateX(-8px);
    transition: all 0.25s ease;
}

.select-description.visible {
    opacity: 1;
    transform: translateX(0);
}

.select-description svg {
    width: 14px;
    height: 14px;
    color: var(--accent);
    flex-shrink: 0;
}

.select-description span {
    line-height: 1.3;
}

/* Tabs */
.config-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    background: var(--bg-card);
    padding: 0.25rem;
    border-radius: 0.5rem;
}

.tab-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Config Sections */
.config-section {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.config-section:last-child {
    margin-bottom: 0;
}

.config-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* SNTP Status */
.sntp-status-group {
    margin-top: 0.5rem;
}

.sntp-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    flex-wrap: wrap;
}

.sntp-status #sntpCurrentTime {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    min-width: 100px;
}

.sntp-status .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-row .form-group {
    margin-bottom: 0;
}

/* Info Tooltip */
.label-with-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: help;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.info-icon:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
    z-index: 9999;
}

.info-icon .info-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 20, 25, 0.97);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-primary);
    white-space: nowrap;
    max-width: 280px;
    white-space: normal;
    text-align: left;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 99999;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.info-icon .info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--accent);
}

.info-icon:hover .info-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Tooltip positioning for edge cases */
.info-icon.tooltip-left .info-tooltip {
    left: auto;
    right: 0;
    transform: none;
}

.info-icon.tooltip-left .info-tooltip::after {
    left: auto;
    right: 10px;
    transform: none;
}

.info-icon.tooltip-right .info-tooltip {
    left: 0;
    right: auto;
    transform: none;
}

.info-icon.tooltip-right .info-tooltip::after {
    left: 10px;
    right: auto;
    transform: none;
}

/* Tabs scrollable on small screens */
.config-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.config-tabs::-webkit-scrollbar {
    height: 4px;
}

.config-tabs::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.config-tabs::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

/* OTA Progress */
.ota-progress {
    margin: 1rem 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
}

.ota-progress-bar {
    height: 24px;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.ota-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #00f0c0);
    border-radius: 12px;
    transition: width 0.3s ease;
}

.ota-progress-fill.success {
    background: linear-gradient(90deg, var(--success), #00cc88);
}

.ota-progress-fill.error {
    background: linear-gradient(90deg, var(--error), #ff6666);
}

.ota-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.ota-progress-percent {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
}

.ota-progress-percent.success {
    color: var(--success);
}

.ota-progress-percent.error {
    color: var(--error);
}

.ota-progress-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.ota-log-content {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    background: var(--bg-primary);
    border-radius: 0.25rem;
}

.ota-log-content .log-line {
    padding: 0.125rem 0;
}

.ota-log-content .log-line.error {
    color: var(--error);
}

.ota-log-content .log-line.success {
    color: var(--success);
}

.ota-log-content .log-line.file {
    color: var(--accent);
}

/* Confirm Dialog */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.confirm-overlay.active {
    opacity: 1;
    visibility: visible;
}

.confirm-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 360px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.2s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.confirm-overlay.active .confirm-dialog {
    transform: scale(1);
}

.confirm-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 165, 2, 0.15);
    color: var(--warning);
}

.confirm-icon svg {
    width: 32px;
    height: 32px;
}

.confirm-dialog h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.confirm-dialog p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.confirm-actions .btn {
    flex: 1;
    max-width: 140px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(21, 38, 45, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 0.75rem;
    border-left: 4px solid var(--accent);
    border: 1px solid var(--glass-border);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }

.toast-message {
    font-size: 0.875rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    margin-left: auto;
}

/* Detail View */
.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.detail-value {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Config Import/Export */
.config-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.config-action-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
}

.config-action-card h4 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.config-action-card p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.config-action-card .btn {
    width: 100%;
}

.config-json-preview {
    margin-top: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
}

.config-json-preview h4 {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.config-json-preview pre {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 0.75rem;
    border-radius: 0.25rem;
    overflow-x: auto;
    max-height: 200px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Bulk Update Confirmation Modal */
.modal-confirm {
    max-width: 700px;
    text-align: center;
}

.modal-confirm .modal-content {
    padding: 1.5rem 2rem 2rem;
}

.confirm-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    color: var(--accent);
}

.confirm-icon.frontend {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.confirm-message {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.confirm-source-version {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
}

.confirm-source-version .source-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.confirm-source-version .source-label {
    color: var(--text-secondary);
    min-width: 60px;
}

.confirm-source-version .source-value {
    color: var(--primary);
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
}

.confirm-source-version .source-url {
    color: var(--text-muted);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

/* Pre-Boot Toggle Row */
.preboot-toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.preboot-toggle-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.preboot-label {
    color: var(--text);
    font-size: 0.9rem;
}

.preboot-toggle-row .form-hint {
    margin-top: 0;
}

.confirm-device-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 1rem;
    max-height: 280px;
    overflow-y: auto;
    text-align: left;
}

.confirm-device-list:empty {
    display: none;
}

.confirm-device-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.375rem;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border);
}

.confirm-device-item:last-child {
    border-bottom: none;
}

.confirm-device-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.confirm-device-item .device-info-main {
    display: flex;
    flex-direction: column;
    min-width: 160px;
}

.confirm-device-item .device-alias {
    font-weight: 500;
    color: var(--text-primary);
}

.confirm-device-item .device-mac-small {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.confirm-device-item .device-info-details {
    display: flex;
    gap: 1rem;
    flex: 1;
}

.confirm-device-item .device-ip {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 100px;
}

.confirm-device-item .device-version {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.15rem 0.4rem;
    background: var(--bg-tertiary);
    border-radius: 0.25rem;
}

.confirm-device-item .device-version.outdated {
    color: #ff9500;
    background: rgba(255, 149, 0, 0.15);
}

.confirm-device-item .device-mac {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.confirm-device-item .device-status {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    flex-shrink: 0;
}

.confirm-device-item .device-status.online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.confirm-device-item .device-status.offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.modal-confirm .modal-actions {
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-confirm .modal-actions .btn {
    min-width: 120px;
    flex: 0;
}

/* BMS Visualization */
.bms-section {
    margin-top: 1rem;
}

.bms-visualization {
    max-height: 400px;
    overflow-y: auto;
}

.bms-visualization-full {
    max-height: 80vh;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
}

.bms-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
    grid-column: 1 / -1;
}

.bms-unit {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.bms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 210, 255, 0.05);
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
    flex-wrap: wrap;
}

.bms-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.bms-battery-icon {
    display: flex;
    align-items: center;
}

.bms-title-text {
    color: var(--text-primary);
}

.bms-soc-inline {
    font-weight: 700;
    font-size: 1.1rem;
    font-family: 'Monaco', 'Menlo', monospace;
}

.bms-header-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    justify-content: center;
}

.bms-header-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', monospace;
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
}

.bms-header-stat svg {
    opacity: 0.7;
}

.bms-header-stat.charging {
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.bms-header-stat.discharging {
    color: var(--warning);
    background: rgba(255, 165, 2, 0.1);
}

.bms-header-stat .current-arrow {
    font-weight: bold;
    margin-right: 2px;
}

.bms-status-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border-radius: 4px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Gateway Info Header */
.gateway-info-header {
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.08) 0%, rgba(58, 123, 213, 0.08) 100%);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    overflow: hidden;
}

.gateway-info-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
}

.gateway-info-identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.gateway-info-icon {
    color: var(--accent);
    opacity: 0.8;
}

.gateway-info-text {
    display: flex;
    flex-direction: column;
}

.gateway-info-mac {
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Monaco', 'Menlo', monospace;
    color: var(--text-primary);
}

.gateway-info-ip {
    font-size: 0.75rem;
    color: var(--accent);
    font-family: 'Monaco', 'Menlo', monospace;
}

.gateway-info-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
}

.gateway-info-status.online {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.gateway-info-status.offline {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.gateway-info-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.gateway-info-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1px;
    background: var(--border);
}

.gateway-stat-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-secondary);
    position: relative;
}

.gateway-stat-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.gateway-stat-icon.active {
    color: var(--success);
}

.gateway-stat-icon.inactive {
    color: var(--error);
    opacity: 0.5;
}

.gateway-stat-icon.network-wlan {
    color: var(--accent);
}

.gateway-stat-icon.network-ethernet {
    color: var(--success);
}

.gateway-stat-content {
    flex: 1;
    min-width: 0;
}

.gateway-stat-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gateway-stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.gateway-rssi-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
}

.gateway-rssi-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.gateway-rssi-value {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Connection Status Grid for Details Modal */
.connection-status-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.connection-status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.connection-status-item.connected {
    background: rgba(46, 213, 115, 0.1);
    border-color: rgba(46, 213, 115, 0.3);
    color: var(--success);
}

.connection-status-item svg {
    flex-shrink: 0;
}

.connection-status-item span {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Connection Status Grid in Gateway Cards (smaller, centered) */
.gateway-card-body .connection-status-grid {
    justify-content: center;
    gap: 0.5rem;
}

.gateway-card-body .connection-status-item {
    padding: 0.4rem 0.6rem;
    gap: 0.35rem;
}

.gateway-card-body .connection-status-item svg {
    width: 16px;
    height: 16px;
}

.gateway-card-body .connection-status-item span {
    font-size: 0.7rem;
}

/* Live Data Grid for Details Modal */
.live-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.live-data-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.live-data-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.live-data-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.live-data-icon.solar {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.live-data-icon.grid {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.live-data-icon.battery {
    background: rgba(46, 213, 115, 0.15);
    color: var(--success);
}

.live-data-icon.power {
    background: rgba(0, 210, 255, 0.15);
    color: var(--accent);
}

.live-data-content {
    flex: 1;
    min-width: 0;
}

.live-data-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', monospace;
}

.live-data-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Temperature Grid for Details Modal */
.temperature-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.temperature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.temperature-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    flex-shrink: 0;
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
}

.temperature-content {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.temperature-content:hover {
    opacity: 0.8;
}

.temperature-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', monospace;
}

.temperature-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.temperature-label small {
    font-size: 0.6rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ============================================
   WaveShare Relay Panel Styles
   ============================================ */

.waveshare-modules {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.waveshare-module {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
}

.waveshare-module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.waveshare-module-header .module-title {
    font-weight: 600;
    color: var(--text-primary);
}

.waveshare-relays {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.waveshare-relay-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}

.waveshare-relay-btn:hover {
    background: rgba(0, 0, 0, 0.3);
    border-color: var(--accent);
}

.waveshare-relay-btn .relay-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.waveshare-relay-btn .relay-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
    transition: all 0.2s ease;
}

.waveshare-relay-btn.on .relay-indicator {
    background: var(--success);
    box-shadow: 0 0 10px rgba(46, 213, 115, 0.6);
}

.waveshare-relay-btn.on {
    border-color: var(--success);
    background: rgba(46, 213, 115, 0.1);
}

.waveshare-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.waveshare-inputs .inputs-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.waveshare-input {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.waveshare-input.high {
    background: rgba(46, 213, 115, 0.15);
    color: var(--success);
    border-color: var(--success);
}

.waveshare-input.low {
    background: rgba(100, 100, 100, 0.15);
    color: var(--text-muted);
}

/* ============================================
   Energy Meter Panel Styles
   ============================================ */

.energy-meters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.energy-meter {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
}

.meter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.meter-header .meter-title {
    font-weight: 600;
    color: var(--text-primary);
}

.meter-data-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.meter-phase {
    display: grid;
    grid-template-columns: 40px repeat(3, 1fr);
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
}

.meter-phase.single-phase {
    grid-template-columns: 40px repeat(3, 1fr);
}

.meter-phase .phase-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent);
    text-align: center;
}

.meter-phase .meter-value {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    text-align: right;
    color: var(--text-primary);
}

.meter-totals {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.meter-total-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 0.5rem;
}

.meter-total-item .total-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.meter-total-item .total-value {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
}

.meter-energy {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.energy-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    background: rgba(46, 213, 115, 0.1);
    border: 1px solid rgba(46, 213, 115, 0.2);
    border-radius: 0.5rem;
}

.energy-item .energy-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.energy-item .energy-value {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--success);
}

/* Responsive adjustments for relay/meter panels */
@media (max-width: 600px) {
    .waveshare-relays {
        grid-template-columns: repeat(4, 1fr);
    }

    .meter-phase {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .meter-phase .phase-label {
        padding-bottom: 0.25rem;
        border-bottom: 1px solid var(--border);
        margin-bottom: 0.25rem;
    }

    .meter-phase .meter-value {
        text-align: center;
    }

    .meter-totals,
    .meter-energy {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Peripherals Config Tab Styles
   ============================================ */

.peripheral-modules {
    margin-top: 0.75rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
}

.peripheral-device {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.peripheral-device:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.peripheral-device h5 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Temperature Alias Modal */
.temp-alias-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.temp-alias-modal-overlay.closing {
    animation: fadeOut 0.2s ease forwards;
}

.temp-alias-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 1rem;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

.temp-alias-modal-overlay.closing .temp-alias-modal {
    animation: slideDown 0.2s ease forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

.temp-alias-modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.15), rgba(255, 152, 0, 0.05));
    border-bottom: 1px solid var(--border);
}

.temp-alias-modal-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 152, 0, 0.2);
    border-radius: 12px;
    color: #ff9800;
    flex-shrink: 0;
}

.temp-alias-modal-title {
    flex: 1;
    min-width: 0;
}

.temp-alias-modal-title h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.temp-alias-modal-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-top: 0.25rem;
}

.temp-alias-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.temp-alias-modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.temp-alias-modal-content {
    padding: 1.5rem;
}

.temp-alias-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.temp-alias-form-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.temp-alias-form-group label strong {
    color: #ff9800;
    font-weight: 600;
}

.temp-alias-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.temp-alias-input:focus {
    outline: none;
    border-color: #ff9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.15);
}

.temp-alias-input::placeholder {
    color: var(--text-muted);
}

.temp-alias-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.temp-alias-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.temp-alias-modal-footer .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
}

.temp-alias-modal-footer .btn-primary {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    border-color: #ff9800;
}

.temp-alias-modal-footer .btn-primary:hover {
    background: linear-gradient(135deg, #ffb74d, #ff9800);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

/* CAN Query Modal Styles */
.can-query-layout {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1.5rem;
    min-height: 400px;
}

.can-query-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.can-query-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 0.5rem;
    color: var(--warning);
    font-size: 0.85rem;
    line-height: 1.4;
}

.can-query-warning svg {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.can-query-form .form-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.can-query-form .form-group-small {
    flex: 0 0 70px;
}

.can-query-form .form-group-medium {
    flex: 1;
    min-width: 100px;
}

.can-query-form select {
    width: 100%;
    padding: 0.6rem 2rem 0.6rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.can-query-form select:focus {
    outline: none;
    border-color: var(--accent);
}

.can-saved-queries {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.can-saved-queries label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.can-saved-queries select {
    width: 100%;
    padding: 0.6rem 2rem 0.6rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.can-saved-queries select:focus {
    outline: none;
    border-color: var(--accent);
}

.can-query-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.can-query-actions .btn-link {
    padding: 0.5rem;
    color: var(--error);
}

.can-query-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.can-response-section,
.can-history-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.can-response-section h4,
.can-history-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin: 0;
}

.can-response-box {
    padding: 0.75rem;
    min-height: 80px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
}

.can-response-placeholder,
.can-history-placeholder {
    color: var(--text-muted);
    font-style: italic;
    padding: 0.75rem;
    display: block;
}

.can-response-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.can-response-row {
    display: flex;
    gap: 1rem;
    align-items: baseline;
}

.can-response-label {
    color: var(--text-muted);
    min-width: 60px;
}

.can-response-value {
    color: var(--accent);
    font-weight: 500;
}

.can-response-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.can-history-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.can-history-list {
    flex: 1;
    overflow-y: auto;
    max-height: 250px;
    padding: 0.5rem 0.75rem;
}

.can-history-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s ease;
}

.can-history-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.can-history-item:last-child {
    border-bottom: none;
}

.can-history-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.can-history-direction {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-weight: 600;
}

.can-history-direction.request {
    background: rgba(0, 210, 255, 0.15);
    color: var(--accent);
}

.can-history-direction.response {
    background: rgba(46, 213, 115, 0.15);
    color: var(--success);
}

.can-history-id,
.can-history-info {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.can-history-item.success .can-history-info {
    color: var(--success);
}

.can-history-item.error .can-history-info {
    color: var(--error);
}

.can-history-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.can-history-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}

.can-history-data {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-left: 0.5rem;
    word-break: break-all;
}

@media (max-width: 768px) {
    .can-query-layout {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Modbus Query Response Styles
   ============================================ */

.modbus-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.modbus-presets .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
}

.modbus-response-success {
    padding: 0.5rem;
}

.modbus-response-success .modbus-response-header {
    color: var(--success);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.modbus-response-success .modbus-response-values {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.modbus-response-hex {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.modbus-response-error {
    padding: 0.5rem;
}

.modbus-response-error .modbus-response-header {
    color: var(--error);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.modbus-response-error .modbus-response-message {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Modbus Scan Progress */
.modbus-scan-progress {
    padding: 1rem;
}

.modbus-scan-progress .scan-progress-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.modbus-scan-progress .scan-progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.modbus-scan-progress .scan-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.modbus-scan-progress .scan-progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.modbus-scan-progress .scan-progress-last {
    font-size: 0.85rem;
    color: var(--success);
    padding: 0.5rem;
    background: rgba(166, 227, 161, 0.1);
    border-radius: 4px;
    margin-top: 0.5rem;
}

.modbus-register-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.modbus-register-item {
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    border: 1px solid var(--border);
}

.modbus-register-more {
    color: var(--text-muted);
    font-style: italic;
    padding: 0.25rem 0.5rem;
}

/* Modbus Decode Grid */
.modbus-decode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.35rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.modbus-decode-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
    border: 1px solid var(--border);
}

.modbus-decode-item .decode-label {
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.modbus-decode-item .decode-value {
    color: var(--accent);
    font-weight: 600;
    text-align: right;
}

/* Modbus Polling Section */
.modbus-polling-section {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.modbus-polling-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.modbus-polling-interval {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.modbus-polling-interval select {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.modbus-polling-chart {
    margin-top: 0.75rem;
    height: 120px;
    background: var(--bg-card);
    border-radius: 6px;
    padding: 0.5rem;
}

.modbus-polling-stats {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.modbus-polling-stats strong {
    color: var(--accent);
    font-weight: 600;
}

/* Toggle Switch Inline (for polling) */
.toggle-switch-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.toggle-switch-inline input {
    display: none;
}

.toggle-switch-inline .toggle-slider {
    width: 36px;
    height: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    position: relative;
    transition: all 0.2s ease;
}

.toggle-switch-inline .toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.toggle-switch-inline input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch-inline input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: white;
}

/* Modbus History Items (extend CAN history styles) */
.can-history-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.can-history-status {
    width: 1.2rem;
    text-align: center;
    font-weight: 600;
}

.can-history-item.success .can-history-status {
    color: var(--success);
}

.can-history-item.error .can-history-status {
    color: var(--error);
}

.can-history-summary {
    flex: 1;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.can-history-duration {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 45px;
    text-align: right;
}

/* ============================================
   User Menu & Authentication Styles
   ============================================ */

.user-menu {
    position: relative;
    margin-left: 1rem;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-menu-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.user-menu-btn span {
    font-size: 0.85rem;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile: User-Menu nur Icon */
@media (max-width: 768px) {
    .user-menu-btn {
        padding: 0.5rem;
        gap: 0;
    }

    .user-menu-btn span,
    .user-menu-btn svg:last-child {
        display: none;
    }

    .user-dropdown {
        position: fixed !important;
        top: 60px !important;
        bottom: auto !important;
        right: 10px !important;
        left: auto !important;
        min-width: 250px;
        max-height: calc(100vh - 140px);
        max-height: calc(100dvh - 140px);
        overflow-y: auto;
        z-index: 10001 !important;
        border-radius: 0.75rem;
    }
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.user-dropdown-header span:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    background: rgba(0, 210, 255, 0.15);
    color: var(--accent);
    border-radius: 3px;
    display: inline-block;
    width: fit-content;
}

.user-role.admin {
    background: rgba(255, 165, 2, 0.15);
    color: var(--warning);
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.user-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.user-dropdown-item.logout {
    color: var(--error);
}

.user-dropdown-item.logout:hover {
    background: rgba(255, 71, 87, 0.1);
}

.user-dropdown-item.admin-only {
    display: none;
}

.user-dropdown-item.admin-only.visible {
    display: flex;
}

/* User Management Modal - Enhanced Design */
.modal-user-management {
    max-width: 1100px;
    width: 95vw;
    min-width: 750px;
}

.user-mgmt-header {
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.1) 0%, rgba(58, 123, 213, 0.1) 100%);
    border-bottom: 1px solid var(--accent);
}

.user-mgmt-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-mgmt-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent));
    border-radius: 12px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.user-mgmt-title h3 {
    margin: 0;
    font-size: 1.25rem;
}

.user-mgmt-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.user-management-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    min-height: 400px;
}

.user-list-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border);
}

.user-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.user-list-header h4 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-list-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-user-stats {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.btn-user-stats:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-user-stats svg {
    width: 14px;
    height: 14px;
}

.btn-add-user {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 2rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-add-user:hover {
    background: var(--accent);
    color: var(--bg-dark);
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.3);
}

.btn-add-user svg {
    width: 14px;
    height: 14px;
}

.user-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 320px;
    overflow-y: auto;
}

.user-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-list-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border);
    transform: translateX(4px);
}

.user-list-item.selected {
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.1) 0%, rgba(58, 123, 213, 0.1) 100%);
    border-color: var(--accent);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.1);
}

.user-list-item-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 50%;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.user-list-item:hover .user-list-item-icon {
    transform: scale(1.1);
}

.user-list-item-icon.admin {
    background: linear-gradient(135deg, rgba(255, 165, 2, 0.2), rgba(255, 165, 2, 0.1));
    color: var(--warning);
    box-shadow: 0 2px 10px rgba(255, 165, 2, 0.15);
}

.user-list-item-info {
    flex: 1;
    min-width: 0;
}

.user-list-item-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-list-item-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.user-list-item-role::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.user-list-item-icon.admin + .user-list-item-info .user-list-item-role::before {
    background: var(--warning);
}

.user-form-section {
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
}

.user-form-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.placeholder-icon {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed var(--border);
    border-radius: 50%;
    color: var(--text-muted);
    opacity: 0.5;
}

.user-form-placeholder h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.user-form-placeholder p {
    margin: 0;
    font-size: 0.85rem;
    max-width: 250px;
    line-height: 1.5;
}

.user-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    animation: slideIn 0.3s ease;
}

.user-form-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.user-form-avatar {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent));
    border-radius: 50%;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.25);
}

.user-form-avatar.admin {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    box-shadow: 0 4px 15px rgba(255, 165, 2, 0.25);
}

.user-form-header h4 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.user-form-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-form-body .form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.user-form-body .form-group label svg {
    opacity: 0.7;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 45px;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: var(--accent);
}

/* Role Selector */
.role-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.role-option {
    cursor: pointer;
}

.role-option input {
    display: none;
}

.role-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    transition: all 0.2s ease;
}

.role-option:hover .role-card {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.role-option input:checked + .role-card {
    border-color: var(--accent);
    background: rgba(0, 210, 255, 0.08);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.1);
}

.role-option input[value="admin"]:checked + .role-card {
    border-color: var(--warning);
    background: rgba(255, 165, 2, 0.08);
    box-shadow: 0 4px 15px rgba(255, 165, 2, 0.1);
}

.role-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.role-icon.user-icon {
    background: rgba(0, 210, 255, 0.15);
    color: var(--accent);
}

.role-icon.admin-icon {
    background: rgba(255, 165, 2, 0.15);
    color: var(--warning);
}

.role-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.role-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.role-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.user-form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.user-form-actions .btn {
    flex: 0 0 auto;
}

.user-form-actions .btn-secondary {
    margin-right: auto;
}

@media (max-width: 768px) {
    .modal-user-management {
        max-width: 98vw;
        min-width: auto;
    }

    .user-management-layout {
        grid-template-columns: 1fr;
    }

    .user-list-section {
        border-bottom: 1px solid var(--border);
    }

    .role-selector {
        grid-template-columns: 1fr;
    }

    .user-mgmt-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .user-mgmt-icon {
        width: 40px;
        height: 40px;
    }
}

.bms-summary-compact {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
}

.bms-metric {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 80px;
}

.bms-metric-soc {
    align-items: flex-start;
}

.bms-metric-soh {
    align-items: flex-end;
}

.bms-metric-header {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

.bms-metric-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bms-metric-value {
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Monaco', 'Menlo', monospace;
}

.bms-metric-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.bms-metric-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.bms-metric-fill.soh {
    background: var(--accent);
}

.bms-stats-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.bms-stat-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', monospace;
    padding: 0.2rem 0.4rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    white-space: nowrap;
}

.bms-stat-item svg {
    opacity: 0.6;
    flex-shrink: 0;
}

.bms-stat-item.charging {
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.bms-stat-item.discharging {
    color: var(--warning);
    background: rgba(255, 165, 2, 0.1);
}

.bms-stat-item .current-arrow {
    font-weight: bold;
    font-size: 0.85rem;
}

/* Inverter Visualization */
.inverter-visualization {
    max-height: 70vh;
    overflow-y: auto;
}

.inverter-unit {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.inverter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(0, 210, 255, 0.05);
    border-bottom: 1px solid var(--border);
}

.inverter-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--accent);
}

.inverter-title-info {
    display: flex;
    flex-direction: column;
}

.inverter-model {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.inverter-sn {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Monaco', 'Menlo', monospace;
}

.bms-status-badge.success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.bms-status-badge.warning {
    background: rgba(255, 165, 2, 0.15);
    color: var(--warning);
}

.inverter-power-flow {
    display: flex;
    justify-content: space-around;
    padding: 1.25rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    gap: 1rem;
}

.power-source {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.5rem;
}

.power-icon {
    color: var(--text-muted);
}

.power-solar .power-icon {
    color: #f59e0b;
}

.power-grid .power-icon {
    color: var(--accent);
}

.power-battery .power-icon {
    color: var(--success);
}

.power-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'Monaco', 'Menlo', monospace;
    color: var(--text-primary);
}

.power-value.selling {
    color: var(--success);
}

.power-value.buying {
    color: var(--warning);
}

.power-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

.inverter-sections {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.inverter-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.inverter-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.inverter-grid-phases {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.phase-item {
    display: grid;
    grid-template-columns: 30px 1fr 1fr 1fr;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.8rem;
    font-family: 'Monaco', 'Menlo', monospace;
}

.phase-label {
    font-weight: 600;
    color: var(--accent);
}

.phase-voltage {
    color: var(--text-secondary);
}

.phase-current {
    color: var(--text-secondary);
}

.phase-power {
    color: var(--text-primary);
    font-weight: 500;
}

.inverter-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.inverter-stat {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.inverter-stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Monaco', 'Menlo', monospace;
    color: var(--text-primary);
}

.inverter-stat-value.charging {
    color: var(--success);
}

.inverter-stat-value.discharging {
    color: var(--warning);
}

.inverter-stat-value.selling {
    color: #22c55e;
}

.inverter-stat-value.buying {
    color: #ef4444;
}

.inverter-stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* BMS Modules */
.bms-modules {
    padding: 0 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bms-module {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.bms-module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    border-radius: 0.5rem 0.5rem 0 0;
}

.bms-module-title {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--accent);
    white-space: nowrap;
}

.bms-module-temps {
    display: flex;
    gap: 0.35rem;
    flex-wrap: nowrap;
}

.bms-module-temp {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-family: 'Monaco', 'Menlo', monospace;
}

.bms-module-info {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: 'Monaco', 'Menlo', monospace;
    white-space: nowrap;
}

/* Balance Indicator */
.bms-balance-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-weight: 600;
}

.bms-balance-indicator.excellent {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.bms-balance-indicator.good {
    background: rgba(132, 204, 22, 0.2);
    color: #84cc16;
}

.bms-balance-indicator.fair {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.bms-balance-indicator.poor {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.balance-delta {
    white-space: nowrap;
}

/* SOH History Panel */
.soh-history-panel {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.soh-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.soh-history-header h4 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text);
}

.soh-history-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.soh-history-controls select {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.8rem;
}

.soh-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.soh-close-btn:hover {
    color: var(--text);
}

.soh-history-stats {
    padding: 0.75rem 1rem;
}

.soh-stats-grid {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.soh-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.soh-stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.soh-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.soh-stat-value.positive {
    color: #22c55e;
}

.soh-stat-value.negative {
    color: #ef4444;
}

.soh-stat-value.neutral {
    color: var(--text-secondary);
}

.soh-history-chart-container {
    padding: 0.5rem 1rem 1rem;
    height: 180px;
}

.soh-loading, .soh-no-data, .soh-error {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.soh-error {
    color: #ef4444;
}

/* SOH Button in BMS Modal */
#showSohHistoryBtn {
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

#showSohHistoryBtn:hover {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.5);
    color: #22c55e;
}

#showSohHistoryBtn svg {
    width: 14px;
    height: 14px;
}

/* Cell Grid */
.bms-cells {
    display: flex;
    gap: 3px;
    padding: 0.4rem 0.75rem;
    flex-wrap: nowrap;
    overflow: visible;
}

.bms-cell {
    flex: 1;
    height: 32px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    cursor: default;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.bms-cell:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.cell-number {
    font-size: 0.6rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1;
}

.cell-voltage {
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Monaco', 'Menlo', monospace;
    line-height: 1;
    margin-top: 2px;
}

/* Cell Sparklines */
.bms-cell.has-sparkline {
    height: 48px;
    padding-bottom: 2px;
}

.cell-sparkline {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.9;
}

.bms-cell:hover .cell-sparkline {
    opacity: 1;
}

/* Sparkline Toggle Button */
#toggleSparklinesBtn {
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

#toggleSparklinesBtn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

#toggleSparklinesBtn.active {
    background: rgba(96, 165, 250, 0.2);
    border-color: rgba(96, 165, 250, 0.5);
    color: #60a5fa;
}

#toggleSparklinesBtn svg {
    width: 14px;
    height: 14px;
}

/* Temperature Sensors */
.bms-temps {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.bms-temp {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: default;
    transition: transform 0.15s ease;
}

.bms-temp:hover {
    transform: scale(1.05);
}

.temp-icon {
    font-size: 0.875rem;
}

.temp-value {
    color: rgba(255, 255, 255, 0.9);
    font-family: 'Monaco', 'Menlo', monospace;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    .intro-section h1 {
        font-size: 1.75rem;
    }

    .section-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Mobile: Gateway toolbar - wrap naturally */
    .gateway-toolbar {
        gap: 0.5rem;
        row-gap: 0.5rem;
    }

    .gateway-toolbar .search-box {
        flex: 1 1 auto;
        min-width: 120px;
        max-width: none;
    }

    .gateway-toolbar .status-toggle {
        flex: 0 0 auto;
    }

    .gateway-toolbar .view-toggle {
        flex: 0 0 auto;
        margin-left: auto;
    }

    .gateway-toolbar .toolbar-select {
        font-size: 0.8rem;
        height: 36px;
    }

    .gateway-toolbar .status-toggle-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .gateway-toolbar .gateway-count {
        display: none;
    }

    .gateway-toolbar .select-actions {
        display: none;
    }

    /* Legacy sort group (if still used elsewhere) */
    .gateway-sort-group {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 0.35rem;
        scrollbar-width: none;
    }

    .gateway-sort-group::-webkit-scrollbar {
        display: none;
    }

    .gateway-sort-group .sort-label {
        display: none;
    }

    .gateway-sort-btn {
        flex-shrink: 0;
    }

    /* Mobile: Bulk action bar responsive */
    .bulk-action-bar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .bulk-action-bar #selectedCount {
        width: 100%;
        text-align: center;
    }

    .bulk-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }

    .bulk-actions .btn {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 0;
        font-size: 0.8rem;
        padding: 0.6rem 0.5rem;
        justify-content: center;
    }

    .bulk-actions .btn svg {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

    .gateway-list {
        grid-template-columns: 1fr;
    }

    .gateway-card-actions {
        flex-wrap: wrap;
    }

    .gateway-status-widgets {
        grid-template-columns: 1fr 1fr;
    }

    .status-widget {
        min-height: 60px;
        padding: 0.4rem 0.5rem;
    }

    .widget-content {
        gap: 0.1rem;
    }

    .widget-title {
        font-size: 0.65rem;
    }

    .widget-values {
        gap: 0.25rem;
    }

    .widget-value-primary {
        font-size: 0.9rem;
    }

    .widget-value-secondary {
        font-size: 0.65rem;
    }

    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    .modal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .modal-data {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        max-height: 100dvh;
    }

    .modal-header {
        flex-shrink: 0;
        position: sticky;
        top: 0;
        background: rgba(21, 38, 45, 0.98);
        z-index: 10;
    }

    .modal-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: env(safe-area-inset-bottom, 1.5rem);
    }

    .modal-footer {
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: rgba(21, 38, 45, 0.98);
        padding-bottom: env(safe-area-inset-bottom, 1rem);
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .bms-cells {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        flex-wrap: wrap;
    }

    .bms-cell {
        flex: none;
        width: 100%;
    }

    .bms-header-stats {
        display: none;
    }

    .bms-soc-details {
        flex-direction: column;
        gap: 0.25rem;
    }

    .bms-visualization-full {
        grid-template-columns: 1fr;
        max-height: calc(100vh - 80px);
        max-height: calc(100dvh - 80px);
    }

    .bms-unit {
        min-width: 0;
    }

    /* Inverter modal mobile */
    .inverter-power-flow {
        flex-direction: column;
        gap: 1rem;
    }

    .inverter-grid-phases {
        flex-direction: column;
    }

    .phase-item {
        flex-wrap: wrap;
        justify-content: space-between;
    }
}

/* MQTT Log Section */
.mqttlog-section {
    padding: 0;
}

.mqttlog-container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 400px;
}

.mqttlog-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mqttlog-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mqttlog-live-badge {
    color: var(--success);
    font-weight: 500;
    font-size: 0.9rem;
}

.mqttlog-memory {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
}

.mqttlog-memory svg {
    color: var(--accent);
}

.mqttlog-container .mqtt-log-entries {
    flex: 1;
    min-height: 0;
}

.mqtt-log-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.mqtt-log-switch {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    padding: 0.25rem;
}

.mqtt-log-tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mqtt-log-tab:hover {
    color: var(--text-primary);
}

.mqtt-log-tab.active {
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent));
    color: #ffffff;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 210, 255, 0.2);
}

.mqtt-log-tab svg {
    width: 14px;
    height: 14px;
}

.mqtt-log-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mqtt-log-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.mqtt-log-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
}

.mqtt-log-filter {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.mqtt-log-filter-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.mqtt-log-gateway-filter {
    flex-shrink: 0;
    min-width: 300px;
}

/* Select2 Dark Theme Styles for MQTT Log */
.mqtt-log-gateway-filter .select2-container {
    width: 100% !important;
}

.mqtt-log-gateway-filter .select2-container--default .select2-selection--single {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    height: 36px;
    padding: 0;
}

.mqtt-log-gateway-filter .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary);
    line-height: 34px;
    padding-left: 0.75rem;
    padding-right: 2rem;
    font-size: 0.8rem;
}

.mqtt-log-gateway-filter .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--text-muted);
}

.mqtt-log-gateway-filter .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 34px;
    right: 0.5rem;
}

.mqtt-log-gateway-filter .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--text-muted) transparent transparent transparent;
}

.mqtt-log-gateway-filter .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--text-muted) transparent;
}

.mqtt-log-gateway-filter .select2-container--default .select2-selection--single .select2-selection__clear {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

.mqtt-log-gateway-filter .select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: var(--text-primary);
}

.mqtt-log-gateway-filter .select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--accent);
}

/* Select2 Dropdown Dark Theme */
.select2-container--default .select2-dropdown {
    background: #1a1f2e;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 9999;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    outline: none;
    border-color: var(--accent);
}

.select2-container--default .select2-results__option {
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--accent);
    color: var(--text-primary);
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.select2-container--default .select2-results__option--selectable {
    cursor: pointer;
}

.select2-container--default .select2-results > .select2-results__options {
    max-height: 300px;
}

.mqtt-log-filter input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.mqtt-log-filter input:focus {
    outline: none;
    border-color: var(--accent);
}

.mqtt-log-entries {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    min-height: 400px;
}

.mqtt-log-entries.ag-theme-alpine-dark {
    padding: 0;
    --ag-background-color: var(--bg-primary);
    --ag-header-background-color: var(--bg-secondary);
    --ag-odd-row-background-color: var(--bg-secondary);
    --ag-row-hover-color: var(--bg-hover);
    --ag-font-family: 'JetBrains Mono', monospace;
    --ag-font-size: 12px;
}

.mqtt-grid-alias {
    padding: 0.1rem 0.3rem;
    background: var(--bg-hover);
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.mqtt-grid-payload {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.mqtt-log-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-family: inherit;
}

.mqtt-log-entry {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-radius: 0.25rem;
    margin-bottom: 0.25rem;
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

.mqtt-log-entry.outgoing {
    border-left-color: var(--success);
}

.mqtt-log-entry.incoming {
    border-left-color: var(--accent);
}

.mqtt-log-entry.hidden {
    display: none;
}

.mqtt-log-time {
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: 0.75rem;
    min-width: 70px;
}

.mqtt-log-topic {
    color: var(--accent);
    font-weight: 500;
    margin-right: 0.75rem;
    flex-shrink: 0;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mqtt-log-entry.outgoing .mqtt-log-topic {
    color: var(--success);
}

.mqtt-log-direction {
    flex-shrink: 0;
    margin-right: 0.5rem;
    font-weight: 600;
    width: 1rem;
    text-align: center;
}

.mqtt-log-entry.outgoing .mqtt-log-direction {
    color: var(--success);
}

.mqtt-log-entry.incoming .mqtt-log-direction {
    color: var(--accent);
}

.mqtt-log-alias {
    flex-shrink: 0;
    margin-right: 0.75rem;
    padding: 0.1rem 0.4rem;
    background: var(--bg-hover);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mqtt-log-payload {
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mqtt-log-payload:hover {
    white-space: normal;
    word-break: break-all;
}

.mqtt-log-stats {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-card);
}

/* MQTT Detail Modal */
.mqtt-detail-modal {
    max-width: 700px;
    width: 90%;
}

.mqtt-detail-section {
    margin-bottom: 1rem;
}

.mqtt-detail-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.mqtt-detail-topic {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    padding: 0.75rem;
    background: var(--bg-hover);
    border-radius: 0.5rem;
    word-break: break-all;
    color: var(--accent);
}

.mqtt-detail-payload {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.mqtt-detail-payload pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

@media (max-width: 768px) {
    .mqttlog-container {
        height: calc(100vh - 140px);
        border-radius: 0.5rem;
    }

    .mqttlog-header {
        padding: 1rem;
    }

    .mqtt-log-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .mqtt-log-switch {
        width: 100%;
    }

    .mqtt-log-tab {
        flex: 1;
        justify-content: center;
    }

    .mqtt-log-actions {
        justify-content: space-between;
    }

    .mqtt-log-topic {
        max-width: 150px;
    }

    .mqtt-log-filter {
        padding: 0.5rem 1rem;
    }

    .mqtt-log-filter-row {
        flex-direction: column;
    }

    .mqtt-log-gateway-filter {
        min-width: 100%;
    }
}

/* MQTT Log Detail Modal */
.mqtt-log-detail-modal {
    max-width: 900px;
    width: 95%;
    max-height: 95vh;
}

.mqtt-log-detail-modal .modal-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.mqtt-log-detail-modal .modal-body {
    padding: 0;
}

.mqtt-log-detail-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mqtt-detail-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem 1.5rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.mqtt-detail-row {
    display: contents;
}

.mqtt-detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.mqtt-detail-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    word-break: break-all;
}

.mqtt-detail-direction {
    padding: 0.3rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: fit-content;
}

.mqtt-detail-direction.incoming {
    background: rgba(0, 210, 255, 0.2);
    color: var(--accent);
    border: 1px solid rgba(0, 210, 255, 0.3);
}

.mqtt-detail-direction.outgoing {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.mqtt-detail-topic {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    color: var(--accent);
}

.mqtt-detail-payload-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.mqtt-detail-payload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.mqtt-detail-payload-header .mqtt-detail-label {
    margin: 0;
}

.mqtt-detail-payload-header .btn {
    margin-left: auto;
}

.mqtt-detail-payload {
    background: var(--bg-primary);
    border: none;
    border-radius: 0;
    padding: 1.25rem;
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
    overflow-y: auto;
    max-height: 65vh;
    line-height: 1.5;
}

.mqtt-detail-payload.json {
    color: var(--text-secondary);
}

.mqtt-detail-payload.json .json-key {
    color: var(--accent);
}

.mqtt-detail-payload.json .json-string {
    color: var(--success);
}

.mqtt-detail-payload.json .json-number {
    color: #f59e0b;
}

.mqtt-detail-payload.json .json-boolean {
    color: #a78bfa;
}

.mqtt-detail-payload.json .json-null {
    color: var(--text-muted);
}

.mqtt-log-entry:hover {
    background: var(--bg-card-hover);
}

/* PDO MQTT Detail Modal */
#pdoMqttDetailModal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

#pdoMqttDetailModal.active {
    display: flex;
}

.pdo-mqtt-modal {
    max-width: 700px;
    width: 95%;
    max-height: 80vh;
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdo-mqtt-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.pdo-mqtt-modal .modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.pdo-mqtt-modal .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.pdo-mqtt-modal .modal-close:hover {
    color: var(--text-primary);
}

.pdo-mqtt-modal .modal-body {
    padding: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.pdo-mqtt-content {
    background: var(--bg-primary);
    padding: 1.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    color: var(--accent);
    white-space: pre-wrap;
    word-break: break-all;
    overflow-y: auto;
    max-height: 60vh;
    line-height: 1.6;
    border-radius: 0;
}

.pdo-mqtt-modal .modal-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* PWA Install Prompt */
.pwa-install-prompt {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    z-index: 10000;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    pointer-events: none;
}

.pwa-install-prompt.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, rgba(21, 38, 45, 0.95), rgba(28, 54, 65, 0.95));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(0, 210, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.pwa-install-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.pwa-install-icon svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pwa-install-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.pwa-install-text strong {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pwa-install-text span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pwa-install-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 0.5rem;
}

.pwa-install-actions button {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.pwa-install-actions button:first-child {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.pwa-install-actions button:first-child:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.pwa-install-actions button:last-child {
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    color: white;
    box-shadow: 0 2px 10px rgba(0, 210, 255, 0.3);
}

.pwa-install-actions button:last-child:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4);
}

/* PWA Install Prompt Mobile */
@media (max-width: 600px) {
    .pwa-install-prompt {
        left: 1rem;
        right: 1rem;
        transform: translateX(0) translateY(150%);
    }

    .pwa-install-prompt.show {
        transform: translateX(0) translateY(0);
    }

    .pwa-install-content {
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
        gap: 0.75rem;
        padding: 1rem;
    }

    .pwa-install-text {
        flex-basis: 100%;
        order: 2;
    }

    .pwa-install-icon {
        order: 1;
    }

    .pwa-install-actions {
        order: 3;
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .pwa-install-actions button {
        flex: 1;
        max-width: 140px;
    }
}

/* Disconnect Popup */
.disconnect-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: popup-fade-in 0.3s ease;
}

.disconnect-popup-overlay.visible {
    display: flex;
}

@keyframes popup-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.disconnect-popup {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: popup-slide-in 0.3s ease;
}

@keyframes popup-slide-in {
    from { transform: translateY(-20px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.disconnect-popup-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: rgba(255, 71, 87, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popup-icon-pulse 2s ease-in-out infinite;
}

.disconnect-popup-icon svg {
    color: #ff4757;
}

@keyframes popup-icon-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(255, 71, 87, 0); }
}

.disconnect-popup-title {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.disconnect-popup-message {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.disconnect-popup-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.disconnect-popup-actions .btn {
    min-width: 120px;
}

/* Light theme disconnect popup */
body.light-theme .disconnect-popup {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* MQTT Config Modal */
.mqtt-config-status {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 0.75rem;
    border: 1px solid var(--glass-border);
}

.mqtt-status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.mqtt-status-indicator.connected {
    color: var(--success);
}

.mqtt-status-indicator.connected svg {
    color: var(--success);
}

.mqtt-status-indicator.disconnected {
    color: #ff4757;
}

.mqtt-status-indicator.disconnected svg {
    color: #ff4757;
}

.mqtt-config-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.mqtt-config-info svg {
    flex-shrink: 0;
    color: var(--info);
    margin-top: 0.1rem;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

/* MQTT Error Banner Mobile */
@media (max-width: 768px) {
    .mqtt-error-content {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .mqtt-error-text {
        align-items: center;
    }

    .mqtt-error-actions {
        width: 100%;
    }

    .mqtt-error-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   Firmware Files Modal
   ============================================ */

.firmware-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.firmware-tab-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.firmware-tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.firmware-tab-btn.active {
    background: rgba(0, 210, 255, 0.1);
    color: var(--accent);
}

.firmware-tab-content {
    display: none;
}

.firmware-tab-content.active {
    display: block;
}

.firmware-section-header {
    margin-bottom: 1rem;
}

.firmware-section-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.firmware-section-header p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

.firmware-file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.firmware-file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.firmware-file-item:hover {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.firmware-file-icon {
    color: var(--accent);
    flex-shrink: 0;
}

.firmware-file-info {
    flex: 1;
    min-width: 0;
}

.firmware-file-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.firmware-file-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.firmware-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.firmware-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.firmware-delete-btn:active {
    transform: scale(0.95);
}

.firmware-file-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.firmware-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.firmware-action-btn:active {
    transform: scale(0.95);
}

.firmware-view-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.firmware-download-btn:hover {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--success);
    color: var(--success);
}

/* File Preview Modal */
.file-preview-modal {
    max-width: 900px;
    width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.file-preview-body {
    flex: 1;
    overflow: auto;
    padding: 0;
}

.file-preview-code {
    margin: 0;
    padding: 1rem;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    background: var(--bg-tertiary);
    border-radius: 0;
    min-height: 300px;
    max-height: 65vh;
    overflow: auto;
}

.file-preview-image {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    min-height: 200px;
    background: var(--bg-tertiary);
}

.file-preview-image img {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    border-radius: 0.25rem;
}

.file-preview-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.file-preview-modal .modal-footer .btn {
    flex: 0 0 auto;
    min-width: 120px;
}

.file-preview-title {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.file-preview-title h3 {
    margin: 0;
    font-size: 1.1rem;
}

.file-preview-url {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    word-break: break-all;
}

/* File Error Modal */
.file-error-modal {
    max-width: 450px;
    width: 90vw;
}

.file-error-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem 0;
}

.file-error-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--error);
}

.file-error-details {
    width: 100%;
}

.file-error-filename {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.file-error-path {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    margin-bottom: 0.75rem;
    word-break: break-all;
}

.file-error-type {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.file-error-message {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: var(--error);
    margin-top: 0.5rem;
}

.file-error-modal .modal-footer {
    display: flex;
    justify-content: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.file-error-modal .modal-footer .btn {
    flex: 0 0 auto;
    min-width: 120px;
}

.version-error-info {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    text-align: left;
    width: 100%;
}

.version-error-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.version-error-row:last-child {
    margin-bottom: 0;
}

.version-error-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    min-width: 60px;
    flex-shrink: 0;
}

.version-error-value {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
}

.version-error-value.error-text {
    color: var(--error);
}

.firmware-version.error {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.firmware-version.error:hover {
    color: var(--error-hover, #ff6b6b);
}

.firmware-loading,
.firmware-empty,
.firmware-error {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.firmware-error {
    color: var(--error);
}

/* ============================================
   Mail Settings Modal
   ============================================ */

.modal-wide {
    max-width: 600px;
}

.mail-settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.mail-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.mail-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.mail-tab.active {
    background: rgba(0, 210, 255, 0.1);
    color: var(--accent);
}

.smtp-status {
    margin-bottom: 1.5rem;
}

.smtp-status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 0.5rem;
    color: #ffc107;
    font-size: 0.85rem;
}

.smtp-status-indicator.connected {
    background: rgba(46, 213, 115, 0.1);
    border-color: rgba(46, 213, 115, 0.3);
    color: #2ed573;
}

.smtp-test-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.input-with-button {
    display: flex;
    gap: 0.5rem;
}

.input-with-button input {
    flex: 1;
}

.input-with-button .btn {
    white-space: nowrap;
}

/* Test Mail Console */
.test-mail-console {
    margin-top: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
}

.console-line {
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border);
}

.console-line:last-child {
    border-bottom: none;
}

/* Webhook Settings */
.webhook-info {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.webhook-info svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #3b82f6;
}

.webhook-master-toggle {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.webhook-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.webhook-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.webhook-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.webhook-item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.webhook-item-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.webhook-name {
    font-weight: 500;
    color: var(--text);
}

.webhook-platform {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.webhook-platform.slack {
    background: rgba(74, 21, 75, 0.3);
    color: #e01e5a;
}

.webhook-platform.teams {
    background: rgba(80, 80, 200, 0.2);
    color: #6264a7;
}

.webhook-platform.discord {
    background: rgba(88, 101, 242, 0.2);
    color: #5865f2;
}

.webhook-platform.generic, .webhook-platform.auto {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.webhook-item-actions {
    display: flex;
    gap: 0.25rem;
}

.webhook-item-details {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 0.5rem;
    padding: 0.75rem;
}

.webhook-name-input,
.webhook-url-input,
.webhook-platform-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.85rem;
}

.webhook-platform-select {
    min-width: 130px;
}

.add-webhook-btn {
    width: 100%;
    justify-content: center;
}

.webhook-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Small toggle switch for webhook items */
.toggle-switch-small {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

.toggle-switch-small input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider-small {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    transition: 0.2s;
    border-radius: 18px;
}

.toggle-slider-small:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: 0.2s;
    border-radius: 50%;
}

.toggle-switch-small input:checked + .toggle-slider-small {
    background-color: rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.5);
}

.toggle-switch-small input:checked + .toggle-slider-small:before {
    transform: translateX(14px);
    background-color: #22c55e;
}

/* Button icon style */
.btn-icon {
    background: none;
    border: none;
    padding: 0.35rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
}

@media (max-width: 768px) {
    .webhook-item-details {
        grid-template-columns: 1fr;
    }

    .webhook-platform-select {
        min-width: auto;
    }
}

.console-status {
    flex-shrink: 0;
    font-weight: bold;
}

.console-status.success {
    color: var(--success);
}

.console-status.error {
    color: var(--error);
}

.console-status.pending {
    color: var(--warning);
}

.console-step {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 100px;
}

.console-details {
    color: var(--text-muted);
    flex: 1;
    word-break: break-word;
}

/* Template List */
.template-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.template-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent);
    transform: translateX(4px);
}

.template-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 210, 255, 0.1);
    border-radius: 0.5rem;
    color: var(--accent);
}

.template-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.template-info strong {
    font-weight: 500;
    color: var(--text-primary);
}

.template-info span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.template-item > svg:last-child {
    color: var(--text-muted);
}

/* Template Editor */
.template-editor-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.template-editor-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
}

/* Template Editor Styles */
.template-body-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.template-variables-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem 0.5rem 0 0;
    border-bottom: none;
    flex-wrap: wrap;
}

.template-variables-bar .variables-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.variable-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.variable-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.15s ease;
}

.variable-chip:hover {
    background: rgba(0, 210, 255, 0.2);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.variable-chip:active {
    transform: translateY(0);
}

.template-editor-wrapper {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 0 0 0.5rem 0.5rem;
    background: var(--bg-primary);
    overflow: hidden;
}

.template-line-numbers {
    padding: 0.75rem 0.5rem;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
    text-align: right;
    user-select: none;
    min-width: 2.5rem;
}

.template-line-numbers span {
    display: block;
}

#templateBody {
    flex: 1;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 0.75rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    resize: none;
    min-height: 280px;
    outline: none;
}

#templateBody:focus {
    box-shadow: inset 0 0 0 1px var(--accent);
}

#templateBody::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

/* ============================================
   Main Navigation
   ============================================ */
.main-nav {
    display: flex;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem;
    border-radius: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: var(--text-primary);
    background: rgba(0, 210, 255, 0.15);
}

.nav-btn svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .nav-btn span {
        display: none;
    }

    .nav-btn {
        padding: 0.5rem;
    }
}

/* ============================================
   Web Flasher - Neues Design
   ============================================ */
.flasher-section {
    padding: 0;
}

.flasher-card {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

/* Header */
.flasher-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.flasher-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.flasher-header h2 svg {
    color: var(--primary);
}

.flasher-tabs {
    display: flex;
    gap: 0.5rem;
}

.flasher-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flasher-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card);
    border-color: var(--text-muted);
}

.flasher-tab-btn.active {
    color: var(--accent);
    background: var(--bg-card);
    border-color: var(--accent);
}

.flasher-tab-btn svg {
    width: 16px;
    height: 16px;
}

/* Body */
.flasher-body {
    padding: 0;
}

.flasher-tab-content {
    display: none;
}

.flasher-tab-content.active {
    display: flex;
}

/* === Flash Tab Layout === */
#flasher-tab-flash.active {
    display: grid;
    grid-template-columns: 1fr 280px;
    padding: 0;
    gap: 0;
}

.flasher-main {
    display: flex;
    flex-direction: column;
    padding: 2rem;
    gap: 1.5rem;
}

/* Zentrale Flash-Box */
.flasher-center-box {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
}

.flasher-chip-icon {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 210, 255, 0.1);
    border-radius: 1rem;
    color: var(--accent);
}

.flasher-chip-icon svg {
    width: 40px;
    height: 40px;
}

.flasher-info {
    flex: 1;
    min-width: 0;
}

.flasher-center-box h3 {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.flasher-chip-info {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.flasher-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* Mode Toggle Chips */
.flasher-mode-toggle {
    display: flex;
    gap: 0.5rem;
}

.flasher-mode-chip {
    cursor: pointer;
}

.flasher-mode-chip input {
    display: none;
}

.flasher-mode-chip .chip-content {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.875rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.flasher-mode-chip:hover .chip-content {
    border-color: var(--text-muted);
}

.flasher-mode-chip input:checked + .chip-content {
    background: rgba(0, 210, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.flasher-mode-chip .chip-content svg {
    width: 14px;
    height: 14px;
}

/* Main Flash Button */
esp-web-install-button::part(button) {
    display: none;
}

.flasher-main-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent));
    border: none;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.flasher-main-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.4);
}

.flasher-main-btn svg {
    width: 18px;
    height: 18px;
}

.flasher-unsupported {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 0.5rem;
    color: var(--error);
    font-size: 0.8rem;
}

.flasher-blocked {
    padding: 0.5rem 1rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 0.5rem;
    color: var(--warning);
    font-size: 0.8rem;
    text-align: center;
}

/* Hint Box */
.flasher-hint {
    display: flex;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.2);
    border-radius: 0.5rem;
}

.flasher-hint.info {
    background: rgba(139, 233, 253, 0.08);
    border-color: rgba(139, 233, 253, 0.2);
}

.flasher-hint.info .hint-icon,
.flasher-hint.info .hint-text {
    color: var(--info);
}

.hint-icon {
    flex-shrink: 0;
    color: var(--warning);
    margin-top: 1px;
}

.hint-text {
    font-size: 0.8rem;
    color: var(--warning);
    line-height: 1.4;
}

/* Flash Layout Visualisierung */
.flash-layout-viz {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(0,0,0,0.3) 100%);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.flash-layout-viz::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 100%);
    opacity: 0.6;
}

.flash-layout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.flash-chip-visual {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
}

.flash-chip-visual svg {
    color: var(--accent);
}

.flash-size-badge {
    padding: 0.25rem 0.625rem;
    background: rgba(0, 210, 255, 0.15);
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
}

.flash-memory-bar {
    display: flex;
    height: 48px;
    background: rgba(0,0,0,0.4);
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
}

.flash-partition {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    border-right: 1px solid rgba(0,0,0,0.4);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
    overflow: hidden;
}

.flash-partition:last-child {
    border-right: none;
}

.flash-partition::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    pointer-events: none;
}

/* Partition Größen (proportional) - Total ~15.6 MB */
.flash-partition.nvs { flex: 0.15; background: #4a5568; }      /* 24K */
.flash-partition.otadata { flex: 0.05; background: #5a6578; }  /* 8K */
.flash-partition.phy { flex: 0.03; background: #4a5568; }      /* 4K */
.flash-partition.ota0 { flex: 25; background: #3182ce; }       /* 4M - Firmware */
.flash-partition.ota1 { flex: 25; background: #2c5282; }       /* 4M */
.flash-partition.coredump { flex: 0.4; background: #744210; }  /* 64K */
.flash-partition.storage { flex: 43; background: #2d3748; }    /* 7M */
.flash-partition.config { flex: 3; background: #553c9a; }      /* 500K */

.partition-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
    z-index: 1;
}

.partition-size {
    font-size: 0.55rem;
    color: rgba(255,255,255,0.6);
    z-index: 1;
}

/* Kleine Partitionen: Label verstecken */
.flash-partition.nvs .partition-label,
.flash-partition.otadata .partition-label,
.flash-partition.phy .partition-label,
.flash-partition.coredump .partition-label {
    display: none;
}

/* Flash Mode States */
/* Neuinstallation: ota0 + storage werden geschrieben, config gelöscht */
.flash-layout-viz.mode-full .flash-partition.ota0,
.flash-layout-viz.mode-full .flash-partition.storage {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    box-shadow: inset 0 0 20px rgba(56, 161, 105, 0.4);
    animation: flash-glow 1.5s infinite alternate;
}

.flash-layout-viz.mode-full .flash-partition.config {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    box-shadow: inset 0 0 15px rgba(229, 62, 62, 0.3);
    animation: flash-pulse 2s infinite;
}

/* Rest bleibt unverändert bei Neuinstallation */
.flash-layout-viz.mode-full .flash-partition.nvs,
.flash-layout-viz.mode-full .flash-partition.otadata,
.flash-layout-viz.mode-full .flash-partition.phy,
.flash-layout-viz.mode-full .flash-partition.ota1,
.flash-layout-viz.mode-full .flash-partition.coredump {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    opacity: 0.5;
}

/* Update: OTA Data + Firmware (ota0) + Storage (Frontend) werden geflasht */
.flash-layout-viz.mode-update .flash-partition.otadata,
.flash-layout-viz.mode-update .flash-partition.ota0,
.flash-layout-viz.mode-update .flash-partition.storage {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    box-shadow: inset 0 0 20px rgba(56, 161, 105, 0.4);
    animation: flash-glow 1.5s infinite alternate;
}

/* Config bleibt explizit erhalten */
.flash-layout-viz.mode-update .flash-partition.config {
    background: linear-gradient(135deg, #805ad5 0%, #6b46c1 100%);
    box-shadow: inset 0 0 15px rgba(128, 90, 213, 0.4);
}

.flash-layout-viz.mode-update .flash-partition.config::after {
    content: '✓';
    position: absolute;
    font-size: 0.85rem;
    font-weight: bold;
    color: #d6bcfa;
    text-shadow: 0 0 4px rgba(214, 188, 250, 0.5);
}

/* Rest bleibt unverändert bei Update */
.flash-layout-viz.mode-update .flash-partition.nvs,
.flash-layout-viz.mode-update .flash-partition.phy,
.flash-layout-viz.mode-update .flash-partition.ota1,
.flash-layout-viz.mode-update .flash-partition.coredump {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    opacity: 0.5;
}

@keyframes flash-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes flash-glow {
    0% { box-shadow: inset 0 0 15px rgba(56, 161, 105, 0.3); }
    100% { box-shadow: inset 0 0 25px rgba(56, 161, 105, 0.6); }
}

/* Legend */
.flash-layout-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.1);
}

.legend-item.flash-write .legend-dot {
    background: linear-gradient(135deg, #38a169, #2f855a);
    box-shadow: 0 0 6px rgba(56, 161, 105, 0.5);
}

.legend-item.unchanged .legend-dot {
    background: linear-gradient(135deg, #2d3748, #1a202c);
    opacity: 0.6;
}

.legend-item.preserved .legend-dot {
    background: linear-gradient(135deg, #805ad5, #6b46c1);
}

.legend-item.erased .legend-dot {
    background: linear-gradient(135deg, #e53e3e, #c53030);
}

/* Sidebar */
.flasher-sidebar {
    padding: 2rem;
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border);
}

.flasher-req-box {
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
}

.flasher-req-box h4 {
    margin: 0 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.flasher-req-box ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.flasher-req-box li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.flasher-req-box li svg {
    flex-shrink: 0;
    color: var(--success);
    opacity: 0.7;
}

/* Steps Liste */
.flasher-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: step;
}

.flasher-steps li {
    position: relative;
    padding: 0.4rem 0 0.4rem 1.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    counter-increment: step;
}

.flasher-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* === Console Tab Layout === */
#flasher-tab-config {
    flex-direction: column;
}

.flasher-console-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 450px;
}

/* Controls Panel */
.flasher-controls-panel {
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.flasher-connect-box {
    margin-bottom: 0.5rem;
}

.flasher-connect-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flasher-connect-btn:hover {
    border-color: var(--accent);
}

.flasher-connect-btn.connected {
    border-color: var(--success);
    background: rgba(46, 213, 115, 0.05);
}

.connect-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 0.375rem;
    color: var(--text-muted);
}

.flasher-connect-btn.connected .connect-icon {
    color: var(--success);
}

.connect-text {
    flex: 1;
    text-align: left;
}

.connect-text span {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.connect-text small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.flasher-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.4;
}

.flasher-status-dot.connected {
    background: var(--success);
    opacity: 1;
    box-shadow: 0 0 8px var(--success);
}

.flasher-status-dot.error {
    background: var(--error);
    opacity: 1;
    box-shadow: 0 0 8px var(--error);
}

/* Config Section */
.flasher-config-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.flasher-config-section.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.config-block h4 {
    margin: 0 0 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.config-inputs input {
    padding: 0.5rem 0.625rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.config-inputs input:focus {
    outline: none;
    border-color: var(--accent);
}

.config-inputs input::placeholder {
    color: var(--text-muted);
}

.config-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-sm {
    flex: 1;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-sm.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-sm.btn-ghost:hover {
    background: var(--bg-card);
    border-color: var(--text-muted);
}

.btn-sm.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-sm.btn-primary:hover {
    background: var(--accent-secondary);
}

/* Quick Commands */
.quick-cmds {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
}

.quick-cmds button {
    padding: 0.4rem 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-cmds button:hover {
    background: rgba(0, 210, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

/* Debug Commands */
.debug-cmds {
    grid-template-columns: 1fr 1fr;
}

.debug-cmds .debug-on {
    background: rgba(46, 213, 115, 0.1);
    border-color: rgba(46, 213, 115, 0.3);
    color: var(--success);
}

.debug-cmds .debug-on:hover {
    background: rgba(46, 213, 115, 0.2);
    border-color: var(--success);
}

.debug-cmds .debug-off {
    background: rgba(255, 71, 87, 0.1);
    border-color: rgba(255, 71, 87, 0.3);
    color: var(--error);
}

.debug-cmds .debug-off:hover {
    background: rgba(255, 71, 87, 0.2);
    border-color: var(--error);
}

/* Terminal Panel */
.flasher-terminal-panel {
    display: flex;
    flex-direction: column;
    background: #0d0d0d;
}

.terminal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.terminal-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.terminal-clear {
    padding: 0.2rem 0.5rem;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0.25rem;
    color: var(--text-muted);
    font-size: 0.65rem;
    cursor: pointer;
}

.terminal-clear:hover {
    background: rgba(255,255,255,0.05);
}

.flasher-terminal {
    flex: 1;
    padding: 0.75rem;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.75rem;
    overflow-y: auto;
    min-height: 250px;
}

.flasher-terminal-line {
    color: #a8b2c1;
    margin: 2px 0;
    word-break: break-all;
}

.flasher-terminal-line.sent {
    color: var(--accent);
}

.flasher-terminal-line.received {
    color: #98c379;
}

.flasher-terminal-line.error {
    color: #e06c75;
}

.flasher-terminal-line.info {
    color: #e5c07b;
}

.terminal-input-row {
    display: flex;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.terminal-input-row input {
    flex: 1;
    padding: 0.625rem 0.75rem;
    background: rgba(0,0,0,0.3);
    border: none;
    color: #fff;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.8rem;
}

.terminal-input-row input:focus {
    outline: none;
    background: rgba(0,0,0,0.5);
}

.terminal-input-row input::placeholder {
    color: #555;
}

.terminal-input-row button {
    padding: 0.625rem 0.875rem;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.terminal-input-row button:hover {
    background: var(--accent-secondary);
}

/* === Responsive === */
@media (max-width: 1024px) {
    #flasher-tab-flash {
        grid-template-columns: 1fr;
    }

    .flasher-sidebar {
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .flasher-sidebar .flasher-req-box:last-child {
        margin-top: 0 !important;
    }

    .flasher-sidebar {
        display: flex;
        gap: 1rem;
    }

    .flasher-sidebar .flasher-req-box {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .flasher-card {
        border-radius: 0.75rem;
    }

    .flasher-main {
        padding: 1.5rem;
    }

    .flasher-center-box {
        flex-direction: column;
        text-align: center;
        gap: 1.25rem;
    }

    .flasher-info {
        text-align: center;
    }

    .flasher-actions {
        flex-direction: column;
        width: 100%;
    }

    .flasher-mode-toggle {
        width: 100%;
        justify-content: center;
    }

    .flasher-sidebar {
        flex-direction: column;
        padding: 1.5rem;
    }

    .flasher-console-layout {
        grid-template-columns: 1fr;
    }

    .flasher-controls-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .flasher-terminal {
        min-height: 200px;
    }
}

@media (max-width: 480px) {
    .flasher-tab-btn {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }

    .flasher-main {
        padding: 1rem;
    }

    .flasher-center-box {
        padding: 1.25rem;
    }

    .flasher-chip-icon {
        width: 56px;
        height: 56px;
    }

    .flasher-chip-icon svg {
        width: 28px;
        height: 28px;
    }

    .flasher-main-btn {
        width: 100%;
        padding: 0.75rem 1rem;
    }

    .flasher-mode-toggle {
        flex-direction: column;
    }

    .flasher-mode-chip .chip-content {
        width: 100%;
        justify-content: center;
    }

    .flasher-sidebar {
        padding: 1rem;
    }

    .quick-cmds {
        grid-template-columns: 1fr 1fr;
    }
}

/* Mobile Gateway Status Widgets - keep 2 columns on mobile */
@media (max-width: 480px) {
    /* Compact toolbar for small screens - horizontal scroll */
    .gateway-toolbar {
        gap: 0.4rem;
    }

    .gateway-toolbar .search-box {
        min-width: 100px;
        max-width: 140px;
    }

    .gateway-toolbar .toolbar-select {
        font-size: 0.7rem;
        height: 32px;
        padding: 0 1.2rem 0 0.4rem;
    }

    .gateway-toolbar .status-toggle-btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.7rem;
    }

    .gateway-toolbar .view-toggle .view-btn {
        padding: 0.25rem;
        min-width: 32px;
        height: 32px;
    }

    .gateway-toolbar .view-toggle .view-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Status widgets - 2 columns but more compact */
    .gateway-status-widgets {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }

    .status-widget {
        min-height: auto;
        padding: 0.375rem 0.5rem;
    }

    .widget-icon svg {
        width: 20px;
        height: 20px;
    }

    .widget-title {
        font-size: 0.6rem;
    }

    .widget-value-primary {
        font-size: 0.8rem;
    }

    .widget-value-secondary {
        font-size: 0.6rem;
    }

    .stat {
        padding: 0.3rem 0.5rem;
    }

    .stat-icon svg {
        width: 12px;
        height: 12px;
    }

    .stat-value {
        font-size: 0.7rem;
    }
}

/* ============================================
   Passkey Management Styles
   ============================================ */

.passkey-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.passkey-add-section {
    background: rgba(0, 210, 255, 0.05);
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.passkey-add-section .form-group {
    margin-bottom: 1rem;
}

.passkey-add-section .btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.passkey-list-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.passkey-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.passkey-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.passkey-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.passkey-item:hover {
    border-color: var(--accent-dim);
    background: rgba(255, 255, 255, 0.02);
}

.passkey-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    background: var(--accent-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.passkey-details {
    flex: 1;
    min-width: 0;
}

.passkey-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.passkey-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.passkey-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.passkey-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.passkey-action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.passkey-action-btn.delete:hover {
    background: rgba(255, 71, 87, 0.1);
    border-color: var(--error);
    color: var(--error);
}

/* Passkey Modal specific */
#passkeysModal {
    max-width: 500px;
}

#passkeysModal .modal-content {
    max-height: 70vh;
    overflow-y: auto;
}

/* ============================================
   ESP Web Tools Dialog Dark Theme
   ============================================ */

ewt-install-dialog,
ewt-page-progress,
ewt-page-message {
    --mdc-theme-primary: var(--accent);
    --mdc-theme-on-primary: #ffffff;
    --mdc-dialog-heading-ink-color: var(--text-primary);
    --mdc-dialog-content-ink-color: var(--text-secondary);
}

ewt-install-dialog::part(dialog) {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

ewt-install-dialog::part(surface) {
    background: var(--bg-secondary);
}

ewt-install-dialog::part(content) {
    color: var(--text-secondary);
}

ewt-install-dialog::part(headline) {
    color: var(--text-primary);
    font-weight: 600;
}

/* Style the dialog buttons */
ewt-install-dialog ewt-button,
ewt-install-dialog mwc-button,
ewt-install-dialog button {
    --mdc-theme-primary: var(--accent);
    --mdc-button-ink-color: var(--accent);
}

/* Progress bar */
ewt-install-dialog ewt-linear-progress,
ewt-install-dialog mwc-linear-progress {
    --mdc-theme-primary: var(--accent);
    --mdc-linear-progress-buffer-color: var(--bg-tertiary);
}

/* Icon colors */
ewt-install-dialog ewt-icon-button,
ewt-install-dialog mwc-icon-button {
    --mdc-icon-button-ink-color: var(--text-secondary);
}

/* Menu styling */
ewt-install-dialog mwc-list-item {
    --mdc-theme-text-primary-on-background: var(--text-primary);
    color: var(--text-primary);
}

/* Text fields inside dialog */
ewt-install-dialog mwc-textfield {
    --mdc-text-field-ink-color: var(--text-primary);
    --mdc-text-field-fill-color: var(--bg-tertiary);
    --mdc-text-field-label-ink-color: var(--text-muted);
    --mdc-text-field-outlined-idle-border-color: var(--border);
    --mdc-text-field-outlined-hover-border-color: var(--accent);
}

/* ============================================
   Firmware Management Section
   ============================================ */

.firmware-section {
    display: none;
    padding: 0;
}

/* .firmware-container - Styles sind in .section-container-base konsolidiert */

/* .firmware-header - Styles sind in .section-header-base konsolidiert */

.firmware-header h2 {
    margin: 0 0 0.25rem 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.firmware-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.firmware-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.firmware-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.firmware-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(0, 210, 255, 0.05);
    border-bottom: 1px solid var(--border);
}

.firmware-card-header > svg {
    color: var(--accent);
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.firmware-card-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.firmware-card-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.firmware-version {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Monaco', 'Menlo', monospace;
}

.firmware-version.error {
    color: var(--error);
    font-style: italic;
    font-family: inherit;
}

.firmware-card-header .btn.btn-small.btn-danger {
    padding: 0 !important;
    min-width: 28px !important;
    max-width: 28px !important;
    width: 28px !important;
    height: 28px !important;
    margin-left: auto;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px !important;
}

.firmware-card-header .btn.btn-small.btn-danger svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.firmware-file-list {
    padding: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.firmware-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.firmware-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.firmware-file-item:last-child {
    margin-bottom: 0;
}

.firmware-file-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1;
}

.firmware-file-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
    word-break: break-all;
}

.firmware-file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   BMS PDO Log Section (Page)
   ============================================ */

.pdolog-section {
    display: none;
    padding: 0;
}

/* .pdolog-container - Base in .section-container-base, nur Überschreibung */
.pdolog-container {
    max-width: 1600px;
}

/* .pdolog-header - Base in .section-header-base, nur Überschreibung */
.pdolog-header {
    background: transparent;
}

.pdolog-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pdolog-gateway-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pdolog-gateway-selector label {
    font-weight: 500;
    color: var(--text-secondary);
}

.pdolog-gateway-selector select {
    min-width: 280px;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.pdolog-gateway-selector select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.1);
}

.pdolog-content {
    background: transparent;
    border: none;
    padding: 1.5rem;
    min-height: 600px;
}

.pdolog-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    text-align: center;
}

.pdolog-empty-state svg {
    color: var(--text-muted);
    opacity: 0.5;
}

.pdolog-empty-state p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0;
}

/* PDO Log Page inherits styles from PDO Log Modal */
.pdolog-section .pdo-log-tabs {
    margin-bottom: 1rem;
}

.pdolog-section .pdo-log-entries {
    /* Auto-height - table grows with content, uses page scroll */
    width: 100%;
}

/* AG Grid container styling */
.pdolog-section .pdo-log-entries.ag-theme-alpine-dark {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
    --ag-background-color: var(--bg-secondary);
    --ag-header-background-color: var(--bg-card);
    --ag-odd-row-background-color: var(--bg-secondary);
    --ag-row-hover-color: var(--bg-card-hover);
    --ag-border-color: var(--border);
    --ag-header-foreground-color: var(--text-primary);
    --ag-foreground-color: var(--text-primary);
    --ag-secondary-foreground-color: var(--text-muted);
    --ag-input-focus-border-color: var(--accent);
    --ag-range-selection-border-color: var(--accent);
    --ag-selected-row-background-color: rgba(59, 130, 246, 0.2);
    --ag-font-size: 13px;
    --ag-row-height: 36px;
    --ag-header-height: 40px;
}

.pdolog-section .pdo-log-main-area {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.pdolog-section .pdo-log-detail-panel {
    width: 400px;
    flex-shrink: 0;
}

/* AG Grid floating filter inputs */
.pdolog-section .ag-theme-alpine-dark .ag-floating-filter-input input,
.pdolog-section .ag-theme-alpine-dark .ag-floating-filter-input select {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 3px;
    font-size: 0.8rem;
}

.pdolog-section .ag-theme-alpine-dark .ag-floating-filter-input input::placeholder {
    color: var(--text-muted);
}

/* AG Grid row styling */
.pdolog-section .ag-theme-alpine-dark .ag-row {
    cursor: pointer;
}

.pdolog-section .ag-theme-alpine-dark .ag-row:hover {
    background: var(--bg-card-hover) !important;
}

/* AG Grid header styling */
.pdolog-section .ag-theme-alpine-dark .ag-header {
    border-bottom: 2px solid var(--border);
}

.pdolog-section .ag-theme-alpine-dark .ag-header-cell {
    border-right: 1px solid var(--border);
}

/* AG Grid cell styling */
.pdolog-section .ag-theme-alpine-dark .ag-cell {
    border-right: 1px solid var(--border);
}

/* PDO Columns Dropdown */
.pdo-columns-dropdown {
    position: relative;
    display: inline-flex;
}

.pdo-columns-dropdown .btn {
    margin: 0;
}

.pdo-columns-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 9999;
    min-width: 180px;
    max-height: 400px;
    overflow-y: auto;
    background: #1a1f2e;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    padding: 0.5rem 0;
    margin-top: 4px;
}

.pdo-columns-menu.show {
    display: block;
}

.pdo-column-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: #1a1f2e;
    transition: background 0.15s;
}

.pdo-column-option:hover {
    background: #252b3d;
}

.pdo-column-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.pdo-column-option span {
    flex: 1;
    white-space: nowrap;
}

.pdo-columns-menu-header {
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.pdo-columns-group {
    padding: 0.25rem 0;
}

.pdo-columns-group-label {
    display: block;
    padding: 0.25rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pdo-column-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: background 0.15s;
}

.pdo-column-checkbox:hover {
    background: var(--bg-hover);
}

.pdo-column-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Select2 styles for PDO Log page */
.pdolog-gateway-selector .select2-container {
    min-width: 350px;
}

.pdolog-gateway-selector .select2-container--default .select2-selection--single {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    height: 38px;
    padding: 4px 8px;
}

.pdolog-gateway-selector .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary);
    line-height: 28px;
    padding-left: 4px;
}

.pdolog-gateway-selector .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

.pdolog-gateway-selector .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--text-muted);
}

/* Select2 Dropdown (rendered in body, not inside section) */
.select2-container--default .select2-dropdown {
    background: #1a1f2e;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 9999;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    background: #151922;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    color: var(--text-primary);
    padding: 6px 10px;
}

.select2-container--default .select2-results__option {
    padding: 8px 12px;
    color: var(--text-primary);
    background: #1a1f2e;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--accent);
    color: white;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background: #151922;
}

.select2-container--default .select2-results__option[aria-disabled=true] {
    color: var(--text-muted);
    opacity: 0.6;
}

.select2-container--default .select2-results {
    background: #1a1f2e;
}

/* Gateway option formatting */
.gateway-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gateway-select-option .gateway-name {
    font-weight: 500;
}

.gateway-select-option .gateway-mac {
    margin-left: auto;
}

/* Mobile responsive - PDO Log Section */
@media (max-width: 768px) {
    .pdolog-section {
        overflow-x: hidden;
        max-width: 100vw;
        padding-bottom: 80px; /* Space for mobile bottom nav */
    }

    .pdolog-container {
        overflow-x: hidden;
        max-width: 100%;
        border-radius: 0.75rem;
    }

    .pdolog-header {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .pdolog-header h2 {
        font-size: 1.2rem;
    }

    .pdolog-gateway-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .pdolog-gateway-selector select,
    .pdolog-gateway-selector .select2-container {
        min-width: auto;
        width: 100% !important;
    }

    .pdolog-section .pdo-log-main-area {
        flex-direction: column;
    }

    .pdolog-section .pdo-log-detail-panel {
        width: 100%;
    }

    .pdolog-content {
        padding: 0.75rem;
        min-height: 300px;
        overflow-x: hidden;
        max-width: 100%;
    }

    /* PDO Log Tabs - prevent overflow */
    .pdolog-section .pdo-log-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .pdolog-section .pdo-log-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* PDO Log Header Buttons on mobile */
    .pdo-log-header-buttons {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .pdo-log-header-buttons .btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    .pdo-log-header-buttons select {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
        min-width: 100px;
    }

    /* PDO Error Sub-tabs on mobile */
    .pdo-error-subtabs {
        flex-wrap: wrap;
    }

    .pdo-error-subtab {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    /* PDO Filter row on mobile */
    .pdo-filter-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .pdo-filter-row input,
    .pdo-filter-row select {
        width: 100%;
        max-width: none;
    }

    .pdo-node-filter {
        flex-wrap: wrap;
    }

    /* PDO Log Header on mobile */
    .pdo-log-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .pdo-log-header-buttons {
        width: 100%;
        justify-content: flex-start;
    }

    /* DateTime picker on mobile */
    .datetime-picker-group {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .datetime-picker-group input[type="datetime-local"] {
        width: 100%;
        max-width: none;
    }

    /* PDO Log search on mobile */
    .pdo-log-search {
        flex-direction: column;
    }

    .pdo-log-search input {
        width: 100%;
    }

    /* PDO Log filters container */
    .pdo-log-filters {
        overflow-x: hidden;
    }

    /* PDO Snapshot header on mobile */
    .pdo-log-snapshot-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* AG Grid container overflow */
    .pdo-log-entries {
        overflow-x: auto;
        max-width: 100%;
    }

    /* Main area overflow */
    .pdo-log-main-area {
        overflow-x: hidden;
        max-width: 100%;
    }

    /* Tab content overflow */
    .pdo-log-tab-content {
        overflow-x: hidden;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .pdolog-header {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .pdolog-header h2 {
        font-size: 1rem;
    }

    .pdolog-content {
        padding: 0.5rem;
    }

    .pdo-log-header-buttons .btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }

    .pdo-log-header-buttons select {
        padding: 0.3rem 0.4rem;
        font-size: 0.7rem;
        min-width: 80px;
    }
}

/* ============================================
   Monitoring Section
   ============================================ */

.monitoring-section {
    display: none;
    padding: 0;
    transition: all 0.3s ease;
}

/* Fullscreen Monitoring Mode */
.monitoring-section.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    padding: 0;
    background: var(--bg-primary);
}

.monitoring-section.fullscreen .monitoring-container {
    max-width: none;
    height: 100vh;
    gap: 0;
}

.monitoring-section.fullscreen .monitoring-map-area {
    flex: 1;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
}

.monitoring-section.fullscreen .monitoring-map {
    flex: 1;
    height: auto !important;
}

.monitoring-section.fullscreen .monitoring-dashboard {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
}

.monitoring-section.fullscreen .monitoring-map-row {
    flex: 1;
    min-height: 0;
    position: relative;
}

.monitoring-section.fullscreen .gateway-detail-panel {
    position: absolute;
    right: 1rem;
    top: 1rem;
    z-index: 1000;
    max-height: calc(100% - 2rem);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.monitoring-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Map and Detail Panel Row */
.monitoring-map-row {
    display: flex;
    gap: 1rem;
}

/* Gateway Detail Panel */
.gateway-detail-panel {
    width: 280px;
    min-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    display: none;
    flex-direction: column;
    max-height: 530px;
    overflow: hidden;
}

.gateway-detail-panel.active {
    display: flex;
}

.detail-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
}

.detail-panel-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.detail-panel-close {
    padding: 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-panel-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.detail-panel-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

/* Detail Panel Sections */
.detail-section {
    margin-bottom: 1rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    font-size: 0.8rem;
}

.detail-label {
    color: var(--text-secondary);
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-value.online {
    color: var(--success);
}

.detail-value.offline {
    color: var(--error);
}

.detail-value.warning {
    color: var(--warning);
}

/* Detail Panel BMS List */
.detail-bms-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-bms-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.detail-bms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.detail-bms-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    font-size: 0.7rem;
}

.detail-bms-stat {
    display: flex;
    justify-content: space-between;
}

.detail-bms-stat .label {
    color: var(--text-muted);
}

.detail-bms-stat .value {
    color: var(--text-primary);
}

/* Detail Panel Actions */
.detail-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.detail-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.detail-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-color: var(--accent);
}

.detail-action-btn.primary {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.detail-action-btn.primary:hover {
    background: var(--accent-hover);
}

@media (max-width: 1200px) {
    .gateway-detail-panel {
        width: 250px;
        min-width: 250px;
    }
}

@media (max-width: 992px) {
    .monitoring-map-row {
        flex-direction: column;
    }

    .gateway-detail-panel {
        width: 100%;
        min-width: auto;
        max-height: 300px;
    }
}

/* Map Area */
.monitoring-map-area {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    overflow: hidden;
}

.monitoring-map-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.monitoring-map-header h2 {
    margin-right: auto;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.last-update-badge {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
}

.fullscreen-btn,
.refit-btn {
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-btn:hover,
.refit-btn:hover {
    background: var(--bg-card-hover);
    color: var(--accent);
    border-color: var(--accent);
}

.map-legend-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
    justify-content: flex-end;
}

.map-legend {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.map-controls {
    display: flex;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.legend-dot.offline {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.legend-dot.warning {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.monitoring-map {
    height: 450px;
    background: var(--bg-primary);
    position: relative;
}

/* Map tile color filter to match app theme - dark cyan theme */
.monitoring-map .leaflet-tile-pane {
    filter: saturate(0.8) brightness(0.95) contrast(1.05);
}

/* Dark mode map - much darker with cyan tint */
.monitoring-map .leaflet-tile-pane {
    filter: brightness(0.4) contrast(1.3) saturate(0.2) sepia(0.3) hue-rotate(160deg);
}

/* Subtle cyan overlay effect for dark mode */
.monitoring-map::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 40, 50, 0.4), rgba(0, 20, 30, 0.5));
    pointer-events: none;
    z-index: 400;
}

/* Leaflet Dark Theme Override */
.monitoring-map .leaflet-control-zoom a,
.monitoring-map .leaflet-control-layers {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

.monitoring-map .leaflet-control-zoom a:hover {
    background: var(--bg-tertiary) !important;
}

.monitoring-map .leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.6) !important;
    color: var(--text-muted) !important;
}

.monitoring-map .leaflet-control-attribution a {
    color: var(--accent) !important;
}

.monitoring-map .leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.monitoring-map .leaflet-popup-tip {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.monitoring-map .leaflet-popup-close-button {
    color: var(--text-muted) !important;
}

/* Gateway Marker Styles */
.gateway-marker {
    position: relative;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.1);
    cursor: grab;
    transition: all 0.2s ease;
}

.gateway-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
}

.gateway-marker:hover {
    transform: scale(1.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.gateway-marker.online {
    background: radial-gradient(circle at 30% 30%, #5af587, var(--success));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 8px rgba(46, 213, 115, 0.4);
}

.gateway-marker.offline {
    background: radial-gradient(circle at 30% 30%, #ff7b7b, var(--error));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 8px rgba(255, 71, 87, 0.4);
}

.gateway-marker.warning {
    background: radial-gradient(circle at 30% 30%, #ffc048, var(--warning));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 8px rgba(255, 165, 2, 0.4);
}

.gateway-marker.dragging {
    cursor: grabbing;
    transform: scale(1.4);
    opacity: 0.9;
}

.gateway-marker-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Highlighted Gateway Marker */
.gateway-marker-highlighted {
    animation: marker-pulse 1s ease-in-out infinite;
    transform: scale(1.5) !important;
    z-index: 10000 !important;
}

.gateway-marker-highlighted::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #00d2ff;
    animation: marker-ring 1s ease-in-out infinite;
    pointer-events: none;
}

@keyframes marker-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.7), 0 0 20px rgba(0, 210, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(0, 210, 255, 0), 0 0 30px rgba(0, 210, 255, 0.8);
    }
}

@keyframes marker-ring {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Gateway Tooltip (on hover) */
.gateway-tooltip {
    background: #15262d !important;
    border: 1px solid rgba(0, 210, 255, 0.3) !important;
    border-radius: 0.5rem !important;
    padding: 0 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6) !important;
    z-index: 10000 !important;
}

.gateway-tooltip .leaflet-tooltip-content {
    padding: 0.75rem;
    background: #15262d;
}

.gateway-tooltip::before {
    border-top-color: #15262d !important;
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-header strong {
    color: #ffffff;
    font-size: 0.85rem;
}

.tooltip-status {
    font-size: 0.7rem;
    font-weight: 600;
}

.tooltip-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.75rem;
}

.tooltip-row span:first-child {
    color: rgba(255, 255, 255, 0.5);
}

.tooltip-row span:last-child {
    color: #ffffff;
    font-weight: 500;
}

/* Gateway Popup (on click) */
.gateway-popup {
    z-index: 10000 !important;
}

.gateway-popup .leaflet-popup-content-wrapper {
    background: #15262d !important;
    border: 1px solid rgba(0, 210, 255, 0.3) !important;
    border-radius: 0.75rem !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 210, 255, 0.1) !important;
    overflow: hidden;
    padding: 0 !important;
}

.gateway-popup .leaflet-popup-content {
    margin: 0 !important;
    width: 280px !important;
    min-width: 280px !important;
}

.gateway-popup .leaflet-popup-tip-container {
    z-index: 10001 !important;
}

.gateway-popup .leaflet-popup-tip {
    background: #15262d !important;
    border: none !important;
    box-shadow: none !important;
}

.gateway-popup .leaflet-popup-close-button {
    color: rgba(255, 255, 255, 0.5) !important;
    font-size: 1.5rem !important;
    font-weight: 300 !important;
    top: 8px !important;
    right: 10px !important;
    width: 24px !important;
    height: 24px !important;
    line-height: 22px !important;
    text-align: center !important;
    transition: color 0.2s ease !important;
    z-index: 10 !important;
}

.gateway-popup .leaflet-popup-close-button:hover {
    color: #00d2ff !important;
}

.popup-content {
    min-width: 260px;
    width: 100%;
    background: #15262d;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1rem 0.75rem 1rem;
    background: linear-gradient(135deg, #1c3641, #15262d);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.popup-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.popup-status {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-details {
    padding: 0.75rem 1rem;
    background: #15262d;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.popup-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.8rem;
}

.popup-row span:first-child {
    color: rgba(255, 255, 255, 0.5);
}

.popup-row span:last-child {
    color: #ffffff;
    font-weight: 500;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
}

.popup-contact {
    padding: 0.875rem 1rem 1rem;
    background: #15262d;
}

.popup-contact h5 {
    margin: 0 0 0.625rem 0;
    font-size: 0.7rem;
    color: #00d2ff;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.popup-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: #0d1a1f;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.375rem;
    color: #ffffff;
    font-size: 0.8rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.popup-input:focus {
    outline: none;
    border-color: #00d2ff;
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.2);
}

.popup-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
}

.popup-textarea {
    resize: vertical;
    min-height: 45px;
    max-height: 80px;
}

.popup-save-btn {
    width: 100%;
    padding: 0.6rem;
    margin-top: 0.25rem;
    background: linear-gradient(135deg, #00d2ff, #00a0a0);
    border: none;
    border-radius: 0.375rem;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-save-btn:hover {
    background: linear-gradient(135deg, #00e5ff, #00b8b8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 210, 255, 0.4);
}

/* Unpositioned Gateways Sidebar */
.unpositioned-gateways {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    max-width: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.unpositioned-gateways h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unpositioned-gateway-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    cursor: grab;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.unpositioned-gateway-item:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.unpositioned-gateway-item.selected {
    border-color: var(--success);
    background: rgba(46, 213, 115, 0.15);
    box-shadow: 0 0 8px rgba(46, 213, 115, 0.4);
}

/* Map placement mode */
#monitoringMap.placement-mode {
    cursor: crosshair !important;
}

#monitoringMap.placement-mode::after {
    content: 'Klicke auf die Karte zum Platzieren';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(46, 213, 115, 0.9);
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 1000;
    pointer-events: none;
    animation: pulse-hint 1.5s ease-in-out infinite;
}

@keyframes pulse-hint {
    0%, 100% { opacity: 0.9; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.02); }
}

.unpositioned-gateway-item .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Dashboard Area */
.monitoring-dashboard {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.dashboard-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.dashboard-card-header svg {
    color: var(--accent);
    flex-shrink: 0;
}

.dashboard-card-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
}

.alerts-card .dashboard-card-header svg {
    color: var(--warning);
}

.production-card .dashboard-card-header svg {
    color: var(--success);
}

.soc-card .dashboard-card-header svg {
    color: var(--error);
}

.temp-high-card .dashboard-card-header svg {
    color: #ff6b6b;
}

.temp-low-card .dashboard-card-header svg {
    color: #74b9ff;
}

.dashboard-card-content {
    padding: 0.75rem;
}

.empty-state-small {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Dashboard List Items */
.dashboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.dashboard-item:hover {
    background: var(--bg-card-hover);
}

.dashboard-item-clickable {
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.dashboard-item-clickable:hover {
    background: rgba(0, 210, 255, 0.1);
    border-color: rgba(0, 210, 255, 0.3);
    transform: translateX(3px);
}

.dashboard-item:last-child {
    margin-bottom: 0;
}

.dashboard-item-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.dashboard-item-value {
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Monaco', 'Menlo', monospace;
}

.dashboard-item-value.positive {
    color: var(--success);
}

.dashboard-item-value.negative {
    color: var(--error);
}

.dashboard-item-value.warning {
    color: var(--warning);
}

.dashboard-item-value.hot {
    color: #ff6b6b;
}

.dashboard-item-value.cold {
    color: #74b9ff;
}

/* Alert Item */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
}

.alert-item:last-child {
    margin-bottom: 0;
}

.alert-item-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.alert-item-clickable:hover {
    background: rgba(255, 71, 87, 0.2);
    border-color: rgba(255, 71, 87, 0.5);
    transform: translateX(3px);
}

.alert-icon {
    color: var(--error);
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.alert-message {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Alert Acknowledge Button */
.alert-ack-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.alert-ack-btn:hover {
    background: rgba(46, 213, 115, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.alert-ack-btn.acknowledged {
    background: rgba(46, 213, 115, 0.2);
    border-color: var(--success);
    color: var(--success);
}

/* Acknowledged Alert */
.alert-item.alert-acknowledged {
    opacity: 0.5;
    background: rgba(255, 71, 87, 0.05);
    border-color: rgba(255, 71, 87, 0.15);
}

.alert-item.alert-acknowledged:hover {
    opacity: 0.7;
}

.alert-item.alert-acknowledged .alert-icon {
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1400px) {
    .monitoring-dashboard {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .monitoring-dashboard {
        grid-template-columns: repeat(2, 1fr);
    }

    .monitoring-map {
        height: 350px;
    }
}

@media (max-width: 640px) {
    .monitoring-dashboard {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .monitoring-map-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .map-legend-controls {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .map-legend {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .map-controls {
        margin-left: 0;
    }

    .monitoring-map {
        height: 300px;
    }
}


/* Notification toggle active state */
.user-dropdown-item#notificationToggle.active {
    color: var(--success);
}

.user-dropdown-item#notificationToggle.active svg {
    color: var(--success);
}

/* ============================================
   AG Grid Custom Theme Override
   ============================================ */

/* Container styling */
.pdo-log-entries.ag-theme-alpine-dark {
    --ag-background-color: var(--bg-tertiary);
    --ag-header-background-color: var(--bg-secondary);
    --ag-odd-row-background-color: transparent;
    --ag-row-hover-color: rgba(0, 210, 255, 0.1);
    --ag-border-color: var(--border);
    --ag-header-foreground-color: var(--accent);
    --ag-foreground-color: var(--text-primary);
    --ag-secondary-foreground-color: var(--text-muted);
    --ag-input-focus-border-color: var(--accent);
    --ag-range-selection-border-color: var(--accent);
    --ag-selected-row-background-color: rgba(0, 210, 255, 0.2);
    --ag-font-size: 0.8rem;
    --ag-row-height: 36px;
    --ag-header-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

/* Header styling */
.pdo-log-entries.ag-theme-alpine-dark .ag-header {
    border-bottom: 2px solid var(--accent);
}

.pdo-log-entries.ag-theme-alpine-dark .ag-header-cell {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0 12px;
}

.pdo-log-entries.ag-theme-alpine-dark .ag-header-cell:hover {
    background: var(--bg-tertiary);
}

.pdo-log-entries.ag-theme-alpine-dark .ag-header-cell-label {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Floating filter inputs */
.pdo-log-entries.ag-theme-alpine-dark .ag-floating-filter-input input,
.pdo-log-entries.ag-theme-alpine-dark .ag-floating-filter-body input {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px;
    color: var(--text-primary) !important;
    padding: 5px 8px;
    font-size: 0.7rem;
}

.pdo-log-entries.ag-theme-alpine-dark .ag-floating-filter-input input::placeholder {
    color: var(--text-muted);
}

.pdo-log-entries.ag-theme-alpine-dark .ag-floating-filter-input input:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.2);
}

/* Row styling */
.pdo-log-entries.ag-theme-alpine-dark .ag-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.15s ease;
}

.pdo-log-entries.ag-theme-alpine-dark .ag-row-even {
    background: rgba(255, 255, 255, 0.02);
}

.pdo-log-entries.ag-theme-alpine-dark .ag-row:hover {
    background: rgba(0, 210, 255, 0.1) !important;
    cursor: pointer;
}

.pdo-log-entries.ag-theme-alpine-dark .ag-row-selected {
    background: rgba(0, 210, 255, 0.2) !important;
    border-left: 3px solid var(--accent);
}

/* Cell styling */
.pdo-log-entries.ag-theme-alpine-dark .ag-cell {
    border-right: none;
    padding: 0 12px;
    font-size: 0.8rem;
    line-height: var(--ag-row-height);
}

/* Placeholder / No rows */
.pdo-log-entries.ag-theme-alpine-dark .ag-overlay-no-rows-center {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 2rem;
}

/* Scrollbar styling */
.pdo-log-entries.ag-theme-alpine-dark ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.pdo-log-entries.ag-theme-alpine-dark ::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 4px;
}

.pdo-log-entries.ag-theme-alpine-dark ::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
    border: 2px solid var(--bg-primary);
}

.pdo-log-entries.ag-theme-alpine-dark ::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Column resize handle */
.pdo-log-entries.ag-theme-alpine-dark .ag-header-cell-resize {
    width: 6px;
}

.pdo-log-entries.ag-theme-alpine-dark .ag-header-cell-resize:hover {
    background: var(--accent);
}

/* ============================================
   Core-Dump / Crash Reports Section
   ============================================ */

.coredump-section {
    padding: 0;
}

/* .coredump-container - Styles sind in .section-container-base konsolidiert */

/* .coredump-header - Base in .section-header-base, nur Überschreibung */
.coredump-header {
    padding: 1.25rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
}

.coredump-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.coredump-header h2 svg {
    color: var(--warning);
}

.coredump-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.coredump-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
}

.coredump-list {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.coredump-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.coredump-empty svg {
    color: var(--success);
    margin-bottom: 1rem;
    opacity: 0.7;
}

.coredump-empty p {
    font-size: 1rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
}

.coredump-empty span {
    font-size: 0.85rem;
}

/* Crash Reports AG Grid */
#coredumpList.ag-theme-alpine-dark {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border);
}

#coredumpList .ag-root-wrapper {
    border-radius: 0.75rem;
}

#coredumpList .ag-header {
    background: var(--bg-tertiary);
}

#coredumpList .ag-row:hover {
    background: rgba(239, 68, 68, 0.05) !important;
}

.coredump-mono {
    font-family: 'Monaco', 'Menlo', monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.85rem;
}

/* Coredump Item Cards */
.coredump-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.coredump-item:hover {
    border-color: var(--warning);
    background: rgba(239, 68, 68, 0.05);
}

.coredump-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

@media (max-width: 768px) {
    .coredump-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .coredump-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .coredump-time-mobile {
        width: 100%;
        margin-top: 0.5rem;
    }

    .coredump-details-mobile {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* ============================================
   Documents Section
   ============================================ */

.documents-section {
    padding: 0;
}

/* .documents-container - Styles sind in .section-container-base konsolidiert */

/* .documents-header - Styles sind in .section-header-base konsolidiert */

.documents-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.documents-header h2 svg {
    color: var(--primary);
}

.documents-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.documents-count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.documents-content {
    padding: 1.5rem;
}

.documents-upload-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.documents-upload-form h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.upload-file-input {
    flex: 1;
    min-width: 200px;
}

.upload-file-input input[type="file"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.upload-file-input input[type="file"]::file-selector-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.4rem 0.75rem;
    border-radius: 0.35rem;
    cursor: pointer;
    margin-right: 0.75rem;
    font-size: 0.85rem;
}

.upload-file-input input[type="file"]::file-selector-button:hover {
    background: var(--primary-hover);
}

.upload-description-input {
    flex: 2;
    min-width: 250px;
}

.upload-description-input input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.upload-description-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.documents-list {
    min-height: 150px;
}

.documents-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
}

.documents-empty svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.documents-empty p {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 500;
}

.documents-empty span {
    font-size: 0.85rem;
}

/* Documents AG Grid */
#documentsList.ag-theme-alpine-dark {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border);
}

#documentsList .ag-root-wrapper {
    border-radius: 0.75rem;
}

#documentsList .ag-header {
    background: var(--bg-tertiary);
}

#documentsList .ag-row:hover {
    background: rgba(0, 210, 255, 0.05) !important;
}

.document-download-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.document-download-link:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .documents-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .upload-row {
        flex-direction: column;
    }

    .upload-file-input,
    .upload-description-input {
        width: 100%;
    }
}

/* ============================================
   Kanban / Todos Section
   ============================================ */

.kanban-section {
    padding: 0;
}

/* .kanban-container - Styles sind in .section-container-base konsolidiert */

/* .kanban-header - Styles sind in .section-header-base konsolidiert */

.kanban-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.kanban-header h2 svg {
    color: var(--primary);
}

.kanban-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.kanban-actions .btn {
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1.5rem;
    min-height: 400px;
}

.kanban-column {
    flex: 1 1 280px;
    min-width: 250px;
    max-width: 350px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 250px);
}

.kanban-column-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 0.75rem 0.75rem 0 0;
    cursor: grab;
    user-select: none;
}

.kanban-column-header:active {
    cursor: grabbing;
}

.kanban-column-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0.4;
    transition: opacity 0.2s, color 0.2s;
    flex-shrink: 0;
}

.kanban-column-header:hover .kanban-column-drag-handle {
    opacity: 0.8;
    color: var(--accent);
}

.kanban-column-header h3 {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.kanban-column-count {
    background: var(--bg-primary);
    color: var(--text-muted);
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.kanban-column-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.kanban-column-header:hover .kanban-column-actions {
    opacity: 1;
}

.btn-icon {
    background: transparent;
    border: none;
    padding: 0.35rem;
    border-radius: 0.35rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.btn-icon-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Task list area */
.kanban-column-tasks {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 100px;
    transition: background 0.2s;
}

.kanban-column-tasks.drag-over {
    background: rgba(0, 210, 255, 0.05);
}

/* Task card */
.kanban-task {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.kanban-task:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.kanban-task.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.kanban-task-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
    flex: 1;
}

.kanban-task-priority {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-weight: 500;
    text-transform: uppercase;
}

/* Priority colors */
.priority-critical {
    border-left-color: #ef4444;
}

.priority-critical .kanban-task-priority {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.priority-high {
    border-left-color: #f97316;
}

.priority-high .kanban-task-priority {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.priority-medium {
    border-left-color: #eab308;
}

.priority-medium .kanban-task-priority {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.priority-low {
    border-left-color: #22c55e;
}

.priority-low .kanban-task-priority {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.kanban-task-content {
    margin: 0.5rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.kanban-task-area {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 500;
}

/* Area colors */
.area-iris {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.area-irismanager {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}

.area-wattsplit {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.area-vzev {
    background: rgba(236, 72, 153, 0.15);
    color: #ec4899;
}

.area-kundenapp {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.kanban-task-assignee {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* Add task button */
.kanban-add-task {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    margin: 0.75rem;
    margin-top: 0;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.kanban-add-task:hover {
    background: var(--bg-primary);
    border-color: var(--primary);
    color: var(--primary);
}

/* Empty state */
.kanban-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    min-height: 400px;
}

.kanban-empty svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.kanban-empty p {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.kanban-empty span {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.modal-medium {
    max-width: 500px;
    width: 90%;
}

.modal-small {
    max-width: 400px;
    width: 90%;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

#taskForm .form-group {
    margin-bottom: 1rem;
}

#taskForm label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

#taskForm input,
#taskForm select,
#taskForm textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

#taskForm input:focus,
#taskForm select:focus,
#taskForm textarea:focus {
    outline: none;
    border-color: var(--primary);
}

#taskForm textarea {
    resize: vertical;
    min-height: 80px;
}

#columnForm .form-group {
    margin-bottom: 1rem;
}

#columnForm label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

#columnForm input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

#columnForm input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Task Modal Footer Layout */
#taskForm .modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#taskForm .modal-footer #taskDeleteBtn {
    flex: 0 0 auto;
    min-width: auto;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.modal-footer-right {
    display: flex;
    gap: 0.75rem;
}

/* Task Modal Wide Layout */
#taskModal.modal-wide {
    max-width: 900px;
    width: 95%;
}

#taskModal.modal-wide.task-editing {
    max-width: 1100px;
}

.task-modal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.task-editing .task-modal-grid {
    grid-template-columns: 1fr 380px;
}

.task-modal-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-modal-right {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-left: 1px solid var(--border);
    padding-left: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
}

.task-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
}

.task-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.task-section-header h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.task-section-header h4 svg {
    color: var(--text-muted);
}

/* Task Attachments */
.task-attachments-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
}

.task-attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.8rem;
}

.task-attachment-item:hover {
    background: var(--bg-card);
}

.task-attachment-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.task-attachment-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.task-attachment-icon svg {
    color: var(--text-muted);
}

.task-attachment-info {
    flex: 1;
    min-width: 0;
}

.task-attachment-name {
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.task-attachment-name:hover {
    color: var(--accent);
}

.task-attachment-meta {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.task-attachment-actions {
    display: flex;
    gap: 0.25rem;
}

.task-attachment-actions .btn-icon {
    padding: 0.25rem;
    opacity: 0.6;
}

.task-attachment-actions .btn-icon:hover {
    opacity: 1;
}

/* Task Comments */
.task-comments-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.task-comments-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 0.75rem;
}

.task-comment-item {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.task-comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.task-comment-author {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--accent);
}

.task-comment-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.task-comment-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.task-comment-input {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.task-comment-input textarea {
    flex: 1;
    resize: none;
    min-height: 60px;
    font-size: 0.85rem;
}

/* Task Icon Buttons */
.btn-icon-add,
.btn-icon-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-icon-add:hover,
.btn-icon-send:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.task-comment-input .btn-icon-send {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.task-comment-input .btn-icon-send:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Task Meta Info */
.task-meta-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
    margin-right: 1rem;
}

.task-meta-item {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Task Empty State */
.task-empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 1rem;
}

/* Responsive Task Modal */
@media (max-width: 900px) {
    #taskModal.modal-wide.task-editing {
        max-width: 95%;
    }

    .task-editing .task-modal-grid {
        grid-template-columns: 1fr;
    }

    .task-modal-right {
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 1rem;
        max-height: none;
    }
}

/* Column Dragging */
.kanban-column.dragging {
    opacity: 0.5;
}

.kanban-column.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.kanban-column-header {
    cursor: grab;
}

.kanban-column-header:active {
    cursor: grabbing;
}

@media (max-width: 768px) {
    .kanban-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .kanban-actions {
        width: 100%;
    }

    .kanban-board {
        flex-direction: column;
    }

    .kanban-column {
        flex: none;
        width: 100%;
        min-width: auto;
        max-height: none;
    }

    .form-row {
        flex-direction: column;
    }
}

/* ============================================
   Modbus Mapping Section
   ============================================ */

.modbus-section {
    padding: 0;
}

/* .modbus-container - Styles sind in .section-container-base konsolidiert */

/* .modbus-header - Styles sind in .section-header-base konsolidiert */

.modbus-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modbus-header h2 svg {
    color: var(--accent);
}

.modbus-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.modbus-gateway-selector select {
    padding: 0.5rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    min-width: 250px;
}

/* Select2 styling for modbus gateway selector */
.modbus-gateway-selector .select2-container {
    min-width: 250px !important;
}

.modbus-gateway-selector .select2-container--default .select2-selection--single {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    height: 36px;
    padding: 0.35rem 0;
}

.modbus-gateway-selector .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary);
    line-height: 24px;
    padding-left: 12px;
}

.modbus-gateway-selector .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 34px;
}

.modbus-gateway-selector .select2-container--default .select2-selection--single .select2-selection__clear {
    color: var(--text-muted);
    margin-right: 5px;
}

.modbus-btn-group {
    display: flex;
    gap: 2px;
}

.modbus-btn-group .btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.modbus-btn-group .btn:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.modbus-btn-divider {
    width: 1px;
    height: 28px;
    background: var(--glass-border);
    margin: 0 0.25rem;
    align-self: center;
}

.modbus-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modbus-status.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.modbus-status.status-loading {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
}

.modbus-status.status-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.modbus-content {
    background: transparent;
    border: none;
    padding: 1.5rem;
}

.modbus-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    text-align: center;
    gap: 1rem;
}

.modbus-empty svg {
    opacity: 0.4;
}

.modbus-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.modbus-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.modbus-toggle input {
    display: none;
}

.modbus-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 12px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.modbus-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.modbus-toggle input:checked + .modbus-slider {
    background: var(--accent);
}

.modbus-toggle input:checked + .modbus-slider::after {
    transform: translateX(20px);
}

.modbus-toggle .toggle-label {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.modbus-info-badge {
    color: var(--text-muted);
    cursor: help;
}

.modbus-tables {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modbus-table-section {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.modbus-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modbus-table-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.modbus-table-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modbus-table-header h3 svg {
    color: var(--accent);
}

.modbus-table-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Smaller add button in table header */
.modbus-table-header .btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.modbus-table-header .btn svg {
    width: 12px;
    height: 12px;
    margin-right: 0.25rem;
}

/* Read Status Display */
.modbus-read-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modbus-read-status.reading {
    color: var(--accent);
}

.modbus-read-progress {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-cancel-read {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.1rem 0.3rem;
    margin-left: 0.25rem;
    border-radius: 3px;
    transition: all 0.15s ease;
    line-height: 1;
}

.btn-cancel-read:hover {
    background: var(--bg-error);
    color: var(--text-primary);
}

.modbus-grid {
    min-height: 200px;
}

.modbus-info-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
}

.modbus-info-panel h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modbus-info-panel code {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent);
}

.modbus-example {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modbus-example strong {
    color: var(--text-primary);
}

.modbus-known-names {
    margin-top: 1rem;
}

.modbus-name-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.modbus-name-tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.modbus-name-more {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Modbus grid button styles */
.modbus-grid .btn-icon {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.modbus-grid .btn-icon:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.modbus-grid .btn-delete {
    font-weight: bold;
}

.modbus-grid .btn-read {
    color: var(--accent);
    font-size: 1rem;
}

.modbus-grid .btn-read:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
}

/* Tiny spinner for grid cells */
.spinner-tiny {
    width: 12px;
    height: 12px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Modbus Grid Cell States */
.modbus-cell-reading {
    background: rgba(59, 130, 246, 0.1) !important;
}

.modbus-cell-error {
    background: rgba(239, 68, 68, 0.1) !important;
}

.modbus-cell-success {
    background: rgba(34, 197, 94, 0.05) !important;
}

.modbus-reading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modbus-error {
    color: var(--error);
    font-size: 0.8rem;
}

.modbus-value {
    color: var(--success);
    font-weight: 500;
    font-family: var(--font-mono);
}

.modbus-no-value {
    color: var(--text-muted);
}

/* Row highlighting for reading state */
.modbus-row-reading {
    background: rgba(59, 130, 246, 0.08) !important;
}

.modbus-row-error {
    background: rgba(239, 68, 68, 0.08) !important;
}

/* Modbus duplicate register styles (in Write grid, also in Read) */
.modbus-row-duplicate {
    background: rgba(156, 163, 175, 0.1) !important;
    opacity: 0.7;
}

.modbus-row-duplicate:hover {
    background: rgba(156, 163, 175, 0.15) !important;
}

.modbus-duplicate-cell {
    color: var(--text-muted) !important;
    font-style: italic;
}

.modbus-duplicate-icon {
    color: var(--warning);
    font-size: 1.1rem;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modbus-duplicate-name {
    color: var(--text-muted);
    font-style: italic;
}

/* Modbus description cell */
.modbus-desc-cell {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.modbus-grid .ag-cell {
    display: flex;
    align-items: center;
}

/* Spinner for modbus status */
.spinner-small {
    width: 14px;
    height: 14px;
    border: 2px solid var(--glass-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@media (max-width: 768px) {
    .modbus-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modbus-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .modbus-gateway-selector select {
        width: 100%;
        min-width: auto;
    }
}

/* ============================================
   Notification Settings Modal
   ============================================ */

.modal-notification-settings {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.notification-section {
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.notification-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.notification-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.notification-section-title svg {
    color: var(--accent);
}

.notification-section-status {
    display: flex;
    align-items: center;
}

.notification-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    top: 2px;
    left: 2px;
    transition: all 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(20px);
    background: white;
}

.toggle-label {
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Checkbox Toggle (gateway notification setting) */
.checkbox-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-toggle input[type="checkbox"] {
    display: none;
}

.checkbox-toggle .toggle-slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-toggle .toggle-slider::before {
    display: none;
}

.checkbox-toggle .toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    top: 2px;
    left: 2px;
    transition: all 0.2s ease;
}

.checkbox-toggle input:checked + .toggle-slider {
    background: var(--success) !important;
    border-color: var(--success) !important;
    box-shadow: 0 0 8px rgba(46, 213, 115, 0.4);
}

.checkbox-toggle input:checked + .toggle-slider::after {
    transform: translateX(20px);
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Danger variant for mute toggle */
.checkbox-toggle input:checked + .toggle-slider-danger {
    background: var(--danger, #e74c3c) !important;
    border-color: var(--danger, #e74c3c) !important;
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.4);
}

.checkbox-toggle .toggle-label.text-muted {
    opacity: 0.5;
}

.checkbox-toggle .toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.checkbox-toggle .toggle-label svg {
    color: var(--text-muted);
}

.checkbox-toggle input:checked ~ .toggle-label svg {
    color: var(--accent);
}

.notification-setting {
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

/* Notification Fields */
.notification-fields {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.notification-fields .form-group {
    margin-bottom: 0;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Events Grid */
.notification-events-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.notification-event-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.notification-event-option:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.notification-event-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.notification-event-option input:checked ~ .event-content {
    color: var(--accent);
}

.event-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.event-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 0.375rem;
    flex-shrink: 0;
}

.event-icon.offline {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.event-icon.online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.event-icon.battery {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
}

.event-icon.inverter {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.event-icon.cold {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
}

.event-icon.hot {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.event-label {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Notification Actions */
.notification-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.status-badge.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .modal-notification-settings {
        max-width: 100%;
        margin: 1rem;
    }

    .notification-events-grid {
        grid-template-columns: 1fr;
    }

    .notification-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .notification-actions {
        flex-direction: column;
    }

    .notification-actions .btn {
        width: 100%;
    }
}

/* ============================================
   InfluxDB Status Modal
   ============================================ */

.influx-status-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.influx-connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.influx-connection-status .status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.influx-connection-status.connected .status-indicator {
    background: var(--success);
    animation: none;
}

.influx-connection-status.disconnected .status-indicator {
    background: var(--danger);
    animation: none;
}

.influx-connection-status .status-text {
    font-weight: 500;
}

.influx-db-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.influx-db-label {
    color: var(--text-secondary);
}

.influx-db-name {
    font-family: monospace;
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.influx-stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.influx-stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.influx-stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    font-family: monospace;
}

.influx-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.influx-gateway-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.influx-gateway-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.influx-gateway-table th {
    background: var(--bg-secondary);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    border-bottom: 1px solid var(--border-color);
}

.influx-gateway-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.influx-gateway-table tbody tr:hover {
    background: var(--bg-secondary);
}

.influx-gateway-table tbody tr:last-child td {
    border-bottom: none;
}

.influx-gateway-table .gateway-mac {
    font-family: monospace;
    font-size: 0.8rem;
}

.influx-gateway-table .gateway-alias {
    font-weight: 500;
}

.influx-gateway-table .record-count {
    font-family: monospace;
    text-align: right;
}

.influx-gateway-table .time-range {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.influx-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.influx-error {
    text-align: center;
    color: var(--danger);
    padding: 2rem;
}

.influx-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.influx-error-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    border-radius: 8px;
    color: var(--danger);
    margin-bottom: 1rem;
}

.influx-error-message svg {
    flex-shrink: 0;
}

.influx-error-message span {
    font-size: 0.9rem;
    word-break: break-word;
}

/* InfluxDB Status Modal - Wide Layout */
#influxDbStatusModal {
    max-width: 900px;
    width: 90vw;
}

#influxDbStatusModal .influx-stats-summary {
    grid-template-columns: repeat(4, 1fr);
}

#influxDbStatusModal .influx-gateway-table-container {
    max-height: 50vh;
}

@media (max-width: 768px) {
    #influxDbStatusModal {
        max-width: 100%;
        width: 100%;
    }

    #influxDbStatusModal .influx-stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* InfluxDB Table Actions */
.influx-gateway-table .actions-col {
    width: 70px;
    text-align: center;
}

.influx-gateway-table .actions-cell {
    text-align: center;
}

.btn-delete-small {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-delete-small:hover {
    background: var(--danger);
    color: white;
}

.btn-delete-small svg {
    display: block;
}

/* ============================================
   Modbus Address Change Section
   ============================================ */

.modbus-address-warning {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    color: #f0ad4e;
}

.modbus-address-warning svg {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.modbus-address-warning strong {
    color: #f0ad4e;
}

.modbus-address-form {
    max-width: 600px;
}

.modbus-address-form .form-group {
    margin-bottom: 1.25rem;
}

.modbus-address-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modbus-address-form .form-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.modbus-address-form .form-actions {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

@media (max-width: 600px) {
    .modbus-address-form .form-row {
        grid-template-columns: 1fr;
    }
}

/* Modbus Address Confirmation Dialog */
.modbus-confirm-details {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.modbus-confirm-details .confirm-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.modbus-confirm-details .confirm-row:last-child {
    border-bottom: none;
}

.modbus-confirm-details .confirm-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.modbus-confirm-details .confirm-value {
    color: var(--text);
    font-weight: 600;
    font-family: 'Monaco', 'Menlo', monospace;
}

.modbus-confirm-details .confirm-value.highlight {
    color: var(--accent);
    font-size: 1.1em;
}

.confirm-warning {
    color: var(--warning);
    font-size: 0.9rem;
    margin: 0;
    padding: 0.75rem;
    background: rgba(249, 226, 175, 0.1);
    border-radius: 0.375rem;
    border-left: 3px solid var(--warning);
}

/* ============================================
   Automation Modal Styles
   ============================================ */

.modal-automation {
    max-width: 700px;
    width: 95vw;
}

.modal-automation .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-automation .modal-header h3 svg {
    color: var(--accent);
}

/* Master Switch */
.automation-master-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
}

.master-switch-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.master-switch-label {
    font-weight: 500;
    color: var(--text-primary);
}

.master-switch-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.master-switch-status.active {
    color: var(--success);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent);
    border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
    background-color: white;
}

.toggle-switch.toggle-small {
    width: 38px;
    height: 22px;
}

.toggle-switch.toggle-small .toggle-slider:before {
    height: 16px;
    width: 16px;
}

.toggle-switch.toggle-small input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* Loading State */
.automation-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
    color: var(--text-secondary);
}

/* Rules Container */
.automation-rules-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.automation-rules-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
    flex: 1;
}

.automation-rules-header .btn {
    flex: 0 0 auto;
}

.automation-rules-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.automation-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

.automation-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    color: var(--text-muted);
    text-align: center;
}

.automation-error svg {
    color: var(--warning);
}

.automation-error span {
    color: var(--text);
}

/* Input error state */
input.input-error,
select.input-error,
textarea.input-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}

input.input-error:focus,
select.input-error:focus,
textarea.input-error:focus {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
}

/* Rule Card */
.automation-rule-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    transition: all 0.2s ease;
}

.automation-rule-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.1);
}

.automation-rule-card.disabled {
    opacity: 0.6;
}

.rule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.rule-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rule-name {
    font-weight: 600;
    color: var(--text-primary);
}

.rule-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.rule-condition,
.rule-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.rule-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    min-width: 40px;
}

.rule-condition .rule-label {
    color: var(--accent);
}

.rule-action .rule-label {
    color: var(--success);
}

.rule-value {
    color: var(--text-secondary);
}

.rule-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.rule-cooldown {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.rule-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon.btn-danger:hover {
    background: rgba(255, 71, 87, 0.1);
    border-color: var(--error);
    color: var(--error);
}

/* Rule Form */
.automation-rule-form {
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.rule-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.rule-form-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.rule-section {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.rule-section h5 {
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.rule-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.action-params {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.condition-params {
    margin-top: 0.75rem;
}

/* Weekday Selector */
.weekday-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.weekday-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.weekday-item input[type="checkbox"] {
    display: none;
}

.weekday-item span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.weekday-item input[type="checkbox"]:checked + span {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.weekday-item:hover span {
    border-color: var(--accent);
}

/* Form Row - Flex Layout */
.form-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.form-group-flex {
    flex: 1;
    min-width: 150px;
}

.form-group-small {
    flex: 0 0 auto;
    min-width: 80px;
    max-width: 120px;
}

.form-group-medium {
    flex: 0 0 auto;
    min-width: 120px;
    max-width: 180px;
}

/* Responsive */
@media (max-width: 600px) {
    .modal-automation {
        max-width: 100%;
        margin: 0.5rem;
    }

    .automation-master-switch {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group-small,
    .form-group-medium {
        max-width: none;
    }

    .rule-actions {
        flex-wrap: wrap;
    }
}

/* ============================================
   Console Log Modal
   ============================================ */

.modal-console-log {
    max-width: 1200px;
    width: 95%;
    max-height: 90vh;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-console-log .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-console-log .modal-header h3 svg {
    color: var(--accent);
}

.modal-console-log .modal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 1rem;
}

.console-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.console-controls-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.console-controls-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.console-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0 0.5rem;
}

.console-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.console-status .status-dot.active {
    background-color: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse 2s infinite;
}

.console-status .status-dot.inactive {
    background-color: var(--text-muted);
}

.console-level-select {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.5rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border);
}

.console-level-select label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.console-level-select select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
}

.console-level-select select:hover {
    border-color: var(--accent);
}

.console-level-select select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}

.console-autoscroll {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.console-autoscroll input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.console-output-container {
    flex: 1;
    min-height: 400px;
    margin: 0.75rem 0;
    border-radius: 6px;
    overflow: hidden;
    background: #0d1117;
    border: 1px solid var(--border);
}

.console-output {
    height: 100%;
    overflow-y: scroll;
    padding: 0.75rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #c9d1d9;
    scroll-behavior: smooth;
}

.console-output::-webkit-scrollbar {
    width: 8px;
}

.console-output::-webkit-scrollbar-track {
    background: #161b22;
}

.console-output::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

.console-output::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

.console-empty {
    color: #6e7681;
    text-align: center;
    padding: 2rem 1rem;
}

.console-line {
    display: flex;
    gap: 0.75rem;
    padding: 1px 0;
    border-bottom: 1px solid transparent;
}

.console-line:hover {
    background: rgba(110, 118, 129, 0.1);
}

.console-line-time {
    color: #6e7681;
    flex-shrink: 0;
    user-select: none;
}

.console-line-content {
    flex: 1;
    word-break: break-all;
    white-space: pre-wrap;
}

/* Log level colors */
.console-line.level-error .console-line-content {
    color: #f85149;
}

.console-line.level-warn .console-line-content {
    color: #d29922;
}

.console-line.level-info .console-line-content {
    color: #58a6ff;
}

.console-line.level-debug .console-line-content {
    color: #8b949e;
}

.console-line.level-verbose .console-line-content {
    color: #7ee787;
}

.console-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 600px) {
    .modal-console-log {
        max-width: 100%;
        margin: 0.5rem;
        max-height: 95vh;
        height: 90vh;
    }

    .console-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .console-controls-left,
    .console-controls-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .console-controls-left {
        /* Put level selector on its own row */
        display: grid;
        grid-template-columns: auto auto auto;
        grid-template-rows: auto auto;
        align-items: center;
    }

    .console-controls-left .console-level-select {
        grid-column: 1 / -1;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        padding-top: 0.5rem;
        margin-top: 0.25rem;
        border-top: 1px solid var(--border);
    }

    .console-output-container {
        min-height: 250px;
    }

    .console-output {
        font-size: 0.75rem;
    }
}

/* ============================================
   System Info Modal
   ============================================ */

.modal-system-info {
    max-width: 700px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-system-info .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-system-info .modal-header h3 svg {
    color: var(--accent);
}

.system-info-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.info-loading,
.info-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-muted);
    text-align: center;
}

.info-error {
    color: var(--error);
}

.info-error small {
    color: var(--text-muted);
}

.info-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.info-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.info-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.info-section h3 svg {
    color: var(--accent);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.info-value.muted {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
}

.info-table-container {
    overflow-x: auto;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.info-table th,
.info-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.info-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-table td code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
}

.info-table td a {
    color: var(--accent);
    text-decoration: none;
}

.info-table td a:hover {
    text-decoration: underline;
}

.license-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

@media (max-width: 600px) {
    .modal-system-info {
        margin: 0.5rem;
        max-height: 95vh;
    }

    .system-info-content {
        padding: 1rem;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* Light theme specific adjustments for System Info Modal */
body.light-theme .info-item {
    background: var(--bg-card);
    border-color: var(--border);
}

body.light-theme .info-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.light-theme .info-table td code {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.light-theme .license-badge {
    background: rgba(0, 136, 204, 0.15);
}

/* ============================================
   Server Logs Modal
   ============================================ */

.modal-server-logs {
    max-width: 1000px;
    width: 95%;
    max-height: 90vh;
    height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-server-logs .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-server-logs .modal-header h3 svg {
    color: var(--accent);
}

.logs-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.logs-filters {
    display: flex;
    gap: 0.25rem;
}

.logs-filter-btn {
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logs-filter-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.logs-filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.logs-search {
    display: flex;
    gap: 0.25rem;
    flex: 1;
    max-width: 300px;
}

.logs-search input {
    flex: 1;
    padding: 0.375rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.logs-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.logs-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.logs-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
}

#serverLogsAutoRefreshBtn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

#serverLogsAutoRefreshBtn.active svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.server-logs-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: var(--bg-primary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
}

.logs-loading,
.logs-error,
.logs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-muted);
    text-align: center;
    height: 100%;
}

.logs-error {
    color: var(--error);
}

.logs-list {
    padding: 0.5rem;
}

.log-entry {
    display: flex;
    gap: 0.75rem;
    padding: 0.375rem 0.5rem;
    border-radius: 0.25rem;
    transition: background 0.15s ease;
    align-items: flex-start;
}

.log-entry:hover {
    background: var(--bg-secondary);
}

.log-time {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    min-width: 110px;
}

.log-level {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
}

.log-message {
    flex: 1;
    word-break: break-word;
    white-space: pre-wrap;
    color: var(--text-primary);
}

/* Log level colors */
.log-entry.log-level-error .log-level {
    color: var(--error);
}

.log-entry.log-level-error .log-message {
    color: var(--error);
}

.log-entry.log-level-warn .log-level {
    color: var(--warning);
}

.log-entry.log-level-warn .log-message {
    color: var(--warning);
}

.log-entry.log-level-info .log-level {
    color: var(--accent);
}

.log-entry.log-level-debug .log-level {
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .modal-server-logs {
        height: 95vh;
        margin: 0.5rem;
    }

    .logs-toolbar {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .logs-search {
        max-width: none;
        order: 3;
        width: 100%;
    }

    .logs-actions {
        margin-left: 0;
    }

    .log-time {
        min-width: 70px;
        font-size: 0.7rem;
    }
}

/* Load more button for logs */
.logs-load-more {
    display: flex;
    justify-content: center;
    padding: 1rem;
    margin-top: 0.5rem;
}

.logs-load-more button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Light theme specific adjustments for Server Logs Modal */
body.light-theme .logs-toolbar {
    background: var(--bg-card);
}

body.light-theme .log-entry:hover {
    background: var(--bg-tertiary);
}

body.light-theme .logs-filter-btn {
    background: var(--bg-card);
    color: var(--text-secondary);
}

body.light-theme .logs-filter-btn.active {
    background: var(--accent);
    color: white;
}

/* ============================================
   Help Modal
   ============================================ */

.modal-help {
    max-width: 1200px;
    width: 95%;
    max-height: 90vh;
    height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-help .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-help .modal-header h3 svg {
    color: var(--accent);
}

.modal-help .modal-content {
    flex: 1;
    display: flex;
    min-height: 0;
    padding: 0;
    gap: 0;
}

/* ============================================
   Help Section - New Design
   ============================================ */

/* .help-container - Base in .section-container-base, nur Überschreibung */
.help-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
}

/* Help Header - Spezielle Styles (nicht Base) */
.help-header {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 2rem;
}

.help-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.help-header-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.help-header-title svg {
    color: var(--accent);
    flex-shrink: 0;
}

.help-header-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.help-header-title p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
}

/* Help Search */
.help-search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 250px;
}

.help-search-container svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.help-search-container input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 3rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.help-search-container input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.help-search-container input::placeholder {
    color: var(--text-tertiary);
}

.help-search-clear {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-search-clear:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Help Main Layout */
.help-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Help Sidebar */
.help-sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1.25rem;
    overflow-y: auto;
}

.help-sidebar-section {
    margin-bottom: 1.5rem;
}

.help-sidebar-section:last-child {
    margin-bottom: 0;
}

.help-sidebar-section h3 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.help-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.help-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
}

.help-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.help-nav a.active {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    font-weight: 500;
}

.help-nav a svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

/* Help Content Area */
.help-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: var(--bg-primary);
}

/* Quick Access Section */
.help-quick-access h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.help-quick-access h2:not(:first-child) {
    margin-top: 2rem;
}

.help-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

/* Help Cards */
.help-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.help-card-icon {
    width: 48px;
    height: 48px;
    background: rgba(var(--accent-rgb), 0.1);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: var(--accent);
}

.help-card-icon.accent-green {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.help-card-icon.accent-purple {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.help-card-icon.accent-orange {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
}

.help-card-icon.accent-red {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.help-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.help-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Search Results */
.help-search-results-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.help-search-results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.help-search-results-header span {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.help-search-results-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.help-search-result-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.help-search-result-item:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.help-search-result-item h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.help-search-result-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.help-search-result-item .highlight {
    background: rgba(var(--accent-rgb), 0.2);
    color: var(--accent);
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
}

/* Help Article View */
.help-article {
    max-width: 800px;
}

.help-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 1.5rem;
}

.help-back-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}

/* Article Content Styling */
.help-article-content {
    color: var(--text-secondary);
    line-height: 1.7;
}

.help-article-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--accent);
}

.help-article-content h2 {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.help-article-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.help-article-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.help-article-content p {
    margin-bottom: 1rem;
}

.help-article-content ul,
.help-article-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.help-article-content li {
    margin-bottom: 0.4rem;
    line-height: 1.6;
}

.help-article-content a {
    color: var(--accent);
    text-decoration: none;
}

.help-article-content a:hover {
    text-decoration: underline;
}

.help-article-content code {
    background: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em;
    color: var(--accent);
}

.help-article-content pre {
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.help-article-content pre code {
    background: none;
    padding: 0;
    color: #c9d1d9;
    font-size: 0.85rem;
}

.help-article-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border-radius: 0.5rem;
    overflow: hidden;
}

.help-article-content table th,
.help-article-content table td {
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    text-align: left;
}

.help-article-content table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.help-article-content table td {
    color: var(--text-secondary);
}

.help-article-content table tr:hover td {
    background: var(--bg-secondary);
}

.help-article-content blockquote {
    border-left: 4px solid var(--accent);
    background: var(--bg-tertiary);
    margin: 1rem 0;
    padding: 1rem 1.25rem;
    border-radius: 0 0.5rem 0.5rem 0;
}

.help-article-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.help-article-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.help-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    gap: 1rem;
    color: var(--text-secondary);
}

/* Responsive Help Section */
@media (max-width: 1024px) {
    .help-container {
        height: calc(100vh - 120px);
        border-radius: 0.75rem;
    }

    .help-header {
        padding: 1.25rem 1.5rem;
    }

    .help-header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .help-search-container {
        max-width: 100%;
        width: 100%;
    }

    .help-sidebar {
        width: 220px;
        min-width: 220px;
    }

    .help-content-area {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .help-container {
        height: calc(100vh - 100px);
        margin: 0 0.5rem;
        border-radius: 0.5rem;
    }

    .help-main {
        flex-direction: column;
    }

    .help-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1rem;
        display: none; /* Hide on mobile, show via toggle */
    }

    .help-sidebar.mobile-open {
        display: block;
    }

    .help-content-area {
        padding: 1rem;
    }

    .help-cards-grid {
        grid-template-columns: 1fr;
    }

    .help-header-title h1 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .help-header {
        padding: 1rem;
    }

    .help-header-title svg {
        display: none;
    }

    .help-article-content h1 {
        font-size: 1.4rem;
    }

    .help-article-content h2 {
        font-size: 1.2rem;
    }
}

/* ============================================
   Notifications / Alarm Rules Section
   ============================================ */

.notifications-section {
    padding: 0;
}

/* .notifications-container - Styles sind in .section-container-base konsolidiert */

/* .notifications-header - Styles sind in .section-header-base konsolidiert */

.notifications-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notifications-header h2 svg {
    color: var(--primary);
}

.notifications-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Notifications Card */
.notifications-card {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    margin: 0;
    overflow: hidden;
}

.notifications-card:last-child {
    border-bottom: none;
}

.notifications-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.notifications-card .card-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notifications-card .card-header h3 svg {
    color: var(--accent);
}

.notifications-card .card-content {
    padding: 1rem;
}

/* Alarm Count Badge */
.alarm-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent);
    color: white;
    border-radius: 10px;
    margin-left: 0.5rem;
}

/* Alarm Card */
.alarm-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.alarm-card:last-child {
    margin-bottom: 0;
}

.alarm-card.unacknowledged {
    border-left: 3px solid var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.alarm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.alarm-title {
    font-weight: 600;
    color: var(--text-primary);
}

.alarm-gateway {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 500;
}

.alarm-details {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.alarm-repeats {
    color: var(--warning);
}

.alarm-ack {
    color: var(--success);
}

.alarm-ack-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 0.25rem;
    color: var(--success);
    font-size: 0.85rem;
}

.alarm-ack-info svg {
    flex-shrink: 0;
}

.alarm-ack-info strong {
    color: var(--text-primary);
}

.alarm-card.acknowledged {
    opacity: 1;
    background: var(--bg-secondary);
    border-left: 3px solid var(--success);
}

.alarm-actions {
    display: flex;
    gap: 0.5rem;
}

/* Alarms Table */
.alarms-table {
    width: 100%;
    border-collapse: collapse;
}

.alarms-table th {
    background: var(--bg-tertiary);
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.alarms-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.85rem;
}

.alarms-table .action-buttons {
    display: flex;
    gap: 0.25rem;
}

.alarm-row-active {
    background: rgba(245, 158, 11, 0.05);
}

.alarm-row-active:hover {
    background: rgba(245, 158, 11, 0.1);
}

.alarm-row-acknowledged {
    background: var(--bg-secondary);
}

.alarm-row-acknowledged:hover {
    background: var(--bg-tertiary);
}

.badge-warning {
    background: var(--warning);
    color: #000;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-clickable {
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.badge-clickable:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

/* Repeat Timestamps Popup */
.repeat-timestamps-popup {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 250px;
    max-width: 350px;
    overflow: hidden;
}

.repeat-timestamps-header {
    background: var(--bg-tertiary);
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.repeat-timestamps-list {
    padding: 0.5rem 0;
    max-height: 300px;
    overflow-y: auto;
}

.repeat-timestamp-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
}

.repeat-timestamp-item:hover {
    background: var(--bg-secondary);
}

.repeat-timestamp-label {
    color: var(--text-secondary);
}

.repeat-timestamp-time {
    color: var(--text-primary);
    font-family: monospace;
}

.repeat-timestamp-item:first-child .repeat-timestamp-label {
    color: var(--primary);
    font-weight: 500;
}

/* Notification Rules Table */
.notification-rules-table {
    width: 100%;
    border-collapse: collapse;
}

.notification-rules-table th {
    background: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.notification-rules-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.notification-rules-table tbody tr:hover {
    background: var(--bg-secondary);
}

.notification-rules-table tbody tr:last-child td {
    border-bottom: none;
}

.notification-rules-table tr.rule-disabled {
    opacity: 0.6;
}

.rule-name {
    font-weight: 500;
    color: var(--text-primary);
}

.condition-cell {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Channel Badges */
.channel-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 0.25rem;
    margin-right: 0.25rem;
}

.channel-badge.push {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
}

.channel-badge.email {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.channel-badge.sms {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

/* System Badge */
.badge-system {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border-radius: 0.25rem;
    margin-left: 0.5rem;
    text-transform: uppercase;
}

/* Small Toggle Switch */
.toggle-switch.small {
    width: 32px;
    height: 18px;
}

.toggle-switch.small .toggle-slider:before {
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
}

.toggle-switch.small input:checked + .toggle-slider:before {
    transform: translateX(14px);
}

/* Sensor Condition Fields */
.sensor-condition-fields {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.sensor-condition-fields .form-group {
    flex: 1;
    min-width: 120px;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Form Hint */
.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Notification Rule Modal */
.modal-rule {
    max-width: 480px;
}

.modal-rule .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-rule .modal-header h3 svg {
    color: var(--accent);
}

/* Rule Form Sections */
.rule-form-section {
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.rule-form-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Sensor Condition Row */
.sensor-condition-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.sensor-condition-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.sensor-condition-row .form-group-small {
    flex: 0 0 70px;
}

/* Checkbox Row */
.checkbox-row {
    display: flex;
    gap: 1.5rem;
}

/* Ack Row */
.form-row-ack {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.form-group-inline label {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.form-group-inline select {
    width: auto;
    min-width: 80px;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 768px) {
    .notifications-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .notifications-actions {
        width: 100%;
    }

    .notification-rules-table {
        font-size: 0.85rem;
    }

    .notification-rules-table th,
    .notification-rules-table td {
        padding: 0.5rem;
    }

    .alarm-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .sensor-condition-fields {
        flex-direction: column;
    }

    .sensor-condition-fields .form-group {
        min-width: 100%;
    }
}

/* ============================================
   User Statistics Modal Styles
   ============================================ */

#userStatsModalOverlay {
    z-index: 2000;
}

.modal-user-stats {
    max-width: 1000px;
    width: 95%;
    max-height: 90vh;
}

.user-stats-header {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-bottom: 1px solid var(--border);
}

.user-stats-header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-stats-header-content svg {
    color: var(--accent);
}

.user-stats-header-content h3 {
    margin: 0;
    font-size: 1.1rem;
}

.user-stats-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.user-stats-content {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

/* Stats Summary Grid */
.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.stats-card:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.stats-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stats-card-today .stats-card-icon {
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.2), rgba(0, 210, 255, 0.1));
    color: var(--accent);
}

.stats-card-week .stats-card-icon {
    background: linear-gradient(135deg, rgba(58, 123, 213, 0.2), rgba(58, 123, 213, 0.1));
    color: var(--accent-secondary);
}

.stats-card-month .stats-card-icon {
    background: linear-gradient(135deg, rgba(46, 213, 115, 0.2), rgba(46, 213, 115, 0.1));
    color: var(--success);
}

.stats-card-views .stats-card-icon {
    background: linear-gradient(135deg, rgba(255, 165, 2, 0.2), rgba(255, 165, 2, 0.1));
    color: var(--warning);
}

.stats-card-content {
    display: flex;
    flex-direction: column;
}

.stats-card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stats-card-sublabel {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Online Users Section */
.stats-online-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.stats-online-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-online-section .online-indicator {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-online 2s ease-in-out infinite;
}

@keyframes pulse-online {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(46, 213, 115, 0.7); }
    50% { opacity: 0.8; box-shadow: 0 0 0 4px rgba(46, 213, 115, 0); }
}

.stats-online-users {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.online-user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(46, 213, 115, 0.1);
    border: 1px solid rgba(46, 213, 115, 0.3);
    border-radius: 2rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.online-user-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

.online-user-name {
    color: var(--text-primary);
    font-weight: 500;
}

.stats-no-data {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

.stats-loading {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Charts */
.stats-charts-row {
    margin-bottom: 1.5rem;
}

.stats-chart-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
}

.stats-chart-container h4 {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}

.stats-chart {
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 0.5rem 0;
}

/* Bar chart styles */
.stats-chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 180px;
    padding-bottom: 1.5rem;
}

.stats-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.stats-bar {
    width: 100%;
    background: linear-gradient(to top, var(--accent), rgba(0, 210, 255, 0.3));
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    position: relative;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.stats-bar:hover {
    background: linear-gradient(to top, var(--accent-hover), rgba(0, 229, 255, 0.5));
}

.stats-bar-value {
    font-size: 0.65rem;
    color: var(--text-primary);
    font-weight: 600;
    padding-top: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stats-bar-container:hover .stats-bar-value {
    opacity: 1;
}

.stats-bar-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    white-space: nowrap;
}

.stats-chart-bar {
    flex: 1;
    background: linear-gradient(to top, var(--accent), rgba(0, 210, 255, 0.3));
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    position: relative;
    transition: all 0.2s ease;
    cursor: pointer;
}

.stats-chart-bar:hover {
    background: linear-gradient(to top, var(--accent-hover), rgba(0, 229, 255, 0.5));
}

.stats-chart-bar:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 10;
    color: var(--text-primary);
}

/* Tables */
.stats-tables-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stats-table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    overflow: hidden;
}

.stats-table-container h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.stats-table thead {
    background: var(--bg-tertiary);
}

.stats-table th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.stats-table td {
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.stats-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.stats-table-clickable tbody tr {
    cursor: pointer;
}

.stats-table-clickable tbody tr:hover {
    background: rgba(0, 210, 255, 0.1);
}

.clickable-row {
    cursor: pointer;
}

.user-link {
    color: var(--accent);
    font-weight: 500;
}

.clickable-row:hover .user-link {
    text-decoration: underline;
}

.stats-table tbody tr:last-child td {
    border-bottom: none;
}

.stats-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem !important;
}

.stats-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
}

.stats-ip-badge {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.stats-time-badge {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Empty State */
.stats-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Responsive */
@media (max-width: 900px) {
    .stats-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-tables-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .stats-summary-grid {
        grid-template-columns: 1fr;
    }

    .modal-user-stats {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .user-stats-content {
        max-height: calc(100vh - 60px);
    }

    .stats-card {
        padding: 0.75rem;
    }

    .stats-card-icon {
        width: 40px;
        height: 40px;
    }

    .stats-card-value {
        font-size: 1.5rem;
    }
}

/* ============================================
   User Detail Stats Modal
   ============================================ */

#userDetailStatsModalOverlay {
    z-index: 2100;
}

.modal-user-detail-stats {
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
}

.user-detail-header {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-bottom: 1px solid var(--border);
}

.user-detail-header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-detail-header-content svg {
    color: var(--accent);
}

.user-detail-header-content h3 {
    margin: 0;
    font-size: 1.1rem;
}

.user-detail-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.user-detail-content {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

/* Summary Cards */
.user-detail-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.user-detail-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    text-align: center;
}

.user-detail-card-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.user-detail-card-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Passkey Status */
.user-detail-passkey-status {
    margin-bottom: 1rem;
}

.passkey-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.passkey-badge.has-passkey {
    background: rgba(46, 213, 115, 0.15);
    border: 1px solid rgba(46, 213, 115, 0.3);
    color: var(--success);
}

.passkey-badge.no-passkey {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.passkey-badge svg {
    width: 14px;
    height: 14px;
}

/* Chart Section */
.user-detail-chart-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.user-detail-chart-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* History Section */
.user-detail-history-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
}

.user-detail-history-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}

.user-detail-login-list {
    max-height: 300px;
    overflow-y: auto;
}

.login-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.login-list-item:last-child {
    border-bottom: none;
}

.login-list-method {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-size: 1rem;
}

.login-list-method.passkey {
    background: rgba(46, 213, 115, 0.15);
}

.login-list-method.password {
    background: rgba(255, 255, 255, 0.05);
}

.login-list-info {
    flex: 1;
}

.login-list-time {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.login-list-ip {
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .user-detail-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .user-detail-card-value {
        font-size: 1.25rem;
    }
}

/* ============================================
   Enhanced Mobile Responsive Styles
   ============================================ */

/* Mobile Navigation Improvements */
@media (max-width: 640px) {
    /* Main padding adjustments */
    main {
        padding: 1rem;
    }

    /* Section header stacking - but NOT gateway-toolbar */
    .section-header:not(.gateway-toolbar) {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .section-header h2 {
        font-size: 1.25rem;
    }

    /* Intro section mobile */
    .intro-section h1 {
        font-size: 1.75rem;
    }

    .intro-section p {
        font-size: 1rem;
    }
}

/* ============================================
   Mobile Bottom Navigation Bar
   ============================================ */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 900px) {
    /* Hide desktop navigation and hamburger toggle */
    .main-nav {
        display: none !important;
    }

    .mobile-nav-toggle {
        display: none !important;
    }

    /* Show mobile bottom navigation */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
        z-index: 10000;
        height: 56px;
        padding: 0 16px;
        justify-content: center;
        align-items: center;
        gap: 8px;
    }

    /* Hide mobile nav when modal is active */
    body:has(.modal-overlay.active) .mobile-bottom-nav {
        display: none !important;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 64px;
        flex-shrink: 0;
        padding: 6px 8px;
        background: transparent;
        border: none;
        border-radius: 8px;
        color: var(--text-secondary);
        cursor: pointer;
        transition: all 0.2s ease;
        gap: 2px;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-item svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
        transition: all 0.2s ease;
    }

    .mobile-nav-item span {
        font-size: 0.65rem;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        text-align: center;
        line-height: 1.2;
    }

    .mobile-nav-item:active {
        transform: scale(0.95);
    }

    .mobile-nav-item.active {
        color: var(--accent);
    }

    .mobile-nav-item.active svg {
        color: var(--accent);
    }

    .mobile-more-btn.menu-open {
        color: var(--accent);
    }

    /* Add bottom padding to main content */
    main {
        padding-bottom: 72px !important;
    }
}

/* ============================================
   Mobile Full Menu Overlay
   ============================================ */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-menu-container {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 320px;
    height: 100%;
    background: var(--bg-primary);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-menu-overlay.active .mobile-menu-container {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.mobile-menu-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.mobile-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-menu-close:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.mobile-menu-close:active {
    transform: scale(0.95);
}

/* User Info Section */
.mobile-menu-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.1), rgba(0, 163, 255, 0.05));
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.mobile-menu-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-menu-user-avatar svg {
    color: var(--accent);
}

.mobile-menu-user-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.mobile-menu-username {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-menu-role {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    background: rgba(0, 210, 255, 0.15);
    color: var(--accent);
    border-radius: 3px;
    width: fit-content;
}

.mobile-menu-role.admin {
    background: rgba(255, 165, 2, 0.15);
    color: var(--warning);
}

/* Scrollable Menu Content */
.mobile-menu-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2rem;
}

/* Menu Sections */
.mobile-menu-section {
    padding: 0.75rem 0;
}

.mobile-menu-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    margin-bottom: 0.25rem;
}

/* Menu Items */
.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

.mobile-menu-item span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-menu-item:hover {
    background: var(--bg-card-hover);
}

.mobile-menu-item:active {
    background: rgba(0, 210, 255, 0.1);
}

.mobile-menu-item:hover svg {
    color: var(--accent);
}

/* Logout Section */
.mobile-menu-logout-section {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.mobile-menu-logout {
    color: var(--error) !important;
}

.mobile-menu-logout svg {
    color: var(--error) !important;
}

.mobile-menu-logout:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

/* Safe area support */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(56px + env(safe-area-inset-bottom));
    }

    @media (max-width: 900px) {
        main {
            padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
        }
    }

    .mobile-menu-scroll {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
}

@media (min-width: 901px) {
    .mobile-nav-toggle {
        display: none;
    }
}

/* Button Mobile Improvements */
@media (max-width: 480px) {
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Button groups stack on mobile */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
    }
}

/* Form Mobile Improvements */
@media (max-width: 640px) {
    .form-group {
        margin-bottom: 1rem;
    }

    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 0.375rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.75rem;
        font-size: 1rem; /* Prevent zoom on iOS */
    }

    /* Form rows stack on mobile */
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }

    .form-row > * {
        width: 100%;
    }

    /* Settings form adjustments */
    .settings-section {
        padding: 1rem;
    }

    .settings-section h3 {
        font-size: 1rem;
    }
}

/* Card Mobile Improvements */
@media (max-width: 640px) {
    .gateway-card {
        padding: 1rem;
    }

    .gateway-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .gateway-name {
        font-size: 1rem;
    }

    .gateway-mac {
        font-size: 0.7rem;
    }

    .gateway-stats {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .gateway-stat {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 100px;
    }
}

/* Modal Mobile Improvements */
@media (max-width: 640px) {
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1.125rem;
    }

    .modal-content {
        padding: 1rem;
    }

    .modal-footer {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        flex: 1;
        min-width: calc(50% - 0.25rem);
    }

    /* Modal tabs stack on very small screens */
    .modal-tabs {
        flex-wrap: wrap;
    }

    .modal-tab {
        flex: 1 1 auto;
        text-align: center;
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
}

/* Table Mobile Improvements */
@media (max-width: 768px) {
    /* Make tables scrollable horizontally */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    table {
        min-width: 600px;
    }

    th, td {
        padding: 0.625rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Specific Component Mobile Fixes */
@media (max-width: 640px) {
    /* Status bar mobile */
    .status-bar {
        gap: 0.5rem;
    }

    .status-bar .status-indicator {
        display: none;
    }

    /* Toast notifications mobile - above bottom nav */
    .toast-container {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 80px;
    }

    .toast {
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }

    /* Map controls mobile */
    .map-controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    .map-controls .btn {
        width: 100%;
    }

    /* Notification settings mobile */
    .notification-settings-grid {
        grid-template-columns: 1fr;
    }

    /* Mail settings mobile */
    .mail-settings-form .form-row {
        flex-direction: column;
    }

    .mail-template-list {
        grid-template-columns: 1fr;
    }

    /* Server logs mobile */
    .logs-filter-bar {
        flex-direction: column;
        gap: 0.75rem;
    }

    .logs-filter-bar .logs-filter-btn {
        flex: 1;
        text-align: center;
    }

    .log-entry {
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    .log-entry .log-time {
        font-size: 0.65rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .nav-item,
    .view-btn,
    .tab-btn,
    .toggle-switch {
        min-height: 44px;
    }

    /* Remove hover effects that don't work well on touch */
    .btn:hover,
    .nav-item:hover,
    .gateway-card:hover {
        transform: none;
    }

    /* Better scrolling */
    .scrollable {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}

/* Safe area padding for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    .modal-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    /* Toast container above mobile nav */
    @media (max-width: 900px) {
        .toast-container {
            bottom: calc(80px + env(safe-area-inset-bottom));
        }
    }
}

/* Print styles */
@media print {
    header,
    .modal-overlay,
    .toast-container,
    .btn,
    .status-bar {
        display: none !important;
    }

    main {
        padding: 0;
    }

    .gateway-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 900px) and (orientation: landscape) {
    .modal {
        max-height: 100vh;
        max-height: 100dvh;
    }

    .modal-content {
        max-height: calc(100vh - 120px);
        max-height: calc(100dvh - 120px);
    }

    .bms-visualization-full {
        max-height: calc(100vh - 60px);
        max-height: calc(100dvh - 60px);
    }

    /* Mobile nav in landscape mode */
    .main-nav {
        top: 50px;
        padding: 1rem;
    }

    .main-nav .nav-btn {
        padding: 0.75rem 1rem;
    }
}

/* Ultra-small screens (< 360px) */
@media (max-width: 360px) {
    .header-content {
        padding: 0.5rem 0.75rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .logo-icon svg {
        width: 16px;
        height: 16px;
    }

    main {
        padding: 0.75rem;
    }

    .gateway-card {
        padding: 0.75rem;
    }

    .modal-content {
        padding: 0.75rem;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* ============================================
   DASHBOARD VIEW - Gateway Cards mit Gauges
   ============================================ */

/* Dashboard Card Container */
.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
    animation: card-slide-in 0.4s ease-out;
}

@keyframes card-slide-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.dashboard-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.3);
}

.dashboard-card.offline {
    opacity: 0.7;
}

/* Stale dashboard card - last update > 5 minutes */
.dashboard-card.stale {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.08);
}

/* Last seen display in dashboard card */
.dashboard-last-seen {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.dashboard-last-seen svg {
    opacity: 0.7;
    flex-shrink: 0;
}

.dashboard-last-seen.stale {
    color: var(--warning);
}

.dashboard-last-seen.stale svg {
    opacity: 1;
}

/* Dashboard Header Right */
.dashboard-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Inline update badge */
.update-badge-inline {
    background: var(--warning);
    color: #000;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    white-space: nowrap;
}

/* Dashboard Connection Row */
.dashboard-connection-row {
    display: flex;
    justify-content: center;
    margin-bottom: 0.5rem;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.dashboard-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

/* Status LED */
.status-led {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-led.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: led-pulse 2s ease-in-out infinite;
}

.status-led.offline {
    background: var(--danger);
}

@keyframes led-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--success); }
    50% { opacity: 0.6; box-shadow: 0 0 4px var(--success); }
}

/* Gateway Name */
.dashboard-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Connection Dots */
.connection-dots {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.3;
    cursor: help;
    transition: all 0.2s ease;
}

.connection-dot.active {
    opacity: 1;
}

.connection-dot.eth { background: #4CAF50; }
.connection-dot.wifi { background: #2196F3; }
.connection-dot.mqtt { background: #9C27B0; }
.connection-dot.modbus { background: #FF9800; }
.connection-dot.can { background: #E91E63; }

/* Connection Icons */
.connection-icons {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.connection-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    opacity: 0.25;
    transition: all 0.3s ease;
    cursor: help;
}

.connection-icon svg {
    width: 100%;
    height: 100%;
}

.connection-icon.active {
    color: var(--accent);
    opacity: 1;
}

/* Dashboard Subheader */
.dashboard-subheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.dashboard-mac-ip {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.dashboard-mac-ip span {
    opacity: 0.7;
}

/* Checkbox */
.dashboard-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* Gauge Section */
.gauge-section {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 1rem 0;
    gap: 0.5rem;
}

/* Individual Gauge Container */
.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 100px;
}

/* Ring Gauge (SOC, Temperature) */
@property --gauge-percent {
    syntax: '<number>';
    initial-value: 0;
    inherits: false;
}

.gauge-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    animation: gauge-appear 0.5s ease-out;
}

/* Farbiger Ring im Hintergrund */
.gauge-ring::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
        var(--gauge-color, var(--accent)) calc(var(--gauge-percent, 0) * 3.6deg),
        var(--bg-tertiary) 0
    );
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.gauge-ring:hover::before {
    opacity: 0.6;
}

/* Innerer prominenter Kreis */
.gauge-ring::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: var(--bg-card);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@keyframes gauge-appear {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.gauge-ring-value {
    position: relative;
    z-index: 2;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.gauge-ring-value small {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* Arc Gauge (Power) */
.gauge-arc {
    width: 80px;
    height: 50px;
    position: relative;
    overflow: hidden;
}

.gauge-arc-bg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(
        from 180deg,
        var(--bg-tertiary) 0deg,
        var(--bg-tertiary) 180deg,
        transparent 180deg
    );
    position: absolute;
    top: 0;
    left: 0;
}

.gauge-arc-fill {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(
        from 180deg,
        var(--gauge-color, var(--accent)) 0deg,
        var(--gauge-color, var(--accent)) calc(var(--gauge-percent, 0) * 1.8deg),
        transparent calc(var(--gauge-percent, 0) * 1.8deg)
    );
    position: absolute;
    top: 0;
    left: 0;
    transition: --gauge-percent 0.8s ease-out;
}

.gauge-arc-inner {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-card);
    position: absolute;
    top: 8px;
    left: 8px;
}

.gauge-arc-value {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 2px;
}

.gauge-arc-value .direction {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* Gauge Label */
.gauge-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* SOC Progress Bar */
.soc-progress-section {
    margin: 0.5rem 0;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
}

.soc-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.soc-progress-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.soh-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 0.25rem;
    color: var(--accent);
}

.soc-progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.soc-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease-out;
    position: relative;
}

.soc-progress-fill.charging {
    animation: charging-shimmer 2s linear infinite;
}

@keyframes charging-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.soc-progress-fill.charging::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: charging-shimmer 1.5s linear infinite;
}

/* Charge Status */
.charge-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.charge-status svg {
    width: 14px;
    height: 14px;
}

.charge-status.charging {
    color: var(--success);
}

.charge-status.discharging {
    color: var(--warning);
}

/* Collapsible Details Section */
.dashboard-details-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    width: 100%;
    transition: color 0.2s ease;
}

.dashboard-details-toggle:hover {
    color: var(--accent);
}

.dashboard-details-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.3s ease;
}

.dashboard-details-toggle.expanded svg {
    transform: rotate(180deg);
}

.dashboard-details-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.dashboard-details-content.expanded {
    max-height: 300px;
}

.dashboard-details-inner {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

/* Temperature Details */
.temp-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.temp-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 0.25rem;
    font-size: 0.7rem;
}

.temp-badge .label {
    color: var(--text-muted);
}

.temp-badge .value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Relay Toggle */
.relay-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.relay-row:last-child {
    border-bottom: none;
}

.relay-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.relay-label svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

/* MQTT Status in Details */
.mqtt-status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mqtt-status-row svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.mqtt-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.mqtt-dot.stale {
    background: var(--warning);
}

/* Dashboard Footer */
.dashboard-footer {
    display: flex;
    justify-content: center;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.dashboard-footer .btn {
    flex: 1;
    max-width: 200px;
}

/* Update Badge */
.update-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.2rem 0.5rem;
    background: var(--warning);
    color: #000;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
}

/* Gauge Color Classes */
.gauge-green { --gauge-color: #4CAF50; }
.gauge-orange { --gauge-color: #FF9800; }
.gauge-red { --gauge-color: #f44336; }
.gauge-blue { --gauge-color: #2196F3; }
.gauge-cyan { --gauge-color: var(--accent); }

/* SOC Colors */
.soc-high { background: linear-gradient(90deg, #4CAF50, #8BC34A); }
.soc-medium { background: linear-gradient(90deg, #FF9800, #FFC107); }
.soc-low { background: linear-gradient(90deg, #f44336, #FF5722); }

/* No Data State */
.gauge-no-data {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.gauge-ring.no-data {
    background: var(--bg-tertiary);
}

.gauge-ring.no-data::before {
    background: var(--bg-card);
}

/* Dashboard Grid */
#gatewayList.dashboard-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

/* Responsive Adjustments for Dashboard */
@media (max-width: 768px) {
    .gauge-section {
        flex-wrap: wrap;
    }

    .gauge-container {
        min-width: 80px;
    }

    .gauge-ring {
        width: 70px;
        height: 70px;
    }

    .gauge-ring-value {
        font-size: 1rem;
    }

    .gauge-arc {
        width: 70px;
        height: 45px;
    }

    .gauge-arc-bg,
    .gauge-arc-fill {
        width: 70px;
        height: 70px;
    }

    .gauge-arc-inner {
        width: 54px;
        height: 54px;
    }

    #gatewayList.dashboard-view {
        grid-template-columns: 1fr;
    }

    .dashboard-card {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .gauge-ring {
        width: 60px;
        height: 60px;
    }

    .gauge-ring::before {
        inset: 6px;
    }

    .gauge-ring-value {
        font-size: 0.9rem;
    }

    .gauge-arc {
        width: 60px;
        height: 38px;
    }

    .gauge-arc-bg,
    .gauge-arc-fill {
        width: 60px;
        height: 60px;
    }

    .gauge-arc-inner {
        width: 44px;
        height: 44px;
        top: 8px;
        left: 8px;
    }
}

/* ============================================
   Admin Sections (System Info, Server Logs, Users)
   ============================================ */

.admin-section {
    padding: 0;
}

/* .admin-container - Styles sind in .section-container-base konsolidiert */

/* .admin-header - Styles sind in .section-header-base konsolidiert */

.admin-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.admin-content {
    padding: 1.5rem;
}

/* Server Logs Header Actions */
.logs-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.logs-filter-group {
    display: flex;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem;
    border-radius: 0.5rem;
}

.logs-filter-btn {
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.logs-filter-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.logs-filter-btn.active {
    color: var(--text-primary);
    background: var(--accent);
}

.logs-search-group {
    display: flex;
    gap: 0.25rem;
}

.logs-search-group input {
    width: 150px;
    padding: 0.375rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.logs-stats {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Server Logs Content */
.logs-list {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.8rem;
}

.log-entry {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.02);
}

.log-time {
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.log-level {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.log-level-error { color: var(--error); }
.log-level-warn { color: var(--warning); }
.log-level-info { color: var(--accent); }
.log-level-debug { color: var(--text-muted); }

.log-message {
    color: var(--text-secondary);
    word-break: break-word;
}

.logs-load-more {
    padding: 1rem;
    text-align: center;
}

.logs-empty,
.logs-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-muted);
    text-align: center;
}

.logs-error svg {
    color: var(--error);
}

/* ============================================
   Automation Log Styles
   ============================================ */

.automation-log-content {
    padding: 1rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.automation-log-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    color: var(--text-muted);
    text-align: center;
}

.automation-log-empty svg {
    opacity: 0.5;
}

.automation-log-empty p {
    font-size: 1.1rem;
    margin: 0;
}

.automation-log-empty span {
    font-size: 0.85rem;
    opacity: 0.7;
}

.automation-log-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.automation-log-entry {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.automation-log-entry:hover {
    border-color: var(--border-hover);
}

.automation-log-entry.success {
    border-left: 4px solid var(--success);
}

.automation-log-entry.failed {
    border-left: 4px solid var(--error);
}

.log-entry-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.log-entry-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    min-width: 100px;
}

.log-entry-status.success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.log-entry-status.failed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.log-entry-name {
    flex: 1;
    font-weight: 600;
    color: var(--text);
}

.log-entry-gateway {
    font-size: 0.85rem;
    color: var(--accent);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background 0.2s ease;
}

.log-entry-gateway:hover {
    background: var(--bg-hover);
}

.log-entry-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.log-entry-details {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.log-entry-action,
.log-entry-condition,
.log-entry-message {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.log-entry-action strong,
.log-entry-condition strong,
.log-entry-message strong {
    color: var(--text-muted);
    font-weight: 500;
    min-width: 80px;
}

.log-action-type {
    background: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.log-action-params {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    color: var(--text-muted);
}

.log-condition {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.log-actual {
    color: var(--accent);
}

/* Filter Group in Header */
.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-group select {
    font-size: 0.8rem;
    padding: 0.35rem 0.5rem;
    min-width: 120px;
}

/* Responsive */
@media (max-width: 768px) {
    .log-entry-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .log-entry-name {
        width: 100%;
        order: -1;
    }

    .log-entry-status {
        min-width: auto;
    }

    .filter-group {
        flex-wrap: wrap;
    }
}

/* ============================================
   User Administration - New Design
   ============================================ */

.users-admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.users-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.users-admin-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.users-admin-title svg {
    color: var(--accent);
    flex-shrink: 0;
}

.users-admin-title h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.users-admin-title p {
    margin: 0.25rem 0 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.users-admin-actions {
    display: flex;
    gap: 0.5rem;
}

/* Single Column Layout for Users Admin */
.users-admin-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Section Panels (Users and API Keys) */
.users-section-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

.users-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
}

.users-section-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.users-section-title svg {
    color: var(--accent);
}

.users-section-actions {
    display: flex;
    gap: 0.5rem;
}

/* Users section buttons - consistent sizing */
.users-section-header .btn {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.users-section-header .btn svg {
    width: 14px;
    height: 14px;
}

/* Users Section Body - Two Column */
.users-section-body {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 300px;
}

@media (max-width: 900px) {
    .users-section-body {
        grid-template-columns: 1fr;
    }
}

.users-list-column {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    max-height: 400px;
}

@media (max-width: 900px) {
    .users-list-column {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 200px;
    }
}

.users-form-column {
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

/* Legacy classes kept for compatibility */
.users-admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .users-admin-grid {
        grid-template-columns: 1fr;
    }
}

/* Users Panel (legacy) */
.users-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.users-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.1) 0%, transparent 100%);
    border-bottom: 1px solid var(--border);
}

.users-panel-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.users-panel-header h3 svg {
    color: var(--accent);
}

.users-panel-content {
    padding: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 0.5rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.user-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.user-item.selected {
    background: rgba(var(--accent-rgb), 0.15);
    border-color: var(--accent);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    flex-shrink: 0;
}

.user-avatar.admin {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* User Form Area */
.users-form-area {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
}

.user-form-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    color: var(--text-muted);
    text-align: center;
}

.user-form-placeholder svg {
    opacity: 0.4;
}

.user-form-placeholder p {
    margin: 0;
    font-size: 0.8125rem;
}

.user-edit-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-form-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.user-form-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    flex-shrink: 0;
}

.user-form-avatar.admin {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.user-edit-form h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-form-fields {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.user-form-fields .form-group {
    margin: 0;
}

.user-form-fields .form-group label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.user-form-fields .form-group input {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.role-selector {
    display: flex;
    gap: 0.5rem;
}

.role-option {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.role-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.role-option-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    transition: all 0.15s ease;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.role-option-content svg {
    opacity: 0.6;
}

.role-option input[type="radio"]:checked + .role-option-content {
    background: rgba(var(--accent-rgb), 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.role-option input[type="radio"]:checked + .role-option-content svg {
    opacity: 1;
    color: var(--accent);
}

.role-option:hover .role-option-content {
    border-color: var(--accent);
}

.user-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.user-form-actions-right {
    display: flex;
    gap: 0.5rem;
}

/* New API Keys Section (single column layout) */
.api-keys-section .users-section-title svg {
    color: #8b5cf6;
}

.api-keys-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1.25rem;
    background: rgba(139, 92, 246, 0.05);
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.api-keys-info svg {
    color: #8b5cf6;
    flex-shrink: 0;
}

.api-keys-info code {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.75rem;
    color: #8b5cf6;
}

.api-keys-list {
    padding: 1rem;
    min-height: 100px;
}

/* API Keys Panel (legacy) */
.api-keys-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.api-keys-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid var(--border);
}

.api-keys-panel-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.api-keys-panel-header h3 svg {
    color: #8b5cf6;
}

.api-keys-panel-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--text-primary);
}

.api-keys-panel-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1.25rem;
    background: rgba(139, 92, 246, 0.05);
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.api-keys-panel-info svg {
    color: #8b5cf6;
    flex-shrink: 0;
}

.api-keys-panel-info code {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.75rem;
    color: #8b5cf6;
}

.api-keys-panel-content {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
    min-height: 200px;
}

/* API Key Items */
.api-keys-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-muted);
    text-align: center;
}

.api-keys-empty svg {
    opacity: 0.3;
    color: #8b5cf6;
}

.api-keys-empty p {
    margin: 0;
    font-size: 0.875rem;
}

.api-key-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    transition: all 0.15s ease;
}

.api-key-item:last-child {
    margin-bottom: 0;
}

.api-key-item:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
}

.api-key-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-radius: 0.5rem;
    color: #8b5cf6;
    flex-shrink: 0;
}

.api-key-info {
    flex: 1;
    min-width: 0;
}

.api-key-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.api-key-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 0.75rem;
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

.api-key-prefix {
    font-family: 'Monaco', 'Consolas', monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.625rem;
}

.api-key-perms {
    color: #8b5cf6;
    font-weight: 500;
}

/* Legacy form actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* API Key Modal Styles */
.api-key-warning {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    color: #f59e0b;
}

.api-key-warning svg {
    flex-shrink: 0;
}

.api-key-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.api-key-display code {
    flex: 1;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
    word-break: break-all;
    color: var(--accent);
}

.api-key-usage {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    overflow-x: auto;
    margin: 0;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    transition: background 0.2s;
}

.checkbox-option:hover {
    background: rgba(var(--accent-rgb), 0.1);
}

.checkbox-option input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.checkbox-option span {
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* System Info Styles */
.info-section {
    margin-bottom: 1.5rem;
}

.info-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.info-section h3 svg {
    color: var(--accent);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.info-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.info-value.muted {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.85rem;
}

.info-table-container {
    overflow-x: auto;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.info-table th,
.info-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.info-table th {
    color: var(--text-muted);
    font-weight: 500;
    background: rgba(0, 0, 0, 0.1);
}

.info-table td {
    color: var(--text-secondary);
}

.info-table code {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', monospace;
}

.info-table a {
    color: var(--accent);
    text-decoration: none;
}

.info-table a:hover {
    text-decoration: underline;
}

.license-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid var(--accent);
    border-radius: 1rem;
    font-size: 0.75rem;
    color: var(--accent);
}

.info-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-muted);
}

.info-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-muted);
    text-align: center;
}

.info-error svg {
    color: var(--error);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .users-layout {
        grid-template-columns: 1fr;
    }

    .users-list-panel {
        max-height: 250px;
    }

    .logs-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .logs-filter-group {
        width: 100%;
        justify-content: center;
    }

    .logs-search-group input {
        width: 120px;
    }
}

/* ============================================
   Gateway Groups Styles
   ============================================ */

.groups-container {
    max-width: 1400px;
    margin: 0 auto;
}

.groups-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    min-height: 500px;
}

/* Groups List Panel */
.groups-list-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.groups-list {
    max-height: 600px;
    overflow-y: auto;
}

.groups-loading,
.groups-error {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.groups-error {
    color: var(--danger);
}

.groups-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    gap: 1rem;
}

.groups-empty svg {
    opacity: 0.5;
}

.groups-empty p {
    margin: 0;
}

/* Group Item */
.group-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    gap: 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s ease;
}

.group-item:hover {
    background-color: var(--bg-hover);
}

.group-item.selected {
    background-color: var(--primary-alpha, rgba(0, 210, 255, 0.1));
    border-left: 3px solid var(--primary);
}

.group-item-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.group-item-info {
    flex: 1;
    min-width: 0;
}

.group-item-name {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-item-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.group-item-arrow {
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.15s ease;
}

.group-item:hover .group-item-arrow {
    opacity: 0.8;
}

/* Groups Detail Panel */
.groups-detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.group-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
    gap: 1rem;
}

.group-placeholder svg {
    opacity: 0.4;
}

.group-placeholder p {
    margin: 0;
    max-width: 250px;
}

/* Group Detail View */
.group-detail {
    padding: 1.5rem;
}

.group-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.group-color-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.group-detail-header h3 {
    flex: 1;
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.group-detail-actions {
    display: flex;
    gap: 0.5rem;
}

/* Group Gateways Section */
.group-gateways-section {
    margin-top: 1rem;
}

.group-gateways-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.group-gateways-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.group-gateways-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.group-gateways-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 0.5rem;
}

/* Group Gateway Item */
.group-gateway-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    transition: background-color 0.15s ease;
}

.group-gateway-item:hover {
    background: var(--bg-hover);
}

.group-gateway-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.group-gateway-status.online {
    background-color: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.group-gateway-status.offline {
    background-color: var(--text-muted);
}

.group-gateway-info {
    flex: 1;
    min-width: 0;
}

.group-gateway-alias {
    font-weight: 500;
    color: var(--text);
}

.group-gateway-mac {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
}

/* Color Picker */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--text);
    transform: scale(1.1);
}

/* Group Modal Content */
.group-modal-content {
    padding: 0.5rem 0;
}

.group-modal-content .form-group {
    margin-bottom: 1.25rem;
}

.group-modal-content .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Button Icon */
.btn-icon {
    padding: 0.4rem;
    min-width: auto;
}

/* Responsive */
@media (max-width: 992px) {
    .groups-layout {
        grid-template-columns: 280px 1fr;
    }
}

@media (max-width: 768px) {
    .groups-layout {
        grid-template-columns: 1fr;
    }

    .groups-list-panel {
        max-height: 300px;
    }

    .group-detail-header {
        flex-wrap: wrap;
    }

    .group-detail-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
