/* ========================================
   SEIYO Design System v4.0
   Dark/Light theme — deep blue primary
   Font: Outfit | Primary: Deep Blue | Accent: Light Blue
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- Design Tokens --- */
:root {
    /* Surface colors — warm charcoal */
    --surface-base: #1a1a1a;
    --surface-raised: #222222;
    --surface-overlay: #2a2a2a;
    --surface-card: rgba(255, 255, 255, 0.04);
    --surface-interactive: #333333;
    --surface-border: rgba(255, 255, 255, 0.1);
    --surface-border-hover: rgba(255, 255, 255, 0.15);
    --surface-border-accent: rgba(24, 95, 165, 0.3);

    /* Brand colors — deep blue primary */
    --brand-primary: #185FA5;
    --brand-primary-hover: #1a6fb8;
    --brand-primary-subtle: rgba(24, 95, 165, 0.1);
    --brand-primary-muted: rgba(24, 95, 165, 0.2);
    --brand-primary-light: #5BA3E8;

    /* Accent — light blue */
    --accent: #5BA3E8;
    --accent-hover: #79b5ee;
    --accent-subtle: rgba(91, 163, 232, 0.08);
    --accent-muted: rgba(91, 163, 232, 0.15);

    /* Semantic colors */
    --success: #97C459;
    --success-subtle: rgba(151, 196, 89, 0.1);
    --warning: #FAC775;
    --warning-subtle: rgba(250, 199, 117, 0.1);
    --danger: #F09595;
    --danger-hover: #ef6b6b;
    --danger-subtle: rgba(240, 149, 149, 0.1);
    --info: #5BA3E8;
    --info-subtle: rgba(91, 163, 232, 0.1);

    /* Text colors */
    --text-primary: #e0e0e0;
    --text-secondary: #999999;
    --text-tertiary: #666666;
    --text-disabled: #444444;

    /* Typography — Outfit: premium geometric sans */
    --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    --text-display: 2.75rem;    /* 44px — page heroes, big numbers */
    --text-title: 1.625rem;     /* 26px — section headers */
    --text-heading: 1.125rem;   /* 18px — card titles */
    --text-body: 0.875rem;      /* 14px — body text */
    --text-caption: 0.8125rem;  /* 13px — labels */
    --text-micro: 0.75rem;      /* 12px — badges, timestamps */

    --leading-tight: 1.15;
    --leading-normal: 1.5;
    --leading-relaxed: 1.6;

    --tracking-tighter: -0.035em;
    --tracking-tight: -0.02em;
    --tracking-normal: 0;
    --tracking-wide: 0.05em;

    /* Spacing scale */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */

    /* Radii — larger for premium squircle feel */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --radius-full: 9999px;

    /* Shadows — tinted to background hue, never pure black */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.3);
    --shadow-diffuse: 0 20px 40px -15px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 24px rgba(24, 95, 165, 0.15);
    --shadow-accent-glow: 0 0 24px rgba(91, 163, 232, 0.15);

    /* Motion — cinematic spring physics */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-premium: cubic-bezier(0.32, 0.72, 0, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 500ms;
}


/* --- Base Reset & Typography --- */
body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--surface-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.text-display {
    font-size: var(--text-display);
    font-weight: 700;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tighter);
}

.text-title {
    font-size: var(--text-title);
    font-weight: 600;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
}

.text-heading {
    font-size: var(--text-heading);
    font-weight: 600;
    line-height: var(--leading-tight);
}

.text-body {
    font-size: var(--text-body);
    line-height: var(--leading-relaxed);
}

.text-caption {
    font-size: var(--text-caption);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
}

.text-micro {
    font-size: var(--text-micro);
    color: var(--text-tertiary);
    line-height: var(--leading-normal);
    letter-spacing: var(--tracking-wide);
}


/* --- Accent Color Utilities --- */
.accent-text { color: var(--accent); }
.accent-text-hover:hover { color: var(--accent-hover); }
.accent-border { border-color: var(--accent); }
.accent-bg { background: var(--accent); color: var(--surface-base); }
.accent-glow { box-shadow: var(--shadow-accent-glow); }


/* --- Button System (no gradients) --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-size: var(--text-body);
    font-weight: 500;
    line-height: 1;
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-5);
    transition: all var(--duration-fast) var(--ease-out);
    cursor: pointer;
    border: 1px solid transparent;
    outline: none;
    white-space: nowrap;
}

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

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

/* Primary — solid indigo, white text */
.btn-primary {
    background: var(--brand-primary);
    color: white;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
    background: var(--brand-primary-hover);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

/* Accent — gold variant, dark text */
.btn-accent {
    background: var(--accent);
    color: var(--surface-base);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.btn-accent:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md), var(--shadow-accent-glow);
    transform: translateY(-1px);
}

/* Secondary — ghost with border */
.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--surface-border);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface-interactive);
    color: var(--text-primary);
    border-color: var(--surface-border-hover);
    transform: translateY(-1px);
}

/* Ghost — no border, text only */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-interactive);
    color: var(--text-primary);
}

/* Danger */
.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
    box-shadow: var(--shadow-md), 0 0 16px rgba(240, 149, 149, 0.2);
}

/* Size variants */
.btn-sm {
    font-size: var(--text-micro);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
}

.btn-lg {
    font-size: 0.9375rem;
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-lg);
}

.btn-xl {
    font-size: 1rem;
    padding: var(--space-4) var(--space-8);
    border-radius: var(--radius-lg);
    font-weight: 600;
}

.btn-full { width: 100%; }
.btn-icon {
    padding: var(--space-2);
    border-radius: var(--radius-md);
    width: 36px;
    height: 36px;
}


/* --- Container Hierarchy --- */

/* Level 1: Page sections, hero areas — most prominent */
.surface-hero {
    background: linear-gradient(135deg, var(--surface-raised) 0%, rgba(24, 95, 165, 0.03) 100%);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
}

/* Level 2: Standard cards — primary content */
.surface-card {
    background: var(--surface-raised);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
}

.surface-card-interactive:hover {
    border-color: var(--surface-border-hover);
    box-shadow: var(--shadow-md);
}

/* Level 3: Nested elements inside cards — subtle */
.surface-inset {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
}

/* Level 4: Flat backgrounds — no border, minimal */
.surface-flat {
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
}

/* Accent-bordered card for emphasis */
.surface-accent {
    background: var(--surface-raised);
    border: 1px solid var(--surface-border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-lg);
}

/* Critical/alert card */
.surface-critical {
    background: var(--danger-subtle);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-left: 3px solid var(--danger);
    border-radius: var(--radius-lg);
}

/* Success card */
.surface-success {
    background: var(--success-subtle);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-left: 3px solid var(--success);
    border-radius: var(--radius-lg);
}


/* --- Input System --- */
.input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-overlay);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-body);
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
    outline: none;
}

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

.input:focus,
.login-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-subtle), 0 0 16px rgba(24, 95, 165, 0.08);
}

.input-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

.input-with-icon {
    padding-left: var(--space-10);
}

.input-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-disabled);
    font-size: var(--text-body);
    pointer-events: none;
}


/* --- Badge System --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    font-size: var(--text-micro);
    font-weight: 500;
    border-radius: var(--radius-full);
    line-height: 1.5;
}

.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-danger { background: var(--danger-subtle); color: var(--danger); }
.badge-info { background: var(--info-subtle); color: var(--info); }
.badge-accent { background: var(--accent-subtle); color: var(--accent); }
.badge-neutral { background: rgba(255,255,255,0.06); color: var(--text-secondary); }


/* --- Motion & Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

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

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

@keyframes pulseRing {
    0% { transform: scale(0.8); opacity: 0.5; }
    100% { transform: scale(2); opacity: 0; }
}

@keyframes subtlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.animate-fade-in { animation: fadeIn var(--duration-normal) var(--ease-out) both; }
.animate-fade-in-up { animation: fadeInUp var(--duration-slow) var(--ease-out) both; }
.animate-fade-in-scale { animation: fadeInScale var(--duration-slow) var(--ease-out) both; }
.animate-slide-in-left { animation: slideInLeft var(--duration-slow) var(--ease-out) both; }

/* Staggered children */
.stagger-children > * { animation: fadeInUp var(--duration-slow) var(--ease-out) both; }
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }
.stagger-children > *:nth-child(7) { animation-delay: 360ms; }
.stagger-children > *:nth-child(8) { animation-delay: 420ms; }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--surface-overlay) 25%, var(--surface-interactive) 50%, var(--surface-overlay) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* Pulse dot (live indicators) */
.pulse-dot {
    position: relative;
}
.pulse-dot::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: inherit;
    border-radius: 50%;
    z-index: -1;
    animation: pulseRing 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}


/* --- Scrollbar --- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-interactive); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-disabled); }


/* --- Accessibility --- */
:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* --- Table Enhancements --- */
.table-row {
    transition: background var(--duration-fast) var(--ease-out);
}

.table-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.table-header {
    font-size: var(--text-micro);
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--surface-border);
}

.table-cell {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-body);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}


/* --- Sidebar (shared across dashboard pages) --- */
.sidebar {
    width: 260px;
    background: var(--surface-raised);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
    z-index: 20;
}

.sidebar > div:first-child {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    border-bottom: 1px solid var(--surface-border);
}

.sidebar-logo-mark {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.sidebar-logo-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    margin: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    font-size: var(--text-body);
    font-weight: 450;
    transition: all var(--duration-fast) var(--ease-out);
    text-decoration: none;
    border: 1px solid transparent;
}

.sidebar-nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-nav-item.active {
    color: var(--brand-primary);
    background: var(--brand-primary-subtle);
    border-color: var(--brand-primary-muted);
}

.sidebar-section-label {
    font-size: var(--text-micro);
    font-weight: 500;
    color: var(--text-disabled);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    padding: var(--space-6) var(--space-6) var(--space-2);
}

.sidebar-nav-icon {
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}


/* --- Header (shared across dashboard pages) --- */
.page-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    border-bottom: 1px solid var(--surface-border);
    flex-shrink: 0;
}

.page-title {
    font-size: var(--text-heading);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
}


/* --- Collapsible Sections --- */
.section-collapsible .section-content {
    overflow: hidden;
    transition: grid-template-rows var(--duration-normal) var(--ease-out);
    display: grid;
    grid-template-rows: 1fr;
}

.section-collapsible.collapsed .section-content {
    grid-template-rows: 0fr;
}

.section-collapsible .section-content > div {
    overflow: hidden;
}

.section-collapsible .collapse-icon {
    transition: transform var(--duration-fast) var(--ease-out);
}

.section-collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}


/* --- Mobile Responsive Sidebar --- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 25;
}

.sidebar-backdrop.open {
    display: block;
    animation: fadeIn var(--duration-fast) var(--ease-out);
}

@media (max-width: 1023px) {
    .sidebar {
        position: fixed;
        inset-block: 0;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.3s var(--ease-out);
        z-index: 30;
    }
    .sidebar.open {
        transform: translateX(0);
    }
}


/* --- Accent line (section divider) --- */
.gold-line {
    width: 48px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 2px;
}


/* --- Utility: Text overflow safety --- */
.truncate-safe {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}


/* --- KPI / Metric Cards --- */
.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
}

.metric-label {
    font-size: var(--text-micro);
    font-weight: 500;
    color: var(--text-tertiary);
    margin-bottom: var(--space-1);
}

.metric-trend-up { color: var(--success); }
.metric-trend-down { color: var(--danger); }
.metric-trend-flat { color: var(--text-tertiary); }


/* ==========================================================================
   Widget System (seiyo-widgets.js)
   ========================================================================== */

.widget-container { min-height: 120px; position: relative; }
.widget-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.widget-header-title { font-size: var(--text-heading); font-weight: 600; color: var(--text-primary); }
.widget-header-action { font-size: var(--text-micro); color: var(--accent); cursor: pointer; }
.widget-header-action:hover { color: var(--accent-hover); }

/* Sparkline container */
.sparkline { display: inline-flex; align-items: flex-end; gap: var(--space-1); height: 32px; }
.sparkline-bar { width: 4px; border-radius: 2px; background: var(--brand-primary); transition: height var(--duration-fast) var(--ease-out); }
.sparkline-bar:last-child { background: var(--accent); }

/* Trend indicators */
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-flat { color: var(--text-tertiary); }

/* Kanban columns */
.kanban-board { display: flex; gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-4); }
.kanban-column { flex: 1; min-width: 250px; }
.kanban-column-header { padding: var(--space-3); border-radius: var(--radius-md) var(--radius-md) 0 0; }
.kanban-cards { min-height: 100px; padding: var(--space-2); }
.kanban-card { padding: var(--space-3); margin-bottom: var(--space-2); border-radius: var(--radius-md); cursor: grab; transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast); }
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kanban-card.sortable-ghost { opacity: 0.4; }

/* Clickable widget deep-link styles */
.seiyo-clickable-widget { cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.seiyo-clickable-widget:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
.seiyo-clickable-widget:active { transform: translateY(0) scale(0.99); }
.seiyo-clickable-widget .seiyo-deep-link-icon { transition: opacity 0.15s; }
.seiyo-clickable-widget:hover .seiyo-deep-link-icon { opacity: 0.8 !important; }

/* Alert banner */
.alert-banner { padding: var(--space-3) var(--space-4); display: flex; align-items: center; gap: var(--space-3); border-radius: var(--radius-md); margin-bottom: var(--space-4); }
.alert-banner-critical { background: var(--danger-subtle); border: 1px solid rgba(248, 113, 113, 0.3); }
.alert-banner-high { background: var(--warning-subtle); border: 1px solid rgba(251, 191, 36, 0.3); }
.alert-banner-medium { background: var(--info-subtle); border: 1px solid rgba(96, 165, 250, 0.3); }


/* ==========================================================================
   Premium Utilities (taste-skill v3)
   ========================================================================== */

/* Glassmorphism — true frosted glass with inner refraction */
.glass {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.glass-strong {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 20px 40px -15px rgba(0, 0, 0, 0.25);
}

/* Grain/noise overlay — fixed, pointer-events-none */
.grain-overlay::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 128px 128px;
}

/* Monospace numbers for data-heavy UI */
.tabular-nums {
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}

/* Spotlight border — card border illuminates near cursor */
.spotlight-card {
    position: relative;
    overflow: hidden;
}
.spotlight-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: radial-gradient(
        300px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(24, 95, 165, 0.15),
        transparent 60%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-out);
}
.spotlight-card:hover::before {
    opacity: 1;
}

/* Premium eyebrow tag */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    border-radius: var(--radius-full);
    background: var(--brand-primary-subtle);
    color: var(--brand-primary);
    border: 1px solid var(--brand-primary-muted);
}

/* Double-bezel nested card (premium hardware feel) */
.bezel-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-xl);
    padding: var(--space-2);
}
.bezel-card-inner {
    background: var(--surface-raised);
    border-radius: calc(var(--radius-xl) - 4px);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.04);
}

/* Viewport-safe full height */
.h-screen-safe {
    min-height: 100dvh;
}

/* Text balance for headlines */
.text-balance {
    text-wrap: balance;
}

/* Scroll reveal animation (viewport entry) */
@keyframes revealUp {
    from {
        opacity: 0;
        transform: translateY(24px);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.reveal-up {
    animation: revealUp 0.8s var(--ease-premium) both;
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}


/* ==========================================================================
   Light Theme Override
   ========================================================================== */

[data-theme="light"] {
    --surface-base: #ffffff;
    --surface-raised: #f5f6f8;
    --surface-overlay: #eef0f3;
    --surface-card: rgba(0, 0, 0, 0.02);
    --surface-interactive: #e8eaed;
    --surface-border: rgba(0, 0, 0, 0.1);
    --surface-border-hover: rgba(0, 0, 0, 0.18);
    --surface-border-accent: rgba(24, 95, 165, 0.2);

    --brand-primary: #185FA5;
    --brand-primary-hover: #1a6fb8;
    --brand-primary-subtle: rgba(24, 95, 165, 0.06);
    --brand-primary-muted: rgba(24, 95, 165, 0.12);
    --brand-primary-light: #2d7fd4;

    --accent: #2d7fd4;
    --accent-hover: #185FA5;
    --accent-subtle: rgba(45, 127, 212, 0.06);
    --accent-muted: rgba(45, 127, 212, 0.12);

    --success: #5a8a2a;
    --success-subtle: rgba(90, 138, 42, 0.08);
    --warning: #b8860b;
    --warning-subtle: rgba(184, 134, 11, 0.08);
    --danger: #c94040;
    --danger-hover: #a83232;
    --danger-subtle: rgba(201, 64, 64, 0.08);
    --info: #2d7fd4;
    --info-subtle: rgba(45, 127, 212, 0.08);

    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-tertiary: #888888;
    --text-disabled: #bbbbbb;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.07);
    --shadow-diffuse: 0 20px 40px -15px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 24px rgba(24, 95, 165, 0.08);
    --shadow-accent-glow: 0 0 24px rgba(91, 163, 232, 0.1);
}

/* Light theme scrollbar */
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #ccc; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* Light theme glass */
[data-theme="light"] .glass {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
[data-theme="light"] .glass-strong {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
}

/* Light theme grain overlay — invisible */
[data-theme="light"] .grain-overlay::after { opacity: 0; }


/* ==========================================================================
   Theme Toggle Component
   ========================================================================== */

.theme-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    background: var(--surface-card);
    transition: all var(--duration-fast) var(--ease-out);
    font-size: var(--text-micro);
    color: var(--text-secondary);
}
.theme-toggle:hover {
    background: var(--surface-interactive);
    color: var(--text-primary);
    border-color: var(--surface-border-hover);
}
.theme-toggle-icon { font-size: 14px; }


/* ==========================================================================
   Tailwind Color Overrides for Theme Consistency
   Applied globally so all pages pick up the new palette
   ========================================================================== */

/* Backgrounds */
.bg-dark-900, .bg-\[\#060608\] { background-color: var(--surface-base) !important; }
.bg-dark-800, .bg-\[\#0C0C12\] { background-color: var(--surface-raised) !important; }
.bg-dark-700, .bg-\[\#121218\] { background-color: var(--surface-overlay) !important; }
.bg-dark-600, .bg-\[\#1A1A26\] { background-color: var(--surface-interactive) !important; }

/* Text */
.text-text-main { color: var(--text-primary) !important; }
.text-text-muted { color: var(--text-secondary) !important; }
.text-text-dim { color: var(--text-tertiary) !important; }

/* Borders */
.border-dark-600 { border-color: var(--surface-border) !important; }
.border-dark-700 { border-color: var(--surface-border) !important; }

/* Brand colors — remap indigo to deep blue */
.bg-brand-primary { background-color: var(--brand-primary) !important; }
.text-brand-primary { color: var(--brand-primary) !important; }
.text-brand-hover { color: var(--brand-primary-light) !important; }
.border-brand-primary { border-color: var(--brand-primary) !important; }

/* Gold → Light Blue accent remap */
.text-gold, .accent-text { color: var(--accent) !important; }
.text-gold-light { color: var(--accent-hover) !important; }

/* Light mode: force "white" text in key areas to use theme text */
[data-theme="light"] .text-white:not(.btn-primary *):not(.btn-accent *):not(.btn-danger *):not([class*="bg-brand"]):not([class*="bg-blue"]):not([class*="bg-green"]):not([class*="bg-red"]):not([class*="bg-amber"]):not(.send-btn *) {
    color: var(--text-primary) !important;
}

/* Light mode: ensure buttons keep white text */
[data-theme="light"] .btn-primary,
[data-theme="light"] .btn-accent,
[data-theme="light"] .btn-danger { color: #fff !important; }

/* Light mode: sidebar adjustments */
[data-theme="light"] .sidebar { background: var(--surface-raised); }
[data-theme="light"] .sidebar-nav-item:hover { background: rgba(0, 0, 0, 0.04); }
[data-theme="light"] .sidebar-nav-item.active {
    background: var(--brand-primary-subtle);
    border-color: var(--brand-primary-muted);
}

/* Light mode: hover states */
[data-theme="light"] .hover\:bg-dark-700:hover { background-color: var(--surface-overlay) !important; }
[data-theme="light"] .hover\:text-white:hover { color: var(--text-primary) !important; }


/* ==========================================================================
   Context Menu System
   ========================================================================== */

/* Context Menu */
.seiyo-context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 220px;
    max-width: 300px;
    background: var(--surface-overlay);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
    transform-origin: top left;
    transition: opacity 120ms ease, transform 120ms ease;
    font-family: var(--font-body);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.seiyo-context-menu.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.seiyo-context-menu-section {
    padding: 6px 12px 2px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
}

.seiyo-context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 80ms ease;
}

.seiyo-context-menu-item:hover,
.seiyo-context-menu-item.focused {
    background: var(--brand-primary-subtle);
}

.seiyo-context-menu-item.destructive {
    color: var(--danger);
}

.seiyo-context-menu-item.destructive:hover,
.seiyo-context-menu-item.destructive.focused {
    background: var(--danger-subtle);
}

.seiyo-context-menu-item .cm-icon {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    flex-shrink: 0;
}

.seiyo-context-menu-item.destructive .cm-icon {
    color: var(--danger);
}

.seiyo-context-menu-item .cm-shortcut {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.seiyo-context-menu-divider {
    height: 1px;
    background: var(--surface-border);
    margin: 4px 0;
}

/* Quick Action Modal (slide-up panel) */
.seiyo-quick-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 200ms var(--ease-out);
}

.seiyo-quick-modal-backdrop.visible {
    opacity: 1;
}

.seiyo-quick-modal {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--surface-raised);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}

.seiyo-quick-modal.visible {
    opacity: 1;
    transform: translateY(0);
}

.seiyo-quick-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--surface-border);
}

.seiyo-quick-modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.seiyo-quick-modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: color var(--duration-fast) ease, background var(--duration-fast) ease;
}

.seiyo-quick-modal-close:hover {
    color: var(--text-primary);
    background: var(--surface-interactive);
}

.seiyo-quick-modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.seiyo-quick-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--surface-border);
}

/* Quick Modal Form Fields */
.sqm-field { display: flex; flex-direction: column; gap: 4px; }
.sqm-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.sqm-field input[type="text"],
.sqm-field input[type="date"],
.sqm-field input[type="datetime-local"],
.sqm-field textarea,
.sqm-field select {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface-overlay);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-body);
    outline: none;
    transition: border-color var(--duration-fast) ease;
}

.sqm-field input:focus,
.sqm-field textarea:focus,
.sqm-field select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-subtle);
}

.sqm-field textarea { resize: vertical; min-height: 60px; }

.sqm-field select { cursor: pointer; }

.sqm-field .sqm-radio-group,
.sqm-field .sqm-checkbox-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 2px;
}

.sqm-field .sqm-radio-group label,
.sqm-field .sqm-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
}

.sqm-field .sqm-readonly {
    padding: 8px 12px;
    background: var(--surface-card);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-secondary);
}

.sqm-field .sqm-ai-draft {
    position: relative;
    min-height: 80px;
}

.sqm-field .sqm-ai-draft .sqm-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* Toast notification */
.seiyo-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface-overlay);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    z-index: 10002;
    opacity: 0;
    transition: opacity 200ms ease, transform 200ms ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.seiyo-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.seiyo-toast.success { border-left: 3px solid var(--success); }
.seiyo-toast.error { border-left: 3px solid var(--danger); }
.seiyo-toast.info { border-left: 3px solid var(--info); }

/* Responsive: smaller modal on mobile */
@media (max-width: 480px) {
    .seiyo-quick-modal {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
    }
}
