/* ══════════════════════════════════════════════════════════════════════
   NEXUS MONITOR — Design System
   Dark theme with cyan/amber/red accent palette
   ══════════════════════════════════════════════════════════════════════ */

/* ── Reset & Tokens ───────────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Backgrounds */
    --bg-deep:       #000000;
    --bg-base:       #0a0a0c;
    --bg-card:       #121214;
    --bg-card-hover: #1e1e24;
    --border-card:   rgba(255, 255, 255, 0.08);
    --border-glow:   rgba(255, 255, 255, 0.03);

    /* Accents (Muted Vercel/Linear style, keeping variable names for JS compat) */
    --cyan:          #3b82f6; /* Now Indigo/Blue acting as primary */
    --cyan-dim:      rgba(59, 130, 246, 0.15);
    --cyan-glow:     rgba(59, 130, 246, 0.25);
    --green:         #10b981; /* Emerald */
    --green-dim:     rgba(16, 185, 129, 0.15);
    --amber:         #f59e0b;
    --amber-dim:     rgba(245, 158, 11, 0.15);
    --red:           #f43f5e; /* Rose */
    --red-dim:       rgba(244, 63, 94, 0.15);

    /* Text */
    --text-primary:  #FAFAFA;
    --text-secondary:#A1A1AA;
    --text-dim:      #52525b;

    /* Typography */
    --font-sans:     'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:     'JetBrains Mono', 'SF Mono', monospace;

    /* Radii */
    --radius-sm:     4px;
    --radius-md:     8px;
    --radius-lg:     12px;

    /* Transitions */
    --ease-smooth:   cubic-bezier(0.16, 1, 0.3, 1);
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────── */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
    background: #000000;
    border-bottom: 1px solid var(--border-card);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-glyph {
    font-size: 1.4rem;
    color: var(--cyan);
}

header h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--text-primary);
}

header h1 .accent {
    color: var(--cyan);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.connection-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    background: transparent;
    border: 1px solid var(--cyan-dim);
    color: var(--cyan);
    transition: all 0.5s var(--ease-smooth);
}

.connection-badge.stale {
    background: var(--amber-dim);
    border-color: rgba(255, 184, 0, 0.2);
    color: var(--amber);
}

.connection-badge.offline {
    background: var(--red-dim);
    border-color: rgba(255, 51, 102, 0.2);
    color: var(--red);
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 6px var(--cyan);
    animation: pulse-live 1.5s ease-in-out infinite;
}

.connection-badge.stale .pulse-dot {
    background: var(--amber);
    box-shadow: 0 0 6px var(--amber);
    animation: pulse-live 2.5s ease-in-out infinite;
}

.connection-badge.offline .pulse-dot {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
    animation: none;
    opacity: 0.5;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.7); }
}

.header-meta {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* ── Auth Bar ─────────────────────────────────────────────────────────── */
.auth-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-display {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-secondary);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.router-select {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    max-width: 200px;
}

.router-select:focus { border-color: var(--cyan); }

.router-select option {
    background: var(--bg-base);
    color: var(--text-primary);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    color: var(--text-dim);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
}

.logout-btn:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-dim);
}

/* ── Main Dashboard ───────────────────────────────────────────────────── */
main {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel-row {
    display: grid;
    gap: 1.5rem;
}

.gauges-row {
    grid-template-columns: 1fr 1fr 1fr;
}

.status-row {
    grid-template-columns: repeat(4, 1fr);
}

.quality-row {
    grid-template-columns: repeat(5, 1fr);
}

/* ── Card Base ────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    transition: all 0.35s var(--ease-smooth);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

/* ── Gauge Cards ──────────────────────────────────────────────────────── */
.gauge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1.5rem 1.5rem;
}

.gauge-ring {
    width: 140px !important;
    height: 140px !important;
    margin: 0 auto 1rem auto;
    display: grid; /* Use grid to safely stack SVG and text */
    place-items: center; /* Center children */
}

.gauge-svg {
    grid-area: 1 / 1; /* Assign to the same cell */
    width: 140px !important; /* Force exact bounds */
    height: 140px !important;
    transform: rotate(-90deg);
    overflow: visible;
}

.gauge-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 3;
}

.gauge-fill {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 326.73;       /* 2 * π * 52 */
    stroke-dashoffset: 326.73;      /* starts empty */
    transition: stroke-dashoffset 1s var(--ease-smooth),
                stroke 0.5s var(--ease-smooth);
}

.gauge-value {
    grid-area: 1 / 1; /* Assign to the same cell to overlap the SVG */
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
}

.gauge-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.gauge-sub {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-dim);
}

.sparkline-canvas {
    width: 180px;
    height: 36px;
    margin: 0.5rem 0;
    opacity: 0.8;
}

/* ── System Info Bar ──────────────────────────────────────────────────── */
.system-info-row {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    background: var(--bg-base);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 0.6rem 2rem;
    margin: 0 auto 1rem auto;
}

.sysinfo-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.sysinfo-label {
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--text-dim);
    text-transform: uppercase;
}

.sysinfo-value {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--cyan);
}

.sysinfo-divider {
    width: 1px;
    height: 28px;
    background: var(--border-card);
}

/* ── Traffic Card ─────────────────────────────────────────────────────── */
.traffic-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.traffic-grid {
    display: flex;
    align-items: center;
    gap: 2rem;
    width: 100%;
}

.traffic-direction {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    justify-content: center;
}

.traffic-arrow {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
}

.traffic-arrow.rx {
    color: var(--green);
}

.traffic-arrow.tx {
    color: var(--cyan);
}

.traffic-info {
    display: flex;
    flex-direction: column;
}

.traffic-rate {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.traffic-label {
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--text-dim);
    margin: 0.15rem 0;
}

.traffic-total {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.traffic-divider-v {
    width: 1px;
    height: 50px;
    background: var(--border-card);
    flex-shrink: 0;
}

/* ── Status Cards ─────────────────────────────────────────────────────── */
.status-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: all 0.5s var(--ease-smooth);
}

.status-indicator.up {
    background: var(--green);
    animation: status-pulse-up 2s ease-in-out infinite;
}

.status-indicator.down {
    background: var(--red);
    animation: status-blink 1s step-end infinite;
}

@keyframes status-pulse-up {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

@keyframes status-blink {
    0%, 49%  { opacity: 1; }
    50%, 100%{ opacity: 0.3; }
}

.status-info {
    flex: 1;
    min-width: 0;
}

.status-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
}

.status-detail {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-badge {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
    transition: all 0.5s var(--ease-smooth);
    flex-shrink: 0;
}

.status-badge.up {
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--green);
}

.status-badge.down {
    border-color: rgba(244, 63, 94, 0.3);
    color: var(--red);
}

/* ── Timeline Card ────────────────────────────────────────────────────── */
.timeline-card {
    padding: 1.5rem;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-card);
}

.timeline-header h2 {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--text-secondary);
}

.incident-count {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-dim);
}

.timeline-scroll {
    max-height: 340px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.timeline-scroll::-webkit-scrollbar {
    width: 4px;
}

.timeline-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
}

.timeline-empty {
    text-align: center;
    padding: 3rem 1rem;
    font-size: 0.82rem;
    color: var(--text-dim);
}

.incident-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.015);
    border-left: 2px solid transparent;
    transition: background 0.2s var(--ease-smooth);
}

.incident-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Severity Colors */
.incident-row.WAN_DOWN,
.incident-row.ROUTER_OFFLINE,
.incident-row.INTERFACE_ERRORS {
    border-left-color: var(--red);
}

.incident-row.HIGH_PACKET_LOSS,
.incident-row.HIGH_LATENCY,
.incident-row.CONNTRACK_SATURATION,
.incident-row.HIGH_MEMORY,
.incident-row.HIGH_CPU {
    border-left-color: var(--amber);
}

.incident-row.DNS_FAILURE {
    border-left-color: var(--cyan);
}

.incident-main {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.incident-count-badge {
    margin-left: 0.4rem;
    background: rgba(255,255,255,0.1);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.55rem;
}

.incident-evidence {
    font-family: var(--font-mono);
    color: var(--cyan);
    background: rgba(0, 240, 255, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.6rem;
}

.incident-explain {
    padding-left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.incident-why {
    font-size: 0.68rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.incident-fix {
    font-size: 0.65rem;
    color: var(--cyan);
    opacity: 0.8;
    line-height: 1.5;
}

/* ── Connected Devices Table ──────────────────────────────────────────── */
.devices-card {
    padding: 1.5rem;
}

.devices-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-card);
}

.devices-header h2 {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--text-secondary);
}

.device-count {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-dim);
}

.devices-table-wrap {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.devices-table-wrap::-webkit-scrollbar {
    width: 4px;
}

.devices-table-wrap::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
}

.devices-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.devices-table thead th {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--text-dim);
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-card);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

.devices-table tbody tr {
    transition: background 0.2s var(--ease-smooth);
}

.devices-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.devices-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
}

.device-hostname {
    color: var(--text-primary) !important;
    font-weight: 500;
}

.device-hostname .dim {
    color: var(--text-dim);
    font-style: italic;
    font-weight: 400;
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.device-conn {
    font-size: 0.72rem;
}

.device-signal {
    font-family: var(--font-mono);
    font-size: 0.68rem;
}

.signal-excellent { color: var(--green); }
.signal-good { color: var(--cyan); }
.signal-fair { color: var(--amber); }
.signal-weak { color: var(--red); }

.devices-empty-row td {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
}

.incident-type-badge {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid currentColor;
}

.incident-type-badge.WAN_DOWN { color: var(--red); }
.incident-type-badge.DNS_FAILURE { color: var(--amber); }
.incident-type-badge.HIGH_CPU { color: var(--amber); }
.incident-type-badge.ROUTER_OFFLINE { color: var(--red); }

.incident-desc {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 500;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.incident-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.incident-confidence {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-dim);
}

.incident-time {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.incident-action {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid currentColor;
}

.incident-action.ACTION_SKIPPED {
    color: var(--text-dim);
}

.incident-action.ACTION_SUCCESS {
    color: var(--green);
}

.incident-action.ACTION_FAILED,
.incident-action.ACTION_SSH_ERROR,
.incident-action.ACTION_TIMEOUT {
    color: var(--red);
}

/* ── Footer ───────────────────────────────────────────────────────────── */
footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-dim);
    letter-spacing: 0.08em;
    border-top: 1px solid var(--border-card);
}

/* ── Metric Cards (Network Quality) ───────────────────────────────────── */
.metric-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
}

.metric-icon {
    font-size: 1.4rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    flex-shrink: 0;
}

.metric-body {
    flex: 1;
    min-width: 0;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.metric-label {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--text-dim);
    margin-top: 0.15rem;
}

.metric-badge {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid currentColor;
    color: var(--text-dim);
    flex-shrink: 0;
    transition: all 0.5s var(--ease-smooth);
}

.metric-badge.good { color: var(--green); }
.metric-badge.warn { color: var(--amber); }
.metric-badge.bad { color: var(--red); }

/* ── Interface Error Highlights ──────────────────────────────────────── */
.iface-error-row {
    background: rgba(255, 51, 102, 0.03) !important;
}

.iface-error-row:hover {
    background: rgba(255, 51, 102, 0.06) !important;
}

.val-bad {
    color: var(--red) !important;
    font-weight: 600;
}

.iface-status-ok {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--green);
    padding: 0.2rem 0.5rem;
    background: var(--green-dim);
    border-radius: 4px;
}

.iface-status-bad {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--red);
    padding: 0.2rem 0.5rem;
    background: var(--red-dim);
    border-radius: 4px;
}

.iface-has-errors {
    color: var(--red) !important;
    font-weight: 600;
}

/* ── Process table ───────────────────────────────────────────────────── */
.process-name {
    color: var(--text-primary) !important;
    font-weight: 500;
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

/* ── System Log ──────────────────────────────────────────────────────── */
.log-filters {
    display: flex;
    gap: 0.5rem;
}

.log-filter-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-dim);
    transition: all 0.2s var(--ease-smooth);
}

.log-filter-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.log-filter-btn.active[data-filter="all"] {
    border-color: var(--cyan);
    color: var(--cyan);
}

.log-filter-btn.active[data-filter="error"] {
    border-color: var(--red);
    color: var(--red);
}

.log-filter-btn.active[data-filter="warning"] {
    border-color: var(--amber);
    color: var(--amber);
}

.log-line {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    line-height: 1.5;
    color: var(--text-secondary);
    word-break: break-all;
}

.log-line.log-error {
    background: rgba(255, 51, 102, 0.04);
    color: var(--red);
}

.log-line.log-warning {
    background: rgba(255, 184, 0, 0.04);
    color: var(--amber);
}

.log-sev {
    flex-shrink: 0;
    width: 14px;
    text-align: center;
    font-weight: 700;
}

.log-msg {
    flex: 1;
    min-width: 0;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .quality-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 960px) {
    .gauges-row {
        grid-template-columns: 1fr 1fr;
    }
    .status-row {
        grid-template-columns: 1fr 1fr;
    }
    .quality-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    main {
        padding: 1rem;
    }
    .gauges-row {
        grid-template-columns: 1fr;
    }
    .status-row {
        grid-template-columns: 1fr;
    }
    .quality-row {
        grid-template-columns: 1fr;
    }
    header {
        padding: 0 1rem;
    }
    .header-meta {
        display: none;
    }
    .system-info-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .sysinfo-divider {
        display: none;
    }
    .history-charts-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ── Telemetry History Charts ────────────────────────────────────────── */
.history-card {
    padding: 1.5rem;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-card);
}

.history-header h2 {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--text-secondary);
}

.history-range-btns {
    display: flex;
    gap: 0.35rem;
}

/* ── Modals & Popups ──────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    width: 440px;
    max-width: 90%;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color var(--ease-smooth) 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.success-banner {
    background: rgba(21, 128, 61, 0.1);
    border: 1px solid #15803d;
    color: #22c55e;
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.mono-input {
    font-family: var(--font-mono);
    color: var(--cyan);
    background: #000;
}

.code-block {
    background: #000;
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.cyan-text {
    color: var(--cyan);
}

.add-router-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    margin-right: 12px;
}

.add-router-btn:hover {
    border-color: var(--cyan-dim);
    background: rgba(0, 240, 255, 0.05);
    color: var(--cyan);
}

.range-btn {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-card);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.25s var(--ease-smooth);
}

.range-btn:hover {
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
}

.range-btn.active {
    background: transparent;
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.history-charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.history-chart-wrap {
    position: relative;
    height: 200px;
}

.history-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.history-chart-bar-wrap {
    margin-top: 1rem;
    position: relative;
    height: 120px;
}

.history-chart-bar-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.history-empty {
    text-align: center;
    padding: 3rem 1rem;
    font-size: 0.82rem;
    color: var(--text-dim);
}

.history-loading {
    text-align: center;
    padding: 2rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    animation: pulse-loading 1.5s ease-in-out infinite;
}

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

/* ══════════════════════════════════════════════════════════════════════
   CROSS-CUTTING POLISH — Added v4.0
   ══════════════════════════════════════════════════════════════════════ */

/* ── Global Scrollbar ────────────────────────────────────────────────── */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Page Fade-In ────────────────────────────────────────────────────── */
main, .admin-container {
    animation: content-fade-in 0.5s ease-out;
}
@keyframes content-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Focus Rings (Accessibility) ─────────────────────────────────────── */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Section Headers ─────────────────────────────────────────────────── */
.section-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: -0.5rem;
}
.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-card);
}

/* ── Device Table Enhanced ───────────────────────────────────────────── */
.devices-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}
.devices-table tbody tr {
    transition: all 0.2s var(--ease-smooth);
}

/* Signal strength bars */
.signal-bars {
    display: inline-flex;
    gap: 2px;
    align-items: flex-end;
    height: 14px;
    margin-right: 4px;
}
.signal-bars .bar {
    width: 3px;
    border-radius: 1px;
    background: rgba(255,255,255,0.1);
    transition: background 0.3s;
}
.signal-bars .bar:nth-child(1) { height: 4px; }
.signal-bars .bar:nth-child(2) { height: 7px; }
.signal-bars .bar:nth-child(3) { height: 10px; }
.signal-bars .bar:nth-child(4) { height: 14px; }
.signal-bars.excellent .bar { background: var(--green); }
.signal-bars.good .bar:nth-child(-n+3) { background: var(--cyan); }
.signal-bars.fair .bar:nth-child(-n+2) { background: var(--amber); }
.signal-bars.weak .bar:nth-child(1) { background: var(--red); }

/* ── Skeleton Loading ────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.06) 50%,
        rgba(255,255,255,0.03) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
    color: transparent !important;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Toast Notifications ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-card);
    animation: toast-slide-in 0.3s ease-out;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.success {
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--green);
}
.toast.warning {
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--amber);
}
.toast.error {
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: var(--red);
}
@keyframes toast-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ── Responsive Polish ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .gauges-row { grid-template-columns: 1fr 1fr; }
    .quality-row { grid-template-columns: repeat(3, 1fr); }
    .status-row { grid-template-columns: repeat(2, 1fr); }
    .history-charts-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    main { padding: 1rem; gap: 1rem; }
    header { padding: 0 1rem; }
    .gauges-row { grid-template-columns: 1fr; }
    .quality-row { grid-template-columns: repeat(2, 1fr); }
    .status-row { grid-template-columns: 1fr; }
    .history-charts-grid { grid-template-columns: 1fr; }
    .system-info-row {
        flex-wrap: wrap;
        border-radius: var(--radius-md);
        padding: 0.8rem 1.2rem;
        gap: 1rem;
    }
    .sysinfo-divider { display: none; }
    .header-right { gap: 0.75rem; }
    .header-meta { display: none; }
}

/* ── AI Intelligence Panels ──────────────────────────────────────────── */

/* AI Health Summary */
.ai-summary-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all 0.35s var(--ease-smooth);
}

.ai-summary-panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--cyan), rgba(59, 130, 246, 0.1));
    opacity: 0.6;
}

.ai-summary-panel.warning::before {
    background: linear-gradient(90deg, var(--amber), rgba(245, 158, 11, 0.1));
}

.ai-summary-panel.critical::before {
    background: linear-gradient(90deg, var(--red), rgba(244, 63, 94, 0.1));
}

.ai-summary-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.ai-badge {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--cyan-dim);
    color: var(--cyan);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.ai-status-indicator {
    font-size: 0.7rem;
    line-height: 1;
}

.ai-status-indicator.healthy { color: var(--green); }
.ai-status-indicator.warning { color: var(--amber); }
.ai-status-indicator.critical { color: var(--red); }
.ai-status-indicator.unknown { color: var(--text-dim); }

.ai-status-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.ai-summary-text {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.ai-recommendation {
    margin-top: 0.6rem;
    padding: 0.5rem 0.75rem;
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.12);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--cyan);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-recommendation::before {
    content: "💡";
    flex-shrink: 0;
}

/* Proactive AI Alerts */
.ai-alert-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-alert-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    border-left: 3px solid transparent;
    transition: all 0.2s var(--ease-smooth);
    cursor: pointer;
}

.ai-alert-card:hover {
    background: var(--bg-card-hover);
}

.ai-alert-card.severity-critical {
    border-left-color: var(--red);
    background: rgba(244, 63, 94, 0.03);
}

.ai-alert-card.severity-warning {
    border-left-color: var(--amber);
    background: rgba(245, 158, 11, 0.03);
}

.ai-alert-card.severity-info {
    border-left-color: var(--cyan);
}

.ai-alert-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.ai-alert-content {
    flex: 1;
    min-width: 0;
}

.ai-alert-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.ai-alert-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.ai-alert-action {
    display: none;
    margin-top: 0.4rem;
    font-size: 0.68rem;
    color: var(--cyan);
    opacity: 0.8;
}

.ai-alert-card.expanded .ai-alert-action {
    display: block;
}

.ai-alert-severity {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.ai-alert-severity.critical {
    color: var(--red);
    background: var(--red-dim);
}

.ai-alert-severity.warning {
    color: var(--amber);
    background: var(--amber-dim);
}

.ai-alert-severity.info {
    color: var(--cyan);
    background: var(--cyan-dim);
}

/* AI Incident Insight */
.ai-incident-insight {
    margin-top: 0.3rem;
    padding: 0.5rem 0.75rem;
    background: rgba(59, 130, 246, 0.04);
    border: 1px solid rgba(59, 130, 246, 0.1);
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.ai-incident-insight .ai-label {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--cyan);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.ai-incident-insight .ai-action {
    margin-top: 0.3rem;
    color: var(--amber);
    font-size: 0.68rem;
}

/* ══════════════════════════════════════════════════════════════════════
   PHASE 2: UX POLISH — Additional Styles
   ══════════════════════════════════════════════════════════════════════ */

/* ── Skeleton / Shimmer Loading ──────────────────────────────────────── */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    position: relative;
    overflow: hidden;
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.08) 50%,
        rgba(255,255,255,0.03) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}

.skeleton * { visibility: hidden; }

.skeleton-gauge {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    margin: 0 auto 1rem auto;
}

.skeleton-text {
    height: 0.8rem;
    border-radius: 4px;
    margin: 0.3rem 0;
}

.skeleton-text.w-60  { width: 60%; }
.skeleton-text.w-80  { width: 80%; }
.skeleton-text.w-40  { width: 40%; }
.skeleton-text.w-100 { width: 100%; }

.skeleton-metric {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-sm);
}

/* ── Toast Notification System ───────────────────────────────────────── */
#nexus-toast-container {
    position: fixed;
    top: 76px; /* Below the header */
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 380px;
}

.nexus-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    font-size: 0.78rem;
    color: var(--text-primary);
    animation: toast-in 0.35s var(--ease-smooth) forwards;
    transform: translateX(100%);
    opacity: 0;
}

.nexus-toast.removing {
    animation: toast-out 0.3s var(--ease-smooth) forwards;
}

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

.nexus-toast .toast-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.nexus-toast .toast-body {
    flex: 1;
    min-width: 0;
}

.nexus-toast .toast-title {
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}

.nexus-toast .toast-msg {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.nexus-toast .toast-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: color 0.2s;
}

.nexus-toast .toast-close:hover {
    color: var(--text-primary);
}

.nexus-toast.toast-error {
    border-left: 3px solid var(--red);
}

.nexus-toast.toast-warn {
    border-left: 3px solid var(--amber);
}

.nexus-toast.toast-info {
    border-left: 3px solid var(--cyan);
}

.nexus-toast.toast-success {
    border-left: 3px solid var(--green);
}

/* ── Collapsible Incident Cards ──────────────────────────────────────── */
.incident-row .incident-explain {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s var(--ease-smooth),
                opacity 0.25s var(--ease-smooth),
                padding 0.25s var(--ease-smooth);
    padding-left: 1rem;
    padding-top: 0;
    padding-bottom: 0;
}

.incident-row.expanded .incident-explain {
    max-height: 500px;
    opacity: 1;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.incident-toggle-btn {
    flex-shrink: 0;
    background: none;
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-dim);
    font-size: 0.62rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
}

.incident-toggle-btn:hover {
    color: var(--cyan);
    border-color: var(--cyan-dim);
    background: var(--cyan-dim);
}

.incident-row.expanded .incident-toggle-btn {
    color: var(--cyan);
    border-color: var(--cyan);
}

/* ── Router Name Badge (shown for single-router users) ───────────────── */
.router-name-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.router-name-badge .router-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}

/* ── Fleet Nav Link (in dashboard header) ────────────────────────────── */
.fleet-nav-link {
    display: none;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.78rem;
    padding: 4px 12px;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    transition: all 0.2s var(--ease-smooth);
}

.fleet-nav-link:hover {
    color: var(--cyan);
    border-color: var(--cyan-dim);
    background: var(--cyan-dim);
}

/* ── Incident Acknowledge Button ─────────────────────────────────────── */
.incident-ack-btn {
    flex-shrink: 0;
    background: none;
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
}

.incident-ack-btn:hover {
    background: var(--green-dim);
    border-color: var(--green);
    color: var(--green);
}

.incident-ack-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.incident-ack-btn.ack-confirmed {
    border-color: var(--green);
    background: var(--green-dim);
    color: var(--green);
    cursor: default;
}

.incident-ack-done {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--green);
    opacity: 0.6;
    padding: 3px 8px;
}

.incident-row.incident-acknowledged {
    opacity: 0.5;
    border-left-color: var(--green) !important;
}

.incident-row.incident-acknowledged:hover {
    opacity: 0.7;
}

/* ── Uptime SLA Card ─────────────────────────────────────────────────── */
.sla-card {
    padding: 1.5rem;
}

.sla-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-card);
}

.sla-header h2 {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--text-secondary);
}

.sla-period-btns {
    display: flex;
    gap: 0.35rem;
}

.sla-period-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-dim);
    transition: all 0.2s var(--ease-smooth);
}

.sla-period-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.sla-period-btn.active {
    border-color: var(--cyan);
    color: var(--cyan);
}

.sla-body {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.sla-uptime-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.sla-uptime-value {
    font-family: var(--font-mono);
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
}

.sla-uptime-value.sla-gold { color: var(--green); }
.sla-uptime-value.sla-silver { color: var(--cyan); }
.sla-uptime-value.sla-bronze { color: var(--amber); }
.sla-uptime-value.sla-violation { color: var(--red); }

.sla-uptime-label {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--text-dim);
    text-transform: uppercase;
}

.sla-tier-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid currentColor;
}

.sla-tier-badge.sla-gold {
    color: var(--green);
    background: var(--green-dim);
}

.sla-tier-badge.sla-silver {
    color: var(--cyan);
    background: var(--cyan-dim);
}

.sla-tier-badge.sla-bronze {
    color: var(--amber);
    background: var(--amber-dim);
}

.sla-tier-badge.sla-violation {
    color: var(--red);
    background: var(--red-dim);
}

.sla-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sla-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.sla-stat-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    text-transform: uppercase;
}

.sla-stat-value {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sla-empty {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ── Network Topology ────────────────────────────────────────────────── */
.topology-card {
    padding: 1.5rem;
}

.topology-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-card);
}

.topology-header h2 {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--text-secondary);
}

.topology-toggle-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    color: var(--text-dim);
    transition: all 0.2s var(--ease-smooth);
}

.topology-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.topology-toggle-btn.active {
    border-color: var(--cyan);
    color: var(--cyan);
    background: var(--cyan-dim);
}

.topology-container {
    width: 100%;
    height: 420px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-card);
    overflow: hidden;
}

.topology-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 0.78rem;
    color: var(--text-dim);
}

.topology-legend {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0;
}

.topology-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.62rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

.topology-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.topology-legend-line {
    width: 20px;
    height: 2px;
    border-radius: 1px;
}

/* ── Maintenance Mode Banner ────────────────────────────────────────── */
.maintenance-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    background: var(--amber-dim);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-md);
    animation: maintenance-pulse 3s ease-in-out infinite;
}

@keyframes maintenance-pulse {
    0%, 100% { border-color: rgba(245, 158, 11, 0.3); }
    50% { border-color: rgba(245, 158, 11, 0.6); }
}

.maintenance-icon {
    font-size: 1.4rem;
}

.maintenance-text {
    font-size: 0.82rem;
    color: var(--amber);
    line-height: 1.4;
}

.maintenance-text strong {
    letter-spacing: 1px;
}

/* ── Speed Test Card ────────────────────────────────────────────────── */
.speed-test-body {
    padding: 20px 0 0;
}

.speed-test-gauges {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.speed-gauge {
    flex: 1;
    text-align: center;
    padding: 16px 0;
}

.speed-gauge-divider {
    width: 1px;
    height: 60px;
    background: var(--border-card);
}

.speed-gauge-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.speed-gauge-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 800;
    color: var(--cyan);
    line-height: 1;
    transition: color 0.3s var(--ease-smooth);
}

.speed-gauge-value.speed-good { color: var(--green); }
.speed-gauge-value.speed-warn { color: var(--amber); }
.speed-gauge-value.speed-bad  { color: var(--red); }

.speed-gauge-unit {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.speed-test-empty {
    text-align: center;
    padding: 16px 20px;
    font-size: 0.78rem;
    color: var(--text-dim);
    font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════════
   INCIDENT DETAIL PANEL — Remediation Diffs & System Log Snapshot
   ══════════════════════════════════════════════════════════════════════ */

.incident-detail-panel {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detail-loading {
    padding: 0.5rem 0;
}

.detail-error, .detail-empty {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-style: italic;
    padding: 0.5rem 0;
}

/* ── Remediation Before/After Diff Card ─────────────────────────────── */
.remediation-diff-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    transition: border-color 0.2s var(--ease-smooth);
}

.remediation-diff-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.diff-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-card);
}

.diff-icon {
    font-size: 0.9rem;
}

.diff-cmd code {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--cyan);
    background: var(--cyan-dim);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
}

.diff-time {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-dim);
}

.diff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.diff-metric {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
}

.diff-metric.improved {
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.05);
}

.diff-metric.worsened {
    border-color: rgba(244, 63, 94, 0.2);
    background: rgba(244, 63, 94, 0.05);
}

.diff-metric.unchanged {
    border-color: rgba(255, 255, 255, 0.05);
}

.diff-label {
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    text-transform: uppercase;
}

.diff-values {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.diff-before {
    color: var(--text-secondary);
}

.diff-arrow {
    font-size: 0.65rem;
    color: var(--text-dim);
}

.diff-metric.improved .diff-arrow { color: var(--green); }
.diff-metric.worsened .diff-arrow { color: var(--red); }

.diff-after {
    font-weight: 600;
    color: var(--text-primary);
}

.diff-metric.improved .diff-after { color: var(--green); }
.diff-metric.worsened .diff-after { color: var(--red); }

/* ── System Log Snapshot ────────────────────────────────────────────── */
.syslog-snapshot {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.syslog-snapshot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-card);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.syslog-count {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-dim);
}

.syslog-snapshot-body {
    padding: 0.4rem 0;
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.syslog-entry {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    line-height: 1.7;
    padding: 0.15rem 1rem;
    color: var(--text-secondary);
    border-left: 2px solid transparent;
    transition: background 0.15s;
}

.syslog-entry:hover {
    background: rgba(255, 255, 255, 0.03);
}

.syslog-entry.syslog-error {
    color: var(--red);
    border-left-color: var(--red);
    background: rgba(244, 63, 94, 0.04);
}

.syslog-entry.syslog-warning {
    color: var(--amber);
    border-left-color: var(--amber);
    background: rgba(245, 158, 11, 0.04);
}

.syslog-entry.syslog-info {
    border-left-color: rgba(255, 255, 255, 0.05);
}

/* ══════════════════════════════════════════════════════════════════════
   FLEET TREND CHARTS (Admin Panel)
   ══════════════════════════════════════════════════════════════════════ */

.fleet-trends-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem 0;
}

.trend-chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    transition: border-color 0.2s var(--ease-smooth);
}

.trend-chart-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.trend-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.trend-chart-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.trend-chart-range {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-dim);
}

.trend-chart-wrap {
    height: 180px;
    position: relative;
}

.fleet-trends-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.trend-range-btn {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
}

.trend-range-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

.trend-range-btn.active {
    border-color: var(--cyan);
    color: var(--cyan);
    background: var(--cyan-dim);
}

/* ── Fleet Overview page (fleet.html) ─────────────────────────────────────── */
/* These classes were referenced by fleet.html but never defined, so the whole
   page rendered unstyled. */
.admin-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 24px 20px;
}

.stat-title {
    font-size: 0.7rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.stat-value {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-unit {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-left: 2px;
}

/* Horizontal scroll container so wide tables never overflow the viewport. */
.remediation-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.input-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.input-group input {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.auth-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--cyan);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s var(--ease-smooth);
}

.auth-btn:hover {
    opacity: 0.9;
}

/* Keep wide admin tables from clipping on small screens. */
.admin-table {
    width: 100%;
}

@media (max-width: 768px) {
    .admin-stats-row {
        grid-template-columns: 1fr;
    }
    .admin-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}
