/* Network Monitoring Dashboard Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #007bff;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #212529;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: var(--text-color);
    line-height: 1.6;
}

/* Container */
.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-role {
    color: var(--text-secondary);
    font-size: 0.88rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
}

/* Header right zone (bell + user info) */
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

/* Notification bell */
.notif-bell {
    position: relative;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.4rem 0.7rem;
    border-radius: 50px;
    transition: background 0.2s;
    line-height: 1;
}
.notif-bell:hover {
    background: rgba(255,255,255,0.3);
}
.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    pointer-events: none;
}

/* Notification panel dropdown */
.notif-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 70px;
    width: 340px;
    max-height: 450px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    border: 1px solid var(--border-color);
    z-index: 200;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.notif-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color);
}
.notif-clear {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
}
.notif-clear:hover { text-decoration: underline; }
.notif-list {
    list-style: none;
    overflow-y: auto;
    max-height: 380px;
    margin: 0;
    padding: 0;
}
.notif-empty {
    padding: 1.5rem;
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
}
.notif-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-left: 4px solid transparent;
}
.notif-item:last-child { border-bottom: none; }
.notif-item--critical { border-left-color: #dc3545; background: #fff5f5; }
.notif-item--high     { border-left-color: #fd7e14; background: #fff8f0; }
.notif-item--medium   { border-left-color: #ffc107; background: #fffdf0; }
.notif-item--low      { border-left-color: #28a745; background: #f5fff8; }
.notif-item-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-color);
}
.notif-item-msg {
    font-size: 0.82rem;
    color: #495057;
}
.notif-item-meta {
    font-size: 0.75rem;
    color: #6c757d;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1.2rem;
    right: 1.2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
    max-width: 360px;
}
.toast {
    pointer-events: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    border-left: 5px solid var(--info-color);
    overflow: hidden;
    animation: toast-slide-in 0.3s ease;
}
.toast--critical { border-left-color: #dc3545; }
.toast--high     { border-left-color: #fd7e14; }
.toast--medium   { border-left-color: #ffc107; }
.toast--low      { border-left-color: #28a745; }
@keyframes toast-slide-in {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}
.toast-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem 0.4rem;
    background: #f8f9fa;
    font-size: 0.85rem;
    border-bottom: 1px solid #eee;
}
.toast-header strong { flex: 1; font-size: 0.88rem; }
.toast-site {
    color: #6c757d;
    font-size: 0.78rem;
}
.toast-severity {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0,0,0,0.07);
}
.toast--critical .toast-severity { color: #dc3545; }
.toast--high     .toast-severity { color: #fd7e14; }
.toast--medium   .toast-severity { color: #856404; }
.toast--low      .toast-severity { color: #28a745; }
.toast-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    color: #6c757d;
    padding: 0 2px;
}
.toast-close:hover { color: #343a40; }
.toast-body {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: #495057;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.25rem 2rem 2rem 2rem;
    width: 100%;
}

/* Tabs */
.tabs {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    margin-bottom: 0.25rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 3px solid transparent;
    transition: all 0.25s ease;
    font-weight: 500;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0;
    margin-bottom: 0.8rem;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--dark-color);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-logout {
    background-color: transparent;
    color: white;
    border: 1px solid white;
}

.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-full {
    width: 100%;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

/* Forms */
.form-container {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.form-actions .btn {
    flex: 1;
}

/* Devices Grid */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.device-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid var(--border-color);
}

.device-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.device-card.online {
    border-left-color: var(--success-color);
}

.device-card.offline {
    border-left-color: var(--danger-color);
    opacity: 0.7;
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.device-name-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.device-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dark-color);
}

.device-type-badge {
    display: inline-block;
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    width: fit-content;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.device-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.device-status.online {
    background-color: #d4edda;
    color: #155724;
}

.device-status.offline {
    background-color: #f8d7da;
    color: #721c24;
}

.device-info {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.device-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.metric-item {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
}

.metric-bar {
    width: 100%;
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    margin-top: 0.25rem;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 2px;
}

/* Alerts List */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alert-item {
    background: white;
    border-left: 4px solid var(--warning-color);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.alert-item.critical {
    border-left-color: var(--danger-color);
}

.alert-item.high {
    border-left-color: var(--danger-color);
}

.alert-item.medium {
    border-left-color: var(--warning-color);
}

.alert-item.low {
    border-left-color: var(--info-color);
}

.alert-item.resolved {
    opacity: 0.6;
    background-color: #f8f9fa;
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.75rem;
}

.alert-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--dark-color);
}

.alert-severity {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
}

.alert-severity.critical {
    background-color: var(--danger-color);
}

.alert-severity.high {
    background-color: var(--danger-color);
}

.alert-severity.medium {
    background-color: var(--warning-color);
}

.alert-severity.low {
    background-color: var(--info-color);
}

.alert-message {
    color: var(--text-color);
    margin-bottom: 0.75rem;
}

.alert-time {
    color: #6c757d;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.alert-actions {
    display: flex;
    gap: 0.5rem;
}

/* Metrics Container */
.metrics-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.metric-card h3 {
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.metric-chart {
    width: 100%;
    height: 200px;
    background-color: var(--light-color);
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

/* Login Container */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: white;
    padding: 2.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.login-card .subtitle {
    text-align: center;
    color: #6c757d;
    margin-bottom: 1.5rem;
}

.form-divider {
    text-align: center;
    color: #6c757d;
    margin: 1.5rem 0;
    position: relative;
}

.form-divider::before,
.form-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background-color: var(--border-color);
}

.form-divider::before {
    left: 0;
}

.form-divider::after {
    right: 0;
}

/* Messages */
.message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    display: none;
}

.message.show {
    display: block;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#device-modal-body {
    padding: 1.5rem;
}

#add-device-modal-body {
    padding: 1.5rem;
}

/* Language Switcher */
.language-switcher {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.4rem 0.8rem;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.lang-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.lang-btn.active {
    background-color: rgba(255, 255, 255, 0.5);
    border-color: white;
}

.login-language-switcher {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    justify-content: center;
}

.login-language-switcher .lang-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.login-language-switcher .lang-btn:hover {
    background-color: var(--light-color);
    border-color: var(--primary-color);
}

.login-language-switcher .lang-btn.active {
    background-color: var(--light-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

.filter-controls {
    display: flex;
    gap: 1rem;
}

.filter-controls select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .main-content {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        gap: 1rem;
    }

    .section-header h2 {
        font-size: 1.2rem;
    }

    .devices-grid {
        grid-template-columns: 1fr;
    }

    .device-metrics {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
    }

    .login-card {
        padding: 1.5rem;
    }
}

/* ================================================================
   NEW MULTI-DEVICE STYLES
   ================================================================ */

/* Status variables */
:root {
    --color-online:   #16a34a;
    --color-degraded: #d97706;
    --color-critical: #b91c1c;
    --color-offline:  #6b7280;
}

/* ---------- Device card status borders ---------- */
.device-card.degraded {
    border-left-color: var(--color-degraded);
}
.device-card.critical {
    border-left-color: var(--color-critical);
    opacity: 0.92;
}
.device-card.offline {
    border-left-color: var(--color-offline);
    opacity: 0.75;
}
.device-card.online {
    border-left-color: var(--color-online);
}

/* ---------- Status badge (replaces device-status) ---------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.status-badge.online {
    background: #dcfce7;
    color: #15803d;
}
.status-badge.degraded {
    background: #fef3c7;
    color: #92400e;
}
.status-badge.critical {
    background: #fee2e2;
    color: #991b1b;
}
.status-badge.offline {
    background: #f3f4f6;
    color: #4b5563;
}

/* ---------- Device type badge ---------- */
.device-type-badge {
    display: inline-block;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.15rem 0.55rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

/* Device name badge (replaces device type) */
.device-name-badge {
    display: inline-block;
    background: #f3e8ff;
    color: #6d28d9;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 0.3rem;
    margin-bottom: 0.5rem;
    border: 1px solid #d8b4fe;
}

/* badge type avec couleur personnalisée (nouveaux types) */
.device-type-badge[style] {
    color: #fff;
}

/* Badge "auto-découvert" */
.badge-auto {
    display: inline-block;
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #86efac;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 0.85rem;
    vertical-align: middle;
    margin-left: 0.25rem;
}

/* Icône appareil dans les alertes */
.alert-ip {
    font-size: 0.75rem;
    color: #6b7280;
    margin-left: 0.25rem;
}

/* ================================================================
   NETWORK DEVICE CARD — NOUVEAUX ÉLÉMENTS
   ================================================================ */

/* Ligne type + badges (perte, auto) sous le header */
.device-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}
.device-meta-row .device-type-badge { margin-bottom: 0; }

/* Dernière vue en petite police en bas de la carte */
.device-lastseen {
    font-size: 0.72rem;
    color: #9ca3af;
    margin-top: 0.4rem;
}

/* ── Jauge de latence réseau ─────────────────────────────────── */
.net-metric-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.55rem;
    font-size: 0.78rem;
}
.nm-label {
    min-width: 56px;
    color: #6b7280;
    font-size: 0.74rem;
    white-space: nowrap;
}
.nm-value {
    min-width: 46px;
    text-align: right;
    font-weight: 600;
    font-size: 0.78rem;
}
.lat-bar-bg {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}
.lat-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}
.lat-bar-fill.lat-ok   { background: #16a34a; }
.lat-bar-fill.lat-warn { background: #d97706; }
.lat-bar-fill.lat-bad  { background: #dc2626; }
.nm-value.lat-ok   { color: #16a34a; }
.nm-value.lat-warn { color: #d97706; }
.nm-value.lat-bad  { color: #dc2626; }

/* ── Badge perte de paquets ──────────────────────────────────── */
.pkt-loss-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 0.85rem;
    white-space: nowrap;
}
.pkt-loss-badge.loss-ok   { background: #fef3c7; color: #92400e; }
.pkt-loss-badge.loss-warn { background: #fed7aa; color: #9a3412; }
.pkt-loss-badge.loss-bad  { background: #fee2e2; color: #991b1b; }

/* Perte de paquets en vue liste */
.pkt-loss-inline {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
}
.pkt-loss-inline.loss-ok   { background: #fef3c7; color: #92400e; }
.pkt-loss-inline.loss-warn { background: #fed7aa; color: #9a3412; }
.pkt-loss-inline.loss-bad  { background: #fee2e2; color: #991b1b; }

/* ── Pills ports TCP ouverts ─────────────────────────────────── */
.port-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.5rem;
}
.port-pill {
    display: inline-block;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.05rem 0.4rem;
    border-radius: 0.25rem;
    font-family: monospace;
    cursor: default;
}
.port-pill.port-more {
    background: #f3f4f6;
    color: #6b7280;
    border-color: #d1d5db;
}

/* ---------- Stats bar ---------- */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    flex: 1 1 120px;
    background: white;
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    text-align: center;
    border-top: 3px solid var(--border-color);
}
.stat-card--total    { border-top-color: var(--primary-color); }
.stat-card--online   { border-top-color: var(--color-online); }
.stat-card--degraded { border-top-color: var(--color-degraded); }
.stat-card--critical { border-top-color: var(--color-critical); }
.stat-card--offline  { border-top-color: var(--color-offline); }
.stat-card--alerts   { border-top-color: var(--warning-color); }
.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
}
.stat-card--total    .stat-value { color: var(--primary-color); }
.stat-card--online   .stat-value { color: var(--color-online); }
.stat-card--degraded .stat-value { color: var(--color-degraded); }
.stat-card--critical .stat-value { color: var(--color-critical); }
.stat-card--offline  .stat-value { color: var(--color-offline); }
.stat-card--alerts   .stat-value { color: var(--warning-color); }
.stat-label {
    font-size: 0.78rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---------- Alert severity (text colours) ---------- */
.alert-item.critical { border-left-color: var(--color-critical); }
.alert-item.high     { border-left-color: #ea580c; }
.alert-item.medium   { border-left-color: var(--color-degraded); }
.alert-item.low      { border-left-color: var(--info-color); }

.alert-severity.critical { background-color: var(--color-critical); }
.alert-severity.high     { background-color: #ea580c; }
.alert-severity.medium   { background-color: var(--color-degraded); color: #1c1c1c; }
.alert-severity.low      { background-color: var(--info-color); }

.alert-device {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 500;
    margin-bottom: 0.4rem;
}

/* ---------- Chart container ---------- */
.chart-container {
    grid-column: 1 / -1;
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    min-height: 300px;
}
.chart-container canvas {
    width: 100% !important;
}

/* ---------- Metrics summary & layout ---------- */
.metrics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.metric-card h4 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}
.metrics-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ---------- Ports grid ---------- */
.ports-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.port-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem 0.65rem;
    border-radius: 0.375rem;
    font-size: 0.78rem;
    min-width: 60px;
    text-align: center;
    border: 1px solid var(--border-color);
    background: #f9fafb;
}
.port-item.open {
    border-color: var(--color-online);
    background: #f0fdf4;
}
.port-item.closed {
    border-color: var(--border-color);
    opacity: 0.6;
}
.port-number  { font-weight: 700; font-size: 0.85rem; }
.port-service { font-size: 0.72rem; color: #6c757d; }
.port-status  { font-size: 1rem; }
.port-ms      { font-size: 0.7rem; color: #6c757d; }

/* ---------- Modal device info ---------- */
.modal-device-info p {
    margin-bottom: 0.5rem;
    font-size: 0.92rem;
}

/* ---------- Responsive adjustments ---------- */
@media (max-width: 768px) {
    .stats-bar { gap: 0.5rem; }
    .stat-card  { flex: 1 1 90px; padding: 0.6rem 0.5rem; }
    .stat-value { font-size: 1.4rem; }
    .chart-container { padding: 0.75rem; }
}

/* ================================================================
   DARK MODE
   ================================================================ */
body.dark-mode {
    --text-color:   #e5e7eb;
    --dark-color:   #f9fafb;
    --border-color: #374151;
    --light-color:  #1f2937;
    --shadow:       0 2px 4px rgba(0,0,0,0.4);
    --shadow-lg:    0 4px 8px rgba(0,0,0,0.5);
    background-color: #111827;
    color: var(--text-color);
}
body.dark-mode .header { background: linear-gradient(135deg, #1e3a5f, #0a1628); }
body.dark-mode .device-card,
body.dark-mode .alert-item,
body.dark-mode .metric-card,
body.dark-mode .chart-container,
body.dark-mode .stat-card,
body.dark-mode .notif-panel,
body.dark-mode .modal-content,
body.dark-mode .toast,
body.dark-mode .login-card,
body.dark-mode .devices-toolbar { background-color: #1f2937; color: var(--text-color); }
body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea,
body.dark-mode .filter-controls select,
body.dark-mode #device-type-filter,
body.dark-mode #device-status-filter,
body.dark-mode .toolbar-select { background: #374151; color: #e5e7eb; border-color: #4b5563; }
body.dark-mode .search-input-wrap input { background: #374151; color: #e5e7eb; border-color: #4b5563; }
body.dark-mode .device-info      { color: #9ca3af; }
body.dark-mode .device-type-badge { background: #1e3a5f; color: #93c5fd; }
body.dark-mode .device-type-badge-small { background: #1e3a8a; color: #bfdbfe; }
body.dark-mode .device-name-badge { background: #3f1d5a; color: #d8b4fe; border-color: #7c3aed; }
body.dark-mode .tab-btn           { color: #9ca3af; }
body.dark-mode .tab-btn.active    { color: #60a5fa; border-bottom-color: #60a5fa; }
body.dark-mode .tabs              { border-bottom-color: #374151; }
body.dark-mode .notif-panel-header { background: #374151; }
body.dark-mode .notif-item         { border-bottom-color: #374151; }
body.dark-mode .notif-empty        { color: #9ca3af; }
body.dark-mode .modal-header       { border-bottom-color: #374151; }
body.dark-mode .status-badge.online   { background: #064e3b; color: #34d399; }
body.dark-mode .status-badge.degraded { background: #451a03; color: #fbbf24; }
body.dark-mode .status-badge.critical { background: #450a0a; color: #f87171; }
body.dark-mode .status-badge.offline  { background: #1f2937; color: #9ca3af; }
body.dark-mode .section-header h2  { color: #e5e7eb; }
body.dark-mode .alert-message      { color: #d1d5db; }
body.dark-mode .view-toggle-btn    { background: #374151; color: #9ca3af; border-color: #4b5563; }
body.dark-mode .view-toggle-btn.active { background: #1e3a5f; color: #60a5fa; border-color: #3b82f6; }
body.dark-mode .devices-list .device-row { background: #1f2937; border-color: #374151; }
body.dark-mode .devices-list .device-row:hover { background: #374151; }
body.dark-mode .group-header       { background: #1f2937; color: #9ca3af; border-color: #374151; }
body.dark-mode .metric-bar-bg      { background: #374151; }
body.dark-mode .port-item          { background: #374151; }
body.dark-mode .port-item.open     { background: #064e3b; }
body.dark-mode .modal-device-info p { color: #d1d5db; }
body.dark-mode .topology-canvas-wrap { background: #1f2937; }
body.dark-mode .topology-legend    { background: #1f2937; }
body.dark-mode .metric-card h4     { color: #d1d5db; }
body.dark-mode .metric-card p      { color: #9ca3af; }
body.dark-mode .chart-panel        { background: #1f2937; }
body.dark-mode .chart-panel h4     { color: #d1d5db; }
body.dark-mode .refresh-info       { color: #6b7280; }
body.dark-mode .refresh-btn        { color: #60a5fa; border-color: #374151; }
body.dark-mode .refresh-btn:hover  { background: #1e3a5f; }
body.dark-mode .group-toggle-btn   { background: #374151; color: #9ca3af; border-color: #4b5563; }
body.dark-mode .group-toggle-btn.active { background: #1e3a5f; color: #60a5fa; border-color: #3b82f6; }
body.dark-mode .btn-export         { background: #064e3b; color: #34d399; border-color: #065f46; }
body.dark-mode .toast-header       { background: #374151; }
body.dark-mode .login-card h2,
body.dark-mode .login-card .subtitle { color: #e5e7eb; }
/* Éléments réseau (dark mode) */
body.dark-mode .lat-bar-bg         { background: #374151; }
body.dark-mode .device-lastseen    { color: #6b7280; }
body.dark-mode .port-pill          { background: #1e3a5f; color: #93c5fd; border-color: #1e40af; }
body.dark-mode .port-pill.port-more { background: #374151; color: #9ca3af; border-color: #4b5563; }
body.dark-mode .pkt-loss-badge.loss-ok,
body.dark-mode .pkt-loss-inline.loss-ok   { background: #451a03; color: #fbbf24; }
body.dark-mode .pkt-loss-badge.loss-warn,
body.dark-mode .pkt-loss-inline.loss-warn { background: #431407; color: #fb923c; }
body.dark-mode .pkt-loss-badge.loss-bad,
body.dark-mode .pkt-loss-inline.loss-bad  { background: #450a0a; color: #f87171; }
body.dark-mode .device-row .row-latency,
body.dark-mode .device-row .row-ports,
body.dark-mode .device-row .row-site     { color: #9ca3af; }

/* ================================================================
   DARK MODE TOGGLE BUTTON
   ================================================================ */
.dark-mode-toggle {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.35rem 0.65rem;
    border-radius: 50px;
    transition: background 0.2s;
    line-height: 1;
}
.dark-mode-toggle:hover { background: rgba(255,255,255,0.3); }

/* ================================================================
   REAL-TIME CLOCK
   ================================================================ */
.real-time-clock {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.8);
    font-variant-numeric: tabular-nums;
    min-width: 160px;
    text-align: right;
    white-space: nowrap;
}

/* ================================================================
   SEARCH & SORT TOOLBAR
   ================================================================ */
.devices-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    background: white;
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}
.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.search-input-wrap input {
    width: 100%;
    padding: 0.42rem 0.42rem 0.42rem 2rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.search-input-wrap input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.12);
}
.search-icon {
    position: absolute;
    left: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    pointer-events: none;
}
.toolbar-select {
    padding: 0.42rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    outline: none;
    color: var(--text-color);
}
.toolbar-select:focus { border-color: var(--primary-color); }
.view-toggle-group {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    overflow: hidden;
}
.view-toggle-btn {
    background: white;
    border: none;
    padding: 0.38rem 0.7rem;
    cursor: pointer;
    font-size: 1rem;
    color: #6c757d;
    transition: background 0.15s, color 0.15s;
}
.view-toggle-btn:first-child { border-right: 1px solid var(--border-color); }
.view-toggle-btn.active { background: var(--primary-color); color: white; }
.view-toggle-btn:hover:not(.active) { background: #f0f4ff; }
.group-toggle-btn {
    padding: 0.38rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: white;
    font-size: 0.82rem;
    cursor: pointer;
    color: #495057;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.group-toggle-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.devices-count-badge {
    font-size: 0.8rem;
    color: #6c757d;
    margin-left: auto;
    white-space: nowrap;
}

/* ================================================================
   LIST VIEW
   ================================================================ */
.devices-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.device-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: box-shadow 0.2s, background 0.15s;
    border-left: 4px solid var(--border-color);
}
.device-row:hover { box-shadow: var(--shadow-lg); }
.device-row.online   { border-left-color: var(--color-online); }
.device-row.degraded { border-left-color: var(--color-degraded); }
.device-row.critical { border-left-color: var(--color-critical); }
.device-row.offline  { border-left-color: var(--color-offline); opacity: 0.75; }
.device-row .row-icon    { font-size: 1.3rem; min-width: 28px; text-align: center; }
.device-row .row-name    { font-weight: 600; min-width: 160px; color: var(--dark-color); font-size: 0.9rem; }
.device-row .row-type-label { font-size: 0.78rem; min-width: 110px; }
.device-row .row-ip      { color: #6c757d; font-size: 0.82rem; min-width: 120px; font-family: monospace; }
.device-row .row-name-configured { font-size: 0.78rem; min-width: 120px; }
.device-row .row-site    { font-size: 0.82rem; color: #6c757d; flex: 1; }
.device-row .row-latency { font-size: 0.82rem; min-width: 72px; text-align: right; color: #6c757d; }
.device-row .row-loss    { font-size: 0.82rem; min-width: 60px; text-align: center; }
.device-row .row-ports   { font-size: 0.78rem; min-width: 52px; text-align: center; color: #6c757d; font-family: monospace; }
.device-row .row-status  { min-width: 100px; text-align: right; }

.device-type-badge-small {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    padding: 0.2rem 0.6rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* ================================================================
   GROUP HEADER
   ================================================================ */
.group-header {
    padding: 0.45rem 1rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6c757d;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: #f9fafb;
    margin-top: 0.25rem;
}

/* ================================================================
   PROGRESS BARS IN DEVICE CARD
   ================================================================ */
.device-metrics-bars {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.metric-bar-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
}
.metric-bar-label {
    min-width: 34px;
    color: #6c757d;
    font-size: 0.74rem;
}
.metric-bar-bg {
    flex: 1;
    height: 5px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}
.metric-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}
.metric-bar-fill.low    { background: var(--color-online); }
.metric-bar-fill.medium { background: var(--color-degraded); }
.metric-bar-fill.high   { background: var(--color-critical); }
.metric-bar-val {
    min-width: 34px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--dark-color);
    font-size: 0.74rem;
    font-weight: 600;
}

/* ================================================================
   REFRESH COUNTDOWN & LAST UPDATED
   ================================================================ */
.refresh-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    justify-content: flex-end;
}
.refresh-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.22rem 0.55rem;
    font-size: 0.78rem;
    cursor: pointer;
    color: var(--primary-color);
}

/* ═══════════════════════════════════════════════════════
   ADMIN TAB — MODERN PROFESSIONAL DESIGN
═══════════════════════════════════════════════════════ */

/* ── Admin tab button ────────────────────────────────── */
.tab-btn-admin {
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    color: #fff !important;
    font-weight: 700;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
    padding: 0.65rem 1.35rem;
    border-bottom: 3px solid transparent;
    transition: all 0.25s ease;
    letter-spacing: 0.02em;
}
.tab-btn-admin.active,
.tab-btn-admin:hover {
    background: linear-gradient(135deg, #6d28d9, #4f46e5) !important;
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

/* ── Admin section header ────────────────────────────── */
#admin-tab .section-header {
    margin-top: 0 !important;
    margin-bottom: 0.5rem;
    padding-top: 0 !important;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-color);
}
.admin-intro {
    margin: 0.05rem 0 0 !important;
    padding: 0 !important;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
    max-width: 720px;
}

/* ── Stats bar ───────────────────────────────────────── */
.admin-stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 0.5rem;
    margin-bottom: 1.8rem;
}
@media (max-width: 700px) {
    .admin-stats-bar { grid-template-columns: repeat(2, 1fr); }
}
.admin-stat-card {
    background: linear-gradient(135deg, #fff, #f8fafc);
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1.2rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}
.admin-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #7c3aed, #6366f1);
    opacity: 0.6;
}
.admin-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,.08);
}
.admin-stat-num {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.admin-stat-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* ── Admin dual panel layouts ────────────────────────── */
.admin-dual-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 0.5rem;
}
@media (max-width: 900px) {
    .admin-dual-panel { grid-template-columns: 1fr; }
}

/* ── Admin panels ────────────────────────────────────── */
.admin-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
    transition: box-shadow 0.25s ease;
}
.admin-panel:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.06);
}
.admin-panel-full {
    grid-column: 1 / -1;
}

.admin-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
.admin-panel-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
    letter-spacing: -0.01em;
}
.admin-panel-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Search bars ─────────────────────────────────────── */
.admin-panel-search {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}
.admin-panel-search input {
    width: 100%;
    padding: 0.5rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    background: #f8fafc;
    color: #334155;
    transition: all 0.2s;
}
.admin-panel-search input:focus {
    outline: none;
    border-color: #7c3aed;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
.admin-search-inline {
    padding: 0.35rem 0.7rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.82rem;
    background: #f8fafc;
    color: #334155;
    width: 160px;
    transition: all 0.2s;
}
.admin-search-inline:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

/* ── Admin scrollers & loading ────────────────────────── */
.admin-users-table-wrap,
.admin-audit-table-wrap {
    overflow-x: auto;
}
.admin-table-loading {
    text-align: center;
    color: #94a3b8;
    padding: 2rem;
    font-style: italic;
    font-size: 0.85rem;
}

/* ── Admin item list (orgs/clients cards) ────────────── */
.admin-list {
    padding: 0.4rem;
    min-height: 100px;
}
.admin-empty {
    color: #94a3b8;
    font-style: italic;
    padding: 1.5rem 1rem;
    text-align: center;
    font-size: 0.85rem;
}

.admin-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    border-radius: 0.65rem;
    cursor: pointer;
    transition: all 0.18s ease;
    border: 1px solid transparent;
    margin-bottom: 2px;
}
.admin-item:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
}
.admin-item.active {
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(124,58,237,0.25);
}
.admin-item.active .admin-item-meta,
.admin-item.active .admin-item-name {
    color: rgba(255,255,255,.9);
}
.admin-item.active .api-key-box {
    background: rgba(255,255,255,.15);
    color: rgba(255,255,255,.8);
}
.admin-item-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 2rem;
    text-align: center;
}
.admin-item-body {
    flex: 1;
    min-width: 0;
}
.admin-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-item-meta {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.15rem;
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}
.admin-item-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.2s;
}
.admin-item:hover .admin-item-actions,
.admin-item.active .admin-item-actions {
    opacity: 1;
}

/* ── Badge counter ───────────────────────────────────── */
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    background: #e0e7ff;
    color: #4338ca;
}
.admin-badge-gray {
    background: #e2e8f0;
    color: #64748b;
}

/* ── Tables ──────────────────────────────────────────── */
.admin-users-table,
.admin-audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.admin-users-table th,
.admin-users-table td,
.admin-audit-table th,
.admin-audit-table td {
    text-align: left;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid #e2e8f0;
}
.admin-users-table th,
.admin-audit-table th {
    font-weight: 700;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    z-index: 1;
}
.admin-users-table tbody tr,
.admin-audit-table tbody tr {
    transition: background 0.12s ease;
}
.admin-users-table tbody tr:hover td,
.admin-audit-table tbody tr:hover td {
    background: #f1f5f9;
}
.admin-users-table td:last-child,
.admin-audit-table td:last-child {
    text-align: right;
}
.admin-users-table td:first-child {
    font-weight: 600;
    color: #1e293b;
}

/* ── Role badge ──────────────────────────────────────── */
.role-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.role-superadmin {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    box-shadow: 0 1px 3px rgba(251,191,36,0.2);
}
.role-org_admin {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e40af;
    box-shadow: 0 1px 3px rgba(59,130,246,0.15);
}
.role-technician {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #065f46;
    box-shadow: 0 1px 3px rgba(16,185,129,0.15);
}

/* ── Admin pagination ────────────────────────────────── */
.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}
.admin-pagination .btn {
    padding: 0.35rem 0.9rem;
    font-size: 0.8rem;
    border-radius: 0.45rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s;
}
.admin-pagination .btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.admin-pagination .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
#users-page-info,
#audit-page-info {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
}

/* ── Audit log action badges ─────────────────────────── */
.audit-action {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.audit-status {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 0.35rem;
    font-size: 0.68rem;
    font-weight: 600;
}

/* ── API key display ─────────────────────────────────── */
.api-key-box {
    font-family: "SF Mono", "Consolas", monospace;
    font-size: 0.7rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 0.35rem;
    padding: 0.25rem 0.55rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    display: inline-block;
    cursor: pointer;
    color: #64748b;
    transition: all 0.15s;
}
.api-key-box:hover {
    background: #e0e7ff;
    color: #4338ca;
    border-color: #a5b4fc;
}
.apikey-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.apikey-row .api-key-box {
    max-width: none;
    flex: 1;
}

/* ── Status dots ─────────────────────────────────────── */
.status-dot-active {
    width: 7px; height: 7px; border-radius: 50%;
    background: #22c55e; display: inline-block; margin-right: 0.3rem;
    box-shadow: 0 0 6px rgba(34,197,94,0.4);
}
.status-dot-inactive {
    width: 7px; height: 7px; border-radius: 50%;
    background: #94a3b8; display: inline-block; margin-right: 0.3rem;
}

.user-status-active {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #16a34a;
    font-size: 0.75rem;
    font-weight: 600;
}
.user-status-inactive {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ── Toggle switch ───────────────────────────────────── */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.88rem;
    user-select: none;
    color: #334155;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-slider {
    display: inline-block;
    width: 38px;
    height: 21px;
    background: #94a3b8;
    border-radius: 99px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: white;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-label input:checked + .toggle-slider { background: #7c3aed; }
.toggle-label input:checked + .toggle-slider::after { transform: translateX(17px); }

/* ── Form helpers ────────────────────────────────────── */
.form-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.3rem;
    font-style: italic;
}
.form-hint-inline {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 400;
    margin-left: 0.3rem;
}
.form-group-inline { margin-bottom: 1rem; }
.form-label-small {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
    display: block;
    margin-bottom: 0.35rem;
}

/* ── Password field with toggle ──────────────────────── */
.pwd-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.pwd-input-wrap input { flex: 1; }
.btn-pwd-toggle {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.45rem;
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    font-size: 1rem;
    color: #64748b;
    transition: all 0.15s;
}
.btn-pwd-toggle:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

/* ── Warning button ──────────────────────────────────── */
.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border: none;
    box-shadow: 0 1px 3px rgba(245,158,11,0.25);
}
.btn-warning:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    box-shadow: 0 2px 8px rgba(245,158,11,0.35);
}

/* ── Danger outline ──────────────────────────────────── */
.btn-danger-outline {
    background: transparent;
    color: #dc2626;
    border: 1px solid #fca5a5;
}
.btn-danger-outline:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

/* ── Deploy Agent Modal ──────────────────────────────── */
.deploy-modal-content {
    max-width: 780px;
    width: 100%;
}
.deploy-info-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border-radius: 0.65rem;
    border: 1px solid #e2e8f0;
    flex-wrap: wrap;
}
.deploy-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.deploy-info-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    font-weight: 600;
}
.deploy-steps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}
.deploy-step {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    font-size: 0.85rem;
    color: #64748b;
}
.deploy-step code {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: "SF Mono", monospace;
    font-size: 0.84em;
    color: #7c3aed;
}
.deploy-step-num {
    min-width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    color: #fff;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}
.deploy-config-wrap {
    border: 1px solid #e2e8f0;
    border-radius: 0.6rem;
    overflow: hidden;
    margin-top: 0.5rem;
}
.deploy-config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.85rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
}
.deploy-config-pre {
    margin: 0;
    padding: 1rem;
    background: #f1f5f9;
    font-family: "SF Mono", "Consolas", monospace;
    font-size: 0.75rem;
    line-height: 1.55;
    color: #334155;
    max-height: 340px;
    overflow-y: auto;
    white-space: pre;
    tab-size: 2;
}

/* ── Danger outline btn-sm (already above) ───────────── */
.btn-danger-outline.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════════
   DARK MODE — ADMIN
═══════════════════════════════════════════════════════ */
body.dark-mode .admin-stat-card {
    background: linear-gradient(135deg, #1e293b, #1a2332);
    border-color: #334155;
}
body.dark-mode .admin-stat-card::before {
    background: linear-gradient(90deg, #a78bfa, #818cf8);
}
body.dark-mode .admin-stat-num {
    background: linear-gradient(135deg, #a78bfa, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
body.dark-mode .admin-stat-label { color: #94a3b8; }

body.dark-mode .admin-panel {
    background: #1e293b;
    border-color: #334155;
}
body.dark-mode .admin-panel-header {
    background: #0f172a;
    border-color: #334155;
}
body.dark-mode .admin-panel-header h3 { color: #e2e8f0; }
body.dark-mode .admin-panel-search {
    background: #1e293b;
    border-color: #334155;
}
body.dark-mode .admin-panel-search input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
body.dark-mode .admin-panel-search input:focus {
    border-color: #a78bfa;
    background: #1e293b;
    box-shadow: 0 0 0 3px rgba(167,139,250,0.15);
}
body.dark-mode .admin-search-inline {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark-mode .admin-item:hover {
    background: #1a2332;
    border-color: #334155;
}
body.dark-mode .admin-item.active {
    background: linear-gradient(135deg, #6d28d9, #4f46e5);
}
body.dark-mode .admin-item-name { color: #e2e8f0; }
body.dark-mode .admin-item-meta { color: #94a3b8; }

body.dark-mode .admin-users-table th,
body.dark-mode .admin-audit-table th {
    background: #0f172a;
    color: #94a3b8;
}
body.dark-mode .admin-users-table td,
body.dark-mode .admin-audit-table td {
    border-color: #334155;
}
body.dark-mode .admin-users-table tbody tr:hover td,
body.dark-mode .admin-audit-table tbody tr:hover td {
    background: #1a2332;
}
body.dark-mode .admin-users-table td:first-child {
    color: #e2e8f0;
}

body.dark-mode .role-superadmin {
    background: linear-gradient(135deg, #451a03, #78350f);
    color: #fde68a;
}
body.dark-mode .role-org_admin {
    background: linear-gradient(135deg, #1e3a8a, #1e40af);
    color: #bfdbfe;
}
body.dark-mode .role-technician {
    background: linear-gradient(135deg, #064e3b, #065f46);
    color: #a7f3d0;
}

body.dark-mode .api-key-box {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}
body.dark-mode .api-key-box:hover {
    background: #1e3a8a;
    border-color: #4f46e5;
    color: #c7d2fe;
}

body.dark-mode .admin-pagination {
    border-color: #334155;
    background: #0f172a;
}
body.dark-mode .admin-pagination .btn {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
body.dark-mode .admin-pagination .btn:hover:not(:disabled) {
    background: #334155;
    border-color: #475569;
}
body.dark-mode #users-page-info,
body.dark-mode #audit-page-info {
    color: #94a3b8;
}

body.dark-mode .toggle-label { color: #e2e8f0; }
body.dark-mode .toggle-slider { background: #475569; }
body.dark-mode .toggle-label input:checked + .toggle-slider { background: #7c3aed; }

body.dark-mode .btn-pwd-toggle {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}
body.dark-mode .btn-pwd-toggle:hover {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .admin-badge {
    background: #312e81;
    color: #c7d2fe;
}

body.dark-mode .deploy-info-bar {
    background: #0f172a;
    border-color: #334155;
}
body.dark-mode .deploy-config-header {
    background: #0f172a;
    border-color: #334155;
}
body.dark-mode .deploy-config-pre {
    background: #0d1117;
    color: #e2e8f0;
}
body.dark-mode .deploy-step code {
    background: #1e293b;
    border-color: #334155;
    color: #a78bfa;
}
body.dark-mode .status-dot-active { box-shadow: 0 0 6px rgba(34,197,94,0.5); }
body.dark-mode .toggle-slider::after { background: #f1f5f9; }
body.dark-mode .admin-panel-search input::placeholder { color: #64748b; }
body.dark-mode .admin-search-inline::placeholder { color: #64748b; }

/* ================================================================
   TOPOLOGY TAB
   ================================================================ */
.topology-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.topology-canvas-wrap {
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1rem;
    overflow: hidden;
    position: relative;
}
#topology-canvas {
    width: 100%;
    display: block;
    border-radius: 0.5rem;
    cursor: grab;
}
#topology-canvas:active { cursor: grabbing; }
.topology-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.65rem 1rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: #6c757d;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ================================================================
   EXPORT BUTTON
   ================================================================ */
.btn-export {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #86efac;
    padding: 0.4rem 0.85rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-export:hover { background: #dcfce7; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
.btn-danger-outline {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}
.btn-danger-outline:hover { background: #fee2e2; }

/* ================================================================
   MULTIPLE CHARTS LAYOUT
   ================================================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1.1rem;
    margin-top: 0.75rem;
}
.chart-panel {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
}
.chart-panel h4 {
    font-size: 0.88rem;
    color: #374151;
    margin-bottom: 0.5rem;
}
.chart-panel canvas { width: 100% !important; max-height: 180px; }

/* ================================================================
   CONFIRM MODAL & DEVICE ACTION BUTTONS
   ================================================================ */
.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}
.modal-device-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}
body.dark-mode .modal-device-actions { border-top-color: #374151; }

/* ================================================================
   BULK ALERT ACTIONS
   ================================================================ */
.alerts-bulk-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

/* ================================================================
   EDIT DEVICE FORM
   ================================================================ */
.edit-device-form .form-group { margin-bottom: 0.7rem; }
.edit-device-form .form-group label { font-size: 0.85rem; margin-bottom: 0.3rem; }
.edit-device-form .form-group input,
.edit-device-form .form-group select,
.edit-device-form .form-group textarea { padding: 0.45rem 0.6rem; font-size: 0.88rem; }
body.dark-mode .edit-device-form .form-group input,
body.dark-mode .edit-device-form .form-group select,
body.dark-mode .edit-device-form .form-group textarea { background: #374151; color: #e5e7eb; border-color: #4b5563; }

/* ================================================================
   RESPONSIVE ADDITIONS
   ================================================================ */
@media (max-width: 768px) {
    .devices-toolbar { flex-wrap: wrap; }
    .search-input-wrap { min-width: 100%; order: -1; }
    .device-row .row-site,
    .device-row .row-type { display: none; }
    .charts-grid { grid-template-columns: 1fr; }
    .real-time-clock { display: none; }
    .refresh-info { flex-wrap: wrap; }
    .topology-toolbar { flex-wrap: wrap; }
}

/* ================================================================
   PAGINATION & AUDIT LOG STYLES
   ================================================================ */

.admin-users-table-wrap,
.admin-audit-table-wrap {
    overflow-x: auto;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.admin-audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.admin-audit-table th,
.admin-audit-table td {
    text-align: left;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
}
.admin-audit-table th {
    font-weight: 600;
    background: #f8f9fa;
    color: #495057;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.admin-audit-table tr:last-child td {
    border-bottom: none;
}
.admin-audit-table tr:hover td {
    background: #f8f9fa;
}

.admin-audit-table .audit-action {
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
}
.audit-action-create  { background: #d1fae5; color: #065f46; }
.audit-action-update  { background: #dbeafe; color: #1e40af; }
.audit-action-delete  { background: #fee2e2; color: #991b1b; }
.audit-action-login   { background: #f3e8ff; color: #6d28d9; }

.audit-status {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}
.audit-status-success { background: #d1fae5; color: #065f46; }
.audit-status-failure { background: #fee2e2; color: #991b1b; }

.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 0.5rem;
}

.admin-pagination.hidden {
    display: none;
}

.admin-pagination #users-page-info,
.admin-pagination #audit-page-info {
    min-width: 80px;
    text-align: center;
    font-size: 0.88rem;
    color: #495057;
    font-weight: 500;
}

/* Dark mode for audit tables */
body.dark-mode .admin-audit-table th {
    background: #0f172a;
    color: #cbd5e1;
}
body.dark-mode .admin-audit-table tr:hover td {
    background: #1e293b;
}
body.dark-mode .audit-action-create,
body.dark-mode .audit-action-update,
body.dark-mode .audit-action-delete,
body.dark-mode .audit-action-login {
    opacity: 0.8;
}

/* Loading state for tables */
.admin-table-loading {
    text-align: center;
    color: #6c757d;
    padding: 1.5rem !important;
    font-style: italic;
}
