/* ══════════════════════════════════════════════════════════════
   QC DEVWORKS OPS — Redesigned 2026
   Refined dark theme: intentional depth, no glass soup,
   tighter typographic hierarchy, premium micro-interactions.
   ══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    /* ── Core Palette ── */
    --bg: #05080d;
    --bg-elevated: #081018;
    --surface: rgba(10,18,26,.96);
    --surface-solid: #0a121a;
    --surface2: rgba(16,184,255,.07);
    --surface3: rgba(52,211,153,.1);
    --glass: rgba(10,18,26,.72);
    --glass-border: rgba(148,163,184,.14);
    --glass-highlight: rgba(16,184,255,.04);

    --border: rgba(148,163,184,.14);
    --border-light: rgba(16,184,255,.24);
    --border-active: rgba(16,184,255,.44);

    --text: #f4f8fb;
    --text-secondary: #c9d6df;
    --text-muted: #8da2b3;
    --text-dim: rgba(141,162,179,.55);

    /* ── Accent System ── */
    --accent: #10b8ff;
    --accent-hover: #38c8ff;
    --accent-light: #7ddcff;
    --accent-glow: rgba(16,184,255,.22);
    --accent-dim: rgba(16,184,255,.12);

    /* ── Semantic Colors ── */
    --green: #10b981;
    --green-glow: rgba(16,185,129,.1);
    --green-border: rgba(16,185,129,.22);
    --red: #ef4444;
    --red-glow: rgba(239,68,68,.1);
    --red-border: rgba(239,68,68,.2);
    --yellow: #f59e0b;
    --yellow-glow: rgba(245,158,11,.1);
    --yellow-border: rgba(245,158,11,.2);
    --blue: #3b82f6;
    --blue-glow: rgba(59,130,246,.1);
    --blue-border: rgba(59,130,246,.2);
    --cyan: #06b6d4;
    --cyan-glow: rgba(6,182,212,.1);
    --pink: #ec4899;
    --pink-glow: rgba(236,72,153,.1);

    /* ── Gradients ── */
    --aurora-1: linear-gradient(135deg, #10b8ff 0%, #34d399 58%, #f59e0b 100%);
    --aurora-2: linear-gradient(135deg, #0f172a 0%, #0e7490 54%, #10b981 100%);
    --aurora-3: linear-gradient(135deg, #f59e0b 0%, #ef4444 50%, #10b8ff 100%);
    --sidebar-gradient: linear-gradient(180deg, #061018 0%, #0b1f2d 50%, #07121a 100%);
    --sidebar-glow:
        radial-gradient(circle at top left, rgba(16,184,255,.12) 0%, transparent 40%),
        radial-gradient(circle at bottom right, rgba(52,211,153,.12) 0%, transparent 35%);

    /* ── Spatial Design ── */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow: 0 4px 16px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.45);
    --shadow-glow: 0 0 30px rgba(16,184,255,.1);
    --shadow-card: 0 2px 12px rgba(0,0,0,.3);

    /* ── Typography ── */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;

    /* ── Motion ── */
    --ease: cubic-bezier(.4,0,.2,1);
    --ease-spring: cubic-bezier(.34,1.56,.64,1);
    --ease-out: cubic-bezier(0,.55,.45,1);
    --transition: all .22s var(--ease);
    --transition-fast: all .14s var(--ease);

    --sidebar-w: 260px;
}

html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

/* ══════════════════════ Light Mode ══════════════════════ */
[data-theme="light"] {
    --bg: #f4f8fb;
    --bg-elevated: #eaf2f7;
    --surface: rgba(255,255,255,.96);
    --surface-solid: #ffffff;
    --surface2: rgba(16,184,255,.05);
    --surface3: rgba(52,211,153,.08);
    --glass: rgba(255,255,255,.85);
    --glass-border: rgba(15,23,42,.1);
    --glass-highlight: rgba(16,184,255,.04);

    --border: rgba(15,23,42,.1);
    --border-light: rgba(16,184,255,.2);

    --text: #1a1a2e;
    --text-secondary: #3d3a5c;
    --text-muted: #5a5580;
    --text-dim: rgba(26,26,46,.4);

    --accent: #0284c7;
    --accent-hover: #0369a1;
    --accent-light: #0ea5e9;
    --accent-glow: rgba(2,132,199,.14);
    --accent-dim: rgba(2,132,199,.08);

    --green: #059669;
    --green-glow: rgba(5,150,105,.08);
    --green-border: rgba(5,150,105,.2);
    --red: #dc2626;
    --red-glow: rgba(220,38,38,.08);
    --red-border: rgba(220,38,38,.15);
    --yellow: #d97706;
    --yellow-glow: rgba(217,119,6,.08);
    --yellow-border: rgba(217,119,6,.15);
    --blue: #2563eb;
    --blue-glow: rgba(37,99,235,.08);
    --blue-border: rgba(37,99,235,.15);
    --cyan: #0891b2;
    --cyan-glow: rgba(8,145,178,.08);
    --pink: #db2777;
    --pink-glow: rgba(219,39,119,.08);

    --shadow-sm: 0 1px 3px rgba(0,0,0,.05);
    --shadow: 0 4px 16px rgba(0,0,0,.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.1);
    --shadow-glow: 0 0 24px rgba(2,132,199,.08);
    --shadow-card: 0 2px 12px rgba(0,0,0,.06);
}

/* Sidebar always stays dark purple */
[data-theme="light"] .sidebar {
    --text: #f0f0f5;
    --text-secondary: rgba(240,240,245,.9);
    --text-muted: rgba(167,139,250,.7);
    --text-dim: rgba(167,139,250,.4);
    --border: rgba(124,58,237,.12);
    --surface2: rgba(124,58,237,.14);
    --glass-border: rgba(255,255,255,.06);
    --accent-dim: rgba(167,139,250,.18);
    background: var(--sidebar-glow), var(--sidebar-gradient);
}
[data-theme="light"] .sidebar .nav-search { background: rgba(0,0,0,.25); border-color: rgba(124,58,237,.2); color: rgba(240,240,245,.45); }
[data-theme="light"] .sidebar .nav-section { color: rgba(167,139,250,.35); }
[data-theme="light"] .sidebar .nav-links li a { color: rgba(200,190,230,.6); }
[data-theme="light"] .sidebar .nav-links li a:hover { color: rgba(240,240,245,.9); background: rgba(124,58,237,.1); }
[data-theme="light"] .sidebar .nav-links li a.active { color: #ede9fe; background: rgba(124,58,237,.2); }
[data-theme="light"] .sidebar .nav-count { background: rgba(124,58,237,.15); color: rgba(167,139,250,.7); }
[data-theme="light"] .sidebar .nav-footer { border-color: rgba(124,58,237,.1); }
[data-theme="light"] .sidebar .nav-user-name { color: #ede9fe; }
[data-theme="light"] .sidebar .logout-link { color: rgba(240,240,245,.55); }
[data-theme="light"] .sidebar .logout-link:hover { color: var(--red); }

/* Light mode content */
[data-theme="light"] body::before { opacity: 0; }
[data-theme="light"] .card { backdrop-filter: none; -webkit-backdrop-filter: none; }
[data-theme="light"] .card:hover { box-shadow: var(--shadow-lg); }
[data-theme="light"] .stat::before { opacity: 0; }
[data-theme="light"] .stat:hover::before { opacity: .7; }
[data-theme="light"] .btn-primary { box-shadow: 0 2px 8px rgba(124,58,237,.2); }
[data-theme="light"] .btn-primary:hover { box-shadow: 0 4px 16px rgba(124,58,237,.25); }
[data-theme="light"] .btn-ghost { background: rgba(124,58,237,.04); }
[data-theme="light"] .form-group input, [data-theme="light"] .form-group select, [data-theme="light"] .form-group textarea,
[data-theme="light"] select {
    background-color: rgba(124,58,237,.03);
    backdrop-filter: none;
    color: var(--text);
    border-color: var(--border);
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236a6a80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 12px 8px !important;
}
[data-theme="light"] select option { background: #fff; color: #1a1a2e; }
[data-theme="light"] thead { background: rgba(124,58,237,.03); }
[data-theme="light"] tbody tr:hover td { background: rgba(124,58,237,.025); }
[data-theme="light"] .flash-success { background: rgba(5,150,105,.06); }
[data-theme="light"] .flash-error { background: rgba(220,38,38,.06); }

/* ── Select ── */
.ui-select, select {
    -webkit-appearance: none !important;
    appearance: none !important;
    background-color: var(--glass) !important;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236a6a80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 12px 8px !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    color: var(--text) !important;
    font-size: 11px !important;
    font-family: var(--font) !important;
    padding: 5px 8px !important;
    padding-right: 30px !important;
    min-height: 30px !important;
}
.ui-select:focus, select:focus { outline: none; border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-dim) !important; }
.ui-select option, select option { color: var(--text) !important; background: var(--surface-solid) !important; }
.ui-select-wide { min-width: 220px !important; }
.ui-select-lg { min-width: 160px !important; }

/* ── Theme Toggle ── */
.theme-toggle {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    background: var(--surface2); border: 1px solid var(--glass-border);
    color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition); padding: 0;
}
.theme-toggle:hover { border-color: var(--border-light); color: var(--text); background: var(--surface3); }

/* ══════════════════════ Reset & Base ══════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
    background: var(--bg); color: var(--text); font-family: var(--font);
    font-size: 14px; line-height: 1.6; overflow-x: hidden;
}
body::before {
    content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(124,58,237,.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(6,182,212,.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(236,72,153,.025) 0%, transparent 40%);
    animation: auroraDrift 30s ease-in-out infinite alternate;
}
@keyframes auroraDrift {
    0%   { transform: translate(0,0) rotate(0deg); }
    100% { transform: translate(-2%,2%) rotate(2deg); }
}
a { color: var(--accent-light); text-decoration: none; transition: var(--transition-fast); }
a:hover { color: var(--text); }
::selection { background: var(--accent); color: #fff; }

/* ══════════════════════ Layout ══════════════════════ */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }
.sidebar {
    width: var(--sidebar-w); background: var(--sidebar-glow), var(--sidebar-gradient);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(124,58,237,.12);
    padding: 0; display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; z-index: 50;
    box-shadow: 8px 0 40px rgba(0,0,0,.5), inset -1px 0 0 rgba(124,58,237,.08);
    transition: width .28s var(--ease);
    overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.content {
    margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px;
    min-height: 100vh; max-width: calc(100vw - var(--sidebar-w));
    position: relative; z-index: 1;
    transition: margin-left .28s var(--ease), max-width .28s var(--ease);
}
.sidebar.collapsed ~ .content,
.content.sidebar-collapsed { margin-left: 64px; max-width: calc(100vw - 64px); }

/* ══════════════════════ Sidebar ══════════════════════ */
.logo {
    padding: 18px 18px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid rgba(124,58,237,.1);
    min-height: 62px; flex-shrink: 0; overflow: hidden;
}
.logo-icon {
    width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--aurora-1); color: #fff; font-size: 13px; font-weight: 900;
    box-shadow: 0 0 20px rgba(124,58,237,.5), 0 4px 12px rgba(0,0,0,.3);
    position: relative; overflow: hidden; cursor: pointer;
    transition: transform .3s var(--ease-spring);
}
.logo-icon::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,.2) 0%, transparent 60%);
}
.logo-icon.wobble { animation: logoWobble .5s var(--ease-spring); }
.logo-text {
    color: var(--text); font-size: 14px; font-weight: 800;
    letter-spacing: -.03em; white-space: nowrap;
}
.logo-sub {
    font-size: 9px; color: rgba(167,139,250,.5); font-weight: 700;
    letter-spacing: .12em; text-transform: uppercase; margin-top: 1px;
}
.sidebar.collapsed .logo { justify-content: center; padding: 18px 0; }
.sidebar.collapsed .logo-text, .sidebar.collapsed .logo-sub, .sidebar.collapsed .nav-search { display: none; }

/* Nav search */
.nav-search {
    display: flex; align-items: center; gap: 8px;
    margin: 10px 10px 4px; padding: 8px 12px;
    background: rgba(0,0,0,.3); border: 1px solid rgba(124,58,237,.18);
    border-radius: var(--radius-sm); color: rgba(240,240,245,.38);
    font-size: 12.5px; cursor: pointer; transition: var(--transition); flex-shrink: 0;
}
.nav-search:hover { border-color: rgba(124,58,237,.38); color: rgba(240,240,245,.7); }
.nav-search kbd {
    margin-left: auto; font-size: 9px; font-weight: 700;
    padding: 2px 5px; border-radius: 4px;
    background: rgba(124,58,237,.12); border: 1px solid rgba(124,58,237,.22);
    font-family: var(--font); color: rgba(167,139,250,.7);
}

/* Nav links */
.nav-links { list-style: none; flex: 1; padding: 6px 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-section {
    font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
    color: rgba(167,139,250,.35); padding: 16px 18px 5px; list-style: none; white-space: nowrap;
}
.sidebar.collapsed .nav-section { height: 10px; padding: 0; overflow: hidden; }
.nav-links li a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px 9px 14px; margin: 1px 8px;
    color: rgba(200,190,230,.58); text-decoration: none; font-size: 13px; font-weight: 475;
    border-radius: var(--radius-sm); transition: var(--transition);
    position: relative; overflow: hidden; white-space: nowrap;
    border-left: 2px solid transparent;
}
.sidebar.collapsed .nav-links li a { justify-content: center; padding: 9px 0; margin: 1px 6px; }
.sidebar.collapsed .nav-links li a span.nav-label, .sidebar.collapsed .nav-count, .sidebar.collapsed .nav-badge { display: none; }
.nav-links li a svg { flex-shrink: 0; opacity: .55; transition: opacity .2s; }
.nav-links li a:hover { color: rgba(220,210,250,.9); background: rgba(124,58,237,.1); }
.nav-links li a:hover svg { opacity: 1; }
.nav-links li a.active {
    color: #ede9fe; background: rgba(124,58,237,.18);
    border-left-color: #9f7aea; font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(124,58,237,.18);
}
.sidebar.collapsed .nav-links li a.active { border-left-color: transparent; }
.nav-links li a.active svg { opacity: 1; }
.nav-count {
    margin-left: auto; font-size: 10px; font-weight: 600;
    background: rgba(124,58,237,.14); color: rgba(167,139,250,.7);
    padding: 1px 7px; border-radius: 100px;
}
.nav-badge {
    margin-left: auto; font-size: 9.5px; font-weight: 800;
    background: rgba(124,58,237,.3); color: #d8b4fe;
    padding: 2px 7px; border-radius: 100px; letter-spacing: .02em;
}
.nav-links li a.active .nav-count { background: rgba(124,58,237,.2); color: #c4b5fd; }

/* Nav footer */
.nav-footer {
    padding: 10px 8px 12px; border-top: 1px solid rgba(124,58,237,.1);
    display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
    background: rgba(124,58,237,.03);
}
.sidebar-collapse-btn {
    display: flex; align-items: center; justify-content: flex-end;
    padding: 5px 8px; cursor: pointer; border-radius: 6px;
    color: rgba(167,139,250,.35); transition: all .15s; background: none; border: none;
    font-family: var(--font); width: 100%;
}
.sidebar.collapsed .sidebar-collapse-btn { justify-content: center; }
.sidebar-collapse-btn:hover { color: rgba(167,139,250,.8); background: rgba(124,58,237,.08); }
.nav-user { display: flex; align-items: center; gap: 10px; }
.sidebar.collapsed .nav-user { justify-content: center; }
.sidebar.collapsed .nav-user-info { display: none; }
.nav-user-avatar {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; position: relative;
    background: var(--aurora-1); display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800; color: #fff;
    box-shadow: 0 0 12px rgba(124,58,237,.4);
}
.nav-user-info { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.nav-user-name { font-size: 13px; font-weight: 600; color: #ede9fe; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-link { font-size: 11px; color: rgba(240,240,245,.5); transition: var(--transition-fast); }
.logout-link:hover { color: var(--red); }

/* Pulse dot — for online status */
.pulse-dot { position: relative; display: inline-block; }
.pulse-dot::before {
    content: ''; position: absolute; inset: -1px; border-radius: 50%;
    background: currentColor; opacity: .3;
    animation: pulseDot 2s ease-out infinite;
}
@keyframes pulseDot {
    0% { transform: scale(1); opacity: .4; }
    80%, 100% { transform: scale(2.2); opacity: 0; }
}

/* ══════════════════════ Page Header ══════════════════════ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px; padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.page-header::after {
    content: ''; position: absolute; bottom: -1px; left: 0; width: 60px; height: 2px;
    background: linear-gradient(90deg, #7c3aed, #06b6d4); border-radius: 2px;
}
.page-header h1 {
    font-size: 22px; font-weight: 900; letter-spacing: -.04em; color: var(--text);
}
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-time { font-size: 11px; color: var(--text-dim); font-weight: 500; font-family: var(--mono); letter-spacing: .04em; }

/* ══════════════════════ Flash Messages ══════════════════════ */
.flash {
    padding: 12px 18px; border-radius: var(--radius); margin-bottom: 20px;
    font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 10px;
    animation: flashIn .35s var(--ease-spring);
}
@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } }
.flash-success { background: var(--green-glow); border: 1px solid var(--green-border); color: var(--green); }
.flash-error   { background: var(--red-glow);   border: 1px solid var(--red-border);   color: var(--red);   }

/* ══════════════════════ Cards ══════════════════════ */
.card {
    background: var(--surface); border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg); padding: 0; margin-bottom: 20px;
    overflow: hidden; box-shadow: var(--shadow-card); transition: var(--transition);
    position: relative;
}
.card:hover { border-color: var(--border-light); box-shadow: var(--shadow-lg), var(--shadow-glow); transform: translateY(-2px); }
.card-header {
    font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    padding: 13px 20px; border-bottom: 1px solid var(--border);
    background: var(--glass-highlight); color: var(--text-muted);
    display: flex; align-items: center; gap: 10px; justify-content: space-between;
}
.card-header-action { font-size: 12px; color: var(--accent-light); font-weight: 600; cursor: pointer; text-transform: none; letter-spacing: 0; }
.card > table { margin: 0; }
.card > .table-wrap { margin: 0; }
.card > form { padding: 22px; }

/* ══════════════════════ Stat Cards ══════════════════════ */
.stats {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
    gap: 12px; margin-bottom: 28px;
}
.stat {
    background: var(--surface); border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg); padding: 18px 20px;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-sm); transition: var(--transition);
    cursor: default;
}
/* Colored top accent per stat — set via inline style or nth-child */
.stat::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--aurora-1); opacity: 0; transition: opacity .25s;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat:hover { border-color: var(--border-light); transform: translateY(-3px); box-shadow: var(--shadow), var(--shadow-glow); }
.stat:hover::before { opacity: 1; }
.stat .n {
    font-size: 32px; font-weight: 900; letter-spacing: -.05em; line-height: 1;
    color: var(--text); font-variant-numeric: tabular-nums;
}
.stat .l {
    font-size: 9.5px; color: var(--text-dim); margin-top: 8px;
    text-transform: uppercase; letter-spacing: .12em; font-weight: 700;
}
.stat .trend {
    display: flex; align-items: center; gap: 4px; margin-top: 6px;
    font-size: 11px; font-weight: 700;
}
.stat .trend.up { color: var(--green); }
.stat .trend.down { color: var(--red); }
.stat .trend-label { font-size: 10px; color: var(--text-dim); font-weight: 500; }

/* Staggered entrance */
.stat { animation: statIn .45s var(--ease-out) forwards; opacity: 1; }
.stat:nth-child(1) { animation-delay: .03s; }
.stat:nth-child(2) { animation-delay: .07s; }
.stat:nth-child(3) { animation-delay: .11s; }
.stat:nth-child(4) { animation-delay: .15s; }
.stat:nth-child(5) { animation-delay: .19s; }
.stat:nth-child(6) { animation-delay: .23s; }
@keyframes statIn {
    from { transform: translateY(10px); opacity: .5; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ══════════════════════ Tables ══════════════════════ */
.table-wrap { width: 100%; overflow-x: auto; }
.table-wrap::-webkit-scrollbar { height: 4px; }
.table-wrap::-webkit-scrollbar-thumb { background: rgba(124,58,237,.18); border-radius: 100px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: rgba(124,58,237,.04); }
th {
    text-align: left; padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim); font-size: 9.5px; text-transform: uppercase;
    letter-spacing: .1em; font-weight: 700; vertical-align: middle; white-space: nowrap;
}
td { padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr { transition: var(--transition-fast); }
tbody tr:hover td { background: rgba(124,58,237,.04); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 rgba(124,58,237,.4); }
td strong { font-weight: 600; color: var(--text); }
.data-table { table-layout: auto; }
.data-table-wide { min-width: 900px; }
.data-table th, .data-table td { padding: 11px 14px; }
.data-table th:first-child, .data-table td:first-child { padding-left: 18px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 18px; }
.data-table th.col-actions, .data-table td.col-actions { text-align: right; white-space: nowrap; }
.cell-stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cell-primary { font-weight: 600; color: var(--text); min-width: 0; }
.cell-secondary { font-size: 11px; color: var(--text-dim); min-width: 0; }
.cell-muted { color: var(--text-dim); }
.cell-date { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.cell-mono { font-family: var(--mono); font-size: 11px; }
.cell-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.cell-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }
.cell-inline { display: inline-flex; align-items: center; gap: 8px; }

/* ══════════════════════ Badges ══════════════════════ */
.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
    border-radius: 100px; font-size: 10.5px; font-weight: 700;
    letter-spacing: .02em; white-space: nowrap; transition: var(--transition-fast);
}
.badge:hover { transform: scale(1.04); }
.badge-ok    { background: var(--green-glow);  color: var(--green);  border: 1px solid var(--green-border); }
.badge-err   { background: var(--red-glow);    color: var(--red);    border: 1px solid var(--red-border); }
.badge-warn  { background: var(--yellow-glow); color: var(--yellow); border: 1px solid var(--yellow-border); }
.badge-hmac  { background: var(--cyan-glow);   color: var(--cyan);   border: 1px solid rgba(6,182,212,.2); }
.badge-purple{ background: var(--accent-dim);  color: var(--accent-light); border: 1px solid rgba(124,58,237,.22); }

/* Integration badge (named, not dots) */
.int-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10px; font-weight: 700; padding: 3px 8px;
    border-radius: 6px; letter-spacing: .03em;
}
.int-badge-dot {
    width: 5px; height: 5px; border-radius: 50%;
    display: inline-block; flex-shrink: 0;
    position: relative;
}
.int-badge-dot.live::after {
    content: ''; position: absolute; inset: -1px; border-radius: 50%;
    background: currentColor; opacity: .3;
    animation: pulseDot 2s ease-out infinite;
}

/* ══════════════════════ Buttons ══════════════════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
    font-family: var(--font); text-decoration: none; cursor: pointer;
    border: 1px solid transparent; transition: var(--transition); white-space: nowrap;
    position: relative; overflow: hidden;
}
.btn-primary {
    background: var(--accent); color: #fff; border-color: rgba(139,92,246,.4);
    box-shadow: 0 2px 12px rgba(124,58,237,.3), inset 0 1px 0 rgba(255,255,255,.1);
}
.btn-primary:hover {
    background: var(--accent-hover); color: #fff;
    box-shadow: 0 4px 20px rgba(124,58,237,.45), 0 0 40px rgba(124,58,237,.12);
    transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(0); }
.btn-sm { padding: 5px 13px; font-size: 12px; }
.btn-danger { background: var(--red-glow); color: var(--red); border: 1px solid var(--red-border); }
.btn-danger:hover { background: var(--red); color: #fff; box-shadow: 0 4px 20px rgba(239,68,68,.3); }
.btn-ghost {
    background: var(--glass); color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-light); background: var(--surface2); box-shadow: var(--shadow-sm); }

/* ══════════════════════ Forms ══════════════════════ */
input[type="text"], input[type="search"], input[type="number"], input[type="email"],
input[type="url"], input[type="password"], input[type="date"],
input[type="datetime-local"], input[type="time"], textarea {
    padding: 5px 8px; background: var(--glass); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text); font-size: 12px; font-family: var(--font); transition: var(--transition);
}
input:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-group { margin-bottom: 20px; padding: 0 22px; }
.form-group label {
    display: block; font-size: 11px; font-weight: 700; color: var(--text-muted);
    margin-bottom: 7px; text-transform: uppercase; letter-spacing: .06em;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 11px 14px; background: rgba(0,0,0,.25);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-size: 14px; font-family: var(--font); transition: var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-dim); }
.form-group textarea { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: 12px; }
.form-group .desc { font-size: 12px; color: var(--text-dim); margin-top: 5px; line-height: 1.5; }
.form-group select {
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236a6a80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px; padding-right: 38px;
}
.form-group input[type="checkbox"] { width: auto; margin-right: 8px; accent-color: var(--accent); }

/* ══════════════════════ Code ══════════════════════ */
code, .mono { font-family: var(--mono); font-size: 12px; }
pre {
    background: rgba(0,0,0,.3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px; overflow-x: auto;
    font-size: 12px; line-height: 1.7;
}

/* ══════════════════════ Grid & Utilities ══════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.actions { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }

/* ══════════════════════ Metric Grid (Client Portal) ══════════════════════ */
.metric-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
    gap: 12px; margin-bottom: 28px;
}
.metric-card {
    background: var(--surface); border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg); padding: 22px 20px;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-card); transition: var(--transition);
}
.metric-card:hover {
    border-color: var(--border-light);
    transform: translateY(-3px); box-shadow: var(--shadow-lg);
}
.metric-card .value {
    font-size: 38px; font-weight: 900; letter-spacing: -.05em; margin-bottom: 5px;
    font-variant-numeric: tabular-nums;
}
.metric-card .label {
    font-size: 9.5px; color: var(--text-dim); text-transform: uppercase;
    letter-spacing: .12em; font-weight: 700;
}
.metric-card .trend-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11px; font-weight: 700; padding: 2px 7px;
    border-radius: 100px; margin-top: 8px;
}
.metric-card .trend-badge.up   { background: rgba(16,185,129,.1);  color: var(--green); }
.metric-card .trend-badge.down { background: rgba(239,68,68,.1);   color: var(--red); }

/* ══════════════════════ Client Portal — Topbar ══════════════════════ */
.client-shell { min-height: 100vh; background: var(--bg); }
.client-topbar {
    display: flex; align-items: center; gap: 0; padding: 0 26px; height: 56px;
    background: var(--surface); backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 0 1px 24px rgba(0,0,0,.2);
    position: sticky; top: 0; z-index: 50;
}
.client-brand { display: flex; align-items: center; gap: 10px; margin-right: 28px; flex-shrink: 0; }
.client-brand-logo {
    width: 28px; height: 28px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 900; flex-shrink: 0;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    color: #fff; box-shadow: 0 0 14px rgba(124,58,237,.4);
}
.client-brand-name { font-size: 14px; font-weight: 800; letter-spacing: -.03em; color: var(--text); }
.client-topbar-nav { display: flex; gap: 0; flex: 1; overflow: hidden; }
.client-topbar-nav a {
    display: flex; align-items: center; padding: 0 13px; height: 56px;
    font-size: 13px; font-weight: 500; color: var(--text-dim); text-decoration: none;
    border-bottom: 2px solid transparent; transition: var(--transition-fast);
    white-space: nowrap; flex-shrink: 0;
}
.client-topbar-nav a:hover { color: var(--text-secondary); }
.client-topbar-nav a.active {
    color: var(--accent); font-weight: 700;
    border-bottom-color: var(--accent);
}
.client-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Named integration badges */
.client-integrations { display: flex; gap: 5px; align-items: center; }
.client-int-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
    border: 1px solid transparent; letter-spacing: .03em; transition: var(--transition-fast);
}
.client-int-badge.connected { cursor: default; }
.client-int-badge.disconnected { opacity: .3; }

.client-main { padding: 26px 28px 60px; max-width: 1400px; margin: 0 auto; }
.client-page-title {
    font-size: 22px; font-weight: 900; letter-spacing: -.04em;
    color: var(--text); margin-bottom: 4px;
}
.client-page-subtitle { font-size: 13px; color: var(--text-dim); margin-bottom: 24px; }

/* Section headers */
.section-header {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
    color: var(--text-dim); margin: 26px 0 12px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.section-header:first-child { margin-top: 0; }
.section-header::before {
    content: ''; display: inline-block; width: 3px; height: 12px;
    background: var(--accent); border-radius: 2px; margin-right: 8px; vertical-align: middle;
}

/* ══════════════════════ Command Palette ══════════════════════ */
.cmd-palette {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: flex-start; justify-content: center; padding-top: 14vh;
    background: rgba(4,3,15,.75); backdrop-filter: blur(10px);
    opacity: 0; visibility: hidden; transition: all .18s var(--ease);
}
.cmd-palette.open { opacity: 1; visibility: visible; }
.cmd-box {
    width: 100%; max-width: 560px;
    background: rgba(14,10,32,.98); border: 1px solid rgba(124,58,237,.22);
    border-radius: 16px; overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,.7), 0 0 80px rgba(124,58,237,.08);
    transform: scale(.95) translateY(-8px); transition: transform .22s var(--ease-spring);
}
.cmd-palette.open .cmd-box { transform: scale(1) translateY(0); }
.cmd-input-wrap {
    display: flex; align-items: center; gap: 12px; padding: 14px 18px;
    border-bottom: 1px solid rgba(124,58,237,.12);
}
.cmd-input-wrap svg { color: rgba(167,139,250,.5); flex-shrink: 0; }
.cmd-input-wrap input {
    flex: 1; background: none; border: none; outline: none;
    color: #ede9fe; font-size: 15px; font-family: var(--font);
}
.cmd-input-wrap input::placeholder { color: rgba(167,139,250,.35); }
.cmd-input-wrap kbd {
    font-size: 10px; padding: 3px 8px; border-radius: 5px;
    background: rgba(124,58,237,.12); border: 1px solid rgba(124,58,237,.2);
    color: rgba(167,139,250,.6); font-family: var(--font); font-weight: 600;
}
.cmd-results { max-height: 380px; overflow-y: auto; padding: 6px; }
.cmd-group {
    font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
    color: rgba(167,139,250,.35); padding: 12px 12px 5px;
}
.cmd-item {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px;
    border-radius: 9px; color: rgba(200,190,230,.75); text-decoration: none;
    transition: var(--transition-fast); cursor: pointer;
}
.cmd-item:hover { background: rgba(124,58,237,.14); color: #ede9fe; }
.cmd-item svg { flex-shrink: 0; opacity: .5; }
.cmd-item:hover svg { opacity: 1; }
.cmd-item span:first-of-type { flex: 1; font-size: 13.5px; font-weight: 500; }
.cmd-hint { font-size: 11px; color: rgba(167,139,250,.4); }

/* ══════════════════════ Scrollbar ══════════════════════ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,58,237,.2); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,58,237,.4); }

/* ══════════════════════ Animations ══════════════════════ */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: .4; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse   { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes logoWobble { 0% { transform: rotate(0); } 25% { transform: rotate(-10deg) scale(1.1); } 50% { transform: rotate(8deg); } 75% { transform: rotate(-5deg); } 100% { transform: rotate(0); } }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes rainbowGlow {
    0%   { filter: hue-rotate(0deg)   drop-shadow(0 0 8px #7c3aed); }
    100% { filter: hue-rotate(360deg) drop-shadow(0 0 8px #06b6d4); }
}
@keyframes flashOut { to { opacity: 0; max-height: 0; padding: 0; margin: 0; overflow: hidden; } }

.page-body { animation: slideUp .38s var(--ease-out) forwards; opacity: 1; }
.card { animation: slideUp .35s var(--ease) forwards; opacity: 1; }

/* Stat hover: gradient number shimmer */
.stat:hover .n {
    background: var(--aurora-1); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; background-size: 200% 200%; animation: gradientShift 2.5s ease infinite;
}

/* Live indicator on badge-ok */
.badge-ok::before {
    content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
    background: var(--green); animation: pulse 2s ease-in-out infinite;
}

/* Flash auto-dismiss */
.flash { animation: flashIn .35s var(--ease-spring), flashOut .5s var(--ease) 4.5s forwards; }

/* Konami */
.konami-active .logo-icon { animation: rainbowGlow 2s linear infinite; }
.konami-active .page-header h1 {
    background: var(--aurora-1) !important; background-size: 200% 200% !important;
    -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important;
    animation: gradientShift 3s ease infinite !important;
}

/* ══════════════════════ Report Documents ══════════════════════ */
.report-document-body { background: linear-gradient(180deg,#f6f7fb 0%,#eef2ff 100%); color: #111827; }
.report-document-shell { max-width: 1120px; margin: 0 auto; padding: 28px 24px 72px; }
.report-screen-bar { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; align-items: start; margin-bottom: 24px; }
.report-screen-actions, .report-period-tabs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.report-screen-actions { justify-content: flex-end; }
.report-period-tabs { grid-column: 1/-1; justify-content: flex-start; }
.report-period-tab { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.75); color: var(--text-muted); font-size: 11px; font-weight: 700; text-decoration: none; }
.report-period-tab.is-active { background: var(--accent); border-color: transparent; color: #fff; }
.report-document { display: grid; gap: 22px; }
.report-cover { padding: 32px !important; background: radial-gradient(circle at top right,rgba(124,58,237,.12),transparent 34%), linear-gradient(135deg,rgba(6,182,212,.08),rgba(124,58,237,.06)), var(--surface); }
.report-cover-brand { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.report-cover-logo { width: 58px; height: 58px; min-width: 58px; max-width: 58px; flex: 0 0 58px; display: block; object-fit: contain; border-radius: 16px; box-shadow: 0 8px 24px rgba(124,58,237,.16); }
.report-eyebrow, .report-meta-label { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--text-dim); }
.report-title { margin: 8px 0 10px; font-size: 34px; font-weight: 900; letter-spacing: -.045em; color: var(--text); }
.report-subtitle { max-width: 720px; font-size: 15px; line-height: 1.7; color: var(--text-secondary); }
.report-trust-note, .report-meta-detail { display: block; margin-top: 8px; font-size: 12px; line-height: 1.6; color: var(--text-dim); }
.report-meta-grid, .report-summary-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 12px; }
.report-meta-card, .report-summary-card, .report-notes-card { padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--border); background: rgba(255,255,255,.72); }
.report-meta-card strong { display: block; margin-top: 6px; font-size: 16px; color: var(--text); }
.report-summary-card p { margin-top: 8px; color: var(--text-secondary); line-height: 1.7; }
.report-section { display: grid; gap: 14px; }
.report-table-card { padding: 0 !important; }
.report-metric-grid { grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); }
.report-note-list { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--text-secondary); line-height: 1.65; }
.report-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 20px 6px 0; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 12px; }

/* ══════════════════════ Print ══════════════════════ */
@media print {
    body { background: #fff !important; color: #000 !important; }
    body::before { display: none !important; }
    .sidebar, .client-topbar, .client-topbar-nav, .nav-search, .nav-footer,
    .theme-toggle, .header-actions, .actions, .btn, #report-actions,
    .cmd-palette { display: none !important; }
    .content, .client-main { margin-left: 0 !important; padding: 0 !important; max-width: 100% !important; }
    .app { display: block !important; }
    .card, .stat, .metric-card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; backdrop-filter: none !important; background: #fff !important; }
    .card:hover, .stat:hover, .metric-card:hover { transform: none !important; box-shadow: none !important; }
    table { font-size: 11px !important; }
    thead { display: table-header-group !important; }
    th, td { padding: 6px 10px !important; }
    .badge { border: 1px solid #999 !important; }
    .report-document-body { background: #fff !important; color: #000 !important; }
    .report-document-shell { max-width: 100% !important; padding: 0 !important; }
    .report-cover, .report-meta-card, .report-summary-card, .report-notes-card { background: #fff !important; box-shadow: none !important; border: 1px solid #ddd !important; }
    .report-section, .report-cover, .report-table-card, .report-notes-card { break-inside: avoid; }
    a { color: #333 !important; text-decoration: none !important; }
    * { animation: none !important; transition: none !important; }
    @page { margin: 1.5cm; size: A4; }
}

/* ══════════════════════ Mobile ══════════════════════ */
.mobile-menu-btn { display: none; }
.mobile-overlay  { display: none; }
@media (max-width: 1024px) {
    .content { padding: 22px 18px; }
    .grid-2 { grid-template-columns: 1fr; }
    .stat .n { font-size: 26px; }
}
@media (max-width: 768px) {
    .sidebar { position: fixed; left: -280px; transition: left .28s var(--ease); z-index: 100; }
    .sidebar.mobile-open { left: 0; }
    .content { margin-left: 0; padding: 16px 14px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2,1fr); }
    .metric-grid { grid-template-columns: repeat(2,1fr); gap: 10px; }
    .metric-card { padding: 16px; }
    .metric-card .value { font-size: 26px; }
    .stat .n { font-size: 22px; }
    .client-topbar { padding: 0 16px; }
    .client-topbar-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .client-main { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .page-header .header-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
    .mobile-menu-btn {
        display: flex; width: 34px; height: 34px; border-radius: var(--radius-sm);
        background: var(--glass); border: 1px solid var(--glass-border);
        align-items: center; justify-content: center; cursor: pointer;
        color: var(--text-muted); font-size: 18px; margin-right: 8px;
    }
    .mobile-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; display: none; }
    .mobile-overlay.active { display: block; }
    .report-screen-bar { grid-template-columns: 1fr; }
    .report-title { font-size: 26px; }
}
