/**
 * Pexip Analytics Portal - Stylesheet
 * ======================================
 * Brand palette (official Pexip Brand Guidelines):
 *   Blue:   #0A2136  (primary)   White: #FFFFFF (primary)
 *   Purple: #5244EE  (accent — text highlights & buttons on LIGHT backgrounds)
 *   Green:  #4EF2BA  (accent — on DARK backgrounds)
 *   Light blue: #D8E3EE (surfaces)   Off-white: #F5F3F3 (light theme bg)
 *
 * NOTE: per the guidelines, purple is the accent for light backgrounds and green
 * for dark ones. The current tokens keep green as the primary light-theme accent
 * (design decision pending) — hues are corrected to the official values.
 *
 * Supports light and dark themes via [data-theme] attribute.
 *
 * @version 1.0
 */

/* ================================================================== */
/*  CSS VARIABLES / THEMES                                             */
/* ================================================================== */

:root {
    /* Pexip Brand (exact HEX from brand guidelines) */
    --pexip-blue: #0A2136;
    --pexip-blue-dark: #071526;
    --pexip-green: #4EF2BA;
    --pexip-green-dark: #2FCEA0;
    --pexip-green-light: #7FF7D0;
    --pexip-purple: #5244EE;
    --pexip-purple-dark: #4234CE;
    --pexip-light-blue: #D8E3EE;
    --pexip-offwhite: #F5F3F3;

    /* Quality Colors (from Pexip media_statistics.htm#color) */
    --quality-good: #4EF2BA;
    --quality-ok: #FFC107;
    --quality-bad: #FF9800;
    --quality-terrible: #F44336;
    --quality-unknown: #9E9E9E;

    /* Alarm Severity */
    --alarm-error: #F44336;
    --alarm-warning: #FF9800;
    --alarm-info: #2196F3;

    /* Sizing */
    --sidebar-width: 260px;
    --header-height: 56px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Fonts */
    --font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* Light Theme (default) */
[data-theme="light"], :root {
    --bg-primary: #F5F3F3;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #EDE8E8;
    --bg-hover: #D8E3EE;
    --bg-active: #5244EE;
    --bg-active-subtle: rgba(82,68,238,0.10);

    /* Semantic accent — purple on LIGHT backgrounds (brand guideline). */
    --accent: #5244EE;
    --accent-hover: #4234CE;
    --accent-contrast: #FFFFFF;
    --accent-subtle: rgba(82,68,238,0.10);

    --text-primary: #0A2136;
    --text-secondary: #465465;
    --text-tertiary: #8A95A3;
    --text-inverse: #FFFFFF;
    --text-accent: #5244EE;

    --border-primary: #E2E0E0;
    --border-secondary: #C8CED6;
    --border-accent: #5244EE;

    --shadow-sm: 0 1px 3px rgba(10,33,54,0.04), 0 1px 2px rgba(10,33,54,0.06);
    --shadow-md: 0 4px 6px -1px rgba(10,33,54,0.07), 0 2px 4px -2px rgba(10,33,54,0.05);
    --shadow-lg: 0 10px 25px -3px rgba(10,33,54,0.10), 0 4px 10px -4px rgba(10,33,54,0.06);
    --shadow-xl: 0 20px 50px -5px rgba(10,33,54,0.12), 0 8px 20px -6px rgba(10,33,54,0.08);

    --sidebar-bg: #0A2136;
    --sidebar-text: #B8C4D0;
    --sidebar-text-active: #FFFFFF;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active-bg: rgba(78,242,186,0.15);
    --sidebar-border: rgba(255,255,255,0.08);

    --chart-grid: rgba(10,33,54,0.06);
    --overlay-bg: rgba(10,33,54,0.35);

    --input-bg: #FFFFFF;
    --input-border: #C8CED6;
    --input-focus: #5244EE;

    --badge-bg: #D8E3EE;
    --badge-text: #0A2136;

    --table-header-bg: #F5F3F3;
    --table-row-hover: #D8E3EE;
    --table-stripe: #FAFAFA;

    --skeleton-from: #EDE8E8;
    --skeleton-to: #F5F3F3;

    --logo-container-bg: transparent;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0A2136;
    --bg-secondary: #112943;
    --bg-tertiary: #0E2339;
    --bg-hover: #1A3654;
    --bg-active: #4EF2BA;
    --bg-active-subtle: rgba(78,242,186,0.12);

    /* Semantic accent — green on DARK backgrounds (brand guideline). */
    --accent: #4EF2BA;
    --accent-hover: #2FCEA0;
    --accent-contrast: #0A2136;
    --accent-subtle: rgba(78,242,186,0.12);

    --text-primary: #F5F3F3;
    --text-secondary: #B8C4D0;
    --text-tertiary: #8A95A3;
    --text-inverse: #0A2136;
    --text-accent: #7FF7D0;

    --border-primary: #1A3654;
    --border-secondary: #2A4A6B;
    --border-accent: #4EF2BA;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.20);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.25), 0 2px 4px -2px rgba(0,0,0,0.15);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.35), 0 4px 10px -4px rgba(0,0,0,0.20);
    --shadow-xl: 0 20px 50px -5px rgba(0,0,0,0.45), 0 8px 20px -6px rgba(0,0,0,0.25);

    --sidebar-bg: #071526;
    --sidebar-text: #B8C4D0;
    --sidebar-text-active: #FFFFFF;
    --sidebar-hover: rgba(255,255,255,0.05);
    --sidebar-active-bg: rgba(78,242,186,0.15);
    --sidebar-border: rgba(255,255,255,0.06);

    --chart-grid: rgba(255,255,255,0.08);
    --overlay-bg: rgba(0,0,0,0.55);

    --input-bg: #112943;
    --input-border: #2A4A6B;
    --input-focus: #4EF2BA;

    --badge-bg: #1A3654;
    --badge-text: #D8E3EE;

    --table-header-bg: #0E2339;
    --table-row-hover: #1A3654;
    --table-stripe: #0D2841;

    --skeleton-from: #112943;
    --skeleton-to: #1A3654;

    --logo-container-bg: #FFFFFF;
}

/* ================================================================== */
/*  RESET & BASE                                                       */
/* ================================================================== */

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

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ================================================================== */
/*  LAYOUT                                                             */
/* ================================================================== */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid var(--sidebar-border);
    transition: transform var(--transition-normal);
    z-index: 100;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Logo container: adapts to theme for contrast against dark sidebar */
.logo-wrap {
    background: var(--logo-container-bg);
    padding: 6px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    transition: background var(--transition-fast);
}

.logo-wrap img {
    display: block;
    height: 22px;
    width: auto;
}

.sidebar-brand img,
.sidebar-brand svg {
    height: 28px;
    width: auto;
}

.sidebar-brand-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--sidebar-text-active);
    letter-spacing: 0.03em;
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: 0.7rem;
    color: var(--sidebar-text);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.sidebar-section {
    margin-bottom: 6px;
}

.sidebar-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sidebar-text);
    opacity: 0.6;
    padding: 12px 12px 6px;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    user-select: none;
    position: relative;
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    transform: translateX(2px);
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--pexip-green-light);
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--pexip-green);
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-host {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    padding: 4px 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.6;
}

/* ---- MAIN CONTENT ---- */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.page-header {
    padding: 24px 32px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-body {
    padding: 20px 32px 40px;
    flex: 1;
}

/* ================================================================== */
/*  COMPONENTS                                                         */
/* ================================================================== */

/* ---- CARDS ---- */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-secondary);
}

.card-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.card-body {
    padding: 20px;
}

.card-body.compact {
    padding: 12px 20px;
}

/* ---- STAT CARDS (KPI) ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    position: relative;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-left-color: var(--pexip-purple);
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
}

.stat-trend.up { color: #22C55E; background: rgba(34,197,94,0.1); }
.stat-trend.down { color: #F44336; background: rgba(244,67,54,0.1); }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    white-space: nowrap;
    position: relative;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
    font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-secondary);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-icon { padding: 7px; }

.btn-group {
    display: inline-flex;
    gap: 0;
}
.btn-group .btn {
    border-radius: 0;
    margin-right: -1px;
}
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.active {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
    z-index: 1;
}

/* Date picker input inline with period buttons */
input[type="date"].form-input {
    color-scheme: light dark;
    min-height: 30px;
    line-height: 1.2;
}

input[type="date"].form-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
}

input[type="date"].form-input:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

/* ---- INPUTS ---- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 9px 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    transition: border-color var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(78,242,186,0.15);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-select {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* ---- FILTER BAR ---- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-sm);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.filter-group label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.filter-group .form-input,
.filter-group .form-select {
    font-size: 0.82rem;
    padding: 7px 10px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-left: auto;
}

/* ---- TABLES ---- */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table thead {
    background: var(--table-header-bg);
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table th {
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.70rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-primary);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--table-row-hover);
}

.data-table tbody tr:nth-child(even) {
    background: var(--table-stripe);
}
.data-table tbody tr:nth-child(even):hover {
    background: var(--table-row-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.70rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: opacity var(--transition-fast);
}

.badge-good { background: rgba(78,242,186,0.12); color: #2FCEA0; }
.badge-ok { background: rgba(255,193,7,0.12); color: #D4A000; }
.badge-bad { background: rgba(255,152,0,0.12); color: #E06A00; }
.badge-terrible { background: rgba(244,67,54,0.12); color: #D32F2F; }
.badge-info { background: rgba(82,68,238,0.12); color: #5244EE; }
.badge-neutral { background: var(--badge-bg); color: var(--badge-text); }
.badge-warning { background: rgba(255,152,0,0.12); color: #FF9800; }
.badge-error { background: rgba(244,67,54,0.12); color: #F44336; }

/* ---- INFO PANELS ---- */
.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.info-tooltip[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--pexip-blue);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 400;
    border-radius: 6px;
    white-space: normal;
    width: 260px;
    z-index: 10;
    box-shadow: var(--shadow-lg);
    line-height: 1.4;
}
.info-tooltip[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--pexip-blue);
    z-index: 10;
}

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
    font-size: 0.82rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.pagination-info {
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.pagination-btn {
    min-width: 32px;
    height: 32px;
    border: 1px solid var(--border-secondary);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}
.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
}
.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
}

.pagination-size {
    padding: 5px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

/* Table cell truncation with tooltip support */
.cell-truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

/* ---- TABS ---- */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-primary);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-item {
    padding: 11px 20px;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-tertiary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.tab-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ---- LOADING ---- */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: inherit;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-hover);
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ---- SKELETON LOADING ---- */
.skeleton {
    background: linear-gradient(90deg, var(--skeleton-from) 0%, var(--skeleton-to) 50%, var(--skeleton-from) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- CHARTS ---- */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container.small {
    height: 200px;
}

.chart-container.tall {
    height: 400px;
}

/* ---- GRID LAYOUTS ---- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-span-2 { grid-column: span 2; }

/* ---- HEATMAP ---- */
.heatmap-grid {
    display: grid;
    grid-template-columns: 50px repeat(24, 1fr);
    gap: 2px;
    font-size: 0.65rem;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
}

.heatmap-cell:hover {
    transform: scale(1.25);
    z-index: 2;
    border-radius: 3px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.heatmap-label {
    display: flex;
    align-items: center;
    color: var(--text-tertiary);
    font-weight: 500;
}

.heatmap-hour-label {
    text-align: center;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* ================================================================== */
/*  LOGIN VIEW                                                         */
/* ================================================================== */

.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 44px 40px 36px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo svg {
    height: 36px;
    width: auto;
}

.login-title {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    letter-spacing: -0.01em;
}

.login-error {
    padding: 10px 14px;
    background: rgba(244,67,54,0.06);
    border: 1px solid rgba(244,67,54,0.18);
    border-left: 3px solid #F44336;
    border-radius: var(--radius-sm);
    color: #F44336;
    font-size: 0.82rem;
    margin-bottom: 16px;
    display: none;
}

.login-error.visible {
    display: block;
}

.login-footer {
    margin-top: 20px;
    text-align: center;
}

.login-lang-select {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-lang-select select {
    padding: 4px 8px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.78rem;
}

/* ================================================================== */
/*  MODAL / DRAWER                                                     */
/* ================================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 1.2rem;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body {
    padding: 24px;
}

/* ================================================================== */
/*  CONNECTION LOGS                                                    */
/* ================================================================== */

.log-entry {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-primary);
    font-size: 0.78rem;
    font-family: var(--font-mono);
}

.log-entry.error {
    background: rgba(244,67,54,0.04);
    border-left: 3px solid #F44336;
}

.log-entry.success {
    border-left: 3px solid #4CAF50;
}

.log-entry-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.log-entry-time {
    color: var(--text-tertiary);
}

.log-entry-status {
    font-weight: 600;
}

.log-entry-url {
    color: var(--text-secondary);
    word-break: break-all;
}

.log-entry-detail {
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ================================================================== */
/*  ABOUT VIEW                                                         */
/* ================================================================== */

.about-card {
    max-width: 520px;
    margin: 0 auto;
    text-align: center;
}

.about-logo {
    margin-bottom: 20px;
}

.about-version {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.about-disclaimer {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    border-left: 3px solid var(--pexip-blue);
}

/* ================================================================== */
/*  RESPONSIVE                                                         */
/* ================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .page-header, .page-body { padding-left: 20px; padding-right: 20px; }
    .sidebar { width: 220px; }
    :root { --sidebar-width: 220px; }
}

/* Small tablet / large phone (sidebar collapses) */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        width: 260px;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 99;
    }

    .sidebar.open ~ .sidebar-backdrop {
        display: block;
    }

    .mobile-header {
        display: flex !important;
    }

    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .grid-span-2 { grid-column: span 1; }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-actions {
        margin-left: 0;
    }
}

.mobile-header {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text-active);
    border-bottom: 1px solid var(--sidebar-border);
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
}

/* ================================================================== */
/*  DISCONNECT REASONS TABLE                                           */
/* ================================================================== */

.disconnect-row.abnormal td:first-child {
    border-left: 3px solid var(--alarm-error);
}

.disconnect-row.normal td:first-child {
    border-left: 3px solid var(--quality-good);
}

.expand-btn {
    background: none;
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    font-size: 0.72rem;
    color: var(--accent);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.expand-btn:hover {
    background: var(--bg-active-subtle);
    border-color: var(--accent);
}

/* ================================================================== */
/*  SORTABLE COLUMN HEADERS                                            */
/* ================================================================== */

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
    position: relative;
    padding-right: 24px;
}

.data-table th.sortable:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.data-table th.sortable .sort-arrow {
    display: inline-block;
    width: 10px;
    margin-left: 6px;
    opacity: 0.3;
    font-size: 0.65rem;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    line-height: 1;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}

.data-table th.sortable:hover .sort-arrow { opacity: 0.6; }

.data-table th.sortable.sort-asc .sort-arrow,
.data-table th.sortable.sort-desc .sort-arrow {
    opacity: 1;
    color: var(--accent-hover);
}

.data-table th.sortable.sort-asc .sort-arrow::before { content: '▲'; }
.data-table th.sortable.sort-desc .sort-arrow::before { content: '▼'; }
.data-table th.sortable:not(.sort-asc):not(.sort-desc) .sort-arrow::before { content: '⇅'; font-size: 0.8rem; }

/* ================================================================== */
/*  PAGINATION                                                         */
/* ================================================================== */

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-primary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.pagination-info {
    color: var(--text-tertiary);
    font-size: 0.78rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.pagination-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    color: var(--text-primary);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 32px;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent-hover);
}

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

.pagination-btn.active {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
    font-weight: 600;
}

.pagination-pagesize {
    padding: 4px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.78rem;
    cursor: pointer;
}

/* ================================================================== */
/*  TOOLTIPS & INFO BADGES                                             */
/* ================================================================== */

/* Use native title attribute for simple tooltips on truncated cells. */
/* This utility creates informational panels below charts and tiles. */

.info-panel {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--pexip-purple);
    padding: 12px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 12px;
    transition: border-color var(--transition-normal);
}

.info-panel:hover {
    border-left-color: var(--accent);
}

.info-panel a {
    color: var(--pexip-purple);
    font-weight: 500;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.info-panel a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Truncated cells */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ================================================================== */
/*  LOGO CONTAINER                                                     */
/* ================================================================== */

/* Container that places the blue Pexip logo on a light background,
   ensuring visibility on both light and dark themes. */
/* Two marks per logo: blue on light surfaces, white on dark surfaces
   (dark theme + the always-dark sidebar). No background chip. */
.logo-container {
    background: transparent;
    padding: 4px 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.logo-container img {
    display: block;
    height: 24px;
    width: auto;
}

.logo-container.large img {
    height: 40px;
}

.logo-container.xl img {
    height: 56px;
}

/* Blue by default; white in dark theme and in the sidebar (selectors kept
   more specific than ".logo-container img" so the toggle wins). */
.logo-container .logo-mark-white { display: none; }
[data-theme="dark"] .logo-container .logo-mark-blue { display: none; }
[data-theme="dark"] .logo-container .logo-mark-white { display: block; }
.sidebar-brand .logo-container .logo-mark-blue { display: none; }
.sidebar-brand .logo-container .logo-mark-white { display: block; }



::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-secondary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ================================================================== */
/*  ANIMATIONS                                                         */
/* ================================================================== */

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

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.fade-in {
    animation: fadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.view-container > * {
    animation: fadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Staggered animation for stat cards and grid children */
.stats-grid > .stat-card:nth-child(1) { animation: fadeInUp 0.3s 0.00s cubic-bezier(0.4, 0, 0.2, 1) both; }
.stats-grid > .stat-card:nth-child(2) { animation: fadeInUp 0.3s 0.05s cubic-bezier(0.4, 0, 0.2, 1) both; }
.stats-grid > .stat-card:nth-child(3) { animation: fadeInUp 0.3s 0.10s cubic-bezier(0.4, 0, 0.2, 1) both; }
.stats-grid > .stat-card:nth-child(4) { animation: fadeInUp 0.3s 0.15s cubic-bezier(0.4, 0, 0.2, 1) both; }
.stats-grid > .stat-card:nth-child(5) { animation: fadeInUp 0.3s 0.20s cubic-bezier(0.4, 0, 0.2, 1) both; }

/* Cards in grids also stagger */
.grid-2 > .card:nth-child(1) { animation: fadeInUp 0.35s 0.05s cubic-bezier(0.4, 0, 0.2, 1) both; }
.grid-2 > .card:nth-child(2) { animation: fadeInUp 0.35s 0.12s cubic-bezier(0.4, 0, 0.2, 1) both; }

/* Sidebar links slide in */
.sidebar-link { animation: slideInLeft 0.25s cubic-bezier(0.4, 0, 0.2, 1) both; }
.sidebar-section .sidebar-link:nth-child(1) { animation-delay: 0.02s; }
.sidebar-section .sidebar-link:nth-child(2) { animation-delay: 0.05s; }
.sidebar-section .sidebar-link:nth-child(3) { animation-delay: 0.08s; }
.sidebar-section .sidebar-link:nth-child(4) { animation-delay: 0.11s; }

/* Loading skeleton pulse */
.skeleton { animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* Smooth expand for disconnect detail panels */
.expand-btn {
    transition: all var(--transition-fast);
}
.expand-btn:hover {
    transform: scale(1.03);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================================================================== */
/*  UTILITY CLASSES                                                    */
/* ================================================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-tertiary); }
.text-accent { color: var(--text-accent); }
.text-sm { font-size: 0.78rem; }
.text-xs { font-size: 0.68rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--font-mono); }
