/* ================================================================
   SCULPTORS PMO — Design System
   Orange / Black / White with Omani-business sophistication
   ================================================================ */

:root {
    /* Brand */
    --orange: #FF6B1C;
    --orange-dark: #E8560E;
    --orange-light: #FF8947;
    --orange-50: #FFF4EC;
    --orange-100: #FFE4D1;
    --orange-glow: rgba(255, 107, 28, 0.35);

    /* Neutrals */
    --black: #0A0A0B;
    --ink: #1A1A1C;
    --ink-2: #242427;
    --ink-3: #2F2F33;
    --slate: #4A4A52;
    --mute: #8B8B93;
    --line: #E6E6EA;
    --line-2: #F0F0F3;
    --paper: #FAFAFB;
    --white: #FFFFFF;

    /* Semantic */
    --green: #16A34A;
    --green-bg: #E7F8ED;
    --red: #DC2626;
    --red-bg: #FDECEC;
    --amber: #F59E0B;
    --amber-bg: #FEF5E7;
    --blue: #2563EB;
    --blue-bg: #E7F0FE;
    --purple: #7C3AED;
    --purple-bg: #F0E7FE;

    /* Chart palette */
    --c1: #FF6B1C;
    --c2: #0A0A0B;
    --c3: #2563EB;
    --c4: #16A34A;
    --c5: #F59E0B;
    --c6: #7C3AED;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(10,10,11,0.04), 0 1px 3px rgba(10,10,11,0.06);
    --shadow-md: 0 4px 6px -1px rgba(10,10,11,0.06), 0 2px 4px -1px rgba(10,10,11,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(10,10,11,0.08), 0 4px 6px -2px rgba(10,10,11,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(10,10,11,0.10), 0 10px 10px -5px rgba(10,10,11,0.04);
    --shadow-orange: 0 10px 30px -10px rgba(255, 107, 28, 0.45);

    /* Motion */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --sidebar-w: 272px;
    --topbar-h: 64px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

/* Dark mode overrides — triggered by data-theme="dark" on <html> */
html[data-theme="dark"] {
    --ink: #E6E6EA;
    --ink-2: #D4D4D8;
    --ink-3: #B8B8BE;
    --slate: #9A9AA2;
    --mute: #6C6C74;
    --line: #26262A;
    --line-2: #1E1E22;
    --paper: #0F0F11;
    --white: #16161A;
    --black: #FFFFFF;
    --green-bg: #0F2A1A;
    --amber-bg: #2A1F0A;
    --red-bg: #2A1010;
    --blue-bg: #0A1A2A;
    --purple-bg: #1A0F2A;
    --orange-50: #2A1A0A;
    --orange-100: #3A2210;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.6);
}
html[data-theme="dark"] body { background: #0F0F11; color: #E6E6EA; }
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .rag-card,
html[data-theme="dark"] .notification-panel,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .drawer,
html[data-theme="dark"] .project-card,
html[data-theme="dark"] .report-template,
html[data-theme="dark"] .wi-controls,
html[data-theme="dark"] .wi-ripple,
html[data-theme="dark"] .wi-impact,
html[data-theme="dark"] .ew-card,
html[data-theme="dark"] .risk-breakdown,
html[data-theme="dark"] .chat-sidebar,
html[data-theme="dark"] .chat-main,
html[data-theme="dark"] .chat-insights,
html[data-theme="dark"] .doc-view,
html[data-theme="dark"] .anomaly-card,
html[data-theme="dark"] .toast,
html[data-theme="dark"] .cmd-panel,
html[data-theme="dark"] .ripple-node,
html[data-theme="dark"] .chat-input-wrap,
html[data-theme="dark"] .search-box,
html[data-theme="dark"] .user-menu-panel,
html[data-theme="dark"] kbd { background: #16161A; color: #E6E6EA; border-color: #26262A; }
html[data-theme="dark"] .data-table th { background: #1A1A1E; color: #9A9AA2; }
html[data-theme="dark"] .data-table tbody tr:hover { background: #1A1A1E; }
html[data-theme="dark"] .btn-outline { background: #16161A; color: #E6E6EA; border-color: #2A2A30; }
html[data-theme="dark"] .btn-outline:hover { background: #1E1E22; border-color: #E6E6EA; color: #FFFFFF; }
html[data-theme="dark"] .chip { background: #16161A; color: #9A9AA2; border-color: #26262A; }
html[data-theme="dark"] .chip:hover { color: #FFFFFF; border-color: #FFFFFF; }
html[data-theme="dark"] .chip.active { background: #FF6B1C; color: white; border-color: #FF6B1C; }
html[data-theme="dark"] .btn-primary { background: #FF6B1C; color: white; }
html[data-theme="dark"] .btn-primary:hover { background: #E8560E; }
html[data-theme="dark"] .msg-bubble { background: #16161A; color: #E6E6EA; border-color: #26262A; }
html[data-theme="dark"] .chat-msg.user .msg-bubble { background: #FF6B1C; color: white; border-color: #FF6B1C; }
html[data-theme="dark"] .chat-body { background: #0F0F11; }
html[data-theme="dark"] .chat-head, html[data-theme="dark"] .chat-footer { background: #16161A; border-color: #26262A; }
html[data-theme="dark"] .splash-brand { color: #FF6B1C; }
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3, html[data-theme="dark"] h4, html[data-theme="dark"] h5 { color: #FFFFFF; }
html[data-theme="dark"] .wi-impact-after, html[data-theme="dark"] .kpi-value { color: #FFFFFF; }
html[data-theme="dark"] .doc-brand-sub, html[data-theme="dark"] .text-mute { color: #6C6C74; }
html[data-theme="dark"] .text-slate { color: #9A9AA2; }

/* === Dark-mode refinement pass === */
html[data-theme="dark"] body { background: #0A0A0B; }
html[data-theme="dark"] .main { background: #0A0A0B; }
html[data-theme="dark"] .sidebar { background: #060607; border-right: 1px solid #1A1A1C; }
html[data-theme="dark"] .sidebar-header { border-bottom-color: #1A1A1C; }

/* Cards: deeper surfaces + subtle gradient instead of flat */
html[data-theme="dark"] .card,
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .rag-card,
html[data-theme="dark"] .notification-panel,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .drawer,
html[data-theme="dark"] .project-card,
html[data-theme="dark"] .report-template,
html[data-theme="dark"] .wi-controls,
html[data-theme="dark"] .wi-ripple,
html[data-theme="dark"] .wi-impact,
html[data-theme="dark"] .ew-card,
html[data-theme="dark"] .risk-breakdown,
html[data-theme="dark"] .chat-sidebar,
html[data-theme="dark"] .chat-main,
html[data-theme="dark"] .chat-insights,
html[data-theme="dark"] .anomaly-card,
html[data-theme="dark"] .toast,
html[data-theme="dark"] .cmd-panel,
html[data-theme="dark"] .ripple-node,
html[data-theme="dark"] .user-menu-panel {
    background: #15151A;
    border-color: #26262A;
    box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
html[data-theme="dark"] .doc-view {
    background: #15151A;
    border-color: #26262A;
}

/* Table headers subtle */
html[data-theme="dark"] .data-table th { background: #0F0F13; border-bottom-color: #1F1F23; color: #8B8B93; }
html[data-theme="dark"] .data-table td { border-bottom-color: #1F1F23; }
html[data-theme="dark"] .data-table tbody tr:hover { background: #1A1A1F; }

/* Report thumbnails — swap the light-to-white gradient for a theme-aware one */
html[data-theme="dark"] .report-thumb {
    background: linear-gradient(135deg, #0F0F13, #15151A);
    border-bottom-color: #26262A;
}
html[data-theme="dark"] .report-thumb::before {
    background: linear-gradient(135deg, rgba(255,107,28,0.12), transparent);
}
html[data-theme="dark"] .report-thumb-lines div { background: #2A2A30; }
html[data-theme="dark"] .report-thumb-lines div:nth-child(1) { background: #E6E6EA; }
html[data-theme="dark"] .report-tpl-foot { border-top-color: #1F1F23; }

/* Geo map (Oman) — invert surface */
html[data-theme="dark"] .geo-map { background: linear-gradient(135deg, #0F0F13, #15151A); }
html[data-theme="dark"] .geo-map path { stroke: #2A2A30; fill: #1A1A1F; }

/* KPI accent strips */
html[data-theme="dark"] .kpi::before { background: #1F1F23; }
html[data-theme="dark"] .kpi.accent::before { background: var(--orange); }
html[data-theme="dark"] .kpi.success::before { background: var(--green); }
html[data-theme="dark"] .kpi.warn::before { background: var(--amber); }
html[data-theme="dark"] .kpi.danger::before { background: var(--red); }

/* Backgrounds that were hardcoded */
html[data-theme="dark"] .card-tight[style*="background:var(--paper)"],
html[data-theme="dark"] [style*="background:var(--paper)"] { background: #1A1A1F !important; }
html[data-theme="dark"] [style*="background: var(--paper)"] { background: #1A1A1F !important; }

/* Linear gradients that use white */
html[data-theme="dark"] .title-badge { background: linear-gradient(135deg, #2A1A0A, #15151A); border-color: #3A2210; color: #FF8947; }
html[data-theme="dark"] .forecast-hero { background: linear-gradient(135deg, #15151A, #0F0F13); border: 1px solid #26262A; }

/* Chat bubble + msg table */
html[data-theme="dark"] .msg-table { border-color: #26262A; }
html[data-theme="dark"] .msg-table th { background: #1A1A1F; color: #E6E6EA; }
html[data-theme="dark"] .msg-table td { border-bottom-color: #26262A; }
html[data-theme="dark"] .msg-citation { background: #1A1A1F; color: #9A9AA2; }
html[data-theme="dark"] .doc-ai-note { background: linear-gradient(90deg, #2A1A0A, transparent) !important; color: #E6E6EA; }

/* Form inputs */
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea {
    background: #15151A;
    color: #E6E6EA;
    border-color: #26262A;
}
html[data-theme="dark"] input::placeholder { color: #6C6C74; }

/* Timeline (Gantt pipeline) */
html[data-theme="dark"] .timeline-wrap { background: transparent; }
html[data-theme="dark"] .timeline-head { background: #0F0F13; border-bottom-color: #26262A; color: #9A9AA2; }
html[data-theme="dark"] .timeline-head .months span { border-left-color: #1F1F23; }
html[data-theme="dark"] .timeline-head .proj-h { color: #9A9AA2; }
html[data-theme="dark"] .timeline-row { border-bottom-color: #1F1F23; background: transparent; }
html[data-theme="dark"] .timeline-row:hover { background: rgba(255,255,255,0.03); }
html[data-theme="dark"] .timeline-proj .proj-name { color: #FFFFFF; }
html[data-theme="dark"] .timeline-proj .proj-meta { color: #8B8B93; }
html[data-theme="dark"] .timeline-track { background: repeating-linear-gradient(to right, transparent, transparent calc(100% / 12 - 1px), #26262A calc(100% / 12 - 1px), #26262A calc(100% / 12)); }

/* Buttons */
html[data-theme="dark"] .btn-ghost { color: #9A9AA2; }
html[data-theme="dark"] .btn-ghost:hover { background: #1F1F23; color: #FFFFFF; }
html[data-theme="dark"] .pager-btn:hover { background: #1F1F23; color: #FFFFFF; }
html[data-theme="dark"] .pager-btn.active { background: var(--orange); color: #FFFFFF; }
html[data-theme="dark"] .icon-btn { color: #9A9AA2; }
html[data-theme="dark"] .icon-btn:hover { background: #1F1F23; color: #FFFFFF; }

/* Chat body */
html[data-theme="dark"] .chat-body { background: #0A0A0B; }
html[data-theme="dark"] .chat-head { background: #15151A; border-bottom-color: #26262A; }
html[data-theme="dark"] .chat-footer { background: #15151A; border-top-color: #26262A; }
html[data-theme="dark"] .chat-input-wrap { background: #0F0F13; border-color: #26262A; }
html[data-theme="dark"] .chat-input-wrap:focus-within { background: #15151A; }
html[data-theme="dark"] .chat-input { color: #E6E6EA; }

/* Signal/Early warning + anomaly left stripes keep their colour */
html[data-theme="dark"] .ew-card::before { background: var(--amber); }
html[data-theme="dark"] .ew-card.critical::before { background: var(--red); }
html[data-theme="dark"] .anomaly-card::before { background: var(--red); }
html[data-theme="dark"] .anomaly-card.amber::before { background: var(--amber); }

/* Drawer */
html[data-theme="dark"] .drawer-head { border-bottom-color: #26262A; }
html[data-theme="dark"] .drawer-foot { border-top-color: #26262A; background: #0F0F13; }

/* Scrollbar */
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2A2A30; border-color: #0A0A0B; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4A4A52; }

/* kbd */
html[data-theme="dark"] kbd { background: #0F0F13; border-color: #26262A; color: #9A9AA2; }

/* Login panel in dark */
html[data-theme="dark"] .login-form-side { background: #0F0F13; }
html[data-theme="dark"] .login-sso { background: #15151A; border-color: #26262A; color: #E6E6EA; }
html[data-theme="dark"] .login-sso:hover { border-color: #FFFFFF; }

/* Modal headers */
html[data-theme="dark"] .modal-head { border-bottom-color: #26262A; }
html[data-theme="dark"] .modal-foot { border-top-color: #26262A; background: #0F0F13; }

/* Tab bar */
html[data-theme="dark"] .tab-bar { border-bottom-color: #26262A; }
html[data-theme="dark"] .tab-item { color: #9A9AA2; }
html[data-theme="dark"] .tab-item:hover { color: #FFFFFF; }
html[data-theme="dark"] .tab-item .tab-count { background: #1F1F23; color: #9A9AA2; }
html[data-theme="dark"] .tab-item.active .tab-count { background: #3A2210; color: var(--orange); }

/* Avatars retain orange */
html[data-theme="dark"] .user-avatar { background: linear-gradient(135deg, var(--orange), var(--orange-dark)); }

/* Doc-view brand marks */
html[data-theme="dark"] .doc-head { border-bottom-color: #FFFFFF; }
html[data-theme="dark"] .doc-highlight { background: #1A1A1F; border-color: #26262A; }

/* Topbar */
html[data-theme="dark"] .topbar { background: #0F0F13; border-bottom-color: #1F1F23; }
html[data-theme="dark"] .search-box { background: #15151A; border-color: #26262A; }
html[data-theme="dark"] .search-box:focus-within { background: #15151A; }

/* Notification panel */
html[data-theme="dark"] .notif-item { border-bottom-color: #1F1F23; }
html[data-theme="dark"] .notif-item:hover { background: #1A1A1F; }
html[data-theme="dark"] .notif-header { border-bottom-color: #26262A; }
html[data-theme="dark"] .notif-footer { border-top-color: #26262A; }

/* Progress bars + sliders */
html[data-theme="dark"] .wi-slider { background: #2A2A30; }
html[data-theme="dark"] .inline-progress .bar { background: #2A2A30; }
html[data-theme="dark"] .inline-progress .bar::before { background: #FFFFFF; }

/* Ripple nodes */
html[data-theme="dark"] .ripple-node.source { background: linear-gradient(135deg, #2A1A0A, #15151A); }

/* Semantic bgs — dark variants */
html[data-theme="dark"] .badge.green { background: rgba(22,163,74,0.18); color: #4ADE80; }
html[data-theme="dark"] .badge.red { background: rgba(220,38,38,0.18); color: #FCA5A5; }
html[data-theme="dark"] .badge.amber { background: rgba(245,158,11,0.18); color: #FDE68A; }
html[data-theme="dark"] .badge.blue { background: rgba(37,99,235,0.18); color: #93C5FD; }
html[data-theme="dark"] .badge.purple { background: rgba(124,58,237,0.18); color: #C4B5FD; }
html[data-theme="dark"] .badge.gray { background: #1F1F23; color: #9A9AA2; }

html[data-theme="dark"] .risk-pill.green { background: rgba(22,163,74,0.15); color: #4ADE80; }
html[data-theme="dark"] .risk-pill.amber { background: rgba(245,158,11,0.15); color: #FDE68A; }
html[data-theme="dark"] .risk-pill.red { background: rgba(220,38,38,0.15); color: #FCA5A5; }

html[data-theme="dark"] .notif-icon.critical { background: rgba(220,38,38,0.18); color: #FCA5A5; }
html[data-theme="dark"] .notif-icon.warn { background: rgba(245,158,11,0.18); color: #FDE68A; }
html[data-theme="dark"] .notif-icon.info { background: rgba(37,99,235,0.18); color: #93C5FD; }
html[data-theme="dark"] .notif-icon.success { background: rgba(22,163,74,0.18); color: #4ADE80; }

/* Primary button in dark should contrast more */
html[data-theme="dark"] .btn-primary { background: #FFFFFF; color: #0A0A0B; }
html[data-theme="dark"] .btn-primary:hover { background: #E6E6EA; }
html[data-theme="dark"] .btn-orange { background: var(--orange); color: #FFFFFF; }

/* Env chip */
html[data-theme="dark"] .env-chip { background: rgba(22,163,74,0.12); border-color: rgba(22,163,74,0.25); }

/* Hover lifts */
html[data-theme="dark"] .card.hover-lift:hover { background: #1A1A1F; border-color: #3A3A42; }

/* Light-blur accent panels (preset dropdown etc.) */
html[data-theme="dark"] .wi-section[style*="orange-50"] { background: linear-gradient(135deg,#2A1A0A,#15151A) !important; border-color: #3A2210 !important; }

/* Hero panels that use var(--black) backgrounds — force signature dark */
html[data-theme="dark"] .forecast-hero {
    background: linear-gradient(135deg, #0A0A0B 0%, #15151A 100%) !important;
    color: #FFFFFF !important;
}
html[data-theme="dark"] .forecast-hero .fh-h,
html[data-theme="dark"] .forecast-hero .fs-value,
html[data-theme="dark"] .forecast-hero h2 { color: #FFFFFF !important; }
html[data-theme="dark"] .forecast-hero .fs-value small { color: rgba(255,255,255,0.5) !important; }
html[data-theme="dark"] .forecast-hero .fh-label { color: var(--orange) !important; }
html[data-theme="dark"] .forecast-hero .fh-sub { color: rgba(255,255,255,0.6) !important; }
html[data-theme="dark"] .forecast-hero .fs-label { color: rgba(255,255,255,0.5) !important; }
html[data-theme="dark"] .forecast-hero .fs-foot { color: rgba(255,255,255,0.6) !important; }
html[data-theme="dark"] .forecast-hero .fs-chip.up { background: rgba(22,163,74,0.25); color: #4ADE80; }
html[data-theme="dark"] .forecast-hero .fs-chip.down { background: rgba(220,38,38,0.25); color: #FCA5A5; }

/* Login side hero (same issue — uses var(--black) via gradient) */
html[data-theme="dark"] .login-side { background: linear-gradient(135deg, #060607 0%, #15151A 100%) !important; }

/* Splash + sidebar brand text must remain legible */
html[data-theme="dark"] .brand-name { color: #FFFFFF !important; }
html[data-theme="dark"] .env-label { color: #FFFFFF !important; }
html[data-theme="dark"] .user-name { color: #FFFFFF !important; }

/* Doc view in dark should not break black-on-black */
html[data-theme="dark"] .doc-head { border-bottom: 2px solid #FFFFFF; }
html[data-theme="dark"] .doc-title { color: #FFFFFF; }
html[data-theme="dark"] .doc-section h3 { color: #FFFFFF; border-bottom-color: #26262A; }

/* Any inline black color text used contextually */
html[data-theme="dark"] [style*="color:var(--black)"] { color: #FFFFFF !important; }
html[data-theme="dark"] [style*="color: var(--black)"] { color: #FFFFFF !important; }

/* Any inline var(--paper) background containers get the dark panel */
html[data-theme="dark"] [style*="background:var(--orange-50)"] { background: #2A1A0A !important; }
html[data-theme="dark"] [style*="background: var(--orange-50)"] { background: #2A1A0A !important; }

/* Any linear-gradient to white in inline styles — commonly used in badges and cards */
html[data-theme="dark"] [style*="linear-gradient(135deg,var(--orange-50),white)"],
html[data-theme="dark"] [style*="linear-gradient(135deg, var(--orange-50), white)"] {
    background: linear-gradient(135deg, #2A1A0A, #15151A) !important;
}
html[data-theme="dark"] [style*="linear-gradient(135deg,#E7F8ED,white)"] {
    background: linear-gradient(135deg, #0F2A1A, #15151A) !important;
    border-color: rgba(22,163,74,0.3) !important;
}

/* chip hover */
html[data-theme="dark"] .chip:hover { background: #1F1F23; border-color: #FFFFFF; color: #FFFFFF; }

/* Divider */
html[data-theme="dark"] .divider-v { background: #26262A; }

/* Help/question icon */
html[data-theme="dark"] .theme-toggle:hover { background: #1F1F23; }

/* User menu dropdown */
.user-menu { position: relative; cursor: pointer; }
.user-menu-panel {
    position: absolute; top: calc(100% + 10px); right: 0;
    width: 260px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    padding: 8px;
    opacity: 0; pointer-events: none;
    transform: translateY(-8px) scale(0.98);
    transition: all 0.2s var(--ease);
    z-index: 300;
}
.user-menu-panel.open { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.user-menu-head {
    padding: 14px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--line-2);
    margin-bottom: 6px;
}
.user-menu-head .user-avatar { width: 42px; height: 42px; font-size: 14px; }
.um-name { font-size: 14px; font-weight: 700; color: var(--black); }
.um-mail { font-size: 11.5px; color: var(--mute); margin-top: 2px; }
.user-menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--slate);
    cursor: pointer;
    transition: all 0.15s;
}
.user-menu-item:hover { background: var(--paper); color: var(--black); }
.user-menu-item svg { width: 15px; height: 15px; }
.user-menu-sep { height: 1px; background: var(--line-2); margin: 6px 0; }
.user-menu-item.danger { color: var(--red); }
.user-menu-item.danger:hover { background: var(--red-bg); }

/* Theme toggle */
.theme-toggle {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--slate);
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.theme-toggle:hover { background: var(--paper); color: var(--black); }
.theme-toggle svg { width: 18px; height: 18px; transition: transform 0.4s var(--ease), opacity 0.3s; }
.theme-toggle .icon-sun { opacity: 0; transform: rotate(-90deg); position: absolute; }
.theme-toggle .icon-moon { opacity: 1; }
html[data-theme="dark"] .theme-toggle .icon-sun { opacity: 1; transform: rotate(0); position: absolute; }
html[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg); position: absolute; }

/* Login screen */
.login-screen {
    position: fixed; inset: 0;
    display: flex;
    z-index: 500;
    background: var(--paper);
    opacity: 0; pointer-events: none;
    transition: opacity 0.4s var(--ease);
}
.login-screen.open { opacity: 1; pointer-events: auto; }
.login-side {
    flex: 1;
    background: linear-gradient(135deg, #0A0A0B 0%, #1A1A1C 100%);
    position: relative;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 48px;
    color: white;
    overflow: hidden;
}
.login-side::before {
    content: ''; position: absolute;
    top: -100px; right: -100px;
    width: 500px; height: 500px;
    background: radial-gradient(circle, #FF6B1C 0%, transparent 70%);
    opacity: 0.3;
    filter: blur(60px);
    animation: splashOrbit 10s ease-in-out infinite;
}
.login-side::after {
    content: ''; position: absolute;
    bottom: -100px; left: -50px;
    width: 400px; height: 400px;
    background: radial-gradient(circle, #FF6B1C 0%, transparent 70%);
    opacity: 0.2;
    filter: blur(60px);
    animation: splashOrbit 12s ease-in-out infinite reverse;
}
.login-side-content { position: relative; z-index: 2; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 48px; }
.login-brand svg { width: 44px; height: 44px; }
.login-brand-text { line-height: 1.2; }
.login-brand-name { font-size: 14px; letter-spacing: 0.2em; color: #FF6B1C; font-weight: 700; }
.login-brand-sub { font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 4px; }
.login-tagline { font-size: 42px; font-weight: 800; line-height: 1.1; letter-spacing: -0.03em; max-width: 500px; }
.login-tagline span { color: #FF6B1C; }
.login-sub { font-size: 15px; color: rgba(255,255,255,0.6); max-width: 500px; margin-top: 20px; line-height: 1.6; }
.login-features { display: grid; gap: 14px; margin-top: 32px; position: relative; z-index: 2; max-width: 460px; }
.login-feature {
    display: flex; gap: 10px; align-items: flex-start;
    font-size: 13px; color: rgba(255,255,255,0.75);
}
.login-feature svg { width: 16px; height: 16px; color: #FF6B1C; flex-shrink: 0; margin-top: 2px; }
.login-foot { position: relative; z-index: 2; display: flex; justify-content: space-between; font-size: 12px; color: rgba(255,255,255,0.4); }
.login-form-side {
    width: 500px;
    display: flex; align-items: center; justify-content: center;
    padding: 48px;
    background: white;
}
html[data-theme="dark"] .login-form-side { background: #16161A; }
.login-form { width: 100%; max-width: 360px; }
.login-form h2 { font-size: 28px; margin-bottom: 8px; letter-spacing: -0.02em; }
.login-form-sub { font-size: 14px; color: var(--mute); margin-bottom: 32px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--slate); }
.login-field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 14px;
    background: var(--paper);
    outline: none;
    transition: all 0.2s;
}
.login-field input:focus { border-color: var(--orange); background: white; box-shadow: 0 0 0 4px var(--orange-50); }
html[data-theme="dark"] .login-field input { background: #0F0F11; color: #E6E6EA; }
.login-sso {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
    font-size: 13.5px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}
.login-sso:hover { border-color: var(--black); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.login-sso-icon {
    width: 24px; height: 24px; border-radius: 6px;
    background: linear-gradient(135deg, var(--orange), var(--orange-dark));
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 11px; font-weight: 800;
}
.login-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--mute); font-size: 11px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

@keyframes rippleAppear {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

/* Flash a value-after cell when it changes */
.wi-impact-after.flash {
    animation: valFlash 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes valFlash {
    0% { background: var(--orange-50); color: var(--orange-dark); border-radius: 6px; padding: 2px 6px; }
    100% { background: transparent; }
}
html[data-theme="dark"] .wi-impact-after.flash {
    animation: valFlashDark 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes valFlashDark {
    0% { background: #2A1A0A; color: #FF8947; border-radius: 6px; padding: 2px 6px; }
    100% { background: transparent; }
}
.wi-impact { transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.wi-impact-after { transition: color 0.3s; display: inline-block; }

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* Default inline-icon sizing for SVGs that aren't inside a styled component (.btn, .nav-item, etc.).
   Prevents icons from blowing up to container width inside headings/paragraphs. */
h1 > svg, h2 > svg, h3 > svg, h4 > svg, h5 > svg,
p > svg, label > svg,
h1 span > svg, h2 span > svg, h3 span > svg, h4 span > svg,
span.ew-signal svg, .doc-ai-note svg, .msg-citation svg:first-child {
    display: inline-block;
    width: 16px; height: 16px;
    vertical-align: -2px;
    flex-shrink: 0;
}
h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: -0.02em; color: var(--black); }

::selection { background: var(--orange); color: white; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--mute); }

/* ================================================================
   Splash screen
   ================================================================ */
.splash {
    position: fixed; inset: 0;
    background: radial-gradient(ellipse at 30% 20%, #1A1A1C 0%, #0A0A0B 70%);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    transition: opacity 0.6s var(--ease);
}
.splash.hiding { opacity: 0; pointer-events: none; }
.splash::before, .splash::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: splashOrbit 8s infinite ease-in-out;
}
.splash::before { background: var(--orange); width: 400px; height: 400px; top: -100px; left: -100px; }
.splash::after { background: var(--orange-dark); width: 300px; height: 300px; bottom: -50px; right: 10%; animation-delay: -4s; }
@keyframes splashOrbit {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(60px, 30px) scale(1.1); }
}

.splash-inner { position: relative; text-align: center; z-index: 2; }
.splash-logo { display: flex; flex-direction: column; align-items: center; gap: 20px; margin-bottom: 48px; }
.logo-mark { width: 72px; height: 72px; animation: logoFloat 3s ease-in-out infinite; }
@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.splash-brand {
    font-size: 11px; font-weight: 700; letter-spacing: 0.3em;
    color: var(--orange);
    margin-bottom: 6px;
}
.splash-product {
    font-size: 28px; font-weight: 800; color: white;
    letter-spacing: -0.03em;
}
.splash-loader { width: 320px; margin: 0 auto; }
.splash-bar {
    height: 2px; background: rgba(255,255,255,0.1); border-radius: 2px;
    overflow: hidden; margin-bottom: 16px;
}
.splash-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--orange), var(--orange-light), var(--orange));
    background-size: 200% 100%;
    animation: splashShimmer 1.5s linear infinite, splashFill 2.5s var(--ease) forwards;
    width: 0;
    border-radius: 2px;
}
@keyframes splashShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes splashFill {
    to { width: 100%; }
}
.splash-status { font-size: 12px; color: rgba(255,255,255,0.5); letter-spacing: 0.02em; }

/* ================================================================
   App layout
   ================================================================ */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ================================================================
   Sidebar
   ================================================================ */
.sidebar {
    background: #0A0A0B;
    color: rgba(255,255,255,0.85);
    display: flex; flex-direction: column;
    border-right: 1px solid #1A1A1C;
    position: relative;
    overflow: hidden;
}
.sidebar::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--orange), transparent);
    opacity: 0.4;
}

.sidebar-header { padding: 24px 20px 20px; border-bottom: 1px solid #1A1A1C; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; height: 36px; flex-shrink: 0; }
.brand-text { line-height: 1.15; }
.brand-name { font-size: 15px; font-weight: 800; letter-spacing: 0.08em; color: white; }
.brand-sub { font-size: 11px; color: var(--orange); font-weight: 500; letter-spacing: 0.04em; margin-top: 2px; }

.nav {
    flex: 1; overflow-y: auto;
    padding: 20px 12px 12px;
}
.nav-section-title {
    font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.35);
    letter-spacing: 0.14em; text-transform: uppercase;
    padding: 16px 10px 8px;
}
.nav-section-title:first-child { padding-top: 0; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,0.72);
    font-size: 13.5px; font-weight: 500;
    position: relative;
    transition: all 0.2s var(--ease);
    cursor: pointer;
    margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: white; }
.nav-item.active {
    background: linear-gradient(90deg, rgba(255, 107, 28, 0.18), rgba(255, 107, 28, 0.02));
    color: white;
}
.nav-item.active::before {
    content: '';
    position: absolute; left: 0; top: 20%; bottom: 20%;
    width: 3px; background: var(--orange); border-radius: 0 3px 3px 0;
}
.nav-item.active .nav-icon { color: var(--orange); }
.nav-icon {
    width: 18px; height: 18px; flex-shrink: 0;
    color: rgba(255,255,255,0.55);
    transition: color 0.2s;
}
.nav-item:hover .nav-icon { color: white; }
.nav-item > span:first-of-type { flex: 1; }
.nav-badge {
    background: var(--orange); color: white;
    font-size: 10px; font-weight: 700;
    padding: 2px 7px; border-radius: 10px;
    min-width: 20px; text-align: center;
}
.nav-badge.badge-warn { background: var(--amber); }
.nav-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2); }
    50% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #1A1A1C;
    display: flex; flex-direction: column; gap: 12px;
}
.env-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: rgba(22, 163, 74, 0.08);
    border: 1px solid rgba(22, 163, 74, 0.2);
    border-radius: 8px;
}
.env-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
    flex-shrink: 0;
}
.env-label { font-size: 12px; font-weight: 600; color: white; }
.env-sub { font-size: 10.5px; color: rgba(255,255,255,0.5); margin-top: 1px; }

.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
.user-chip:hover { background: rgba(255,255,255,0.04); }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--orange), var(--orange-dark));
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255, 107, 28, 0.3);
}
.user-avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.user-name { font-size: 13px; font-weight: 600; color: white; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 1px; }

/* ================================================================
   Main area
   ================================================================ */
.main {
    display: flex; flex-direction: column;
    overflow: hidden;
    background: var(--paper);
    position: relative;
}

/* Top bar */
.topbar {
    height: var(--topbar-h);
    display: flex; align-items: center;
    padding: 0 24px;
    background: white;
    border-bottom: 1px solid var(--line);
    gap: 16px;
    position: relative;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-center { flex: 1; max-width: 560px; margin: 0 auto; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    color: var(--slate);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    position: relative;
}
.icon-btn:hover { background: var(--paper); color: var(--black); }
.icon-btn svg { width: 18px; height: 18px; }

.breadcrumb {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px;
    color: var(--mute);
}
.breadcrumb svg { width: 12px; height: 12px; }
.breadcrumb .current { color: var(--black); font-weight: 600; }

.search-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 12px;
    height: 40px;
    transition: all 0.2s;
}
.search-box:focus-within {
    background: white;
    border-color: var(--orange);
    box-shadow: 0 0 0 4px var(--orange-50);
}
.search-box svg { width: 16px; height: 16px; color: var(--mute); flex-shrink: 0; }
.search-box input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: 13.5px;
}
.search-box input::placeholder { color: var(--mute); }
kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    padding: 3px 6px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--slate);
    box-shadow: 0 1px 0 var(--line);
}

.notification-btn { position: relative; }
.notification-count {
    position: absolute; top: 4px; right: 4px;
    background: var(--orange);
    color: white;
    font-size: 9px; font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    border: 2px solid white;
    animation: countPop 2s infinite;
}
@keyframes countPop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.divider-v { width: 1px; height: 24px; background: var(--line); }
.currency-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px;
    background: var(--paper);
    border-radius: 8px;
    font-size: 12.5px; font-weight: 600;
    cursor: pointer;
}
.currency-chip svg { width: 12px; height: 12px; }
.currency-flag { font-size: 14px; }

/* ================================================================
   Notification panel
   ================================================================ */
.notification-panel {
    position: absolute;
    top: calc(var(--topbar-h) + 8px);
    right: 24px;
    width: 420px;
    max-height: calc(100vh - var(--topbar-h) - 40px);
    background: white;
    border-radius: 14px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--line);
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
    pointer-events: none;
    transition: all 0.2s var(--ease);
    z-index: 100;
    display: flex; flex-direction: column;
}
.notification-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.notif-header {
    padding: 16px 18px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--line);
}
.notif-header h4 { font-size: 15px; }
.link-btn {
    font-size: 12px; font-weight: 600;
    color: var(--orange);
}
.link-btn:hover { color: var(--orange-dark); }

.notif-list {
    flex: 1; overflow-y: auto;
    max-height: 460px;
}
.notif-item {
    display: flex; gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-2);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}
.notif-item:hover { background: var(--paper); }
.notif-item.unread::before {
    content: '';
    position: absolute; top: 20px; left: 7px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--orange);
}
.notif-item.unread { padding-left: 22px; }
.notif-icon {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.notif-icon svg { width: 14px; height: 14px; }
.notif-icon.critical { background: var(--red-bg); color: var(--red); }
.notif-icon.warn { background: var(--amber-bg); color: var(--amber); }
.notif-icon.info { background: var(--blue-bg); color: var(--blue); }
.notif-icon.success { background: var(--green-bg); color: var(--green); }
.notif-title { font-size: 13px; font-weight: 600; color: var(--black); margin-bottom: 3px; }
.notif-desc { font-size: 12px; color: var(--slate); line-height: 1.45; }
.notif-time { font-size: 11px; color: var(--mute); margin-top: 4px; }
.notif-footer { padding: 12px 18px; border-top: 1px solid var(--line); text-align: center; }

/* ================================================================
   Command palette
   ================================================================ */
.cmd-overlay {
    position: fixed; inset: 0;
    background: rgba(10, 10, 11, 0.5);
    backdrop-filter: blur(8px);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 100px;
    z-index: 500;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.cmd-overlay.open { opacity: 1; pointer-events: auto; }
.cmd-panel {
    width: 640px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transform: translateY(-10px);
    transition: transform 0.2s var(--ease);
}
.cmd-overlay.open .cmd-panel { transform: translateY(0); }
.cmd-input-wrap {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}
.cmd-input-wrap svg { width: 18px; height: 18px; color: var(--mute); }
.cmd-input-wrap input {
    flex: 1; border: none; outline: none;
    font-size: 15px;
}
.cmd-results { max-height: 420px; overflow-y: auto; padding: 8px; }
.cmd-section-title {
    font-size: 10px; font-weight: 700;
    color: var(--mute); letter-spacing: 0.12em;
    text-transform: uppercase; padding: 10px 14px 6px;
}
.cmd-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 8px;
    cursor: pointer; font-size: 13.5px;
    transition: background 0.15s;
}
.cmd-item:hover { background: var(--paper); }
.cmd-item svg { width: 16px; height: 16px; color: var(--slate); flex-shrink: 0; }
.cmd-item.ai svg { color: var(--orange); }
.cmd-item > span:first-of-type { flex: 1; }
.cmd-badge {
    font-size: 10px; font-weight: 700;
    padding: 2px 7px; border-radius: 10px;
    letter-spacing: 0.04em;
}
.cmd-badge.red { background: var(--red-bg); color: var(--red); }
.cmd-badge.amber { background: var(--amber-bg); color: var(--amber); }
.cmd-badge.green { background: var(--green-bg); color: var(--green); }

/* ================================================================
   Content area
   ================================================================ */
.content {
    flex: 1; overflow-y: auto;
    padding: 24px 28px 48px;
    position: relative;
}
.content > .view { animation: viewFadeIn 0.4s var(--ease); }
@keyframes viewFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Page header */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 24px;
    gap: 24px;
    flex-wrap: wrap;
}
.page-title-wrap h1 {
    font-size: 24px; font-weight: 800;
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 4px;
}
.page-title-wrap .page-sub {
    font-size: 13.5px; color: var(--slate);
}
.title-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, var(--orange-50), white);
    border: 1px solid var(--orange-100);
    color: var(--orange-dark);
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.04em;
    border-radius: 20px;
    text-transform: uppercase;
}
.title-badge svg { width: 11px; height: 11px; }

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

/* ================================================================
   Buttons
   ================================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    border-radius: 9px;
    font-size: 13px; font-weight: 600;
    transition: all 0.2s var(--ease);
    white-space: nowrap;
    border: 1px solid transparent;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
    background: var(--black); color: white;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--ink); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-orange {
    background: var(--orange); color: white;
    box-shadow: 0 2px 8px rgba(255,107,28,0.25);
}
.btn-orange:hover { background: var(--orange-dark); transform: translateY(-1px); box-shadow: var(--shadow-orange); }
.btn-outline {
    background: white; color: var(--black);
    border: 1px solid var(--line);
}
.btn-outline:hover { border-color: var(--black); background: var(--paper); }
.btn-ghost { color: var(--slate); }
.btn-ghost:hover { background: var(--paper); color: var(--black); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 7px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { padding: 12px 20px; font-size: 14px; }

/* Chip-style filters */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 20px;
    font-size: 12.5px; font-weight: 500;
    color: var(--slate);
    cursor: pointer;
    transition: all 0.2s;
}
.chip:hover { border-color: var(--black); color: var(--black); }
.chip.active { background: var(--black); color: white; border-color: var(--black); }
.chip svg { width: 13px; height: 13px; }

/* ================================================================
   Cards
   ================================================================ */
.card {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.2s var(--ease);
}
.card.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--line);
}
.card-header {
    padding: 18px 20px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--line-2);
    gap: 16px;
}
.card-header h3 { font-size: 15px; }
.card-header .card-sub { font-size: 12px; color: var(--mute); margin-top: 2px; }
.card-body { padding: 20px; }
.card-tight .card-body { padding: 16px; }

/* ================================================================
   KPI cards
   ================================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.kpi {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s var(--ease);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--line);
}
.kpi.accent::before { background: var(--orange); }
.kpi.success::before { background: var(--green); }
.kpi.warn::before { background: var(--amber); }
.kpi.danger::before { background: var(--red); }

.kpi-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
}
.kpi-label {
    font-size: 11.5px; font-weight: 600;
    color: var(--mute);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.kpi-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--paper);
    color: var(--slate);
}
.kpi.accent .kpi-icon { background: var(--orange-50); color: var(--orange); }
.kpi.success .kpi-icon { background: var(--green-bg); color: var(--green); }
.kpi.warn .kpi-icon { background: var(--amber-bg); color: var(--amber); }
.kpi.danger .kpi-icon { background: var(--red-bg); color: var(--red); }
.kpi-icon svg { width: 16px; height: 16px; }

.kpi-value {
    font-size: 30px; font-weight: 800;
    color: var(--black);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 10px;
    display: flex; align-items: baseline; gap: 6px;
}
.kpi-value small {
    font-size: 14px; font-weight: 600;
    color: var(--mute);
}
.kpi-foot {
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px;
    font-size: 12px;
}
.kpi-delta {
    display: inline-flex; align-items: center; gap: 3px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
}
.kpi-delta.up { background: var(--green-bg); color: var(--green); }
.kpi-delta.down { background: var(--red-bg); color: var(--red); }
.kpi-delta.neutral { background: var(--paper); color: var(--slate); }
.kpi-delta svg { width: 11px; height: 11px; }
.kpi-foot-note { color: var(--mute); }

.kpi-spark {
    position: absolute; right: 0; bottom: 0;
    width: 60%; height: 50px;
    pointer-events: none;
    opacity: 0.7;
}

/* ================================================================
   Grids & layouts
   ================================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-23 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-32 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }
.grid-stack > * + * { margin-top: 20px; }
.row-24 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }

/* ================================================================
   Tables
   ================================================================ */
.table-wrap {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.table-toolbar {
    padding: 14px 18px;
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--line-2);
    flex-wrap: wrap;
}
.table-toolbar h3 { font-size: 14px; }
.table-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.table-scroll { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--mute);
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table th.right { text-align: right; }
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s; cursor: pointer; }
.data-table tbody tr:hover { background: var(--paper); }
.td-right { text-align: right; font-variant-numeric: tabular-nums; }
.td-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

.pager {
    padding: 14px 18px;
    display: flex; justify-content: space-between; align-items: center;
    border-top: 1px solid var(--line-2);
    font-size: 12.5px; color: var(--slate);
}
.pager-info { color: var(--mute); }
.pager-controls { display: flex; align-items: center; gap: 4px; }
.pager-btn {
    width: 30px; height: 30px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    color: var(--slate);
    transition: background 0.15s;
}
.pager-btn:hover { background: var(--paper); color: var(--black); }
.pager-btn.active { background: var(--black); color: white; }
.pager-btn.disabled { opacity: 0.3; pointer-events: none; }
.pager-btn svg { width: 14px; height: 14px; }
.pager-size {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--mute);
}
.pager-size select {
    padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px;
    background: white; font-size: 12px; cursor: pointer;
}

/* ================================================================
   Status badges
   ================================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 10.5px; font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.badge::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.gray { background: var(--paper); color: var(--slate); }
.badge.purple { background: var(--purple-bg); color: var(--purple); }
.badge.outline {
    background: transparent;
    border: 1px solid currentColor;
}
.badge-plain {
    display: inline-flex; align-items: center;
    padding: 3px 9px; border-radius: 12px;
    font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
}
.badge-plain.red { background: var(--red-bg); color: var(--red); }
.badge-plain.amber { background: var(--amber-bg); color: var(--amber); }
.badge-plain.green { background: var(--green-bg); color: var(--green); }

/* Risk score pill */
.risk-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 9px;
    border-radius: 10px;
    font-size: 11px; font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.risk-pill .risk-bar {
    width: 36px; height: 4px; border-radius: 2px;
    background: rgba(0,0,0,0.08); overflow: hidden;
}
.risk-pill .risk-bar::before {
    content: '';
    display: block; height: 100%;
    width: var(--pct, 0%);
    background: currentColor;
    border-radius: 2px;
}
.risk-pill.red { background: var(--red-bg); color: var(--red); }
.risk-pill.amber { background: var(--amber-bg); color: var(--amber); }
.risk-pill.green { background: var(--green-bg); color: var(--green); }

/* Progress bar inline */
.inline-progress {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--slate);
}
.inline-progress .bar {
    width: 80px; height: 5px;
    background: var(--line-2); border-radius: 3px;
    overflow: hidden;
}
.inline-progress .bar::before {
    content: '';
    display: block; height: 100%;
    width: var(--pct, 0);
    background: var(--black);
    border-radius: 3px;
    transition: width 0.5s var(--ease);
}
.inline-progress.orange .bar::before { background: var(--orange); }
.inline-progress.red .bar::before { background: var(--red); }
.inline-progress.amber .bar::before { background: var(--amber); }
.inline-progress.green .bar::before { background: var(--green); }

/* Avatar stack */
.avatar-stack { display: flex; }
.avatar-stack .avatar-mini {
    width: 24px; height: 24px; border-radius: 50%;
    margin-left: -6px;
    border: 2px solid white;
    background: var(--line);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: var(--slate);
}
.avatar-stack .avatar-mini:first-child { margin-left: 0; }
.avatar-stack .avatar-mini.more { background: var(--black); color: white; }

/* ================================================================
   Charts
   ================================================================ */
.chart-wrap { position: relative; width: 100%; height: 240px; }
.chart-wrap.sm { height: 160px; }
.chart-wrap.lg { height: 320px; }
.chart-wrap.xl { height: 400px; }

.chart-legend {
    display: flex; flex-wrap: wrap; gap: 16px;
    margin-top: 12px;
    font-size: 12px;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ================================================================
   RAG health strip (portfolio)
   ================================================================ */
.rag-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
.rag-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    display: flex; justify-content: space-between; align-items: center;
    transition: all 0.2s;
    cursor: pointer;
}
.rag-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.rag-card::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.rag-card.green::before { background: var(--green); }
.rag-card.amber::before { background: var(--amber); }
.rag-card.red::before { background: var(--red); }
.rag-card.gray::before { background: var(--mute); }
.rag-card .rag-label {
    font-size: 10.5px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--mute);
    margin-bottom: 6px;
}
.rag-card .rag-value {
    font-size: 28px; font-weight: 800;
    line-height: 1;
}
.rag-card .rag-foot {
    font-size: 11px; color: var(--slate); margin-top: 4px;
}
.rag-card .rag-ring {
    position: relative;
    width: 54px; height: 54px;
}

/* ================================================================
   Portfolio dashboard — map/geo card
   ================================================================ */
.geo-card { padding: 0; overflow: hidden; }
.geo-map {
    position: relative;
    background: linear-gradient(135deg, var(--paper), white);
    height: 320px;
    overflow: hidden;
}
.geo-map svg { width: 100%; height: 100%; }
.geo-pin {
    position: absolute;
    transform: translate(-50%, -100%);
}
.geo-pin .pin-dot {
    width: 14px; height: 14px; border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.geo-pin .pin-pulse {
    position: absolute; inset: 0;
    border-radius: 50%;
    animation: pinPulse 2s infinite;
}
@keyframes pinPulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.5); opacity: 0; }
}
.geo-pin.red .pin-dot, .geo-pin.red .pin-pulse { background: var(--red); }
.geo-pin.amber .pin-dot, .geo-pin.amber .pin-pulse { background: var(--amber); }
.geo-pin.green .pin-dot, .geo-pin.green .pin-pulse { background: var(--green); }
.geo-pin .pin-label {
    position: absolute; left: 50%; top: calc(100% + 4px);
    transform: translateX(-50%);
    background: var(--black); color: white;
    padding: 3px 7px;
    border-radius: 5px;
    font-size: 10px; font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.geo-pin:hover .pin-label { opacity: 1; }

/* ================================================================
   Timeline / Gantt-ish strip
   ================================================================ */
.timeline-wrap {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
}
.timeline-head {
    display: grid;
    grid-template-columns: 240px 1fr;
    border-bottom: 1px solid var(--line);
    font-size: 11px; color: var(--mute);
    font-weight: 600;
}
.timeline-head .months {
    display: grid; grid-template-columns: repeat(12, 1fr);
    padding: 10px 0;
    text-align: center;
}
.timeline-head .months span { border-left: 1px solid var(--line-2); padding: 0 4px; }
.timeline-head .months span:first-child { border-left: none; }
.timeline-head .proj-h { padding: 10px 14px; }

.timeline-row {
    display: grid;
    grid-template-columns: 240px 1fr;
    border-bottom: 1px solid var(--line-2);
    align-items: center;
    min-height: 48px;
}
.timeline-row:last-child { border-bottom: none; }
.timeline-row:hover { background: var(--paper); }
.timeline-proj {
    padding: 10px 14px;
    display: flex; align-items: center; gap: 10px;
    overflow: hidden;
}
.timeline-proj .proj-name {
    font-size: 12.5px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.timeline-proj .proj-meta { font-size: 10.5px; color: var(--mute); margin-top: 2px; }
.timeline-track {
    position: relative;
    height: 48px;
    background: repeating-linear-gradient(to right, transparent, transparent calc(100% / 12 - 1px), var(--line-2) calc(100% / 12 - 1px), var(--line-2) calc(100% / 12));
}
.timeline-bar {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    height: 20px;
    border-radius: 6px;
    display: flex; align-items: center;
    padding: 0 8px;
    font-size: 10.5px; font-weight: 600; color: white;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}
.timeline-bar:hover { transform: translateY(-50%) scale(1.02); z-index: 2; }
.timeline-bar.green { background: linear-gradient(90deg, var(--green), #22C55E); }
.timeline-bar.amber { background: linear-gradient(90deg, var(--amber), #FBBF24); }
.timeline-bar.red { background: linear-gradient(90deg, var(--red), #EF4444); }
.timeline-bar.blue { background: linear-gradient(90deg, var(--blue), #3B82F6); }
.timeline-bar .bar-fill {
    position: absolute; left: 0; top: 0; bottom: 0;
    background: rgba(255,255,255,0.25);
    border-radius: 6px 0 0 6px;
}

/* ================================================================
   Project list cards
   ================================================================ */
.project-card {
    background: white; border: 1px solid var(--line);
    border-radius: var(--radius-lg); padding: 18px;
    transition: all 0.25s var(--ease);
    cursor: pointer;
}
.project-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--orange-100);
}
.project-card .pc-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 12px; gap: 12px;
}
.project-card .pc-name { font-size: 14.5px; font-weight: 700; }
.project-card .pc-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px; color: var(--mute);
    margin-top: 3px;
}
.pc-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    margin: 14px 0;
}
.pc-stat .stat-label {
    font-size: 10.5px; color: var(--mute);
    text-transform: uppercase; letter-spacing: 0.06em;
    font-weight: 600;
}
.pc-stat .stat-val {
    font-size: 15px; font-weight: 700; margin-top: 3px;
    font-variant-numeric: tabular-nums;
}
.pc-foot {
    display: flex; justify-content: space-between; align-items: center;
    padding-top: 12px; border-top: 1px solid var(--line-2);
}

/* ================================================================
   Risk module — specific
   ================================================================ */
.risk-overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.risk-breakdown {
    display: flex; align-items: center; gap: 16px;
    padding: 16px;
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.risk-donut {
    width: 72px; height: 72px;
    position: relative;
    flex-shrink: 0;
}
.risk-donut svg { transform: rotate(-90deg); }
.risk-donut-text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800;
}
.risk-breakdown .rb-info { flex: 1; }
.risk-breakdown .rb-title { font-size: 12.5px; font-weight: 700; margin-bottom: 4px; }
.risk-breakdown .rb-sub { font-size: 11px; color: var(--mute); }
.risk-breakdown .rb-foot {
    font-size: 11px; margin-top: 6px;
    display: flex; justify-content: space-between;
    color: var(--slate);
}

/* Early warning cards (projects about to drift) */
.ew-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative; overflow: hidden;
}
.ew-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--amber);
}
.ew-card.critical::before { background: var(--red); }
.ew-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--amber);
}
.ew-card.critical:hover { border-color: var(--red); }
.ew-top { display: flex; justify-content: space-between; gap: 10px; }
.ew-name { font-size: 13.5px; font-weight: 700; }
.ew-sub { font-size: 11px; color: var(--mute); margin-top: 2px; }
.ew-signals { display: flex; flex-direction: column; gap: 6px; }
.ew-signal {
    font-size: 11.5px;
    display: flex; gap: 8px; align-items: flex-start;
    color: var(--slate);
}
.ew-signal svg { width: 12px; height: 12px; margin-top: 2px; flex-shrink: 0; color: var(--amber); }
.ew-card.critical .ew-signal svg { color: var(--red); }

/* ================================================================
   AI Assistant / Chatbot
   ================================================================ */
.chat-shell {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 20px;
    height: calc(100vh - var(--topbar-h) - 48px);
}
.chat-sidebar {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.chat-sidebar-head {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center;
}
.chat-sidebar-head h4 { font-size: 13px; }
.chat-new-btn {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--orange); color: white;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.chat-new-btn:hover { background: var(--orange-dark); transform: scale(1.05); }
.chat-new-btn svg { width: 14px; height: 14px; }
.chat-sessions { flex: 1; overflow-y: auto; padding: 10px; }
.chat-session {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12.5px;
    transition: background 0.15s;
    margin-bottom: 2px;
}
.chat-session:hover { background: var(--paper); }
.chat-session.active { background: var(--orange-50); color: var(--orange-dark); font-weight: 600; }
.chat-session .cs-title { font-weight: 600; margin-bottom: 2px; }
.chat-session .cs-sub { font-size: 11px; color: var(--mute); }
.chat-sessions-group {
    font-size: 10px; color: var(--mute); font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    padding: 10px 12px 4px;
}

.chat-main {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.chat-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center;
}
.chat-head-left { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--orange), var(--orange-dark));
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.chat-avatar svg { width: 18px; height: 18px; color: white; }
.chat-avatar::after {
    content: ''; position: absolute; bottom: -2px; right: -2px;
    width: 10px; height: 10px; background: var(--green); border: 2px solid white;
    border-radius: 50%;
}
.chat-head-title { font-size: 14px; font-weight: 700; }
.chat-head-sub { font-size: 11px; color: var(--mute); }
.chat-head-right { display: flex; gap: 6px; }

.chat-body {
    flex: 1; overflow-y: auto;
    padding: 24px;
    display: flex; flex-direction: column; gap: 16px;
    background: var(--paper);
}
.chat-msg {
    display: flex; gap: 12px;
    max-width: 85%;
}
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
    width: 32px; height: 32px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 11px; font-weight: 700;
}
.chat-msg.ai .msg-avatar {
    background: linear-gradient(135deg, var(--orange), var(--orange-dark));
    color: white;
}
.chat-msg.user .msg-avatar {
    background: var(--black); color: white;
}
.msg-bubble {
    background: white;
    border: 1px solid var(--line);
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    box-shadow: var(--shadow-sm);
}
.chat-msg.ai .msg-bubble { border-bottom-left-radius: 4px; }
.chat-msg.user .msg-bubble {
    background: var(--black); color: white; border-color: var(--black);
    border-bottom-right-radius: 4px;
}
.msg-bubble strong { color: var(--orange); font-weight: 700; }
.chat-msg.user .msg-bubble strong { color: var(--orange-light); }
.msg-time { font-size: 10.5px; color: var(--mute); margin-top: 4px; padding: 0 4px; }

.msg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.msg-chip {
    padding: 5px 10px;
    background: var(--orange-50);
    color: var(--orange-dark);
    border-radius: 20px;
    font-size: 11.5px; font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}
.msg-chip:hover { background: var(--orange-100); border-color: var(--orange); }

.msg-table {
    width: 100%;
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
}
.msg-table th, .msg-table td {
    padding: 8px 10px;
    text-align: left;
    font-size: 12px;
    border-bottom: 1px solid var(--line-2);
}
.msg-table th {
    background: var(--paper); font-weight: 700; font-size: 11px;
}
.msg-table tr:last-child td { border-bottom: none; }
.msg-chart { margin-top: 12px; height: 180px; }

.msg-citation {
    margin-top: 10px;
    padding: 8px 10px;
    background: var(--paper);
    border-left: 3px solid var(--orange);
    border-radius: 4px;
    font-size: 11.5px;
    color: var(--slate);
    display: flex; align-items: center; gap: 8px;
}
.msg-citation svg { width: 13px; height: 13px; color: var(--orange); }

.chat-typing {
    display: flex; align-items: center; gap: 6px;
    padding: 12px 14px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.chat-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--mute);
    animation: typingBounce 1.3s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.chat-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    background: white;
}
.chat-input-wrap {
    display: flex; align-items: flex-end; gap: 10px;
    background: var(--paper);
    border: 1.5px solid var(--line);
    border-radius: 14px;
    padding: 10px 14px;
    transition: all 0.2s;
}
.chat-input-wrap:focus-within {
    border-color: var(--orange);
    background: white;
    box-shadow: 0 0 0 4px var(--orange-50);
}
.chat-input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: 14px; resize: none;
    max-height: 120px;
    font-family: inherit;
    line-height: 1.4;
    padding: 4px 0;
}
.chat-tools { display: flex; gap: 4px; }
.chat-tool {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--slate);
    transition: all 0.15s;
}
.chat-tool:hover { background: var(--line-2); color: var(--black); }
.chat-tool svg { width: 16px; height: 16px; }
.chat-send {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--orange); color: white;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.chat-send:hover { background: var(--orange-dark); transform: translateY(-1px); }
.chat-send:disabled { background: var(--line); cursor: not-allowed; transform: none; }
.chat-send svg { width: 15px; height: 15px; }

.chat-foot-row {
    display: flex; justify-content: space-between;
    margin-top: 10px;
    font-size: 11px; color: var(--mute);
}
.chat-model {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 8px;
    background: var(--paper);
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--slate);
}
.chat-model .model-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--green);
}

.chat-insights {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow-y: auto;
    padding: 16px;
}
.chat-insights-title {
    font-size: 10px; font-weight: 700;
    color: var(--mute); letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.insight-item {
    padding: 12px;
    background: var(--paper);
    border-radius: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--line-2);
    cursor: pointer;
    transition: all 0.2s;
}
.insight-item:hover { border-color: var(--orange); transform: translateX(2px); }
.insight-item h5 { font-size: 12.5px; margin-bottom: 4px; }
.insight-item p { font-size: 11.5px; color: var(--slate); line-height: 1.5; }
.insight-item .insight-foot {
    display: flex; justify-content: space-between;
    margin-top: 8px;
    font-size: 10.5px; color: var(--mute);
}

/* ================================================================
   What-If Simulator
   ================================================================ */
.whatif-shell {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    min-height: calc(100vh - var(--topbar-h) - 48px);
}
.wi-controls {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex; flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    max-height: calc(100vh - var(--topbar-h) - 48px);
}
.wi-scenario-title {
    font-size: 11px; font-weight: 700;
    color: var(--mute); letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.wi-scenario-select {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}
.wi-section {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line-2);
}
.wi-section:last-child { border-bottom: none; padding-bottom: 0; }
.wi-section-h {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.wi-section-h h5 {
    font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.wi-section-h h5 svg { width: 14px; height: 14px; color: var(--orange); }

.wi-slider-wrap { margin-bottom: 14px; }
.wi-slider-label {
    display: flex; justify-content: space-between;
    font-size: 12px; color: var(--slate);
    margin-bottom: 8px;
}
.wi-slider-label .val {
    font-weight: 700; color: var(--black);
    font-variant-numeric: tabular-nums;
}
.wi-slider {
    width: 100%; height: 6px;
    background: var(--line-2);
    border-radius: 3px;
    appearance: none;
    outline: none;
    cursor: pointer;
}
.wi-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: white;
    border: 3px solid var(--orange);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.15s;
}
.wi-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

.wi-chip-select {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 12px;
}

.wi-canvas {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 20px;
}

.wi-impact-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.wi-impact {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
}
.wi-impact.good { border-color: var(--green); }
.wi-impact.bad { border-color: var(--red); }
.wi-impact.warn { border-color: var(--amber); }
.wi-impact-label {
    font-size: 10.5px; font-weight: 700;
    color: var(--mute);
    letter-spacing: 0.06em; text-transform: uppercase;
    margin-bottom: 8px;
}
.wi-impact-row {
    display: flex; align-items: baseline; gap: 10px;
}
.wi-impact-before {
    font-size: 13px; color: var(--mute);
    text-decoration: line-through;
    font-variant-numeric: tabular-nums;
}
.wi-impact-after {
    font-size: 20px; font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.wi-impact-delta {
    font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 6px; border-radius: 5px;
    margin-top: 6px;
}
.wi-impact-delta.good { background: var(--green-bg); color: var(--green); }
.wi-impact-delta.bad { background: var(--red-bg); color: var(--red); }
.wi-impact-delta.warn { background: var(--amber-bg); color: var(--amber); }

.wi-ripple {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.wi-ripple-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center;
}

.ripple-canvas {
    position: relative;
    height: 360px;
    background: linear-gradient(135deg, var(--paper), white);
    overflow: hidden;
}
.ripple-node {
    position: absolute;
    width: 110px;
    padding: 10px;
    background: white;
    border: 2px solid var(--line);
    border-radius: 10px;
    text-align: center;
    box-shadow: var(--shadow-md);
    transition: all 0.3s var(--ease);
    cursor: pointer;
}
.ripple-node:hover { transform: scale(1.05); z-index: 3; }
.ripple-node.source {
    border-color: var(--orange);
    background: linear-gradient(135deg, var(--orange-50), white);
}
.ripple-node.red { border-color: var(--red); }
.ripple-node.amber { border-color: var(--amber); }
.ripple-node.green { border-color: var(--green); }
.ripple-node .rn-name {
    font-size: 11px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
}
.ripple-node .rn-impact {
    font-size: 10px; margin-top: 4px;
    color: var(--slate);
}
.ripple-line {
    position: absolute;
    pointer-events: none;
}
.ripple-line svg { width: 100%; height: 100%; overflow: visible; }
.ripple-line path {
    stroke-dasharray: 5 4;
    animation: rippleDash 2s linear infinite;
}
@keyframes rippleDash {
    to { stroke-dashoffset: -36; }
}

/* ================================================================
   Reports module
   ================================================================ */
.report-template {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.25s var(--ease);
    cursor: pointer;
    display: flex; flex-direction: column;
}
.report-template:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--orange);
}
.report-thumb {
    height: 180px;
    background: white;
    border-bottom: 1px solid var(--line);
    position: relative;
    overflow: hidden;
    padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
}
html[data-theme="dark"] .report-thumb { background: #0F0F13; border-bottom-color: #26262A; }

/* Per-template corner accent */
.report-thumb::after {
    content: ''; position: absolute; top: 0; right: 0;
    width: 60px; height: 60px;
    background: radial-gradient(circle at top right, var(--orange-50), transparent 60%);
    pointer-events: none;
}
html[data-theme="dark"] .report-thumb::after {
    background: radial-gradient(circle at top right, rgba(255,107,28,0.15), transparent 60%);
}

/* Thumb header strip */
.rt-head {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--line);
}
html[data-theme="dark"] .rt-head { border-bottom-color: #26262A; }
.rt-head-brand {
    font-size: 7px; font-weight: 800; letter-spacing: 0.14em;
    color: var(--orange);
}
.rt-head-meta { font-size: 7px; color: var(--mute); font-weight: 600; }
.rt-head-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); margin-right: 4px; display: inline-block; vertical-align: middle; }

/* Document-like content zone */
.rt-content { flex: 1; display: flex; flex-direction: column; gap: 6px; position: relative; z-index: 1; }

/* Type 1 — exec-summary: title + 3 KPI tiles + sparkline */
.rt-title-row {
    display: flex; flex-direction: column; gap: 4px;
}
.rt-title { height: 7px; width: 58%; background: var(--black); border-radius: 2px; }
.rt-subtitle { height: 4px; width: 38%; background: var(--line); border-radius: 2px; }
html[data-theme="dark"] .rt-title { background: #FFFFFF; }
html[data-theme="dark"] .rt-subtitle { background: #26262A; }

.rt-kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 2px; }
.rt-kpi {
    padding: 6px 4px;
    background: var(--paper);
    border-radius: 4px;
    text-align: center;
}
html[data-theme="dark"] .rt-kpi { background: #15151A; }
.rt-kpi-val { font-size: 10px; font-weight: 800; color: var(--black); line-height: 1; }
html[data-theme="dark"] .rt-kpi-val { color: #FFFFFF; }
.rt-kpi-val.green { color: var(--green); }
.rt-kpi-val.red { color: var(--red); }
.rt-kpi-val.orange { color: var(--orange); }
.rt-kpi-lbl { font-size: 6px; color: var(--mute); margin-top: 2px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }

.rt-spark { display: flex; align-items: flex-end; gap: 2px; height: 24px; margin-top: 4px; }
.rt-spark span { flex: 1; background: var(--orange); border-radius: 1px; opacity: 0.9; }

/* Type 2 — board-pack: multi-mini-chart grid */
.rt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex: 1; }
.rt-tile {
    background: var(--paper); border-radius: 4px; padding: 6px;
    display: flex; flex-direction: column; gap: 3px;
    overflow: hidden;
}
html[data-theme="dark"] .rt-tile { background: #15151A; }
.rt-tile-cap { font-size: 6px; color: var(--mute); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.rt-tile-line { height: 18px; background:
    linear-gradient(90deg,
        var(--orange) 0 20%, transparent 20% 100%),
    linear-gradient(to top, var(--orange-50) 0 100%);
}
.rt-tile-donut {
    width: 24px; height: 24px; border-radius: 50%; margin: 2px auto 0;
    background: conic-gradient(var(--green) 0 55%, var(--amber) 55% 85%, var(--red) 85% 100%);
}

/* Type 3 — letter: realistic lines */
.rt-lines { display: flex; flex-direction: column; gap: 4px; }
.rt-lines div { height: 3px; background: var(--line); border-radius: 2px; }
.rt-lines div.wide { width: 100%; }
.rt-lines div.mid { width: 72%; }
.rt-lines div.narrow { width: 54%; }
.rt-lines div.highlight { background: var(--black); height: 4px; }
html[data-theme="dark"] .rt-lines div { background: #26262A; }
html[data-theme="dark"] .rt-lines div.highlight { background: #FFFFFF; }

/* Type 4 — scorecard: vendor star rows */
.rt-score-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 2px 0; gap: 6px;
}
.rt-score-name { flex: 1; height: 4px; background: var(--line); border-radius: 2px; }
html[data-theme="dark"] .rt-score-name { background: #26262A; }
.rt-score-dot { width: 4px; height: 4px; border-radius: 50%; }
.rt-score-stars { display: flex; gap: 1px; }
.rt-score-stars span { width: 4px; height: 4px; border-radius: 50%; background: var(--amber); }
.rt-score-stars span.empty { background: var(--line); }
html[data-theme="dark"] .rt-score-stars span.empty { background: #26262A; }

/* Type 5 — audit: formal doc with seal */
.rt-seal {
    position: absolute; right: 14px; bottom: 14px;
    width: 44px; height: 44px; border-radius: 50%;
    border: 2px dashed var(--orange); color: var(--orange);
    display: flex; align-items: center; justify-content: center;
    font-size: 6px; font-weight: 800; letter-spacing: 0.1em;
    text-transform: uppercase;
    transform: rotate(-12deg);
    opacity: 0.75;
}

/* Type 6 — checklist */
.rt-check { display: flex; align-items: center; gap: 6px; }
.rt-check-box { width: 8px; height: 8px; border: 1px solid var(--mute); border-radius: 2px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.rt-check-box.done { background: var(--green); border-color: var(--green); color: white; font-size: 6px; }
.rt-check-bar { flex: 1; height: 3px; background: var(--line); border-radius: 2px; }
html[data-theme="dark"] .rt-check-bar { background: #26262A; }

.report-tpl-body { padding: 16px; flex: 1; }
.report-tpl-tag {
    display: inline-flex; padding: 3px 8px;
    background: var(--orange-50); color: var(--orange-dark);
    border-radius: 5px;
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.04em; text-transform: uppercase;
    margin-bottom: 8px;
}
html[data-theme="dark"] .report-tpl-tag { background: #2A1A0A; color: #FF8947; }

.report-tpl-body h4 { font-size: 14px; margin-bottom: 6px; }
.report-tpl-body p { font-size: 12px; color: var(--slate); line-height: 1.5; }

.report-tpl-foot {
    padding: 12px 16px; border-top: 1px solid var(--line-2);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; color: var(--mute);
}
html[data-theme="dark"] .report-tpl-foot { border-top-color: #1F1F23; }
.report-tpl-foot .rtf-cell { display: flex; align-items: center; gap: 6px; }
.report-tpl-foot .rtf-cell svg { width: 12px !important; height: 12px !important; color: var(--mute); flex-shrink: 0; }

/* ================================================================
   Report document view (board pack / exec summary)
   ================================================================ */
.doc-view {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 900px;
    margin: 0 auto;
    box-shadow: var(--shadow-sm);
}
.doc-head {
    display: flex; justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--black);
    margin-bottom: 24px;
}
.doc-brand { display: flex; align-items: center; gap: 12px; }
.doc-brand .brand-mark { width: 32px; height: 32px; }
.doc-brand-text .doc-brand-name {
    font-size: 11px; font-weight: 700; letter-spacing: 0.2em; color: var(--orange);
}
.doc-brand-text .doc-brand-sub { font-size: 10px; color: var(--mute); }
.doc-meta {
    text-align: right; font-size: 11px; color: var(--slate);
    line-height: 1.6;
}
.doc-title { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.doc-sub { font-size: 13px; color: var(--slate); margin-bottom: 24px; }

.doc-section { margin-bottom: 28px; }
.doc-section h3 {
    font-size: 15px; margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 8px;
}
.doc-section h3 .section-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 6px;
    background: var(--orange); color: white;
    font-size: 11px; font-weight: 700;
}
.doc-section p { font-size: 13px; color: var(--ink); line-height: 1.7; margin-bottom: 10px; }
.doc-section .doc-ai-note {
    padding: 10px 14px;
    background: linear-gradient(90deg, var(--orange-50), transparent);
    border-left: 3px solid var(--orange);
    font-size: 12px; color: var(--slate);
    font-style: italic;
    border-radius: 4px;
    margin: 10px 0;
}
.doc-highlight {
    background: var(--paper);
    border-radius: 10px;
    padding: 16px 20px;
    margin: 14px 0;
    border: 1px solid var(--line);
}

/* ================================================================
   Finance / Forecasting
   ================================================================ */
.forecast-hero {
    background: linear-gradient(135deg, var(--black), var(--ink-2));
    color: white;
    border-radius: var(--radius-lg);
    padding: 28px;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
}
.forecast-hero::before {
    content: '';
    position: absolute; top: -50%; right: -10%;
    width: 400px; height: 400px;
    background: radial-gradient(circle, var(--orange) 0%, transparent 70%);
    opacity: 0.15;
}
.forecast-hero::after {
    content: '';
    position: absolute; bottom: -30%; left: 20%;
    width: 300px; height: 300px;
    background: radial-gradient(circle, var(--orange) 0%, transparent 70%);
    opacity: 0.1;
}
.fh-top {
    position: relative;
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 24px;
}
.fh-label {
    font-size: 11px; font-weight: 700;
    color: var(--orange);
    letter-spacing: 0.12em; text-transform: uppercase;
    margin-bottom: 6px;
}
.fh-h {
    font-size: 20px; font-weight: 700;
    margin-bottom: 4px;
}
.fh-sub { font-size: 13px; color: rgba(255,255,255,0.6); }

.fh-stats {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}
.fh-stat .fs-label {
    font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
    color: rgba(255,255,255,0.5); font-weight: 600;
    margin-bottom: 8px;
}
.fh-stat .fs-value {
    font-size: 28px; font-weight: 800; line-height: 1;
    letter-spacing: -0.03em;
    display: flex; align-items: baseline; gap: 6px;
}
.fh-stat .fs-value small {
    font-size: 13px; color: rgba(255,255,255,0.5); font-weight: 500;
}
.fh-stat .fs-foot {
    display: flex; align-items: center; gap: 6px;
    margin-top: 8px;
    font-size: 11.5px;
}
.fh-stat .fs-chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 7px; border-radius: 5px;
    font-size: 10.5px; font-weight: 700;
}
.fh-stat .fs-chip.up { background: rgba(22, 163, 74, 0.2); color: #4ADE80; }
.fh-stat .fs-chip.down { background: rgba(220, 38, 38, 0.2); color: #FCA5A5; }

/* Anomaly cards */
.anomaly-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex; gap: 14px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.anomaly-card::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--red);
}
.anomaly-card.amber::before { background: var(--amber); }
.anomaly-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.anomaly-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--red-bg); color: var(--red);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.anomaly-card.amber .anomaly-icon { background: var(--amber-bg); color: var(--amber); }
.anomaly-icon svg { width: 18px; height: 18px; }
.anomaly-info { flex: 1; }
.anomaly-title { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.anomaly-desc { font-size: 12px; color: var(--slate); line-height: 1.5; }
.anomaly-meta {
    display: flex; gap: 12px;
    margin-top: 8px;
    font-size: 11px; color: var(--mute);
}
.anomaly-meta span { display: flex; align-items: center; gap: 4px; }
.anomaly-meta svg { width: 11px; height: 11px; }

/* ================================================================
   Modals
   ================================================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(10, 10, 11, 0.5);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s;
    z-index: 1000;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 820px;
    max-height: calc(100vh - 48px);
    overflow: hidden;
    display: flex; flex-direction: column;
    transform: scale(0.96) translateY(10px);
    transition: transform 0.25s var(--ease);
    box-shadow: var(--shadow-xl);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal.wide { max-width: 1100px; }
.modal.narrow { max-width: 480px; }

.modal-head {
    padding: 20px 24px;
    border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 20px;
}
.modal-head h3 { font-size: 18px; margin-bottom: 2px; }
.modal-head .modal-sub { font-size: 12.5px; color: var(--mute); }
.modal-close {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--slate);
    transition: all 0.15s;
}
.modal-close:hover { background: var(--paper); color: var(--black); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-foot {
    padding: 16px 24px;
    border-top: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px;
    background: var(--paper);
}

/* ================================================================
   Toasts
   ================================================================ */
.toast-container {
    position: fixed;
    top: 24px; right: 24px;
    z-index: 2000;
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
    max-width: 380px;
}
.toast {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: var(--shadow-lg);
    display: flex; gap: 12px; align-items: flex-start;
    pointer-events: auto;
    animation: toastIn 0.3s var(--ease);
    position: relative;
    overflow: hidden;
}
.toast::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.toast.success::before { background: var(--green); }
.toast.info::before { background: var(--blue); }
.toast.warn::before { background: var(--amber); }
.toast.error::before { background: var(--red); }
.toast.hiding { animation: toastOut 0.3s var(--ease) forwards; }
@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
    to { transform: translateX(120%); opacity: 0; }
}
.toast-icon {
    width: 24px; height: 24px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.toast-icon svg { width: 14px; height: 14px; }
.toast.success .toast-icon { background: var(--green-bg); color: var(--green); }
.toast.info .toast-icon { background: var(--blue-bg); color: var(--blue); }
.toast.warn .toast-icon { background: var(--amber-bg); color: var(--amber); }
.toast.error .toast-icon { background: var(--red-bg); color: var(--red); }
.toast-body { flex: 1; }
.toast-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.toast-desc { font-size: 12px; color: var(--slate); line-height: 1.4; }
.toast-close {
    color: var(--mute);
    padding: 2px;
}

/* ================================================================
   Dialog panels, drawers
   ================================================================ */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(10, 10, 11, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
    z-index: 900;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 560px; max-width: 100vw;
    background: white;
    box-shadow: var(--shadow-xl);
    transform: translateX(100%);
    transition: transform 0.35s var(--ease);
    z-index: 950;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
    padding: 20px 24px;
    border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: flex-start;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-foot {
    padding: 16px 24px;
    border-top: 1px solid var(--line);
    display: flex; justify-content: flex-end; gap: 10px;
}

/* ================================================================
   Tab bar
   ================================================================ */
.tab-bar {
    display: flex; gap: 2px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab-item {
    padding: 10px 16px;
    font-size: 13px; font-weight: 500;
    color: var(--slate);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color 0.2s;
}
.tab-item:hover { color: var(--black); }
.tab-item.active { color: var(--orange); font-weight: 600; }
.tab-item.active::after {
    content: '';
    position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px;
    background: var(--orange);
    border-radius: 2px 2px 0 0;
}
.tab-item .tab-count {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: var(--paper);
    border-radius: 8px;
    font-size: 10.5px; font-weight: 700;
    color: var(--slate);
}
.tab-item.active .tab-count { background: var(--orange-50); color: var(--orange); }

/* ================================================================
   Helpers
   ================================================================ */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-6 { margin-top: 6px; } .mt-10 { margin-top: 10px; } .mt-14 { margin-top: 14px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-10 { margin-bottom: 10px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; }
.text-mute { color: var(--mute); }
.text-slate { color: var(--slate); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.bold { font-weight: 700; }
.semibold { font-weight: 600; }
.monospace { font-family: 'JetBrains Mono', monospace; }
.text-right { text-align: right; }
.full-w { width: 100%; }

.skeleton {
    background: linear-gradient(90deg, var(--line-2), #E8E8EC, var(--line-2));
    background-size: 200% 100%;
    animation: skelShimmer 1.5s linear infinite;
    border-radius: 6px;
}
@keyframes skelShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Oman flag mini */
.om-flag {
    display: inline-block;
    width: 16px; height: 10px;
    border-radius: 2px;
    background: linear-gradient(to bottom, white 0%, white 33%, red 33%, red 66%, #0A4A1E 66%, #0A4A1E 100%);
    vertical-align: middle;
    margin-right: 4px;
}

/* ================================================================
   Responsive niceties
   ================================================================ */
@media (max-width: 1400px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .chat-shell { grid-template-columns: 240px 1fr 280px; }
}
@media (max-width: 1200px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .fh-stats { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .chat-shell { grid-template-columns: 220px 1fr; }
    .chat-insights { display: none; }
}
