/* =========================================
   Techware Hub — Cosmic Gradient Theme
   ========================================= */

:root {
    --bg: #07071c;
    --surface: #0e0e2a;
    --surface-raised: #141440;
    --border: rgba(110, 110, 220, 0.15);
    --border-light: rgba(150, 150, 255, 0.25);
    --text: #eeeeff;
    --text-muted: #8888c0;
    --text-dim: #4a4a90;
    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.22);
    --green: #10b981;
    --red: #ef4444;
    --yellow: #f59e0b;
}

/* Animated background orb positions */
@property --ob1x { syntax: '<percentage>'; initial-value: 15%; inherits: false; }
@property --ob1y { syntax: '<percentage>'; initial-value: 40%; inherits: false; }
@property --ob2x { syntax: '<percentage>'; initial-value: 85%; inherits: false; }
@property --ob2y { syntax: '<percentage>'; initial-value: 10%; inherits: false; }
@property --ob3x { syntax: '<percentage>'; initial-value: 60%; inherits: false; }
@property --ob3y { syntax: '<percentage>'; initial-value: 80%; inherits: false; }

@keyframes orb-move {
    0%   { --ob1x: 15%; --ob1y: 40%; --ob2x: 85%; --ob2y: 10%; --ob3x: 60%; --ob3y: 80%; }
    20%  { --ob1x: 28%; --ob1y: 55%; --ob2x: 72%; --ob2y: 28%; --ob3x: 45%; --ob3y: 65%; }
    40%  { --ob1x: 8%;  --ob1y: 70%; --ob2x: 92%; --ob2y: 8%;  --ob3x: 70%; --ob3y: 50%; }
    60%  { --ob1x: 40%; --ob1y: 25%; --ob2x: 55%; --ob2y: 40%; --ob3x: 30%; --ob3y: 85%; }
    80%  { --ob1x: 20%; --ob1y: 60%; --ob2x: 80%; --ob2y: 22%; --ob3x: 65%; --ob3y: 70%; }
    100% { --ob1x: 15%; --ob1y: 40%; --ob2x: 85%; --ob2y: 10%; --ob3x: 60%; --ob3y: 80%; }
}

body {
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse at var(--ob1x) var(--ob1y), rgba(99,102,241,0.10) 0%, transparent 55%),
        radial-gradient(ellipse at var(--ob2x) var(--ob2y), rgba(139,92,246,0.07) 0%, transparent 50%),
        radial-gradient(ellipse at var(--ob3x) var(--ob3y), rgba(6,182,212,0.05) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    animation: orb-move 30s ease-in-out infinite alternate;
}

/* --- Portal Navbar --- */
.twh-nav {
    background: rgba(7, 7, 28, 0.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 2px 30px rgba(99, 102, 241, 0.08);
    overflow: visible;
}
.twh-nav::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #06b6d4, #8b5cf6, #6366f1);
    background-size: 300% 100%;
    animation: nav-gradient-slide 5s linear infinite;
    z-index: 1;
}
@keyframes nav-gradient-slide {
    0%   { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}
.twh-nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.twh-nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.twh-nav-brand img { height: 32px; }
.twh-nav-divider { width: 1px; height: 20px; background: var(--border-light); }
.twh-nav-title { font-weight: 700; font-size: 15px; color: var(--text); }
.twh-nav-sub { font-size: 12px; color: var(--text-dim); }
.twh-nav-right { display: flex; align-items: center; gap: 12px; }
.twh-nav-badge {
    font-size: 12px; font-weight: 600;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 3px 12px; border-radius: 20px;
}
.twh-nav-signout {
    font-size: 12px; color: var(--text-muted);
    background: none; border: 1px solid var(--border);
    padding: 5px 14px; border-radius: 8px; cursor: pointer;
    transition: all 0.15s;
}
.twh-nav-signout:hover { color: var(--text); border-color: var(--border-light); }

/* --- Auth Gate --- */
#auth-gate {
    position: fixed; inset: 0;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 30% 50%, rgba(99,102,241,0.12) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.08) 0%, transparent 45%);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
}
.auth-card {
    background: linear-gradient(145deg, #0e0e2a, #141445);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 20px; padding: 40px; width: 100%; max-width: 360px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 50px rgba(99,102,241,0.12);
    position: relative;
}
.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #06b6d4);
    border-radius: 20px 20px 0 0;
}
.auth-logo { height: 48px; display: block; margin: 0 auto 12px; }
.auth-title { font-size: 20px; font-weight: 800; color: var(--text); text-align: center; }
.auth-sub {
    font-size: 11px; color: var(--text-dim); text-align: center;
    text-transform: uppercase; letter-spacing: 1.5px;
    margin-top: 4px; margin-bottom: 28px;
}
.auth-btn {
    width: 100%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white; font-weight: 700; font-size: 15px;
    padding: 12px; border-radius: 10px; border: none; cursor: pointer;
    transition: all 0.2s; margin-top: 4px;
    box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}
.auth-btn:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 6px 28px rgba(99,102,241,0.55);
    transform: translateY(-1px);
}
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* --- Card & Container --- */
.card-hover { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.card-hover:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px -8px rgba(99,102,241,0.3);
    border-color: var(--accent);
}

/* --- Input Fields --- */
.input-field {
    width: 100%;
    background-color: rgba(255,255,255,0.04) !important;
    border: 1px solid var(--border-light);
    border-radius: 10px; padding: 0.75rem 1rem;
    color: var(--text) !important; font-size: 1rem;
    outline: none; transition: all 0.2s ease-in-out; appearance: none;
}
.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background-color: rgba(255,255,255,0.07) !important;
}
.input-field::placeholder { color: var(--text-dim); }

/* Select Arrow Fix */
select.input-field {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%234a4a90' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center; background-repeat: no-repeat;
    background-size: 1.5em 1.5em; padding-right: 2.5rem;
}

/* Dark color scheme for native date/time pickers and select dropdowns */
input[type="date"],
input[type="time"],
input[type="datetime-local"] { color-scheme: dark; }
select { color-scheme: dark; }
select option {
    background-color: #0e0e2a;
    color: #eeeeff;
}

/* Autofill Fix */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #0e0e2a inset !important;
    -webkit-text-fill-color: var(--text) !important;
    caret-color: white;
    transition: background-color 5000s ease-in-out 0s;
}

/* --- TOAST NOTIFICATION --- */
.toast {
    visibility: hidden; min-width: 250px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff; text-align: center; border-radius: 10px;
    padding: 16px; position: fixed; z-index: 100; left: 50%; top: 30px;
    transform: translateX(-50%); font-size: 17px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    opacity: 0; transition: opacity 0.3s, top 0.3s;
}
.toast.show { visibility: visible; opacity: 1; top: 50px; }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* --- PENDING CARD STYLES --- */
.pending-card {
    background: linear-gradient(145deg, #0e0e2a, #111135);
    border: 1px solid var(--border);
    border-radius: 1rem; padding: 1.5rem;
    display: flex; flex-direction: column; gap: 1rem;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.pending-card:hover {
    transform: scale(1.01);
    border-color: rgba(99,102,241,0.4);
    box-shadow: 0 0 20px rgba(99,102,241,0.1);
}

/* --- CHAT WIDGET STYLES --- */
#chatMessages {
    overflow-y: auto; max-height: 20rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(99,102,241,0.3) transparent;
}
#chatMessages::-webkit-scrollbar { width: 4px; }
#chatMessages::-webkit-scrollbar-track { background: transparent; }
#chatMessages::-webkit-scrollbar-thumb {
    background: rgba(99,102,241,0.3); border-radius: 2px;
}

/* --- TABLE EDITABLE CELLS --- */
td[contenteditable="true"]:hover {
    background-color: rgba(99,102,241,0.08); cursor: text; border-radius: 4px;
}
td[contenteditable="true"]:focus {
    background-color: rgba(99,102,241,0.15); outline: 2px solid var(--accent);
}

/* --- ANIMATIONS --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in-up { animation: fadeInUp 0.3s ease-out forwards; }
.fade-in { animation: fadeInUp 0.25s ease-out; }

/* --- @MENTION DROPDOWN --- */
#mention-dropdown {
    position: absolute; bottom: 100%; left: 0; right: 0;
    background: linear-gradient(145deg, #0e0e2a, #141445);
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: 10px; max-height: 180px; overflow-y: auto;
    z-index: 100; box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
    margin-bottom: 4px;
}
#mention-dropdown .mention-item {
    padding: 8px 14px; cursor: pointer; font-size: 13px;
    color: var(--text-muted); transition: background 0.1s;
}
#mention-dropdown .mention-item:hover {
    background: rgba(99,102,241,0.15); color: var(--text);
}

/* =========================================
   GRADIENT TAILWIND OVERRIDES
   ========================================= */

/* Body backgrounds */
.bg-slate-900  { background-color: var(--bg) !important; }
.bg-slate-800  { background-color: var(--surface) !important; }
.bg-slate-800\/50 { background-color: rgba(14,14,42,0.5) !important; }
.bg-slate-900\/90 { background-color: rgba(7,7,28,0.92) !important; }
.bg-slate-900\/50 { background-color: rgba(7,7,28,0.5) !important; }
.bg-slate-900\/30 { background-color: rgba(7,7,28,0.3) !important; }
.bg-slate-700\/50 { background-color: rgba(20,20,64,0.5) !important; }
.bg-slate-700\/30 { background-color: rgba(20,20,64,0.3) !important; }

/* Borders */
.border-slate-700 { border-color: var(--border) !important; }
.border-slate-600 { border-color: var(--border-light) !important; }
.divide-slate-700 > * { border-color: var(--border) !important; }
.divide-slate-800 > * { border-color: rgba(99,102,241,0.08) !important; }

/* Text */
.text-slate-400 { color: var(--text-muted) !important; }
.text-slate-300 { color: #c4c4e8 !important; }
.text-slate-500 { color: var(--text-dim) !important; }
.text-white     { color: var(--text) !important; }

/* Blue / Accent overrides */
.bg-blue-600 { background-color: var(--accent) !important; }
.bg-blue-700 { background-color: #4338ca !important; }
.bg-blue-500 { background-color: #818cf8 !important; }
.hover\:bg-blue-500:hover,
.hover\:bg-blue-600:hover { background-color: var(--accent-hover) !important; }
.border-blue-500 { border-color: var(--accent) !important; }
.focus\:border-blue-500:focus { border-color: var(--accent) !important; }
.text-blue-400 { color: #818cf8 !important; }
.text-blue-300 { color: #a5b4fc !important; }
.shadow-blue-500\/30,
.shadow-blue-500\/20 { --tw-shadow-color: rgba(99,102,241,0.3) !important; }

/* Input overrides for Tailwind form elements */
.bg-slate-900.border { background-color: rgba(255,255,255,0.04) !important; }

/* Landing page gradient */
.from-blue-400  { --tw-gradient-from: #818cf8 !important; }
.to-purple-500  { --tw-gradient-to: #8b5cf6 !important; }

/* Manager nav specific */
.manager-nav {
    background: rgba(7, 7, 28, 0.95);
    backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 40;
    box-shadow: 0 2px 30px rgba(99,102,241,0.08);
    padding-top: 2px;
    background-image: linear-gradient(90deg, rgba(99,102,241,1) 0%, rgba(139,92,246,1) 50%, rgba(6,182,212,1) 100%);
    background-size: 100% 2px;
    background-repeat: no-repeat;
    background-position: top;
}

/* --- AGENT PORTAL ANALYSIS TABS --- */
.agent-tab-bar {
    position: sticky; top: 57px; z-index: 30;
    background: rgba(9,9,11,0.97);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(63,63,70,0.7);
}
.agent-tab-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px; border-radius: 8px;
    font-size: 13px; font-weight: 600;
    color: #71717a; border: 1px solid transparent;
    cursor: pointer; background: transparent;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.agent-tab-btn:hover { color: #e4e4e7; background: rgba(255,255,255,0.05); }
.agent-tab-active {
    color: #a5b4fc !important;
    background: rgba(99,102,241,0.12) !important;
    border-color: rgba(99,102,241,0.3) !important;
}
.game-sub-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 700;
    color: #71717a; border: 1px solid rgba(63,63,70,0.6);
    cursor: pointer; background: rgba(39,39,42,0.6);
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.game-sub-btn:hover { color: #e4e4e7; background: rgba(255,255,255,0.07); border-color: rgba(99,102,241,0.3); }
.game-sub-active {
    color: #a5b4fc !important;
    background: rgba(99,102,241,0.14) !important;
    border-color: rgba(99,102,241,0.4) !important;
}

/* Toast notification (professional) */
#toast-container {
    position: fixed; bottom: 80px; right: 20px;
    z-index: 10000; display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
}
.toast-message {
    display: flex; align-items: flex-start; gap: 12px;
    background: linear-gradient(145deg, #0e0e2a, #141440);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 14px; padding: 14px 16px;
    color: #eeeeff; font-size: 13px;
    min-width: 260px; max-width: 340px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
    pointer-events: all;
    animation: toastSlideIn 0.3s cubic-bezier(0.4,0,0.2,1) forwards;
}
.toast-success { border-color: rgba(16,185,129,0.35); }
.toast-error   { border-color: rgba(239,68,68,0.35); }
.toast-content { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.toast-title   { font-weight: 700; font-size: 13px; }
.toast-body    { color: #8888c0; font-size: 12px; }
.toast-close   { color: #4a4a90; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.toast-close:hover { color: #eeeeff; }
@keyframes toastSlideIn  { from { opacity:0; transform:translateY(12px) scale(0.97); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes toastSlideOut { from { opacity:1; transform:translateY(0) scale(1); } to { opacity:0; transform:translateY(8px) scale(0.96); } }

/* =========================================
   ENHANCED CARD EFFECTS
   ========================================= */

/* Glowing hover on all main surface cards */
.bg-slate-800 {
    transition: box-shadow 0.3s ease, border-color 0.3s ease !important;
}
.bg-slate-800:hover {
    box-shadow: 0 0 0 1px rgba(99,102,241,0.15), 0 20px 50px rgba(0,0,0,0.45) !important;
}

/* Stat number glow pulse */
@keyframes stat-glow {
    0%, 100% { text-shadow: 0 0 12px currentColor; }
    50%       { text-shadow: 0 0 28px currentColor, 0 0 8px currentColor; }
}
.text-green-400 { animation: stat-glow 4s ease-in-out infinite; }
.text-blue-400  { animation: stat-glow 4s ease-in-out infinite 1s; }
.text-yellow-400 { animation: stat-glow 4s ease-in-out infinite 2s; }

/* Stagger entrance helpers */
@keyframes staggerIn {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.stagger-1 { animation: staggerIn 0.4s cubic-bezier(0.4,0,0.2,1) 0.05s backwards; }
.stagger-2 { animation: staggerIn 0.4s cubic-bezier(0.4,0,0.2,1) 0.10s backwards; }
.stagger-3 { animation: staggerIn 0.4s cubic-bezier(0.4,0,0.2,1) 0.15s backwards; }
.stagger-4 { animation: staggerIn 0.4s cubic-bezier(0.4,0,0.2,1) 0.20s backwards; }
.stagger-5 { animation: staggerIn 0.4s cubic-bezier(0.4,0,0.2,1) 0.25s backwards; }

/* Auth card entrance */
.auth-card {
    animation: staggerIn 0.5s cubic-bezier(0.34,1.36,0.64,1) forwards;
}

/* Shimmer loading skeleton */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}
.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.03) 0%,
        rgba(255,255,255,0.07) 50%,
        rgba(255,255,255,0.03) 100%);
    background-size: 800px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 6px;
}

/* Nav gradient line enhanced — faster pulse */
@keyframes nav-gradient-slide {
    0%   { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

/* Button press micro-interaction */
button:active:not(:disabled) { transform: scale(0.97) !important; }

/* Input focus ring pulse */
@keyframes focus-ring {
    0%   { box-shadow: 0 0 0 3px var(--accent-glow); }
    50%  { box-shadow: 0 0 0 5px rgba(99,102,241,0.12); }
    100% { box-shadow: 0 0 0 3px var(--accent-glow); }
}
.input-field:focus {
    animation: focus-ring 2s ease-in-out infinite;
}

/* =========================================
   MOBILE RESPONSIVE
   ========================================= */

/* Tables always have horizontal scroll on narrow screens */
.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(99,102,241,0.25) transparent;
}

/* Agent analysis tab bar — horizontal scroll on mobile */
.agent-tab-bar > div {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap !important;
}
.agent-tab-bar > div::-webkit-scrollbar { display: none; }
.agent-tab-btn { white-space: nowrap; }

@media (max-width: 768px) {
    /* Nav */
    .twh-nav-sub  { display: none !important; }
    .twh-nav-inner { padding: 10px 14px; gap: 8px; }

    /* Auth card */
    .auth-card { margin: 16px; padding: 28px 20px; max-width: calc(100vw - 32px); }

    /* Big stat numbers */
    .text-4xl { font-size: 2rem !important; }
    .text-3xl { font-size: 1.5rem !important; }

    /* Form grids stack */
    .grid.md\:grid-cols-2 { grid-template-columns: 1fr !important; }

    /* Toast full width */
    #toast-container { right: 10px; left: 10px; bottom: 75px; }
    .toast-message   { min-width: unset; max-width: 100%; }

    /* Chat widget full width */
    #chatWindow {
        left: 8px !important; right: 8px !important;
        width: auto !important; bottom: 76px !important;
    }
    #chatToggleBtn { bottom: 14px !important; left: 14px !important; }

    /* Reduce padding */
    .p-8  { padding: 18px !important; }
    .p-10 { padding: 20px !important; }

    /* Manager stats grid — force 1 col */
    #viewStats .grid { grid-template-columns: 1fr !important; }

    /* Performance list — 1 col */
    #agentPerformanceList { grid-template-columns: 1fr !important; }

    /* Pending sub-tab buttons wrap */
    #viewPending .flex.gap-4 { flex-wrap: wrap; gap: 8px !important; }

    /* Manager nav — scrollable row */
    .manager-nav-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    .manager-nav-row::-webkit-scrollbar { display: none; }
    .manager-nav-row button { white-space: nowrap !important; }

    /* Analysis charts */
    canvas { max-width: 100% !important; }

    /* Table min-width for content */
    .overflow-x-auto table { min-width: 520px; }

    /* Landing page hero */
    .text-5xl { font-size: 2.2rem !important; }
    .text-6xl { font-size: 2.5rem !important; }
}

/* =========================================
   THEMES
   ========================================= */
:root[data-theme="dark"] {
    --bg: #0a0a0a; --surface: #111111; --surface-raised: #1a1a1a;
    --border: rgba(255,255,255,0.07); --border-light: rgba(255,255,255,0.12);
    --text: #f0f0f0; --text-muted: #888888; --text-dim: #555555;
}
:root[data-theme="dark"] body {
    background-image: radial-gradient(ellipse at 20% 30%, rgba(99,102,241,0.06) 0%, transparent 50%);
    animation: none;
}
:root[data-theme="dark"] .bg-slate-800 { background-color: #111111 !important; }
:root[data-theme="dark"] .bg-slate-900 { background-color: #0a0a0a !important; }
:root[data-theme="dark"] .bg-slate-900\/90 { background-color: rgba(10,10,10,0.93) !important; }
:root[data-theme="dark"] .twh-nav { background: rgba(10,10,10,0.96) !important; }

:root[data-theme="light"] {
    --bg: #f3f4ff; --surface: #ffffff; --surface-raised: #eef0ff;
    --border: rgba(99,102,241,0.15); --border-light: rgba(99,102,241,0.3);
    --text: #111827; --text-muted: #4b5563; --text-dim: #9ca3af;
    --accent-glow: rgba(99,102,241,0.1);
}
:root[data-theme="light"] body {
    background-image: radial-gradient(ellipse at 15% 40%, rgba(99,102,241,0.07) 0%, transparent 55%),
                      radial-gradient(ellipse at 85% 10%, rgba(139,92,246,0.05) 0%, transparent 50%);
    animation: none;
}
:root[data-theme="light"] .bg-slate-800  { background-color: #ffffff !important; }
:root[data-theme="light"] .bg-slate-900  { background-color: #f8f8ff !important; }
:root[data-theme="light"] .bg-slate-800\/50 { background-color: rgba(255,255,255,0.7) !important; }
:root[data-theme="light"] .bg-slate-900\/90 { background-color: rgba(248,248,255,0.95) !important; }
:root[data-theme="light"] .text-white    { color: #111827 !important; }
:root[data-theme="light"] .text-slate-400 { color: #6b7280 !important; }
:root[data-theme="light"] .text-slate-300 { color: #374151 !important; }
:root[data-theme="light"] .text-slate-500 { color: #9ca3af !important; }
:root[data-theme="light"] .border-slate-700 { border-color: rgba(99,102,241,0.15) !important; }
:root[data-theme="light"] .border-slate-600 { border-color: rgba(99,102,241,0.25) !important; }
:root[data-theme="light"] .bg-zinc-950  { background-color: #f3f4ff !important; }
:root[data-theme="light"] .bg-zinc-800  { background-color: #ffffff !important; }
:root[data-theme="light"] .text-zinc-200 { color: #111827 !important; }
:root[data-theme="light"] .bg-slate-700 { background-color: #eef0ff !important; }
:root[data-theme="light"] .twh-nav { background: rgba(255,255,255,0.95) !important; }
:root[data-theme="light"] .pending-card { background: linear-gradient(145deg,#fff,#f8f8ff) !important; }
:root[data-theme="light"] .auth-card    { background: linear-gradient(145deg,#fff,#eef0ff) !important; }
:root[data-theme="light"] #chatWindow   { background: #ffffff !important; }
:root[data-theme="light"] .bg-slate-800.border { border-color: rgba(99,102,241,0.2) !important; }

/* =========================================
   NIGHT WIDGET — THEME AWARE + MOBILE
   ========================================= */
#night-widget {
    background: linear-gradient(135deg,#4338ca,#6366f1);
    border-color: rgba(99,102,241,0.4);
    color: white;
    cursor: default;
    transition: all 0.3s;
    user-select: none;
}
#night-widget.nw-collapsed #nw-expanded { display: none !important; }
#night-widget.nw-collapsed .nw-value    { margin-bottom: 0 !important; }
#night-widget .nw-label  { color: rgba(255,255,255,0.65); font-size:10px; }
#night-widget .nw-value  { color: white; }
#night-widget .nw-select { color: white; background: rgba(255,255,255,0.15) !important; }
#night-widget .nw-breakdown { color: rgba(255,255,255,0.85); border-color: rgba(255,255,255,0.15); }

:root[data-theme="dark"] #night-widget {
    background: linear-gradient(135deg,#141445,#1e1e5a);
    border-color: rgba(99,102,241,0.4); color: #eeeeff;
}
:root[data-theme="dark"] #night-widget .nw-label  { color: rgba(200,200,255,0.55); }
:root[data-theme="dark"] #night-widget .nw-value  { color: #a5b4fc; }
:root[data-theme="dark"] #night-widget .nw-select { color: #eeeeff; }
:root[data-theme="dark"] #night-widget .nw-breakdown { color: #c4c4e8; border-color: rgba(99,102,241,0.2); }

:root[data-theme="light"] #night-widget {
    background: linear-gradient(135deg,#6366f1,#8b5cf6);
    border-color: rgba(99,102,241,0.3); color: white;
}
:root[data-theme="light"] #night-widget .nw-label  { color: rgba(255,255,255,0.7); }
:root[data-theme="light"] #night-widget .nw-value  { color: white; }
:root[data-theme="light"] #night-widget .nw-select { color: white; background: rgba(255,255,255,0.15) !important; }
:root[data-theme="light"] #night-widget .nw-breakdown { color: rgba(255,255,255,0.85); border-color: rgba(255,255,255,0.2); }

/* =========================================
   PARALLAX ORBS
   ========================================= */
.px-orb {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    will-change: transform;
}
.px-orb-1 {
    width: 700px; height: 700px;
    top: -250px; left: -180px;
    background: radial-gradient(circle at center, rgba(99,102,241,0.22) 0%, transparent 68%);
    filter: blur(55px);
}
.px-orb-2 {
    width: 550px; height: 550px;
    bottom: -180px; right: -120px;
    background: radial-gradient(circle at center, rgba(139,92,246,0.18) 0%, transparent 65%);
    filter: blur(50px);
}
.px-orb-3 {
    width: 350px; height: 350px;
    top: 40vh; left: 60vw;
    background: radial-gradient(circle at center, rgba(167,139,250,0.14) 0%, transparent 60%);
    filter: blur(45px);
}

/* =========================================
   SCROLL REVEAL — 3D rise + left/right fly-in
   ========================================= */
.sr { opacity: 0; }
.sr.sr-in { animation: sr-rise 0.7s cubic-bezier(0.22,1,0.36,1) both; }
@keyframes sr-rise {
    from { opacity: 0; transform: perspective(700px) rotateX(7deg) translateY(30px); }
    to   { opacity: 1; transform: perspective(700px) rotateX(0deg) translateY(0); }
}

.sr-left { opacity: 0; }
.sr-left.sr-in { animation: sr-fly-left 0.65s cubic-bezier(0.22,1,0.36,1) both; }
@keyframes sr-fly-left {
    from { opacity: 0; transform: translateX(-36px); }
    to   { opacity: 1; transform: translateX(0); }
}

.sr-right { opacity: 0; }
.sr-right.sr-in { animation: sr-fly-right 0.65s cubic-bezier(0.22,1,0.36,1) both; }
@keyframes sr-fly-right {
    from { opacity: 0; transform: translateX(36px); }
    to   { opacity: 1; transform: translateX(0); }
}

.sr-d1 { animation-delay: 0.06s !important; }
.sr-d2 { animation-delay: 0.13s !important; }
.sr-d3 { animation-delay: 0.20s !important; }
.sr-d4 { animation-delay: 0.27s !important; }
.sr-d5 { animation-delay: 0.34s !important; }

/* =========================================
   SCROLL PROGRESS BAR
   ========================================= */
#scroll-progress {
    position: fixed; top: 0; left: 0; z-index: 99999;
    height: 3px; width: 0%;
    background: linear-gradient(90deg, #4338ca, #6366f1, #a78bfa);
    box-shadow: 0 0 8px rgba(99,102,241,0.6);
    transition: width 0.12s linear;
    pointer-events: none;
}

@media (max-width: 768px) {
    #night-widget {
        min-width: 100px !important; padding: 7px 10px !important;
        top: 62px !important; right: 5px !important;
    }
    #night-widget .nw-value { font-size: 1.1rem !important; }
    #night-widget .nw-label { font-size: 9px !important; }
    #nw-expanded { display: none; }
    #night-widget:not(.nw-collapsed) #nw-expanded { display: block !important; }
}

/* =========================================
   BROADCAST BANNER
   ========================================= */
#broadcast-banner {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; z-index: 99999;
    padding: 13px 20px;
    background: linear-gradient(135deg,#6366f1,#8b5cf6);
    color: white; font-weight: 700; font-size: 14px;
    box-shadow: 0 4px 24px rgba(99,102,241,0.5);
    animation: toastSlideIn 0.3s ease-out;
}
#broadcast-banner.bcast-show { display: flex; align-items: center; justify-content: center; gap: 10px; }
#broadcast-banner .bcast-close { cursor: pointer; opacity: 0.7; padding: 0 8px; font-size: 16px; }
#broadcast-banner .bcast-close:hover { opacity: 1; }

/* =========================================
   SETTINGS PANEL (theme + sound)
   ========================================= */
#settings-btn {
    position: fixed; bottom: 20px; right: 20px; z-index: 9998;
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3);
    cursor: pointer; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; backdrop-filter: blur(8px); color: var(--text);
}
#settings-btn:hover { background: rgba(99,102,241,0.3); transform: scale(1.08) rotate(30deg); }
#settings-panel {
    display: none; position: fixed;
    bottom: 74px; right: 12px; z-index: 9999;
    background: linear-gradient(145deg,#0e0e2a,#141445);
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: 16px; padding: 16px 18px; min-width: 230px;
    box-shadow: 0 16px 56px rgba(0,0,0,0.7); backdrop-filter: blur(16px);
    animation: toastSlideIn 0.2s ease-out;
}
#settings-panel.sp-show { display: block; }
:root[data-theme="light"] #settings-panel { background: linear-gradient(145deg,#fff,#eef0ff); border-color: rgba(99,102,241,0.25); }
.sp-label { font-size: 10px; font-weight: 800; color: #4a4a90; text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 8px; }
.sp-row   { display: flex; gap: 6px; margin-bottom: 14px; }
.sp-opt {
    flex: 1; padding: 6px 4px; border-radius: 8px; cursor: pointer;
    border: 1px solid rgba(99,102,241,0.2); background: rgba(99,102,241,0.07);
    color: var(--text-muted); font-size: 11px; font-weight: 700; text-align: center;
    transition: all 0.15s;
}
.sp-opt:hover { background: rgba(99,102,241,0.2); color: var(--text); }
.sp-opt.sp-active { background: rgba(99,102,241,0.25); color: #a5b4fc; border-color: rgba(99,102,241,0.5); }

/* =========================================
   SHIFT COUNTDOWN
   ========================================= */
#shift-countdown {
    font-size: 11px; font-weight: 800;
    font-family: ui-monospace, monospace;
    padding: 3px 10px; border-radius: 20px;
    background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.3);
    color: #a5b4fc; display: none;
    transition: all 0.3s;
}
#shift-countdown.sc-show  { display: inline-block; }
#shift-countdown.sc-urgent { background: rgba(239,68,68,0.15) !important; border-color: rgba(239,68,68,0.4) !important; color: #fca5a5 !important; }

@media (max-width: 480px) {
    .twh-nav-brand img { height: 26px; }
    .twh-nav-title     { font-size: 13px; }
    .auth-card         { padding: 22px 16px; }
    .auth-btn          { font-size: 14px; }

    /* Stack pending sub-tabs */
    #viewPending .flex.items-center.gap-6 { flex-direction: column; align-items: flex-start; gap: 12px !important; }
}

/* =========================================
   PARTICLE FIELD CANVAS
   ========================================= */
#twh-particles {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0; pointer-events: none;
    opacity: 0.82;
}

/* =========================================
   3D EXTRUDED TEXT
   ========================================= */
.twh-3d-text {
    text-shadow:
        0 1px 0 rgba(99,102,241,0.65),
        0 2px 0 rgba(99,102,241,0.45),
        0 3px 0 rgba(99,102,241,0.28),
        0 4px 0 rgba(99,102,241,0.15),
        0 5px 0 rgba(99,102,241,0.08),
        0 8px 20px rgba(0,0,0,0.55);
}

/* =========================================
   SUBMIT BUTTON RIPPLE
   ========================================= */
.twh-ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: twh-ripple-out 0.65s ease-out forwards;
    background: rgba(255,255,255,0.28);
    pointer-events: none;
}
@keyframes twh-ripple-out {
    to { transform: scale(4); opacity: 0; }
}

/* =========================================
   ANALYSIS TABLE — ROW SCROLL EFFECTS
   ========================================= */
tbody tr.tbl-row-reveal {
    opacity: 0;
    transition: opacity 0.52s ease, transform 0.52s cubic-bezier(0.22,1,0.36,1),
                background 0.18s ease, box-shadow 0.18s ease;
}
tbody tr.tbl-row-reveal.from-left  { transform: translateX(-34px) perspective(600px) rotateY(-7deg); }
tbody tr.tbl-row-reveal.from-right { transform: translateX(34px)  perspective(600px) rotateY(7deg); }
tbody tr.tbl-row-reveal.visible    { opacity: 1; transform: translateX(0) perspective(600px) rotateY(0); }
tbody tr.tbl-row-reveal:hover      {
    background: rgba(99,102,241,0.09) !important;
    box-shadow: inset 4px 0 0 rgba(99,102,241,0.6);
    transform: translateX(4px) scale(1.004) !important;
}

/* Scan-line sweep across table on load */
.tbl-scan-wrap { position: relative; }
.tbl-scan-line {
    position: absolute; left: 0; right: 0; top: 0;
    height: 2px; pointer-events: none; z-index: 20;
    background: linear-gradient(90deg, transparent 0%, rgba(99,102,241,0.85) 35%,
                rgba(167,139,250,1) 50%, rgba(99,102,241,0.85) 65%, transparent 100%);
    box-shadow: 0 0 14px 2px rgba(99,102,241,0.5);
    animation: tbl-scan 1.9s cubic-bezier(0.4,0,0.6,1) forwards;
}
@keyframes tbl-scan {
    0%   { top: 0%;   opacity: 1; }
    88%  { top: 100%; opacity: 0.9; }
    100% { top: 100%; opacity: 0; }
}

/* Analysis stat cards — 3D hover lift */
.analysis-stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    cursor: default;
}
.analysis-stat-card:hover {
    transform: perspective(700px) rotateX(-5deg) translateY(-5px) scale(1.035) !important;
    box-shadow: 0 18px 44px rgba(99,102,241,0.28), 0 0 0 1px rgba(99,102,241,0.35) !important;
}

/* =========================================
   CARD TILT — extended to index + manager cards
   ========================================= */
.twh-tilt {
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.twh-tilt:hover { outline: none; }

/* =========================================
   TWH MODAL — custom alert/confirm popup
   ========================================= */
.twh-modal-backdrop {
    position: fixed; inset: 0; z-index: 99999;
    background: rgba(7, 7, 28, 0.78);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.18s ease;
    padding: 16px;
}
.twh-modal-backdrop.show { opacity: 1; pointer-events: auto; }
.twh-modal-card {
    background: linear-gradient(145deg, #0e0e2a, #141445);
    border: 1px solid rgba(99,102,241,0.35);
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(99,102,241,0.15);
    width: 100%; max-width: 420px;
    transform: translateY(14px) scale(0.96);
    transition: transform 0.22s cubic-bezier(0.22,1,0.36,1);
    overflow: hidden;
    color: #e5e7ff;
}
.twh-modal-backdrop.show .twh-modal-card { transform: translateY(0) scale(1); }
.twh-modal-head {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 22px 14px;
    border-bottom: 1px solid rgba(99,102,241,0.18);
}
.twh-modal-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800;
    flex-shrink: 0;
}
.twh-modal-icon.info    { background: rgba(99,102,241,0.18);  color: #a5b4fc; }
.twh-modal-icon.success { background: rgba(34,197,94,0.18);   color: #4ade80; }
.twh-modal-icon.warning { background: rgba(251,191,36,0.18);  color: #fbbf24; }
.twh-modal-icon.error   { background: rgba(239,68,68,0.18);   color: #f87171; }
.twh-modal-icon.confirm { background: rgba(168,85,247,0.18);  color: #c084fc; }
.twh-modal-title {
    font-size: 15px; font-weight: 700;
    color: #eeeeff;
}
.twh-modal-body {
    padding: 16px 22px 20px;
    font-size: 14px; line-height: 1.55;
    color: #cdd0e8;
    white-space: pre-wrap;
    max-height: 50vh; overflow-y: auto;
}
.twh-modal-foot {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 12px 20px 18px;
    background: rgba(7,7,28,0.4);
    border-top: 1px solid rgba(99,102,241,0.12);
}
.twh-modal-btn {
    padding: 9px 18px; font-size: 13px; font-weight: 700;
    border-radius: 9px; border: none; cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
    min-width: 82px;
}
.twh-modal-btn:hover { filter: brightness(1.12); }
.twh-modal-btn:active { transform: scale(0.97); }
.twh-modal-btn.primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
}
.twh-modal-btn.danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
}
.twh-modal-btn.ghost {
    background: rgba(255,255,255,0.06);
    color: #cbd5e1;
    border: 1px solid rgba(255,255,255,0.1);
}
