/* ==========================================================================
   RIO7 Network Monitor — Modern Enterprise Design System
   ========================================================================== */
:root {
    --bg-body: #080d1a;
    --bg-card: #0f172a;
    --bg-card-subtle: rgba(255, 255, 255, 0.03);
    --bg-card-hover: #17223b;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    --text-main: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #38bdf8;
    --accent-green: #10b981;
    --accent-red: #f43f5e;
    --accent-yellow: #f59e0b;
    --accent-purple: #a855f7;
    --theme-3bb: #ff6600;
    --theme-3bb-up: #fb923c;
    --theme-tot: #06b6d4;
    --theme-tot-up: #38bdf8;
    --font-sans: 'Plus Jakarta Sans', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(56, 189, 248, 0.07) 0%, transparent 40%),
        radial-gradient(circle at 90% 90%, rgba(99, 102, 241, 0.06) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    padding: 24px 20px 48px;
    -webkit-font-smoothing: antialiased;
}

.dashboard-container {
    max-width: 1320px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tnum {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* Top Navbar / Header Card */
.header-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(99, 102, 241, 0.15));
    border: 1px solid rgba(56, 189, 248, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
}

.brand-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.brand-title-wrap h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.ros-badge {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 9999px;
    color: var(--text-secondary);
}

.brand-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.badge-live-pulse {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.live-dot {
    width: 7px;
    height: 7px;
    background-color: var(--accent-green);
    border-radius: 50%;
    animation: live-pulse-anim 2s infinite ease-in-out;
}

@keyframes live-pulse-anim {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.connection-lost {
    background: rgba(244, 63, 94, 0.15) !important;
    color: var(--accent-red) !important;
    border-color: rgba(244, 63, 94, 0.3) !important;
}
.connection-lost .live-dot {
    background-color: var(--accent-red) !important;
    animation: none !important;
}

.btn-refresh-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-refresh-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: var(--border-hover);
}
.btn-refresh-icon.spinning svg {
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-login-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent-blue);
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-login-header:hover {
    background: rgba(56, 189, 248, 0.22);
    transform: translateY(-1px);
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 4px 6px 4px 12px;
    border-radius: 9999px;
    font-size: 0.8rem;
}
.user-pill-name { color: var(--accent-blue); font-weight: 600; }
.user-pill-logout {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(244, 63, 94, 0.25);
    padding: 3px 9px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
}
.user-pill-logout:hover { background: rgba(244, 63, 94, 0.3); }

/* System Metrics Grid (4 Quick Stats Cards) */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s, border-color 0.2s;
}
.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.metric-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.metric-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-cpu-theme { background: rgba(56, 189, 248, 0.12); color: var(--accent-blue); }
.icon-ram-theme { background: rgba(168, 85, 247, 0.12); color: var(--accent-purple); }
.icon-uptime-theme { background: rgba(245, 158, 11, 0.12); color: var(--accent-yellow); }
.icon-dhcp-theme { background: rgba(16, 185, 129, 0.12); color: var(--accent-green); }

.metric-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-card-val {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 10px;
}

.metric-number {
    font-size: 1.7rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
}
.metric-number.font-uptime {
    font-size: 1.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric-unit-tag {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-pill-right {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.metric-meter-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 8px;
}

.metric-meter-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.4s ease;
}
.fill-cpu-gradient { background: linear-gradient(90deg, #38bdf8, #818cf8); }
.fill-ram-gradient { background: linear-gradient(90deg, #a855f7, #ec4899); }
.fill-dhcp-gradient { background: linear-gradient(90deg, #10b981, #34d399); }

.metric-sub-label {
    font-size: 0.74rem;
    color: var(--text-muted);
}

/* Dual-WAN Section (Side-by-Side 2 Columns) */
.wan-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.wan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s ease;
}
.wan-card:hover {
    border-color: var(--border-hover);
}

.wan-card.wan-card-3bb {
    border-top: 3px solid var(--theme-3bb);
    box-shadow: 0 0 25px rgba(255, 102, 0, 0.08), 0 8px 32px rgba(0, 0, 0, 0.35);
}
.wan-card.wan-card-tot {
    border-top: 3px solid var(--theme-tot);
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.08), 0 8px 32px rgba(0, 0, 0, 0.35);
}

.wan-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.wan-title-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.isp-badge-tag {
    font-size: 0.8rem;
    font-weight: 800;
    padding: 5px 11px;
    border-radius: 8px;
    letter-spacing: 0.04em;
}
.tag-3bb-brand {
    background: rgba(255, 102, 0, 0.15);
    color: var(--theme-3bb);
    border: 1px solid rgba(255, 102, 0, 0.35);
}
.tag-tot-brand {
    background: rgba(6, 182, 212, 0.15);
    color: var(--theme-tot);
    border: 1px solid rgba(6, 182, 212, 0.35);
}

.wan-title-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.wan-title-main h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
}

.pcc-chip {
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 6px;
    color: var(--text-secondary);
}

.wan-meta-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
    flex-wrap: wrap;
}
.code-meta {
    font-family: var(--font-mono);
    color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.08);
    padding: 1px 6px;
    border-radius: 4px;
}
.sep-dot { color: var(--text-muted); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.status-dot-sm {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}
.status-online {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.25);
}
.status-offline {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(244, 63, 94, 0.25);
}
.status-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Bandwidth Cockpit (Down / Up Tiles with Dedicated Charts) */
.bandwidth-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.bandwidth-tile {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 14px 16px 12px;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
}
.bandwidth-tile:hover {
    background: rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.12);
}

.bandwidth-tile-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.tile-dir-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.tile-dir-down { color: var(--theme-3bb); }
.wan-card-tot .tile-dir-down { color: var(--theme-tot); }
.tile-dir-up { color: var(--theme-3bb-up); }
.wan-card-tot .tile-dir-up { color: var(--theme-tot-up); }

.tile-total-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}
.tile-total-label b { color: #e2e8f0; }

.bandwidth-speed-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 8px;
}

.speed-val-big {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1;
}
.speed-unit-sm {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.color-3bb-down { color: var(--theme-3bb); }
.color-3bb-up   { color: var(--theme-3bb-up); }
.color-tot-down { color: var(--theme-tot); }
.color-tot-up   { color: var(--theme-tot-up); }

/* Dedicated Canvas Box (Below Numbers) */
.sparkline-canvas-box {
    width: 100%;
    height: 52px;
    position: relative;
    margin-top: 4px;
}
.sparkline-canvas-box canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.wan-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-wrap: wrap;
    gap: 8px;
}

.target-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}
.dot-green {
    width: 6px;
    height: 6px;
    background-color: var(--accent-green);
    border-radius: 50%;
}

.cap-pill {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.04);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-muted);
}

/* Content Card (Table & Admin Sections) */
.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.content-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.content-title-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-icon-circle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
}

.content-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.content-title-row h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
}

.count-pill-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-blue);
    border: 1px solid rgba(56, 189, 248, 0.2);
}
.unlocked-pill-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.content-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Router Reboot Actions */
.reboot-actions-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-reboot-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.btn-reboot-3bb {
    background: rgba(255, 102, 0, 0.12);
    color: var(--theme-3bb);
    border-color: rgba(255, 102, 0, 0.28);
}
.btn-reboot-3bb:hover {
    background: rgba(255, 102, 0, 0.22);
    transform: translateY(-1px);
}

.btn-reboot-tot {
    background: rgba(6, 182, 212, 0.12);
    color: var(--theme-tot);
    border-color: rgba(6, 182, 212, 0.28);
}
.btn-reboot-tot:hover {
    background: rgba(6, 182, 212, 0.22);
    transform: translateY(-1px);
}

/* Services Grid */
.services-grid-box {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.service-tile {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.service-tile:hover {
    background: rgba(0, 0, 0, 0.32);
    border-color: var(--border-hover);
}

.service-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.service-icon-sq {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-plex { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.icon-qts  { background: rgba(56, 189, 248, 0.15); color: var(--accent-blue); }
.icon-bt   { background: rgba(244, 63, 94, 0.15); color: var(--accent-red); }

.service-left h4 {
    font-size: 0.92rem;
    font-weight: 600;
    color: #ffffff;
}

.port-strip {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    font-size: 0.75rem;
}
.port-tag-ext {
    font-family: var(--font-mono);
    color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.08);
    padding: 1px 6px;
    border-radius: 4px;
}
.port-tag-int {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.admin-footer-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 8px;
}

.btn-logout-text-link {
    background: none;
    border: none;
    color: var(--accent-red);
    cursor: pointer;
    font-size: 0.8rem;
    text-decoration: underline;
    font-family: inherit;
}
.btn-logout-text-link:hover { color: #f87171; }

/* DHCP Search & Filter */
.filter-controls-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-box-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.search-box-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-box-wrap input {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 32px 8px 36px;
    color: #ffffff;
    font-size: 0.82rem;
    font-family: inherit;
    width: 260px;
    transition: all 0.2s;
}
.search-box-wrap input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
    background: rgba(0, 0, 0, 0.5);
    width: 290px;
}
.btn-clear-x {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 4px;
}
.btn-clear-x:hover { color: #fff; }

.refresh-tag-chip {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Modern Data Table */
.table-wrap-responsive {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table-main {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    text-align: left;
}
.data-table-main th {
    padding: 12px 16px;
    color: var(--text-secondary);
    background: rgba(10, 15, 29, 0.75);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.data-table-main td {
    padding: 13px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}
.data-table-main tr:hover td {
    background: rgba(255, 255, 255, 0.025);
}

.device-cell-flex {
    display: flex;
    align-items: center;
    gap: 10px;
}
.device-icon-chip {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.device-name-bold {
    font-weight: 600;
    color: #ffffff;
}

.ip-badge-chip {
    font-family: var(--font-mono);
    color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.08);
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(56, 189, 248, 0.15);
    font-size: 0.8rem;
    display: inline-block;
}

.mac-code-text {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 0.78rem;
}

.time-seen-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.76rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.status-bound-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--accent-green);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 9999px;
    background: rgba(16, 185, 129, 0.12);
}

.table-loading-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 36px 16px;
    color: var(--text-muted);
}
.spinner-circle {
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent-blue);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Modals */
.modal-overlay-bg {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.18s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-box-card {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    width: 100%;
    max-width: 420px;
    padding: 26px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
    animation: scaleUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes scaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}
.modal-icon-badge {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
}
.modal-icon-warn {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--accent-yellow);
}

.btn-modal-x {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
}
.btn-modal-x:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.modal-form-row { margin-bottom: 16px; }
.modal-form-row label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.modal-form-row input {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px 14px;
    color: #ffffff;
    font-size: 0.9rem;
    font-family: inherit;
}
.modal-form-row input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.modal-error-banner {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-btn-row {
    display: flex;
    gap: 12px;
    margin-top: 22px;
}
.btn-modal-gray {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 10px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-modal-gray:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.btn-modal-blue {
    flex: 1.4;
    background: linear-gradient(135deg, #0284c7, #2563eb);
    border: none;
    color: #ffffff;
    padding: 10px;
    border-radius: 10px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.btn-modal-blue:hover {
    background: linear-gradient(135deg, #0369a1, #1d4ed8);
    transform: translateY(-1px);
}

.btn-modal-red {
    flex: 1.4;
    background: linear-gradient(135deg, #e11d48, #be123c);
    border: none;
    color: #ffffff;
    padding: 10px;
    border-radius: 10px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35);
}
.btn-modal-red:hover {
    background: linear-gradient(135deg, #be123c, #9f1239);
    transform: translateY(-1px);
}

.toast-popup {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    z-index: 10000;
    animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Responsive Layout */
@media (max-width: 1024px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .wan-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    body { padding: 16px 12px 32px; }
    .dashboard-container { gap: 16px; }
    .header-card { flex-direction: column; align-items: flex-start; gap: 14px; }
    .header-right { width: 100%; justify-content: space-between; }
    .metrics-grid { grid-template-columns: 1fr; }
    .bandwidth-row { grid-template-columns: 1fr; }
    .search-box-wrap input { width: 100%; }
}

/* ==========================================================================
   Full-Page States: Loading & Connection Error
   ========================================================================== */
.state-overlay-screen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 50% 35%, #111a2e 0%, #060910 100%);
    backdrop-filter: blur(8px);
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

#state-error-screen {
    background: radial-gradient(circle at 50% 30%, #241119 0%, #080910 100%);
}

.state-card-box {
    width: 100%;
    max-width: 520px;
    background: rgba(17, 24, 39, 0.88);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 20px;
    padding: 38px 30px;
    text-align: center;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 40px rgba(59, 130, 246, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: stateCardPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.state-card-error {
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 40px rgba(239, 68, 68, 0.18);
}

@keyframes stateCardPop {
    from { opacity: 0; transform: scale(0.94) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.state-scanner-visual {
    position: relative;
    width: 90px;
    height: 90px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.state-pulse-glow {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.35) 0%, transparent 70%);
    animation: scannerPulse 2s infinite ease-in-out;
}

.state-dual-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #ff6600;
    border-right-color: #06b6d4;
    border-bottom-color: #3b82f6;
    animation: ringSpin 1.4s linear infinite;
}

.state-icon-center {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
    animation: iconFloat 2s ease-in-out infinite alternate;
}

.state-error-icon-visual {
    position: relative;
    width: 86px;
    height: 86px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.state-error-pulse-glow {
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.4) 0%, transparent 70%);
    animation: errorPulse 2s infinite ease-in-out;
}

.state-error-icon-center {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.12);
    border: 2px solid rgba(239, 68, 68, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}

@keyframes ringSpin { 100% { transform: rotate(360deg); } }
@keyframes scannerPulse {
    0%, 100% { transform: scale(0.9); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 0.85; }
}
@keyframes errorPulse {
    0%, 100% { transform: scale(0.9); opacity: 0.4; }
    50% { transform: scale(1.25); opacity: 0.8; }
}
@keyframes iconFloat {
    from { transform: translateY(-2px); }
    to { transform: translateY(2px); }
}

.state-heading {
    font-size: 1.35rem;
    font-weight: 800;
    color: #f8fafc;
    letter-spacing: -0.01em;
    margin: 0;
}
.state-heading.text-red { color: #f87171; }

.state-desc {
    font-size: 0.86rem;
    color: #94a3b8;
    line-height: 1.55;
    margin: 0;
}

.state-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.25);
    color: #38bdf8;
    font-size: 0.78rem;
    font-weight: 600;
    margin-top: 4px;
}

.state-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #06b6d4;
    box-shadow: 0 0 10px #06b6d4;
    animation: dotPulse 1.2s infinite;
}

.error-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.err-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
    animation: dotPulse 1s infinite;
}

.state-progress-track {
    width: 100%;
    max-width: 280px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin-top: 4px;
}

.state-progress-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 45%;
    border-radius: 4px;
    background: linear-gradient(90deg, #ff6600, #06b6d4, #3b82f6);
    animation: progressSlide 1.6s infinite ease-in-out;
}

@keyframes progressSlide {
    0% { left: -45%; }
    100% { left: 100%; }
}

.state-diag-box {
    width: 100%;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    margin-top: 2px;
}

.diag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
}

.diag-label { color: #64748b; font-weight: 500; }
.diag-val { color: #cbd5e1; font-weight: 600; font-family: monospace; }
.diag-val.text-red { color: #f87171; }

.state-retry-counter {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    color: #94a3b8;
}

.state-retry-counter b { color: #38bdf8; font-size: 0.88rem; }

.spin-slow {
    animation: ringSpin 3s linear infinite;
}

.state-btn-group {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
}

.btn-state-action {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
}

.btn-state-primary {
    background: linear-gradient(135deg, #0284c7, #2563eb);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.btn-state-primary:hover {
    background: linear-gradient(135deg, #0369a1, #1d4ed8);
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
    transform: translateY(-1px);
}

.btn-state-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
}

.btn-state-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

@media (max-width: 640px) {
    .state-card-box {
        padding: 28px 18px;
        gap: 14px;
    }
    .state-heading { font-size: 1.15rem; }
    .state-desc { font-size: 0.8rem; }
    .state-btn-group { flex-direction: column; }
    .diag-item { flex-direction: column; align-items: flex-start; gap: 2px; }
}
