/* CMLC x RadiCare Dashboard — Sidebar Layout */

/* ─── Light Theme ────────────────────────────────── */
:root {
    --primary:       #166534;
    --primary-light: #15803d;
    --primary-dark:  #14532d;
    --primary-glow:  rgba(22, 101, 52, 0.07);

    --bg-page:     #f4f6fb;
    --bg-card:     #ffffff;
    --bg-elevated: #f0f4f8;
    --bg-input:    #f8fafc;

    --border:       #e2e8f0;
    --border-light: #cbd5e1;

    --text-primary:   #0f172a;
    --text-secondary: #475569;
    --text-muted:     #94a3b8;

    --shadow-card:       0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    --shadow-card-hover: 0 4px 20px rgba(0,97,75,0.12), 0 1px 4px rgba(0,0,0,0.06);

    --dot-color: rgba(0,0,0,0.07);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  16px;
    --space-lg:  24px;
    --space-xl:  32px;
    --space-2xl: 48px;

    --sidebar-width:  240px;
    --topbar-height:  60px;
}

/* ─── Dark Theme ─────────────────────────────────── */
[data-theme="dark"] {
    --primary:       #34d399;
    --primary-light: #6ee7b7;
    --primary-dark:  #10b981;
    --primary-glow:  rgba(52, 211, 153, 0.09);

    --bg-page:     #0d1117;
    --bg-card:     #161b27;
    --bg-elevated: #1c2333;
    --bg-input:    #1c2333;

    --border:       #21293d;
    --border-light: #2a3450;

    --text-primary:   #e6edf3;
    --text-secondary: #8b949e;
    --text-muted:     #4a5568;

    --shadow-card:       0 1px 3px rgba(0,0,0,0.4), 0 4px 20px rgba(0,0,0,0.3);
    --shadow-card-hover: 0 0 0 1px rgba(0,217,139,0.2), 0 8px 32px rgba(0,0,0,0.5);

    --dot-color: rgba(255,255,255,0.04);
}

/* ─── Base ───────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.hidden { display: none !important; }

/* ─── Auth Gate ──────────────────────────────────── */
.auth-gate {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-page);
    background-image: radial-gradient(circle, var(--dot-color) 1.5px, transparent 1.5px);
    background-size: 24px 24px;
}

.auth-header {
    background: var(--primary-dark);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.auth-header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.auth-header-brand:hover { opacity: 0.8; }

.auth-header-logo { height: 32px; width: auto; }

.auth-header-title {
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.auth-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.auth-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: var(--space-2xl);
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-card);
    animation: fadeIn 0.3s ease;
    position: relative;
    overflow: hidden;
}

.auth-modal::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-dark), var(--primary));
}

.auth-logo img { max-width: 140px; margin-bottom: var(--space-lg); }

.auth-modal h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    letter-spacing: -0.3px;
}

.auth-modal > p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--space-xl);
}

#auth-form,
#set-password-form,
#forgot-form { display: flex; flex-direction: column; gap: var(--space-md); }

#auth-form input,
#set-password-form input,
#request-form input,
#forgot-form input {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    text-align: left;
    font-family: inherit;
    transition: all 0.15s ease;
}

#auth-form input::placeholder,
#set-password-form input::placeholder,
#request-form input::placeholder,
#forgot-form input::placeholder { color: var(--text-muted); }

#auth-form input:focus,
#set-password-form input:focus,
#request-form input:focus,
#forgot-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

#auth-form button,
#set-password-form button,
#request-form button,
#forgot-form button {
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

[data-theme="dark"] #auth-form button,
[data-theme="dark"] #set-password-form button,
[data-theme="dark"] #request-form button,
[data-theme="dark"] #forgot-form button { color: #0d1117; }

#auth-form button:hover,
#set-password-form button:hover,
#request-form button:hover,
#forgot-form button:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* Auth helper text + links (forgot password, back to sign in, set-password intro) */
.auth-helper-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--space-md);
    text-align: center;
    line-height: 1.5;
}

.auth-helper-row {
    text-align: center;
    margin-top: var(--space-md);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.auth-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.auth-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.error-text { color: #ef4444; font-size: 0.875rem; min-height: 1.25rem; }

/* Auth tabs */
.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: var(--space-lg);
}

.auth-tab {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 7px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.auth-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* Request form textarea */
#auth-form textarea,
#request-form textarea {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    text-align: left;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: all 0.15s ease;
}

#auth-form textarea:focus,
#request-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

#auth-form textarea::placeholder,
#request-form textarea::placeholder { color: var(--text-muted); }

#request-form { display: flex; flex-direction: column; gap: var(--space-md); }

/* Success state */
.request-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) 0;
    color: var(--primary);
    text-align: center;
}

.request-success p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ─── Dashboard Shell ────────────────────────────── */
.dashboard {
    display: flex;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}

/* ─── Sidebar ────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}

.sidebar-brand:hover { opacity: 0.8; }

.sidebar-dual-logo { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.sidebar-logo-sep { font-size: 0.7rem; color: var(--text-muted); line-height: 1; }

.sidebar-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-brand-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 1px;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-group-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0 8px;
    margin-bottom: 4px;
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.3s ease, background 0.3s ease;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}
.nav-item:hover svg { opacity: 1; }

.nav-item:active {
    transform: scale(0.97);
}

.nav-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* Ripple from center on click */
.nav-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), var(--primary) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0);
    transition: none;
    pointer-events: none;
    border-radius: inherit;
}
.nav-item.ripple::after {
    opacity: 0.1;
    transform: scale(3);
    transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.8s ease-out;
}

/* ─── View transition splash ──────────────────────── */
.view-transition-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background: radial-gradient(circle at 50% 50%, var(--primary) 0%, rgba(22,163,74,0.8) 30%, transparent 65%);
    opacity: 0;
    transform: scale(0);
    transform-origin: center;
}
.view-transition-overlay.active {
    animation: viewSplash 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes viewSplash {
    0%   { opacity: 0.5; transform: scale(0); }
    40%  { opacity: 0.2; transform: scale(1.2); }
    100% { opacity: 0; transform: scale(3); }
}

.nav-item.active svg { opacity: 1; }

/* Sidebar Footer */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    width: 100%;
}

.sidebar-logout:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239,68,68,0.06);
}

/* ─── Content Wrapper ────────────────────────────── */
.content-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--bg-page);
    background-image: radial-gradient(circle, var(--dot-color) 1.5px, transparent 1.5px);
    background-size: 24px 24px;
}

/* ─── Top Bar ────────────────────────────────────── */
.top-bar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    gap: var(--space-md);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.breadcrumb-root {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

.breadcrumb svg { stroke: var(--text-muted); flex-shrink: 0; }

.breadcrumb-current {
    font-size: 0.8125rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* Topbar Right */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.global-date-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}
.global-tabs {
    margin: 0;
}
.global-tabs .stab {
    padding: 4px 10px;
    font-size: 0.75rem;
}
.view-panel.hidden { display: none; }

/* Search (decorative) */
.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.topbar-search svg { flex-shrink: 0; }

.topbar-search-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-family: inherit;
    width: 140px;
    cursor: default;
}

.topbar-search-input::placeholder { color: var(--text-muted); }

/* ─── Theme Toggle ───────────────────────────────── */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-glow);
}

/* ─── Buttons ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid var(--border);
    font-family: inherit;
    letter-spacing: -0.1px;
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

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

.btn-small { padding: 5px 10px; font-size: 0.75rem; }

.btn-primary-solid { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary-solid:hover { filter: brightness(1.1); }

/* ─── Filter Select ──────────────────────────────── */
.filter-select {
    padding: 6px 28px 6px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    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%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

[data-theme="dark"] .filter-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

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

/* ─── Page Content ───────────────────────────────── */
.page-content {
    max-width: 1500px;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-xl);
    flex: 1;
}

/* ─── Welcome Row ────────────────────────────────── */
.welcome-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    gap: var(--space-md);
}

.welcome-heading {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.welcome-sub {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.welcome-actions { display: flex; gap: var(--space-sm); align-items: center; }

/* ─── Hero Banner ────────────────────────────────── */
@keyframes heroGradient {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes heroOrb1 {
    0%, 100% { transform: translate(0px,  0px) scale(1);    }
    33%       { transform: translate(70px,-40px) scale(1.12); }
    66%       { transform: translate(-30px, 55px) scale(0.93); }
}
@keyframes heroOrb2 {
    0%, 100% { transform: translate(0px,  0px) scale(1);    }
    40%       { transform: translate(-60px, 35px) scale(1.18); }
    70%       { transform: translate(45px,-25px) scale(0.88); }
}
@keyframes heroOrb3 {
    0%, 100% { transform: translate(0px,  0px) scale(1);    }
    25%       { transform: translate(35px, 45px) scale(1.06); }
    75%       { transform: translate(-45px,-35px) scale(1.14); }
}
@keyframes heroPulseDot {
    0%, 100% { opacity: 1;   transform: scale(1);    box-shadow: 0 0 0 0 rgba(74,222,128,0.6); }
    50%       { opacity: 0.7; transform: scale(0.85); box-shadow: 0 0 0 5px rgba(74,222,128,0); }
}

.hero-banner {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    margin-bottom: var(--space-xl);
    padding: 44px 48px;
    background: linear-gradient(-45deg, #064e3b, #166534, #0c4a6e, #065f46, #0e7490, #1d4ed8, #14532d);
    background-size: 350% 350%;
    animation: heroGradient 16s ease infinite;
    min-height: 180px;
    display: flex;
    align-items: center;
    box-shadow: 0 8px 40px rgba(6,78,59,0.35), 0 2px 8px rgba(0,0,0,0.12);
}

[data-theme="dark"] .hero-banner {
    background: linear-gradient(-45deg, #022c22, #14532d, #0c3a5c, #064e3b, #0c4a6e, #1e3a5f, #023020);
    background-size: 350% 350%;
    animation: heroGradient 16s ease infinite;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
}

/* Floating orbs */
.hero-orb {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform;
}
.hero-orb-1 {
    width: 340px; height: 340px;
    background: radial-gradient(circle, rgba(74,222,128,0.55) 0%, transparent 65%);
    top: -120px; left: 8%;
    filter: blur(55px);
    animation: heroOrb1 11s ease-in-out infinite;
}
.hero-orb-2 {
    width: 280px; height: 280px;
    background: radial-gradient(circle, rgba(34,211,238,0.5) 0%, transparent 65%);
    top: -90px; right: 18%;
    filter: blur(50px);
    animation: heroOrb2 14s ease-in-out infinite;
}
.hero-orb-3 {
    width: 220px; height: 220px;
    background: radial-gradient(circle, rgba(167,139,250,0.45) 0%, transparent 65%);
    bottom: -90px; left: 45%;
    filter: blur(45px);
    animation: heroOrb3 12s ease-in-out infinite;
}

/* Dot-grid overlay texture */
.hero-grid-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255,255,255,0.12) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.4) 40%, rgba(0,0,0,0.4) 60%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.4) 40%, rgba(0,0,0,0.4) 60%, transparent 100%);
}

/* Content layer */
.hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.8px;
    line-height: 1.1;
    margin-bottom: 8px;
    text-shadow: 0 2px 24px rgba(0,0,0,0.25);
}

.hero-sub {
    font-size: 0.9375rem;
    color: rgba(255,255,255,0.7);
    font-weight: 400;
    margin-bottom: 4px;
}

.hero-date-line {
    font-size: 0.8125rem;
    color: rgba(255,255,255,0.48);
    font-weight: 400;
}

@media (max-width: 768px) {
    .hero-banner { padding: 32px 24px; min-height: 140px; }
    .hero-title { font-size: 1.75rem; }
}

/* ─── Section Labels ─────────────────────────────── */
.section-label {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-left: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.section-label::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 2px;
    flex-shrink: 0;
}

/* ─── KPI Cards ──────────────────────────────────── */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid transparent;
    border-radius: var(--radius-lg);
    padding: 20px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.18s ease;
    box-shadow: var(--shadow-card);
}

.kpi-card:hover {
    border-left-color: var(--primary);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}

/* Header row: label + tiny icon */
.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.kpi-icon-sm {
    stroke: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.5;
}

/* Number */
.kpi-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.04em;
}

/* Footer row: subtext/trend + sparkline */
.kpi-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 2px;
}

.kpi-subtext {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.kpi-sparkline {
    width: 64px;
    height: 22px;
    flex-shrink: 0;
    opacity: 0.35;
    transition: opacity 0.18s;
}

.kpi-card:hover .kpi-sparkline { opacity: 0.7; }

.kpi-trend {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
}

.kpi-trend.positive { color: #15803d; }
.kpi-trend.negative { color: #b91c1c; }
[data-theme="dark"] .kpi-trend.positive { color: #4ade80; }
[data-theme="dark"] .kpi-trend.negative { color: #f87171; }

/* ─── Charts ─────────────────────────────────────── */
.charts-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

@media (max-width: 900px) { .charts-section { grid-template-columns: 1fr; } }

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    height: 390px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
}

.chart-container:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-card-hover);
}

.chart-container canvas { flex: 1; min-height: 0; }

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.chart-subtitle { font-size: 0.6875rem; color: var(--text-muted); margin-top: 3px; }

.chart-controls { display: flex; gap: 4px; }

.trend-btn {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.trend-btn.active, .trend-btn:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
}

.trends-section {
    margin-bottom: var(--space-xl);
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.chart-trends { height: 430px; }

/* ─── Table ──────────────────────────────────────── */
.table-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-card);
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.table-header h3 { font-size: 0.875rem; font-weight: 600; letter-spacing: -0.2px; }

.table-controls { display: flex; gap: var(--space-sm); align-items: center; flex-wrap: wrap; }

.table-controls .btn {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text-secondary);
}

.table-controls .btn:hover { border-color: var(--primary); color: var(--primary); }

.table-controls .btn-ghost { background: transparent; border: none; color: var(--text-muted); }

.date-input {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

.date-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
[data-theme="dark"] .date-input::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

/* Column group toggles */
.col-group-toggles {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.col-group-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; margin-right: 4px; }
.col-toggle {
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.col-toggle.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.col-toggle:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* Group visibility via table class */
#data-table.hide-group-people    [data-group="people"]    { display: none; }
#data-table.hide-group-incidents [data-group="incidents"] { display: none; }
#data-table.hide-group-visits    [data-group="visits"]    { display: none; }
#data-table.hide-group-other     [data-group="other"]     { display: none; }

/* Mirror scrollbar at the top of the table */
.table-scroll-top {
    overflow-x: auto;
    overflow-y: hidden;
    height: 10px;
    border-bottom: 1px solid var(--border);
}
.table-scroll-top-inner { height: 1px; }
.table-wrapper { overflow-x: auto; }

#data-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }

#data-table th,
#data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* Sticky Date + Total columns */
#data-table th.sticky-col,
#data-table td.sticky-col {
    position: sticky;
    z-index: 2;
}
#data-table th.sticky-col { background: var(--bg-elevated); }
#data-table td.sticky-col { background: var(--bg-card); }
#data-table tbody tr:hover td.sticky-col { background: var(--bg-elevated); }
.sticky-date  { left: 0;     min-width: 110px; box-shadow: 2px 0 4px rgba(0,0,0,0.04); }
.sticky-total { left: 110px; min-width: 68px;  box-shadow: 2px 0 4px rgba(0,0,0,0.04); }

#data-table th {
    background: var(--bg-elevated);
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

#data-table th:hover { color: var(--primary); }

#data-table td { color: var(--text-secondary); }
#data-table td:first-child { color: var(--text-primary); font-weight: 500; }
#data-table td:nth-child(2) { color: var(--primary); font-weight: 600; }
#data-table tbody tr:hover { background: var(--bg-elevated); }
#data-table td:last-child { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; color: var(--text-muted); }

.table-pagination { display: flex; justify-content: center; align-items: center; gap: var(--space-md); margin-top: var(--space-lg); }

.table-pagination .btn { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary); }
.table-pagination .btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.table-pagination .btn:disabled { opacity: 0.35; cursor: not-allowed; }
#page-info { font-size: 0.8125rem; color: var(--text-muted); }

/* ─── Live Status ────────────────────────────────── */
.live-status {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; transition: background 0.3s; }

.live-status.connected .live-dot { background: #4ade80; animation: pulse 2s infinite; }
.live-status.connected { border-color: rgba(74,222,128,0.3); }
[data-theme="dark"] .live-status.connected { border-color: rgba(0,217,139,0.3); }
[data-theme="dark"] .live-status.connected .live-dot { background: #00d98b; }
.live-status.error .live-dot { background: #f87171; }

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

/* ─── Log Section ────────────────────────────────── */
.log-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-card);
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.log-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-md); }
.log-header h3 { font-size: 0.875rem; font-weight: 600; letter-spacing: -0.2px; }
.log-controls { display: flex; align-items: center; gap: var(--space-md); }
.log-controls span { font-size: 0.8125rem; color: var(--text-muted); }
.log-list { max-height: 300px; overflow-y: auto; }
.log-empty { text-align: center; padding: var(--space-xl); color: var(--text-muted); font-size: 0.875rem; }

.log-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
    animation: slideIn 0.3s ease;
    transition: background 0.15s;
}

.log-item:hover { background: var(--bg-elevated); }
.log-item:last-child { border-bottom: none; }
.log-item.new { background: var(--primary-glow); border-left: 2px solid var(--primary); }

@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.log-time { font-size: 0.6875rem; color: var(--text-muted); white-space: nowrap; min-width: 72px; font-variant-numeric: tabular-nums; }
.log-content { flex: 1; }
.log-title { font-size: 0.875rem; font-weight: 500; color: var(--text-primary); margin-bottom: 2px; }
.log-details { font-size: 0.75rem; color: var(--text-secondary); }

.log-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(0,97,75,0.2);
    border-radius: 99px;
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
}

[data-theme="dark"] .log-badge { border-color: rgba(0,217,139,0.2); }

/* ─── Footer ─────────────────────────────────────── */
.footer {
    text-align: center;
    padding: var(--space-xl) 0 var(--space-2xl);
    color: var(--text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border);
    margin-top: var(--space-md);
}

.last-updated { margin-top: 4px; font-size: 0.75rem; }

/* ─── Animations ─────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── Page Loader ────────────────────────────────── */
#page-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-page, #0d1117);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    transition: opacity 0.25s ease;
}

#page-loader.pl-out {
    opacity: 0;
    pointer-events: none;
}

.pl-ring {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(0, 97, 75, 0.12);
    border-top-color: var(--primary, #00614B);
    border-radius: 50%;
    animation: pl-spin 0.7s linear infinite;
}

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

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 1024px) {
    :root { --sidebar-width: 200px; }
    .topbar-search { display: none; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .content-wrapper { margin-left: 0; }
    .kpi-section { grid-template-columns: 1fr 1fr; }
    .kpi-value { font-size: 1.75rem; }
    .page-content { padding: var(--space-md); }
    .top-bar { padding: 0 var(--space-md); }
    .topbar-right .btn span { display: none; }
    .welcome-heading { font-size: 1.375rem; }
}

@media (max-width: 480px) {
    .kpi-section { grid-template-columns: 1fr; }
}

/* ─── Section Tab Bars ───────────────────────────── */
.section-tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
}

.section-tabs {
    display: flex;
    gap: 3px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.stab {
    padding: 5px 14px;
    background: transparent;
    border: none;
    border-radius: 5px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.stab.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    font-weight: 600;
}

.stab:not(.active):hover { color: var(--text-secondary); }

.tab-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-picker-current {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── KPI Hero Row ───────────────────────────────── */
.kpi-hero-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

@media (max-width: 900px) { .kpi-hero-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpi-hero-row { grid-template-columns: 1fr; } }

/* ─── Hero Cards ────────────────────────────────── */
.hero-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
@media (max-width: 1000px) { .hero-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .hero-cards { grid-template-columns: 1fr; } }

.hero-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 24px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    border-left: 4px solid var(--border);
    transition: transform 0.15s, box-shadow 0.15s;
}
.hero-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.06);
}
.hero-card--primary { border-left-color: #16a34a; }
.hero-card--primary .hero-card-icon { background: rgba(22,163,74,0.08); color: #16a34a; }
.hero-card--red { border-left-color: #ef4444; }
.hero-card--red .hero-card-icon { background: rgba(239,68,68,0.08); color: #ef4444; }
.hero-card--green { border-left-color: #16a34a; }
.hero-card--green .hero-card-icon { background: rgba(22,163,74,0.08); color: #16a34a; }

.hero-card-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--bg-elevated);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: var(--text-muted);
}
.hero-card-icon svg { width: 22px; height: 22px; stroke: currentColor; }

.hero-card-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-card-label {
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted);
}
.hero-card-value {
    font-size: 2rem; font-weight: 800; color: var(--text-primary); line-height: 1.1;
}
.hero-card-sub {
    font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px;
}

/* ─── Overview Grid (referral charts) ────────────── */
.overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
@media (max-width: 800px) { .overview-grid { grid-template-columns: 1fr; } }

.overview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.overview-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}
.overview-card-header h3 {
    font-size: 1rem; font-weight: 700; color: var(--text-primary); margin: 0;
}
.overview-card-total {
    font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
    background: var(--bg-elevated); padding: 3px 10px; border-radius: 99px;
}

/* ─── Notes Timeline ────────────────────────────── */
.notes-section { margin-bottom: 24px; }
.notes-timeline { display: flex; flex-direction: column; gap: 0; }

.note-entry {
    display: flex; gap: 16px; align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.note-entry:last-child { border-bottom: none; }

.note-entry--incident { }
.note-entry--incident::before {
    content: '';
    position: absolute; left: -24px; top: 14px; bottom: 14px;
    width: 3px; background: #ef4444; border-radius: 2px;
}

.note-entry-date {
    font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
    min-width: 100px; flex-shrink: 0; padding-top: 2px;
}
.note-entry-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.note-entry-text { font-size: 0.88rem; color: var(--text-primary); line-height: 1.5; }
.note-entry-badge {
    display: inline-flex; align-self: flex-start;
    font-size: 0.7rem; font-weight: 700; padding: 2px 10px;
    border-radius: 99px; background: #fef2f2; color: #dc2626;
    border: 1px solid #fecaca;
}

/* ─── Raw Data Table (CPL) ──────────────────────── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.data-table th {
    text-align: left; padding: 10px 12px; font-size: 0.68rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
    border-bottom: 2px solid var(--border); white-space: nowrap; background: var(--bg-elevated);
    position: sticky; top: 0; z-index: 1;
}
.data-table td {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    color: var(--text-secondary); white-space: nowrap;
}
.data-table td:first-child { color: var(--text-primary); font-weight: 500; }
.data-table tbody tr:hover td { background: var(--bg-elevated); }

/* ─── Chart Cards ───────────────────────────────── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 800px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* ─── KPI Groups (legacy CMLC compat) ────────────── */
.kpi-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.kpi-group-header:hover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.kpi-group-header-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.kpi-group-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kpi-chevron {
    stroke: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.kpi-group-header.collapsed .kpi-chevron {
    transform: rotate(-90deg);
}

.kpi-group-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 14px;
    margin-bottom: var(--space-md);
    transition: all 0.2s ease;
}

.kpi-group-tiles.collapsed {
    display: none;
}

/* ─── KPI Badge (% in header) ────────────────────── */
.kpi-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 99px;
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(22,101,52,0.15);
    white-space: nowrap;
    flex-shrink: 0;
}

[data-theme="dark"] .kpi-badge { border-color: rgba(52,211,153,0.2); }

.kpi-badge-amber {
    background: rgba(217,119,6,0.08);
    color: #d97706;
    border-color: rgba(217,119,6,0.2);
}

[data-theme="dark"] .kpi-badge-amber {
    background: rgba(251,191,36,0.1);
    color: #fbbf24;
    border-color: rgba(251,191,36,0.2);
}

.kpi-badge-blue {
    background: rgba(37,99,235,0.08);
    color: #2563eb;
    border-color: rgba(37,99,235,0.2);
}

[data-theme="dark"] .kpi-badge-blue {
    background: rgba(59,130,246,0.1);
    color: #60a5fa;
    border-color: rgba(59,130,246,0.2);
}

.kpi-badge-gray {
    background: rgba(107,114,128,0.08);
    color: #6b7280;
    border-color: rgba(107,114,128,0.2);
}

/* ─── KPI Sparkline Container ────────────────────── */
.kpi-spark {
    width: 64px;
    height: 22px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.18s;
}

.kpi-card:hover .kpi-spark { opacity: 0.85; }

/* ─── Analytics Section ──────────────────────────── */
.analytics-section-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.chart-row-full { width: 100%; }

.chart-row-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}
@media (max-width: 900px) { .chart-row-half { grid-template-columns: 1fr; } }

.chart-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

@media (max-width: 900px) { .chart-row-2col { grid-template-columns: 1fr; } }

.chart-container-apex {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
}

.chart-container-apex:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-card-hover);
}

.chart-heatmap { min-height: 260px; }
.chart-cat-bar { min-height: 380px; }
.chart-donut   { min-height: 300px; }
.chart-trends-apex { min-height: 420px; }

/* ─── Trends v2 Section ──────────────────────────── */
.trends-section-v2 {
    margin-bottom: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.trends-controls-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.trends-series-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 6px 12px;
}

.series-cb-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.series-cb-item input[type="checkbox"] {
    accent-color: var(--primary);
    cursor: pointer;
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.series-cb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.trends-mode-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.mode-toggle-group, .range-toggle-group {
    display: flex;
    gap: 3px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.mode-btn {
    padding: 5px 12px;
    background: transparent;
    border: none;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.mode-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-weight: 600;
}

.mode-btn:not(.active):hover { color: var(--text-secondary); }

/* ─── Monthly Summary Section ────────────────────── */
.monthly-section-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.monthly-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

@media (max-width: 900px) { .monthly-charts-row { grid-template-columns: 1fr; } }

.top-days-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
}

.top-days-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    margin-top: var(--space-md);
}

.top-days-table th,
.top-days-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.top-days-table th {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    background: var(--bg-elevated);
}

.top-days-table td { color: var(--text-secondary); }
.top-days-table td:first-child { color: var(--text-muted); font-weight: 600; }
.top-days-table td:nth-child(2) { color: var(--text-primary); font-weight: 500; }
.top-days-table td:nth-child(3) { color: var(--primary); font-weight: 700; }
.top-days-table tbody tr:hover { background: var(--bg-elevated); }
.top-days-dow {
    font-size: 0.7rem; font-weight: 600; color: var(--text-muted);
    background: var(--bg-elevated); padding: 1px 6px; border-radius: 4px; margin-left: 4px;
}
.top-days-note {
    font-size: 0.75rem; color: var(--text-muted); font-style: italic; max-width: 200px;
}

/* ─── Notes Section ─────────────────────────────── */
.notes-section { margin-bottom: var(--space-lg); }
.notes-list { max-height: 400px; overflow-y: auto; }
.note-item {
    display: grid;
    grid-template-columns: 140px 80px 1fr;
    gap: 12px;
    align-items: baseline;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: none; }
.note-item:hover { background: var(--bg-elevated); }
.note-date { font-weight: 500; font-size: 0.85rem; color: var(--text-primary); }
.note-dow {
    font-size: 0.7rem; font-weight: 600; color: var(--text-muted);
    background: var(--bg-elevated); padding: 1px 6px; border-radius: 4px;
}
.note-total { font-size: 0.8rem; color: var(--primary); font-weight: 600; }
.note-text { font-size: 0.85rem; color: var(--text-secondary); }

/* ─── ApexCharts Overrides ───────────────────────── */
.apexcharts-tooltip {
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-card) !important;
}

.apexcharts-canvas { width: 100% !important; }

/* Ensure ApexCharts respects container */
#heatmap-chart,
#category-chart-apex,
#group-donut-chart,
#yoy-chart,
#trends-chart-apex,
#monthly-bar-chart,
#weekday-chart {
    min-height: 1px;
}

/* ─── Mobile Responsive Updates ──────────────────── */
@media (max-width: 768px) {
    .section-tab-bar { flex-direction: column; align-items: flex-start; }
    .kpi-group-tiles { grid-template-columns: 1fr 1fr; }
    .trends-series-grid { grid-template-columns: repeat(2, 1fr); }
    .trends-mode-bar { flex-direction: column; align-items: flex-start; }
    .chart-container-apex { padding: var(--space-md); }
}

@media (max-width: 480px) {
    .kpi-group-tiles { grid-template-columns: 1fr; }
    .trends-series-grid { grid-template-columns: 1fr; }
}

/* ── System Logs ─────────────────────────────────────── */
.syslog-section-inner { padding: var(--space-md, 16px) 0; }
.slog-filters {
    display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap;
}
.slog-filters select {
    padding: 6px 10px; border: 1px solid var(--border, #e2e8f0); border-radius: 6px;
    background: var(--input-bg, #f8fafc); color: var(--text-primary, #1e293b); font-size: 0.85rem;
}
.slog-list { display: flex; flex-direction: column; gap: 8px; }
.slog-empty { padding: 40px; text-align: center; color: var(--text-muted, #94a3b8); font-size: 0.875rem; }
.slog-item {
    padding: 12px 16px; border-radius: 8px; border-left: 4px solid var(--border, #e2e8f0);
    background: var(--card-bg, #fff);
}
.slog-item.slog-error { border-left-color: #ef4444; background: rgba(239,68,68,0.04); }
.slog-item.slog-warning { border-left-color: #f59e0b; background: rgba(245,158,11,0.04); }
.slog-item.slog-info { border-left-color: var(--border, #cbd5e1); }
.slog-header { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.slog-level-badge {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase; padding: 2px 6px;
    border-radius: 4px; letter-spacing: 0.05em;
}
.slog-lvl-error { background: #fecaca; color: #991b1b; }
.slog-lvl-warning { background: #fef3c7; color: #92400e; }
.slog-lvl-info { background: var(--bg-elevated, #f1f5f9); color: var(--text-secondary, #64748b); }
.slog-category-badge {
    font-size: 0.7rem; font-weight: 600; padding: 2px 6px; border-radius: 4px;
    background: var(--bg-elevated, #f1f5f9); color: var(--text-secondary, #64748b);
}
.slog-time { font-size: 0.75rem; color: var(--text-muted, #94a3b8); margin-left: auto; }
.slog-message { font-size: 0.85rem; color: var(--text-primary, #1e293b); }
.slog-details {
    margin-top: 6px; padding: 8px; border-radius: 6px; font-size: 0.75rem;
    background: var(--bg-elevated, #f1f5f9); color: var(--text-secondary, #64748b);
    overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.slog-alerts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.slog-alert {
    padding: 10px 14px; border-radius: 8px; font-size: 0.85rem; font-weight: 500;
}
.slog-alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.slog-alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fef3c7; }
.slog-badge {
    font-size: 0.6rem; font-weight: 700; background: #f59e0b; color: #fff;
    padding: 1px 5px; border-radius: 99px; margin-left: 6px; vertical-align: middle;
}
.slog-badge-error { background: #ef4444; }
.slog-badge.hidden { display: none; }

/* ─── Incident Clickable Links ─────────────────── */
.incident-link {
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}

.incident-link:hover {
    opacity: 0.85;
    text-decoration: underline;
    text-decoration-color: #ef4444;
    text-underline-offset: 3px;
}

.hero-card.incident-link:hover {
    text-decoration: none;
    border-color: #ef4444;
    box-shadow: 0 6px 24px rgba(239,68,68,0.12);
    transform: translateY(-3px);
}

/* ── What's New (release-notes archive) ───────────────────────────────── */
.whats-new-list { display: flex; flex-direction: column; gap: 12px; }
.whats-new-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    background: var(--bg-card);
}
/* Unread is shown by the dot next to the title — no side rail. */
.wn-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.wn-cat {
    font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.03em;
    text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
}
.wn-title { font-size: 0.95rem; font-weight: 600; margin: 0; color: var(--text-primary); }
.wn-new-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,0.18); flex-shrink: 0;
}
.wn-date { margin-left: auto; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.wn-body { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.5; }
.wn-line { margin: 2px 0; }
.wn-readmore {
    background: none; border: none; padding: 4px 0; margin-top: 4px;
    color: #166534; font-size: 0.8rem; font-weight: 700; cursor: pointer;
    font-family: inherit;
}
.wn-readmore:hover { text-decoration: underline; }
[data-theme="dark"] .wn-readmore { color: #4ade80; }
.wn-details { margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border); }
.wn-details .wn-line { color: var(--text-secondary); }
.wn-details .wn-head-line {
    font-weight: 700; color: var(--text-primary); margin-top: 12px;
    font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase;
}
.wn-details .wn-head-line:first-child { margin-top: 0; }

/* What's New popup — roomier layout, borderless cards, comfortable reading */
.wn-popup-list { gap: 0; }
.wn-popup-list .whats-new-item { border: none; padding: 0; background: transparent; border-radius: 0; }
.wn-popup-list .whats-new-item + .whats-new-item { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--border); }
.wn-popup-list .wn-title { font-size: 1.05rem; }
.wn-popup-list .wn-body { line-height: 1.6; font-size: 0.9rem; margin-top: 4px; }
.wn-popup-list .wn-details .wn-line { line-height: 1.6; font-size: 0.875rem; }
.wn-popup-list .wn-details { max-width: 800px; }
.wn-popup-list .wn-readmore { font-size: 0.85rem; }

/* Article-style release note: real headings, proper bullets, clean rhythm */
.whats-new-item .wn-title { font-size: 1.15rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.wn-popup-list .wn-title { font-size: 1.4rem; }
.whats-new-item .wn-body { line-height: 1.6; }
.wn-details .wn-h {
    font-size: 1rem; font-weight: 700; color: var(--text-primary);
    margin: 22px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
    text-transform: none; letter-spacing: 0; line-height: 1.3;
}
.wn-details .wn-h:first-child { margin-top: 4px; }
.wn-details .wn-p { margin: 0 0 10px; line-height: 1.65; }
.wn-details .wn-bullet { position: relative; padding-left: 18px; margin: 0 0 8px; line-height: 1.6; }
.wn-details .wn-bullet::before {
    content: ""; position: absolute; left: 3px; top: 9px;
    width: 5px; height: 5px; border-radius: 50%; background: #166534;
}
[data-theme="dark"] .wn-details .wn-bullet::before { background: #4ade80; }

.note-entry-badge.incident-link:hover {
    text-decoration: none;
    background: #fecaca;
    transform: scale(1.05);
}

/* ─── Reports Section ──────────────────────────── */
.reports-upload-card {
    margin-bottom: 24px;
}

.upload-zone {
    background: var(--bg-card);
    border: 2px dashed var(--border-light);
    border-radius: 16px;
    padding: 48px 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.upload-zone.drag-over {
    transform: scale(1.01);
}

.upload-zone-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

.upload-zone-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.upload-zone-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Upload progress toast */
.upload-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    animation: toastIn 0.3s ease;
}

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

.upload-toast-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.upload-toast-icon.success { background: rgba(22,163,74,0.1); color: #16a34a; }
.upload-toast-icon.error { background: rgba(239,68,68,0.1); color: #ef4444; }

.upload-toast-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.upload-toast-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-toast-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Reports list */
.reports-list-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.reports-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.reports-list-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.reports-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
}

.reports-search svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.reports-search input {
    border: none;
    background: transparent;
    font-size: 0.8rem;
    color: var(--text-primary);
    outline: none;
    width: 180px;
    font-family: inherit;
}

.reports-search input::placeholder {
    color: var(--text-muted);
}

.reports-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.report-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
}

.report-item:last-child {
    border-bottom: none;
}

.report-item:hover {
    background: var(--bg-elevated);
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
}

.report-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(239,68,68,0.08);
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.report-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    margin-top: 2px;
}

.report-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    border-radius: 99px;
    flex-shrink: 0;
    align-self: center;
}

.report-badge-monthly {
    background: rgba(37,99,235,0.08);
    color: #2563eb;
    border: 1px solid rgba(37,99,235,0.15);
}

.report-badge-quarterly {
    background: rgba(124,58,237,0.08);
    color: #7c3aed;
    border: 1px solid rgba(124,58,237,0.15);
}

.report-badge-annual {
    background: rgba(22,163,74,0.08);
    color: #16a34a;
    border: 1px solid rgba(22,163,74,0.15);
}

.report-badge-special {
    background: rgba(245,158,11,0.08);
    color: #d97706;
    border: 1px solid rgba(245,158,11,0.15);
}

.report-download {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    flex-shrink: 0;
}

.report-download:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-glow);
}

.report-download svg {
    width: 14px;
    height: 14px;
}

.reports-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

@media (max-width: 640px) {
    .report-item { flex-wrap: wrap; gap: 10px; }
    .report-badge { order: 3; }
    .report-download { order: 4; width: 100%; justify-content: center; }
    .reports-search input { width: 120px; }
}
