/* ========================================
   ABC & EOQ Dashboard - Custom Styles
   ======================================== */

/* Root Variables for Theme Management */
:root {
    --primary-color: #3b82f6;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --border-color: #e5e7eb;
}

/* Dark Theme Variables */
.dark {
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --border-color: #374151;
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #f3f4f6 !important;
}

body.dark {
    background-color: #0f172a !important;
}

main {
    flex: 1;
    background-color: #f3f4f6 !important;
}

main.dark {
    background-color: #0f172a !important;
}

/* Ensure all container backgrounds respect dark mode */
.dark .container {
    background-color: transparent !important;
}

.dark section {
    background-color: transparent !important;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

/* Navigation Tabs */
.tab-btn {
    position: relative;
    color: #6b7280;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.05);
}

.tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.dark .tab-btn {
    color: #9ca3af;
}

.dark .tab-btn:hover {
    color: #60a5fa;
    background-color: rgba(96, 165, 250, 0.1);
}

.dark .tab-btn.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

/* ── Section-specific tab accent colors (overrides default blue) ── */
.tab-btn[data-tab="abc"].active,
.tab-btn[data-tab="abc-double"].active { color: #16a34a; border-bottom-color: #16a34a; }
.dark .tab-btn[data-tab="abc"].active,
.dark .tab-btn[data-tab="abc-double"].active { color: #4ade80; border-bottom-color: #4ade80; }

.tab-btn[data-tab="wilson"].active { color: #9333ea; border-bottom-color: #9333ea; }
.dark .tab-btn[data-tab="wilson"].active { color: #c084fc; border-bottom-color: #c084fc; }

.tab-btn[data-tab="inventory"].active { color: #2563eb; border-bottom-color: #2563eb; }
.dark .tab-btn[data-tab="inventory"].active { color: #60a5fa; border-bottom-color: #60a5fa; }

.tab-btn[data-tab="lean"].active { color: #ea580c; border-bottom-color: #ea580c; }
.dark .tab-btn[data-tab="lean"].active { color: #fb923c; border-bottom-color: #fb923c; }

.tab-btn[data-tab="budget"].active { color: #0891b2; border-bottom-color: #0891b2; }
.dark .tab-btn[data-tab="budget"].active { color: #22d3ee; border-bottom-color: #22d3ee; }

.tab-btn[data-tab="warehouse"].active { color: #0d9488; border-bottom-color: #0d9488; }
.dark .tab-btn[data-tab="warehouse"].active { color: #2dd4bf; border-bottom-color: #2dd4bf; }

/* Section Sub-tabs (within page sections like ABC/Compare) */
.section-sub-tab {
    position: relative;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s ease;
    background: transparent;
    cursor: pointer;
}

.section-sub-tab:hover {
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.04);
}

.section-sub-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    font-weight: 600;
}

.dark .section-sub-tab {
    color: #9ca3af;
}

.dark .section-sub-tab:hover {
    color: #60a5fa;
    background-color: rgba(96, 165, 250, 0.08);
}

.dark .section-sub-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block !important;
}

.tab-content.hidden {
    display: none !important;
}

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

/* Form Elements */
.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: white;
    color: #1f2937;
}

.input-field:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dark .input-field {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

.dark .input-field:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

/* File Input Styling */
.file-input {
    padding: 0.75rem;
    border: 2px dashed #cbd5e1;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #f8fafc;
    color: #475569;
}

.file-input:hover {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

.dark .file-input {
    background-color: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
}

.dark .file-input:hover {
    border-color: #60a5fa;
    background-color: #1e3a5f;
}

/* Tables */
.data-table {
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 0.875rem;
}

.data-table th {
    background-color: #f3f4f6;
    color: #1f2937;
    font-weight: 600;
    text-align: left;
    padding: 1rem;
    border-bottom: 2px solid #e5e7eb;
}

.data-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    color: #374151;
    text-align: left;
}

.data-table tbody tr {
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: #f9fafb;
}

.dark .data-table th {
    background-color: #374151;
    color: #f9fafb;
    border-bottom-color: #4b5563;
}

.dark .data-table td {
    border-bottom-color: #4b5563;
    color: #d1d5db;
}

.dark .data-table tbody tr:hover {
    background-color: #374151;
}

/* ABC Group Badges */
.group-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.875rem;
}

.group-A {
    background-color: #dcfce7;
    color: #166534;
}

.group-B {
    background-color: #fef3c7;
    color: #92400e;
}

.group-C {
    background-color: #fee2e2;
    color: #991b1b;
}

.dark .group-A {
    background-color: #166534;
    color: #dcfce7;
}

.dark .group-B {
    background-color: #92400e;
    color: #fef3c7;
}

.dark .group-C {
    background-color: #991b1b;
    color: #fee2e2;
}

/* Result Cards */
.result-card {
    background-color: #f9fafb;
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

/* Secondary result cards — de-emphasised to let primary stand out */
.result-card.secondary {
    background-color: #f9fafb;
    opacity: 0.82;
    padding: 0.875rem 1rem;
}
.dark .result-card.secondary { background-color: #1f2937; opacity: 0.8; }
.result-card.secondary p { font-size: 1.25rem !important; }

/* Input modified from default indicator */
.input-modified {
    border-left: 3px solid #f59e0b !important;
    padding-left: calc(0.625rem - 3px) !important;
}

/* Slider bubble tooltip */
.slider-bubble-wrap {
    position: relative;
    padding-top: 22px;
    margin-top: 4px;
}
.slider-bubble {
    position: absolute;
    top: 0;
    background: #6b7280;
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    transform: translateX(-50%);
    pointer-events: none;
    white-space: nowrap;
    transition: left 0.08s ease;
}
.slider-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 3px solid transparent;
    border-top-color: #6b7280;
}
.dark .slider-bubble { background: #4b5563; }
.dark .slider-bubble::after { border-top-color: #4b5563; }

/* Wilson inline validation error */
#wilsonValidationError {
    display: none;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    border: 1.5px solid #fca5a5;
    background: #fff1f2;
    color: #b91c1c;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 1rem;
    animation: shake 0.3s ease;
}
.dark #wilsonValidationError { background: rgba(239,68,68,0.12); border-color: #f87171; color: #fca5a5; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.dark .result-card {
    background-color: #374151;
    border-color: #4b5563;
}

/* Settings Options */
.theme-option,
.language-option {
    padding: 0.625rem 1.25rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #374151;
}

.theme-option:hover,
.language-option:hover {
    border-color: #3b82f6;
    background-color: #eff6ff;
    transform: translateY(-1px);
}

.theme-option.active,
.language-option.active {
    background-color: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.dark .theme-option,
.dark .language-option {
    background-color: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

.dark .theme-option:hover,
.dark .language-option:hover {
    border-color: #60a5fa;
    background-color: #1e3a5f;
}

.dark .theme-option.active,
.dark .language-option.active {
    background-color: #60a5fa;
    border-color: #60a5fa;
    color: white;
}

/* Setting Items */
.setting-item {
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background-color: #f9fafb;
    transition: all 0.3s ease;
}

.setting-item:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dark .setting-item {
    background-color: #374151;
    border-color: #4b5563;
}

/* Buttons */
button {
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Hide scrollbar but allow scrolling */
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.dark ::-webkit-scrollbar-track {
    background: #1f2937;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .tab-btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .data-table {
        font-size: 0.75rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
    
    .result-card {
        padding: 1rem;
    }
    
    .result-card p {
        font-size: 1.5rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAV  —  base styles (hidden on desktop)
═══════════════════════════════════════════════════════════════ */
.mobile-bottom-nav {
    display: none; /* shown only via @media below */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 200;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    align-items: stretch;
}
.dark .mobile-bottom-nav {
    background: #1f2937;
    border-top-color: #374151;
}
.mob-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    color: #6b7280;
    min-width: 0;
    padding: 6px 4px 4px;
    border-radius: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.mob-nav-btn:active {
    background: rgba(99, 102, 241, 0.08);
}
.mob-nav-btn.mob-active {
    color: #6366f1;
}
.dark .mob-nav-btn {
    color: #9ca3af;
}
.dark .mob-nav-btn.mob-active {
    color: #818cf8;
}
.mob-nav-icon {
    font-size: 1.35rem;
    line-height: 1;
}
.mob-nav-label {
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 54px;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE "MORE" SHEET  — slide-up overlay
═══════════════════════════════════════════════════════════════ */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 198;
    backdrop-filter: blur(2px);
}
.mobile-menu-sheet {
    position: fixed;
    /* Sits just above the bottom nav, which is 60px + safe-area-inset-bottom */
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    left: 0; right: 0;
    z-index: 199;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
    padding: 12px 16px 20px;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: slideUp 0.22s ease;
}
.dark .mobile-menu-sheet {
    background: #1f2937;
}
@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@keyframes slideDown {
    from { transform: translateY(0);    opacity: 1; }
    to   { transform: translateY(100%); opacity: 0; }
}
.mobile-menu-sheet.closing {
    animation: slideDown 0.2s ease forwards;
}
.mobile-menu-sheet-handle {
    width: 40px; height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 0 auto 12px;
}
.dark .mobile-menu-sheet-handle { background: #4b5563; }
.mobile-menu-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 12px;
    text-align: center;
}
.dark .mobile-menu-title { color: #f3f4f6; }
.mobile-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}
.mobile-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: #f3f4f6;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    transition: background 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 70px;
}
.mobile-menu-item:active { transform: scale(0.96); }
.dark .mobile-menu-item { background: #374151; color: #e5e7eb; }
.dark .mobile-menu-item:hover { background: #4b5563; }
.mobile-menu-close {
    display: block;
    width: 100%;
    padding: 12px;
    background: #f3f4f6;
    border: none;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.dark .mobile-menu-close { background: #374151; color: #9ca3af; }

/* ═══════════════════════════════════════════════════════════════
   COMPREHENSIVE MOBILE STYLES  ≤640px
═══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    /* ── Show/hide mobile-specific elements ────────────── */
    .mobile-only { display: flex !important; }
    #topNavBar   { display: none !important; }
    .mobile-bottom-nav { display: flex !important; }

    /* ── Body padding for fixed bottom bar ──────────────── */
    body { padding-bottom: 60px; }

    /* ── Header compression ─────────────────────────────── */
    header .container { padding-left: 0.75rem; padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }
    .header-title-full { display: none !important; }
    .header-title-short { display: inline !important; }
    #headerTitle { font-size: 1.1rem !important; }
    #headerExportBtn span.hidden,
    #headerHelpBtn span.hidden { display: none !important; }
    #mobileMenuToggle { display: flex !important; }

    /* ── Typography ─────────────────────────────────────── */
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.1rem !important; }

    /* ── Touch targets ──────────────────────────────────── */
    button:not(.mob-nav-btn):not(.mobile-menu-item):not(.matrix-cell) {
        min-height: 40px;
    }

    /* ── Form inputs: prevent iOS auto-zoom ─────────────── */
    input[type="number"],
    input[type="text"],
    input[type="email"],
    input[type="search"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px !important;
        min-height: 44px;
    }
    input[type="range"] {
        height: 28px;
        cursor: pointer;
        touch-action: pan-x;
    }

    /* ── Main container padding ─────────────────────────── */
    main.container,
    main > .container,
    .container { padding-left: 0.75rem; padding-right: 0.75rem; }

    /* ── Section cards ──────────────────────────────────── */
    .tab-content.active > .bg-white,
    .tab-content.active > div > .bg-white,
    .rounded-xl.shadow,
    .rounded-xl.shadow-lg,
    .rounded-lg.shadow-lg { padding: 0.875rem !important; }

    /* ── Result cards ────────────────────────────────────── */
    .result-card { padding: 0.875rem !important; }
    .result-card p { font-size: 1.75rem !important; }
    #eoqValue   { font-size: 2.5rem !important; }
    #ropValue   { font-size: 2.5rem !important; }
    #ssValue    { font-size: 2.5rem !important; }

    /* ── Data tables: ensure horizontal scroll ───────────── */
    .data-table-wrapper,
    .overflow-x-auto {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    /* Force any bare table inside a tab-content to scroll */
    .tab-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    .data-table { font-size: 0.72rem; min-width: 500px; }
    .data-table th,
    .data-table td { padding: 0.4rem 0.5rem; white-space: nowrap; }

    /* ── Grid helpers ────────────────────────────────────── */
    /* Collapse any 3- and 4-col grid to 2-col on mobile */
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    /* Leave 2-col grids as-is; some are fine on mobile */

    /* ── Spacing helpers ─────────────────────────────────── */
    .px-6 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .py-6 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
    .gap-6 { gap: 0.75rem !important; }
    .space-y-6 > * + * { margin-top: 0.75rem !important; }

    /* ── Lagerstyring shared params ──────────────────────── */
    .grid.grid-cols-2.md\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    /* ── Slider value bubbles ────────────────────────────── */
    .slider-bubble { font-size: 0.65rem; padding: 2px 6px; }

    /* ── Modals ──────────────────────────────────────────── */
    .fixed.inset-0 > .bg-white,
    .fixed.inset-0 > .bg-gray-800,
    .fixed.inset-0 > div > .bg-white {
        border-radius: 12px !important;
        margin: 0.5rem !important;
        max-height: calc(100vh - 1rem) !important;
    }

    /* ── KPI dashboard cards ─────────────────────────────── */
    #kpiCardsContainer { grid-template-columns: repeat(2, 1fr) !important; gap: 0.5rem !important; }

    /* ── Wilson insight pills ────────────────────────────── */
    .insight-pills-row { flex-wrap: wrap; gap: 0.5rem; }
    .insight-pill      { font-size: 0.7rem; padding: 4px 10px; }

    /* ── ABC matrix ──────────────────────────────────────── */
    .matrix-cell { min-height: 80px; padding: 8px; font-size: 0.75rem; }

    /* ── Warehouse canvas ────────────────────────────────── */
    #warehouseCanvas { max-width: 100% !important; height: auto !important; touch-action: none; }

    /* ── Budget tables ───────────────────────────────────── */
    #budgetTable th, #budgetTable td { font-size: 0.7rem; padding: 0.35rem 0.4rem; }

    /* ── Custom page wizard ──────────────────────────────── */
    #customPageModal > div { margin: 0 !important; border-radius: 0 !important; height: 100vh !important; max-width: 100vw !important; }

    /* ── General scroll ──────────────────────────────────── */
    * { -webkit-overflow-scrolling: touch; }

    /* ── Dashboard homepage ─────────────────────────────── */
    /* py-8 override for main */
    #mainContent { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; padding-left: 0.625rem !important; padding-right: 0.625rem !important; }

    /* Stats cards — smaller values in 2×2 grid */
    #dashboard-section .result-card { padding: 0.625rem 0.75rem !important; }
    #dashboard-section .result-card h4 { font-size: 0.68rem !important; line-height: 1.3; margin-bottom: 0.125rem !important; }
    #dashboard-section .result-card p { font-size: 1.3rem !important; }
    #dashboard-section .result-card .text-lg { font-size: 0.9rem !important; }

    /* Quick action cards — compact */
    #quickActionsGrid button { padding: 0.75rem !important; border-radius: 0.75rem !important; }
    #quickActionsGrid button .text-4xl { font-size: 1.6rem !important; margin-bottom: 0.375rem !important; display: block; }
    #quickActionsGrid button h3 { font-size: 0.8rem !important; margin-bottom: 0.125rem !important; line-height: 1.2 !important; }
    #quickActionsGrid button p.text-sm { font-size: 0.68rem !important; line-height: 1.3 !important; }

    /* Suggestions bar */
    #dashboard-suggestions { padding: 0.75rem !important; margin-bottom: 0.75rem !important; }
    #dashboard-suggestions h3 { font-size: 0.9rem !important; }

    /* Session history */
    #sessionHistoryPanel { padding: 0.625rem !important; margin-top: 0.625rem !important; }
    #sessionHistoryPanel h3 { font-size: 0.8rem !important; }

    /* Quick customizer panel */
    #quickActionsCustomizer { padding: 0.75rem !important; }

    /* Dashboard top-5 table title */
    #dashTopItems h2 { font-size: 1rem !important; margin-bottom: 0.5rem !important; }
}

/* ═══════════════════════════════════════════════════════════════
   TABLET  641px – 1024px  — lighter touch-ups
═══════════════════════════════════════════════════════════════ */
@media (min-width: 641px) and (max-width: 1024px) {
    input[type="number"],
    input[type="text"],
    select { font-size: 16px !important; }
    input[type="range"] { height: 24px; }
    .tab-btn { padding: 0.625rem 1rem; font-size: 0.875rem; }
    .data-table { font-size: 0.8rem; }
    .result-card p { font-size: 1.75rem !important; }
}

/* ABC Double Analysis Matrix Styles */
.matrix-cell {
    min-height: 120px;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.matrix-cell:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.matrix-cell:active {
    transform: translateY(-2px) scale(1.01);
}

/* Print Styles */
@media print {
    /* Hide navigation elements */
    header, nav, .no-print {
        display: none !important;
    }
    
    /* Hide ALL tab-content sections regardless of class */
    .tab-content,
    .tab-content.active,
    .tab-content.hidden,
    section.tab-content {
        display: none !important;
        visibility: hidden !important;
    }
    
    /* Show ONLY sections marked for printing */
    .tab-content.print-this,
    section.tab-content.print-this,
    .tab-content.active.print-this,
    .tab-content.hidden.print-this {
        display: block !important;
        visibility: visible !important;
        position: relative !important;
        opacity: 1 !important;
    }
    
    /* Force all descendant elements to be visible */
    .tab-content.print-this,
    .tab-content.print-this > *,
    .tab-content.print-this > * > *,
    .tab-content.print-this > * > * > *,
    .tab-content.print-this > * > * > * > *,
    .tab-content.print-this > * > * > * > * > * {
        visibility: visible !important;
        display: block !important;
        opacity: 1 !important;
    }
    
    /* Preserve flex and grid layouts */
    .tab-content.print-this .flex,
    .tab-content.print-this .grid {
        display: flex !important;
    }
    
    .tab-content.print-this .grid {
        display: grid !important;
    }
    
    /* Hide interactive elements within print sections */
    .tab-content.print-this input,
    .tab-content.print-this select,
    .tab-content.print-this textarea,
    .tab-content.print-this button:not(.print-keep),
    .tab-content.print-this label {
        display: none !important;
    }
    
    /* Override hidden class within print sections */
    .tab-content.print-this .hidden {
        display: block !important;
        visibility: visible !important;
    }
    
    /* Reset colors and backgrounds for print */
    body, main {
        background-color: white !important;
        color: black !important;
    }
    
    .tab-content.print-this * {
        color: black !important;
        background-color: white !important;
        border-color: #ddd !important;
    }
    
    /* Preserve semantic colors for results */
    .tab-content.print-this .text-purple-600,
    .tab-content.print-this .text-purple-400 {
        color: #9333ea !important;
    }
    
    .tab-content.print-this .text-blue-600,
    .tab-content.print-this .text-blue-400 {
        color: #2563eb !important;
    }
    
    .tab-content.print-this .text-green-600,
    .tab-content.print-this .text-green-400 {
        color: #16a34a !important;
    }
    
    .tab-content.print-this .text-orange-600,
    .tab-content.print-this .text-orange-400 {
        color: #ea580c !important;
    }
    
    .tab-content.print-this .text-red-600,
    .tab-content.print-this .text-red-400 {
        color: #dc2626 !important;
    }
    
    /* Optimize tables for print */
    table {
        page-break-inside: avoid;
        border-collapse: collapse;
        width: 100%;
    }
    
    th, td {
        border: 1px solid #ddd !important;
        padding: 8px;
    }
    
    th {
        background-color: #f0f0f0 !important;
        font-weight: bold;
        color: black !important;
    }
    
    /* Page breaks */
    .print-page-break {
        page-break-before: always;
    }
    
    h2, h3 {
        page-break-after: avoid;
        color: black !important;
    }
    
    /* Ensure charts print */
    canvas {
        max-width: 100%;
        page-break-inside: avoid;
    }
    
    /* Add print margins */
    @page {
        margin: 1.5cm;
        size: A4;
    }
    
    /* Ensure content fits on page */
    .tab-content.print-this {
        max-width: 100%;
        overflow: visible;
    }
}
    
    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 20px;
        border-bottom: 2px solid #333;
        padding-bottom: 10px;
    }
    
    .print-timestamp {
        display: block !important;
        text-align: right;
        font-size: 10pt;
        color: #666;
        margin-bottom: 10px;
    }
    
    /* Print sections on separate pages */
    .tab-content {
        page-break-after: always;
    }
}

/* Loading Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #f3f4f6;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Chart Container */
canvas {
    max-width: 100%;
    height: auto !important;
}

/* Smooth Transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

button,
.tab-btn,
.theme-option,
.language-option,
.input-field {
    transition-property: all;
    transition-duration: 300ms;
}

/* ========================================
   NEW ENHANCEMENT STYLES
   ======================================== */

/* Dashboard Metric Cards */
.metric-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.dark .metric-card {
    background: #1f2937;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

/* Stat Cards (for Compare section) */
.stat-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.dark .stat-card {
    background: #1f2937;
    border-color: #374151;
}

/* File Drop Zone */
.file-drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: 0.5rem;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.dark .file-drop-zone {
    border-color: #4b5563;
    background: #111827;
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.dark .file-drop-zone:hover,
.dark .file-drop-zone.dragover {
    border-color: #3b82f6;
    background: #1e3a5f;
}

/* File Info Card */
.file-info-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-top: 0.75rem;
}

.dark .file-info-card {
    background: #111827;
    border-color: #374151;
}

/* Quality Check Badge */
.quality-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.quality-badge.excellent {
    background: #d1fae5;
    color: #065f46;
}

.quality-badge.good {
    background: #dbeafe;
    color: #1e40af;
}

.quality-badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.quality-badge.poor {
    background: #fee2e2;
    color: #991b1b;
}

.dark .quality-badge.excellent {
    background: #065f46;
    color: #d1fae5;
}

.dark .quality-badge.good {
    background: #1e40af;
    color: #dbeafe;
}

.dark .quality-badge.warning {
    background: #92400e;
    color: #fef3c7;
}

.dark .quality-badge.poor {
    background: #991b1b;
    color: #fee2e2;
}

/* Compare Upload Card */
.compare-upload-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.5rem;
}

.dark .compare-upload-card {
    background: #111827;
    border-color: #374151;
}

/* Trend Indicators */
.trend-up {
    color: #10b981;
}

.trend-down {
    color: #ef4444;
}

.trend-neutral {
    color: #6b7280;
}

/* Export Button */
.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #10b981;
    color: white;
    border-radius: 0.375rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.export-btn:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

/* Keyboard Shortcut Hint */
.kbd {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    background: #e5e7eb;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dark .kbd {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

/* Toast Notification (for exports and actions) */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #1f2937;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    background: #10b981;
}

.toast.error {
    background: #ef4444;
}

.toast.warning {
    background: #f59e0b;
}

/* Responsive adjustments for new features */
@media (max-width: 768px) {
    .metric-card {
        padding: 1rem;
    }
    
    .file-drop-zone {
        padding: 1.5rem 0.75rem;
    }
    
    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
}

/* Tutorial Styles */
.tutorial-highlight {
    position: relative;
    z-index: 45;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5), 0 0 20px rgba(59, 130, 246, 0.3);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5), 0 0 20px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.3), 0 0 30px rgba(59, 130, 246, 0.5);
    }
}

/* Quick Actions Customizer Drag and Drop */
.drag-over {
    border-color: #8b5cf6 !important;
    background-color: rgba(139, 92, 246, 0.1) !important;
    transform: scale(1.02);
}

.dragging {
    opacity: 0.4 !important;
    cursor: grabbing !important;
}

[draggable="true"] {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

[draggable="true"]:active {
    cursor: grabbing;
}

/* Quick Actions Grid Animation */
#quickActionsGrid > * {
    animation: fadeInUp 0.4s ease-out;
}

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

/* Emoji Picker Styles */
.emoji-btn {
    @apply px-3 py-3 bg-gray-100 dark:bg-gray-700 hover:bg-indigo-200 dark:hover:bg-indigo-600 rounded text-2xl transition-all cursor-pointer;
    min-width: 3rem;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center;
}

.emoji-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    z-index: 10;
}

/* ========================================
   CUSTOM PAGES SYSTEM STYLES
   ======================================== */

/* Custom Page Tabs */
#customPagesTabs .custom-page-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #e5e7eb;
    border-radius: 0.375rem 0.375rem 0 0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    color: #374151;
}

.dark #customPagesTabs .custom-page-tab {
    background: #374151;
    color: #d1d5db;
}

#customPagesTabs .custom-page-tab:hover {
    background: #d1d5db;
    transform: translateY(-2px);
}

.dark #customPagesTabs .custom-page-tab:hover {
    background: #4b5563;
}

#customPagesTabs .custom-page-tab.active {
    background: white;
    color: #3b82f6;
    border-bottom: 2px solid #3b82f6;
}

.dark #customPagesTabs .custom-page-tab.active {
    background: #1f2937;
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

#customPagesTabs .custom-page-tab .close-btn {
    opacity: 0;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

#customPagesTabs .custom-page-tab:hover .close-btn {
    opacity: 1;
}

#customPagesTabs .custom-page-tab .close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Modal Overlay */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Modal Content */
.modal-content {
    background: white;
    border-radius: 0.75rem;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s ease;
}

.dark .modal-content {
    background: #1f2937;
    border: 1px solid #374151;
}

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

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.dark .modal-header {
    border-bottom-color: #374151;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Modal Body */
.modal-body {
    padding: 1.5rem;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.dark .modal-footer {
    border-top-color: #374151;
}

/* Form Sections */
.form-section {
    margin-bottom: 2rem;
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-section h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
}

.dark .form-section h4 {
    color: #f9fafb;
}

/* Form Groups */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #374151;
}

.dark .form-group label {
    color: #d1d5db;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: all 0.2s;
    background: white;
    color: #1f2937;
}

.dark .form-group input,
.dark .form-group select,
.dark .form-group textarea {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dark .form-group input:focus,
.dark .form-group select:focus,
.dark .form-group textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

/* Dynamic Fields Container */
.dynamic-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    position: relative;
}

.dark .field-item {
    background: #374151;
    border-color: #4b5563;
}

.field-item .remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.dark .field-item .remove-btn {
    background: #7f1d1d;
    color: #fecaca;
}

.field-item .remove-btn:hover {
    background: #fecaca;
    transform: scale(1.05);
}

.dark .field-item .remove-btn:hover {
    background: #991b1b;
}

/* Add Button */
.add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.875rem;
}

.dark .add-btn {
    background: #312e81;
    color: #e0e7ff;
}

.add-btn:hover {
    background: #c7d2fe;
    transform: translateY(-1px);
}

.dark .add-btn:hover {
    background: #3730a3;
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.template-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.dark .template-card {
    background: #374151;
    border-color: #4b5563;
}

.template-card:hover {
    border-color: #3b82f6;
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
}

.template-card .icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.template-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.dark .template-card h4 {
    color: #f9fafb;
}

.template-card p {
    font-size: 0.875rem;
    color: #6b7280;
}

.dark .template-card p {
    color: #9ca3af;
}

/* Custom Page Content */
.custom-page-content {
    padding: 2rem;
}

.custom-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
}

.dark .custom-page-header {
    border-bottom-color: #374151;
}

.custom-page-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}

.custom-page-actions {
    display: flex;
    gap: 0.5rem;
}

/* Page Sections */
.page-section {
    margin-bottom: 2.5rem;
}

.page-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #1f2937;
}

.dark .page-section h3 {
    color: #f9fafb;
}

/* Input Grid */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.input-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.25rem;
    transition: all 0.2s;
}

.dark .input-item {
    background: #374151;
    border-color: #4b5563;
}

.input-item:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.input-item label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.625rem;
    color: #374151;
}

.dark .input-item label {
    color: #d1d5db;
}

.input-item input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: all 0.2s;
}

.dark .input-item input {
    background: #1f2937;
    border-color: #4b5563;
    color: #f9fafb;
}

.input-item input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Output Grid */
.output-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
}

.output-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.output-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.output-item .label {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.output-item .value {
    font-size: 2rem;
    font-weight: 700;
}

.output-item .unit {
    font-size: 0.875rem;
    opacity: 0.85;
    margin-left: 0.25rem;
}

/* Graph Container */
.graph-container {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.dark .graph-container {
    background: #374151;
    border-color: #4b5563;
}

.graph-container h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
}

.dark .graph-container h4 {
    color: #f9fafb;
}

.graph-canvas {
    width: 100%;
    height: 400px;
}

/* Formula Display */
.formula-display {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    font-family: 'Courier New', monospace;
}

.dark .formula-display {
    background: #1f2937;
    border-color: #4b5563;
    color: #d1d5db;
}

.formula-display .formula-name {
    font-weight: 600;
    color: #3b82f6;
    margin-bottom: 0.25rem;
}

.dark .formula-display .formula-name {
    color: #60a5fa;
}

.formula-display .formula-expression {
    color: #374151;
    font-size: 0.95rem;
}

.dark .formula-display .formula-expression {
    color: #d1d5db;
}

.formula-display .formula-result {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e5e7eb;
    color: #059669;
    font-weight: 600;
}

.dark .formula-display .formula-result {
    border-top-color: #374151;
    color: #34d399;
}

/* Error Message */
.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.dark .error-message {
    background: #7f1d1d;
    color: #fecaca;
}

/* Icon Picker */
.icon-picker {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 0.375rem;
}

.dark .icon-picker {
    background: #1f2937;
}

.icon-option {
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
    text-align: center;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.icon-option:hover {
    background: #e5e7eb;
    transform: scale(1.1);
}

.dark .icon-option:hover {
    background: #374151;
}

/* Toast Animations */
@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.animate-slide-in {
    animation: slide-in 0.3s ease-out;
}

/* Help Info Tooltips */
.group:hover .group-hover\:block {
    display: block;
    animation: fadeIn 0.2s ease-in;
}

/* Preview Modal Animations */
#previewModal.hidden {
    display: none;
}

#previewModal:not(.hidden) {
    animation: fadeIn 0.3s ease-in;
}

/* Responsive Design for Custom Pages */
@media (max-width: 768px) {
    .custom-page-content {
        padding: 1rem;
    }
    
    .custom-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .input-grid,
    .output-grid {
        grid-template-columns: 1fr;
    }
    
    .template-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    #customPagesTabs {
        flex-wrap: wrap;
    }
    
    .graph-canvas {
        height: 300px;
    }
    
    /* Make help tooltips work better on mobile */
    .group .hidden {
        position: fixed;
        left: 50%;
        transform: translateX(-50%);
        width: 90vw;
        max-width: 300px;
    }
}

/* ========================================
   WIZARD ENHANCEMENTS
   ======================================== */

/* Autocomplete dropdown */
.autocomplete-dropdown {
    width: calc(100% - 2rem);
    left: 1rem;
    top: 100%;
    margin-top: 0.25rem;
}

.autocomplete-item {
    transition: background-color 0.15s ease;
}

.autocomplete-item:hover {
    background-color: #eff6ff;
}

.dark .autocomplete-item:hover {
    background-color: #374151;
}

/* Drag handle styling */
.drag-handle {
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.drag-handle:hover {
    color: #4b5563;
}

.dark .drag-handle:hover {
    color: #9ca3af;
}

[draggable="true"] {
    cursor: move;
}

/* Formula validation styling */
.formula-success {
    animation: slideIn 0.3s ease;
}

.formula-error {
    animation: slideIn 0.3s ease;
}

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

.wizard-tab {
    position: relative;
    transition: all 0.3s ease;
}

.wizard-tab-active {
    font-weight: 600;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.wizard-badge {
    display: inline-block;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5rem;
    text-align: center;
}

.wizard-step {
    animation: fadeIn 0.3s ease-in;
}

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

/* Enhanced Input/Formula Cards */
.input-card, .formula-card {
    transition: all 0.2s ease;
}

.input-card:hover, .formula-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.1);
}

/* Drag Handle Cursor */
.drag-handle {
    cursor: move;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Live Preview Styles */
#livePreviewContent {
    min-height: 400px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.dark #livePreviewContent {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Enhanced Validation Styles */
.validation-details {
    border-left: 3px solid #3b82f6;
    padding-left: 0.75rem;
    margin-top: 0.5rem;
}

.validation-error {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.05);
}

.validation-success {
    border-color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.05);
}

/* Formula Syntax Highlighting */
.formula-expression {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}

/* Template Grid Enhancement */
.template-card {
    transition: all 0.2s ease;
    cursor: pointer;
}

.template-card:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.15);
}

/* Progress Bar Animation */
#wizardProgress {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth Scroll for Wizard Content */
#wizardContent {
    scroll-behavior: smooth;
}

/* Enhanced Button Styles */
.btn-wizard {
    position: relative;
    overflow: hidden;
}

.btn-wizard::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-wizard:active::before {
    width: 300px;
    height: 300px;
}

/* Sidebar Enhancements */
#templateSidebar {
    box-shadow: 2px 0 8px -2px rgba(0, 0, 0, 0.1);
}

.dark #templateSidebar {
    box-shadow: 2px 0 8px -2px rgba(0, 0, 0, 0.3);
}

/* Empty State Animations */
#inputsEmptyState, #formulasEmptyState {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Variable Badge Hover Effect */
#availableVariablesList button {
    position: relative;
}

#availableVariablesList button::after {
    content: '📋';
    position: absolute;
    right: -20px;
    opacity: 0;
    transition: all 0.2s ease;
}

#availableVariablesList button:hover::after {
    opacity: 1;
    right: -25px;
}

/* Mobile Wizard Optimization */
@media (max-width: 768px) {
    #templateSidebar {
        display: none !important;
    }
    
    .wizard-tab {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    .wizard-badge {
        font-size: 0.625rem;
        min-width: 1.25rem;
        height: 1.25rem;
        line-height: 1.25rem;
    }
    
    #wizardTabs {
        gap: 0.25rem;
    }
}

/* ========================================
   LEAN TOOLS SPECIFIC STYLES
   ======================================== */

/* LEAN Calculator Cards - Enhanced hover effects */
#lean-section .hover\:shadow-xl:hover {
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

/* OEE Result Display */
#oeeResult {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

/* SMED Calculator animations */
#smedAnnualSavings {
    animation: fadeInUp 0.5s ease;
}

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

/* Waste Cost Checkboxes */
#lean-section input[type="checkbox"]:checked {
    animation: checkBounce 0.3s ease;
}

@keyframes checkBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* SWOT Analysis Textareas */
#lean-section textarea {
    transition: all 0.2s ease;
}

#lean-section textarea:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Reference Library Cards - Gradient borders on hover */
#lean-section .border-2:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dark #lean-section .border-2:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Integration Tips - Enhanced visibility */
#lean-section .bg-white.dark\:bg-gray-800 {
    backdrop-filter: blur(10px);
}

/* Smooth number transitions */
#oeeResult, #smedTimeSaved, #smedReduction, #smedAnnualSavings, #wasteTotalCost {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* LEAN section responsive improvements */
@media (max-width: 768px) {
    #lean-section .grid {
        gap: 1rem;
    }
    
    #lean-section h1 {
        font-size: 2rem;
    }
    
    #lean-section h2 {
        font-size: 1.5rem;
    }
}

/* ============================================
   LEAN SECTION BOX STYLING
   ============================================ */

/* Section box cards — always open, with colored header */
.lean-section-box {
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.lean-section-box:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.10);
}

.lean-section-box > div:first-child:focus-visible {
    outline: 3px solid rgba(16, 185, 129, 0.45);
    outline-offset: 2px;
}

/* Highlight flash animation for navigation */
@keyframes lean-box-flash {
    0%, 100% { box-shadow: 0 4px 6px -1px rgba(0,0,0,.1); }
    50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.4), 0 4px 6px -1px rgba(0,0,0,.1); }
}

.lean-highlight-flash {
    animation: lean-box-flash 0.75s ease 2;
}

/* ── LEAN home: category chip active state ───────────────────── */
.lean-cat-chip-active {
    background-color: #111827 !important;
    color: #ffffff !important;
}
.dark .lean-cat-chip-active {
    background-color: #f9fafb !important;
    color: #111827 !important;
}

/* ── LEAN home: tool cards ───────────────────────────────────── */
.lean-card {
    border: 2px solid transparent;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.lean-card:hover {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.11);
}

/* ── LEAN tool view: enter animation ────────────────────────── */
#lean-tool-view .lean-tool-item {
    animation: lean-tool-enter 0.18s ease forwards;
}
@keyframes lean-tool-enter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Drag-over visual feedback (supply chain drag-drop) */
.drag-over {
    outline: 2px dashed #3b82f6;
    outline-offset: -2px;
    background-color: rgba(59, 130, 246, 0.08) !important;
    transition: outline 0.15s ease, background-color 0.15s ease;
}

/* ============================================
   LEAN TOOL LAUNCHER CARD GRID
   ============================================ */

/* Collapsible category accordions */
.lean-category-group summary {
    list-style: none;
}
.lean-category-group summary::-webkit-details-marker {
    display: none;
}
.lean-category-group summary > span:first-child {
    display: inline-block;
    transition: transform 0.2s ease;
}
.lean-category-group[open] > summary > span:first-child {
    transform: rotate(90deg);
}
.lean-category-group > div {
    animation: lean-accordion-open 0.25s ease;
}
@keyframes lean-accordion-open {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Tool launcher cards */
.lean-tool-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.lean-tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.10);
}

.dark .lean-tool-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.lean-tool-card:active {
    transform: translateY(-1px) scale(0.98);
    transition: transform 0.1s ease;
}

/* Subtle gradient overlay on hover */
.lean-tool-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, transparent 60%, rgba(255,255,255,0.3));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.lean-tool-card:hover::after {
    opacity: 1;
}

.dark .lean-tool-card::after {
    background: linear-gradient(135deg, transparent 60%, rgba(255,255,255,0.05));
}

/* Responsive card sizing */
@media (max-width: 640px) {
    .lean-tool-card {
        padding: 10px !important;
    }
}

/* ============================================
   LEAN SUB-TAB NAVIGATION & SEARCH
   ============================================ */

/* Sticky sub-tab navigation bar */
.lean-nav-bar {
    position: sticky;
    top: 64px; /* below main header */
    z-index: 30;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: box-shadow 0.2s ease;
}

.lean-nav-bar.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dark .lean-nav-bar.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Sub-tab buttons */
.lean-sub-tab {
    position: relative;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 2px solid transparent;
    white-space: nowrap;
}

.lean-sub-tab:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.lean-sub-tab.active {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Quick-jump toolbar */
.lean-quick-jumps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
    min-height: 40px;
    align-items: center;
}

.lean-quick-jump-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.7);
    color: #374151;
}

.dark .lean-quick-jump-btn {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(55, 65, 81, 0.7);
    color: #d1d5db;
}

.lean-quick-jump-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.95);
}

.dark .lean-quick-jump-btn:hover {
    background: rgba(75, 85, 99, 0.9);
}

/* Search input styling */
.lean-search-input {
    transition: width 0.3s ease, box-shadow 0.2s ease;
    min-width: 160px;
}

.lean-search-input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    outline: none;
}

/* Search results info */
.lean-search-info {
    font-size: 0.75rem;
    color: #6b7280;
    padding: 4px 12px;
    transition: opacity 0.2s ease;
}

/* Search highlight on matching blocks */
.lean-searchable.search-match {
    position: relative;
}

.lean-searchable.search-match::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid #6366f1;
    border-radius: 12px;
    pointer-events: none;
    animation: searchPulse 1.5s ease-out;
}

@keyframes searchPulse {
    0% { border-color: #6366f1; box-shadow: 0 0 12px rgba(99, 102, 241, 0.4); }
    100% { border-color: #6366f1; box-shadow: none; }
}

/* Panel transition */
[id^="leanPanel-"] {
    transition: opacity 0.25s ease;
}

[id^="leanPanel-"].hidden {
    display: none !important;
}

/* Quick-jump highlight effect */
.lean-highlight-flash {
    animation: highlightFlash 1.2s ease-out;
}

@keyframes highlightFlash {
    0% { box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.6); }
    100% { box-shadow: none; }
}

/* Responsive: stack sub-tabs on small screens */
@media (max-width: 768px) {
    .lean-nav-bar .flex {
        flex-wrap: wrap;
    }
    
    .lean-sub-tab {
        font-size: 0.75rem;
        padding: 6px 10px;
    }
    
    .lean-search-input {
        min-width: 120px;
        width: 100%;
    }
    
    .lean-quick-jumps {
        gap: 4px;
    }
    
    .lean-quick-jump-btn {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
}

/* ============================================
   LEAN SECTION PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Removed content-visibility: auto and contain from #lean-section
   because it caused blank/invisible content when navigating to tools
   via the dashboard or Jump To menu. GPU acceleration is kept only
   for gradient backgrounds. */

/* Simplified GPU acceleration */
#lean-section .bg-gradient-to-br {
    backface-visibility: hidden;
}

/* Optimize collapsible sections - simplified transitions */
#metrics-content,
#improvement-content,
#planning-content,
#reference-content {
    transition: opacity 0.2s ease;
    overflow: hidden;
}

/* Remove expensive transforms */
.expanding {
    opacity: 1;
}

.collapsing {
    opacity: 0;
}

/* Simplified toggle icon rotation */
#metrics-toggle,
#improvement-toggle,
#planning-toggle,
#reference-toggle {
    transition: transform 0.2s ease;
}

/* ============================================
   REAL-TIME VALIDATION FEEDBACK
   ============================================ */

/* Simplified input validation states - removed expensive box-shadows */
.input-valid {
    border-color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.05) !important;
}

.input-warning {
    border-color: #f59e0b !important;
    background-color: rgba(245, 158, 11, 0.05) !important;
}

.input-error {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.05) !important;
}

/* Validation icons */
.validation-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.validation-icon.show {
    opacity: 1;
}

.validation-icon.hide {
    opacity: 0;
}

/* Simplified result panel states - removed expensive animations */
.result-excellent {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
}

.result-good {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

.result-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: #f59e0b;
}

.result-critical {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

/* ============================================
   ENHANCED ANIMATIONS
   ============================================ */

/* Card hover effects - only on the tool cards in the dashboard grid */
#leanToolGrid .lean-tool-card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#leanToolGrid .lean-tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.dark #leanToolGrid .lean-tool-card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

/* Button press effect */
#lean-section button:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Tooltip fade-in */
[id$="-tooltip"] {
    animation: tooltipFadeIn 0.3s ease;
}

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

/* Number counter animation */
@keyframes countUp {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-count {
    animation: countUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Progress bar animation */
@keyframes progressBar {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

.progress-animate {
    animation: progressBar 1s ease-out;
}

/* ============================================
   KEYBOARD SHORTCUT INDICATORS
   ============================================ */

.keyboard-hint {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(156, 163, 175, 0.2);
    border: 1px solid rgba(156, 163, 175, 0.3);
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: #6b7280;
    margin-left: 8px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.keyboard-hint:hover {
    opacity: 1;
}

.dark .keyboard-hint {
    color: #9ca3af;
    background: rgba(156, 163, 175, 0.1);
}

/* Keyboard focus indicator */
#lean-section input:focus,
#lean-section textarea:focus,
#lean-section button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ============================================
   VSM CANVAS OPTIMIZATIONS
   ============================================ */

#vsmCanvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: crosshair;
    transition: opacity 0.2s ease;
}

#vsmCanvas:active {
    cursor: grabbing;
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    #lean-section * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
/* Notification animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Shimmer effect for loading states */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.shimmer {
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0) 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        rgba(255, 255, 255, 0) 100%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

@media (prefers-contrast: high) {
    .input-valid {
        border-width: 3px !important;
    }
    
    .input-warning {
        border-width: 3px !important;
    }
    
    .input-error {
        border-width: 3px !important;
    }
}

/* ========================================
   FEATURE ENHANCEMENTS STYLES
   ======================================== */

/* Matrix Cell Clickable */
.matrix-cell-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.matrix-cell-clickable:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Sensitivity Analysis Table */
.sensitivity-table-container table {
    border-collapse: collapse;
}

.sensitivity-table-container td,
.sensitivity-table-container th {
    min-width: 70px;
}

/* Sparkline Styles */
.sparkline {
    vertical-align: middle;
}

/* Safety Stock Gauge */
.safety-stock-gauge .gauge-visual svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Unified Dashboard Card */
.unified-inventory-card .method-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.unified-inventory-card .method-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Quality Score Circle */
.quality-score-card .score-circle svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* History Panel */
.history-panel .history-item {
    transition: all 0.15s ease;
}

.history-panel .history-item:hover {
    transform: translateX(4px);
}

/* Change Summary Cards */
.change-summary-cards .summary-card {
    transition: transform 0.2s ease;
}

.change-summary-cards .summary-card:hover {
    transform: scale(1.02);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    animation: fadeInDown 0.15s ease;
}

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

/* Suggestions Bar */
.suggestions-bar button {
    transition: all 0.2s ease;
}

.suggestions-bar button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Keyboard Shortcut Badge */
kbd {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Enhanced Modal */
#enhanced-modal {
    animation: fadeIn 0.2s ease;
}

#enhanced-modal > div {
    animation: slideUp 0.2s ease;
}

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

/* Trend Arrows */
.trend-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: bold;
}

.trend-arrow.upgraded {
    background-color: rgba(34, 197, 94, 0.15);
}

.trend-arrow.downgraded {
    background-color: rgba(239, 68, 68, 0.15);
}

.trend-arrow.stable {
    background-color: rgba(107, 114, 128, 0.15);
}

/* Benchmark Lines in Charts */
.benchmark-line {
    stroke-dasharray: 5, 5;
    stroke-width: 2;
}

/* Waste Pie Chart Container */
.waste-pie-container {
    min-height: 300px;
}

/* Real-time Slider Toggle */
.realtime-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.realtime-toggle input[type="checkbox"] {
    width: 40px;
    height: 22px;
    appearance: none;
    background: #d1d5db;
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.realtime-toggle input[type="checkbox"]:checked {
    background: #3b82f6;
}

.realtime-toggle input[type="checkbox"]::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.realtime-toggle input[type="checkbox"]:checked::after {
    transform: translateX(18px);
}

/* Confidence Badge */
.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Link Button for Cross-Feature Navigation */
.link-feature-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.link-feature-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);
}

/* Compare Trend Arrows */
.compare-trend-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    min-width: 24px;
}

.compare-trend-arrow.up {
    color: #22c55e;
    animation: bounceUp 1s ease-in-out;
}

.compare-trend-arrow.down {
    color: #ef4444;
    animation: bounceDown 1s ease-in-out;
}

.compare-trend-arrow.neutral {
    color: #9ca3af;
}

@keyframes bounceUp {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-4px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-2px); }
}

@keyframes bounceDown {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(4px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(2px); }
}

/* OEE Benchmark Bar */
#oee-benchmark-bar {
    position: relative;
}

#oee-benchmark-marker,
#oee-current-marker {
    transition: left 0.5s ease-out;
}

/* ========================================
   IMPORT PREVIEW MODAL STYLES
   ======================================== */

/* Editable cell styling */
#editablePreviewBody input {
    transition: all 0.15s ease;
}

#editablePreviewBody input:focus {
    background-color: white !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.dark #editablePreviewBody input:focus {
    background-color: #374151 !important;
}

/* Edited cell highlight */
#editablePreviewBody td.edited-cell {
    background-color: #fef3c7 !important;
}

.dark #editablePreviewBody td.edited-cell {
    background-color: rgba(251, 191, 36, 0.2) !important;
}

/* Row highlighting */
#editablePreviewBody tr[data-has-issue="true"] {
    background-color: #fef2f2;
}

.dark #editablePreviewBody tr[data-has-issue="true"] {
    background-color: rgba(239, 68, 68, 0.1);
}

#editablePreviewBody tr.skipped-row {
    opacity: 0.5;
    background-color: #f3f4f6 !important;
}

.dark #editablePreviewBody tr.skipped-row {
    background-color: #1f2937 !important;
}

/* Step indicator animations */
#importPreviewModal .step-indicator {
    transition: all 0.3s ease;
}

/* Table scrolling */
#editablePreviewTable {
    border-collapse: separate;
    border-spacing: 0;
}

#editablePreviewTable thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

#editablePreviewTable th {
    white-space: nowrap;
}

/* Column mapping select styling */
#columnMappingBody select {
    min-width: 140px;
}

/* Issue badge animations */
#validationIssues .issue-badge {
    animation: fadeIn 0.3s ease;
}

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

/* Modal overlay */
#importPreviewModal {
    animation: fadeInModal 0.2s ease;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive adjustments for import preview */
@media (max-width: 768px) {
    #importPreviewModal > div {
        margin: 0.5rem;
        max-height: 95vh;
    }
    
    #columnMappingBody select {
        min-width: 100px;
        font-size: 0.75rem;
    }
    
    .step-indicator span:last-child {
        display: none;
    }
}

/* Print Styles for Enhancements */
/* ========================================
   BUDGET FOCUS MODE
   ======================================== */

/* Focus mode overlay strip */
.focus-strip {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9900;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 1rem;
    background: #1f2937;
    color: #fff;
    font-size: 0.8rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

body.budget-focus-active .focus-strip { display: flex; }

.focus-strip-left { font-weight: 700; color: #a78bfa; white-space: nowrap; }
.focus-strip-center { flex: 1; display: flex; justify-content: center; gap: 1.5rem; }
.focus-income { color: #34d399; }
.focus-expense { color: #f87171; }
.focus-net { color: #e5e7eb; }
.focus-strip-exit {
    padding: 0.25rem 0.75rem;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.focus-strip-exit:hover { background: #b91c1c; }

/* Body class hides elements in focus mode */
body.budget-focus-active nav { display: none !important; }
body.budget-focus-active #budget-controls-bar { display: none !important; }
body.budget-focus-active #budget-help-section { display: none !important; }
body.budget-focus-active #budget-sidebar { display: none !important; }
body.budget-focus-active #budget-summary-stats { display: none !important; }
body.budget-focus-active #budget-section { padding-top: 3rem !important; }

/* ========================================
   STICKY BUDGET TABLE HEADERS (Step L)
   ======================================== */

#budget-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 280px);
}

body.budget-focus-active #budget-table-wrapper {
    max-height: calc(100vh - 3.5rem);
}

#budget-table thead th,
#budget-table thead td {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: #f9fafb;
}

.dark #budget-table thead th,
.dark #budget-table thead td {
    background-color: #111827;
}

/* ========================================
   PRINT / PDF EXPORT (Step K)
   ======================================== */

@media print {
    /* Hide everything by default */
    body > * { display: none !important; }

    /* Show only budget section */
    body.printing-budget #budget-section { display: block !important; }
    #budget-section { display: block !important; }

    /* Hide non-printable controls inside budget */
    #budget-controls-bar,
    #budget-help-section,
    #budget-sidebar,
    #budget-table-toolbar,
    .budget-action-buttons,
    #budgetFocusMode,
    nav,
    .focus-strip {
        display: none !important;
    }

    /* Reset padding */
    #budget-section { padding-top: 0 !important; }
    #budget-summary-stats { display: grid !important; }
    #budget-content { overflow: visible !important; }
    #budget-table-wrapper { overflow: visible !important; max-height: none !important; }

    /* Nice print styling */
    #budget-table { font-size: 8pt; }
    #budget-table thead th { background-color: #e5e7eb !important; color: #111 !important; }
    .budget-print-header { display: block !important; }
    @page { margin: 1cm; }
}

/* Hidden print header (shown only when printing) */
.budget-print-header {
    display: none;
    margin-bottom: 0.5rem;
    font-size: 11pt;
    font-weight: 700;
    color: #111;
}

/* Original print rules */
.suggestions-bar,
.history-panel,
.autocomplete-dropdown,
#enhanced-modal,
#importPreviewModal {
    /* keep non-budget print rules */
}

@media print {
    .suggestions-bar,
    .history-panel,
    .autocomplete-dropdown,
    #enhanced-modal,
    #importPreviewModal {
        display: none !important;
    }

    .safety-stock-gauge,
    .quality-score-card,
    .unified-inventory-card {
        break-inside: avoid;
    }
}

/* ============================================================
   Custom Page Result Threshold Colors (Steps D/E)
   ============================================================ */
.result-card {
    transition: border-color 0.3s, background-color 0.3s;
}
.result-card.threshold-good {
    border-left: 3px solid #10b981;
    background-color: rgba(16, 185, 129, 0.05);
}
.result-card.threshold-warn {
    border-left: 3px solid #ef4444;
    background-color: rgba(239, 68, 68, 0.05);
}
.result-card.threshold-neutral {
    border-left: 3px solid transparent;
}

/* ============================================================
   Inventory Sub-tab Styles
   ============================================================ */
.inv-tool-tab {
    transition: all 0.2s ease;
    position: relative;
}
.inv-tool-tab:hover {
    background-color: rgba(0, 0, 0, 0.03);
}
.dark .inv-tool-tab:hover {
    background-color: rgba(255, 255, 255, 0.05);
}
.inv-tool-content {
    animation: invFadeIn 0.25s ease;
}
@keyframes invFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Advanced Warehouse Floor Plan
   ============================================================ */

/* ---------- Toolbar buttons ---------- */
.wh-tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    color: #4b5563;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}
.wh-tb-btn:hover {
    background: rgba(59, 130, 246, 0.08);
    color: #2563eb;
}
.wh-tb-active {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #1d4ed8 !important;
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.15);
}
.dark .wh-tb-btn {
    color: #9ca3af;
}
.dark .wh-tb-btn:hover {
    background: rgba(96, 165, 250, 0.12);
    color: #60a5fa;
}
.dark .wh-tb-active {
    background: rgba(96, 165, 250, 0.2) !important;
    color: #93bbfd !important;
    border-color: rgba(96, 165, 250, 0.35);
}

/* ---------- Toolbar group separators ---------- */
.wh-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding-right: 8px;
    margin-right: 8px;
    border-right: 1px solid #e5e7eb;
}
.wh-toolbar-group:last-child {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
}
.dark .wh-toolbar-group {
    border-right-color: #374151;
}

/* ---------- Canvas container ---------- */
#whCanvasContainer {
    position: relative;
    overflow: hidden;
    cursor: default;
    touch-action: none;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    min-height: 500px;
}
.dark #whCanvasContainer {
    background: #0f172a;
    border-color: #1e293b;
}

/* ---------- Canvas itself ---------- */
#warehouseCanvas {
    display: block;
    transform-origin: 0 0;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ---------- Mini-map ---------- */
#whMinimap {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: #ffffffee;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 20;
    transition: opacity 0.2s;
}
#whMinimap:hover {
    opacity: 1 !important;
}
.dark #whMinimap {
    background: #1e293bee;
    border-color: #334155;
}
#whMinimapCanvas {
    display: block;
    border-radius: 4px;
}

/* ---------- Scale ruler ---------- */
#whScaleRuler {
    position: absolute;
    bottom: 14px;
    left: 14px;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    z-index: 20;
    pointer-events: none;
}
#whScaleRuler .ruler-bar {
    width: 80px;
    height: 4px;
    background: #3b82f6;
    border-radius: 2px;
    position: relative;
}
#whScaleRuler .ruler-bar::before,
#whScaleRuler .ruler-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 2px;
    height: 10px;
    background: #3b82f6;
    border-radius: 1px;
}
#whScaleRuler .ruler-bar::before { left: 0; }
#whScaleRuler .ruler-bar::after { right: 0; }
#whScaleLabel {
    font-size: 0.65rem;
    font-weight: 600;
    color: #3b82f6;
    line-height: 1;
}

/* ---------- Coordinate display ---------- */
#whCoordDisplay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.8);
    color: #e2e8f0;
    font-size: 0.7rem;
    font-weight: 500;
    font-family: 'Courier New', monospace;
    padding: 4px 10px;
    border-radius: 6px;
    z-index: 20;
    pointer-events: none;
    transition: opacity 0.2s;
    letter-spacing: 0.5px;
}

/* ---------- Context menu ---------- */
#whContextMenu {
    position: fixed;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 6px 0;
    min-width: 200px;
    animation: whCtxIn 0.12s ease-out;
}
.dark #whContextMenu {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
@keyframes whCtxIn {
    from { opacity: 0; transform: scale(0.95) translateY(-4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
#whContextMenu button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 7px 14px;
    font-size: 0.82rem;
    background: none;
    border: none;
    color: #374151;
    cursor: pointer;
    transition: background 0.1s;
}
#whContextMenu button:hover {
    background: rgba(59, 130, 246, 0.08);
    color: #2563eb;
}
.dark #whContextMenu button {
    color: #d1d5db;
}
.dark #whContextMenu button:hover {
    background: rgba(96, 165, 250, 0.12);
    color: #93bbfd;
}
#whContextMenu button .ctx-shortcut {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-left: 20px;
}
#whContextMenu hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 4px 0;
}
.dark #whContextMenu hr {
    border-top-color: #374151;
}

/* ---------- Zoom controls ---------- */
.wh-zoom-display {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    min-width: 42px;
    justify-content: center;
}
.dark .wh-zoom-display {
    color: #9ca3af;
}

/* ---------- Palette scroll container ---------- */
.wh-palette-scroll {
    max-height: 340px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 transparent;
    padding-right: 2px;
}
.wh-palette-scroll::-webkit-scrollbar {
    width: 5px;
}
.wh-palette-scroll::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}
.wh-palette-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
    transition: background 0.2s;
}
.wh-palette-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
.dark .wh-palette-scroll {
    scrollbar-color: #475569 transparent;
}
.dark .wh-palette-scroll::-webkit-scrollbar-thumb {
    background: #475569;
}
.dark .wh-palette-scroll::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ---------- Palette buttons ---------- */
.wh-palette-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.68rem;
    font-weight: 500;
    color: #64748b;
    text-align: center;
    line-height: 1.2;
}
.wh-palette-btn:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
    transform: translateY(-1px);
}
.wh-palette-btn.ring-2 {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.06);
    color: #1d4ed8;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.dark .wh-palette-btn {
    background: #1e293b;
    color: #94a3b8;
}
.dark .wh-palette-btn:hover {
    border-color: #475569;
    background: #334155;
}
.dark .wh-palette-btn.ring-2 {
    border-color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
    color: #93bbfd;
}

/* ---------- Layers panel ---------- */
#whLayersPanel label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.12s;
}
#whLayersPanel label:hover {
    background: rgba(0, 0, 0, 0.03);
}
.dark #whLayersPanel label:hover {
    background: rgba(255, 255, 255, 0.04);
}
#whLayersPanel input[type="checkbox"] {
    accent-color: #3b82f6;
    width: 14px;
    height: 14px;
}

/* ---------- Properties panel ---------- */
#whPropsPanel {
    transition: opacity 0.2s;
}
#whPropsPanel input,
#whPropsPanel select {
    font-size: 0.82rem;
}

/* ---------- Dimensions bar ---------- */
.wh-dim-bar input[type="number"] {
    width: 70px;
    text-align: center;
    font-weight: 600;
    border-radius: 6px;
}
.wh-dim-bar .dim-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
}
.dark .wh-dim-bar .dim-label {
    color: #9ca3af;
}

/* ---------- Stats bar ---------- */
.wh-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}
.dark .wh-stat-pill {
    background: #1e293b;
    color: #94a3b8;
}

/* ---------- Template select ---------- */
#whTemplateSelect {
    font-size: 0.78rem;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: white;
    color: #374151;
    cursor: pointer;
}
.dark #whTemplateSelect {
    border-color: #4b5563;
    background: #1e293b;
    color: #d1d5db;
}

/* ---------- Warehouse responsive ---------- */
@media (max-width: 1024px) {
    #whCanvasContainer {
        min-height: 350px;
    }
    #whMinimap {
        display: none;
    }
}
@media (max-width: 640px) {
    .wh-toolbar-group {
        flex-wrap: wrap;
    }
    .wh-tb-btn {
        padding: 4px 7px;
        font-size: 0.72rem;
    }
    #whContextMenu {
        min-width: 170px;
    }
    .wh-palette-btn {
        padding: 6px 2px;
        font-size: 0.62rem;
    }
}

/* ========================================
   Quiz System Styles
   ======================================== */

/* Quiz option buttons */
.quiz-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    border: 2px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    font-size: 0.95rem;
    line-height: 1.4;
}
.dark .quiz-option {
    border-color: #374151;
    background: #1f2937;
    color: #f3f4f6;
}
.quiz-option:hover:not(.quiz-option-disabled) {
    border-color: #93c5fd;
    background: #eff6ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59,130,246,0.15);
}
.dark .quiz-option:hover:not(.quiz-option-disabled) {
    border-color: #3b82f6;
    background: #1e3a5f;
}

/* Selected state */
.quiz-option-selected {
    border-color: #3b82f6 !important;
    background: #dbeafe !important;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.dark .quiz-option-selected {
    border-color: #60a5fa !important;
    background: #1e3a5f !important;
}

/* Correct answer */
.quiz-option-correct {
    border-color: #22c55e !important;
    background: #dcfce7 !important;
    box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
}
.dark .quiz-option-correct {
    border-color: #4ade80 !important;
    background: #14532d !important;
}

/* Wrong answer */
.quiz-option-wrong {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.2);
}
.dark .quiz-option-wrong {
    border-color: #f87171 !important;
    background: #450a0a !important;
}

/* Disabled after answering */
.quiz-option-disabled {
    cursor: default;
    opacity: 0.7;
    pointer-events: none;
}
.quiz-option-disabled.quiz-option-correct,
.quiz-option-disabled.quiz-option-wrong {
    opacity: 1;
}

/* Option letter circle */
.quiz-option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    border-radius: 9999px;
    background: #e5e7eb;
    color: #374151;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}
.dark .quiz-option-letter {
    background: #374151;
    color: #d1d5db;
}
.quiz-option-selected .quiz-option-letter {
    background: #3b82f6;
    color: #fff;
}
.quiz-option-correct .quiz-option-letter {
    background: #22c55e;
    color: #fff;
}
.quiz-option-wrong .quiz-option-letter {
    background: #ef4444;
    color: #fff;
}

/* Question dot navigator */
.quiz-dot {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    border: 2px solid #d1d5db;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}
.dark .quiz-dot {
    border-color: #4b5563;
    background: #1f2937;
    color: #9ca3af;
}
.quiz-dot:hover {
    border-color: #93c5fd;
    transform: scale(1.15);
}
.quiz-dot-active {
    border-color: #3b82f6 !important;
    background: #dbeafe !important;
    color: #1e40af !important;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}
.dark .quiz-dot-active {
    background: #1e3a5f !important;
    color: #93c5fd !important;
}
.quiz-dot-correct {
    border-color: #22c55e !important;
    background: #dcfce7 !important;
    color: #166534 !important;
}
.dark .quiz-dot-correct {
    background: #14532d !important;
    color: #86efac !important;
}
.quiz-dot-wrong {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    color: #991b1b !important;
}
.dark .quiz-dot-wrong {
    background: #450a0a !important;
    color: #fca5a5 !important;
}
.quiz-dot-answered {
    border-color: #a5b4fc;
    background: #eef2ff;
    color: #4338ca;
}
.dark .quiz-dot-answered {
    border-color: #6366f1;
    background: #312e81;
    color: #a5b4fc;
}

/* Feedback box */
.quiz-feedback {
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1rem;
    animation: quizFeedbackIn 0.3s ease;
}
.quiz-feedback-correct {
    background: #dcfce7;
    border: 2px solid #86efac;
    color: #166534;
}
.dark .quiz-feedback-correct {
    background: #14532d;
    border-color: #22c55e;
    color: #bbf7d0;
}
.quiz-feedback-wrong {
    background: #fef2f2;
    border: 2px solid #fecaca;
    color: #991b1b;
}
.dark .quiz-feedback-wrong {
    background: #450a0a;
    border-color: #ef4444;
    color: #fecaca;
}

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

/* Results review item */
.quiz-review-item {
    padding: 1rem;
    border-radius: 0.75rem;
    border: 2px solid #e5e7eb;
    margin-bottom: 0.75rem;
}
.dark .quiz-review-item {
    border-color: #374151;
}
.quiz-review-correct {
    border-color: #86efac;
    background: #f0fdf4;
}
.dark .quiz-review-correct {
    border-color: #22c55e;
    background: rgba(20,83,45,0.3);
}
.quiz-review-wrong {
    border-color: #fecaca;
    background: #fef2f2;
}
.dark .quiz-review-wrong {
    border-color: #ef4444;
    background: rgba(69,10,10,0.3);
}

/* Category progress bar */
.quiz-category-bar {
    height: 0.5rem;
    border-radius: 9999px;
    background: #e5e7eb;
    overflow: hidden;
}
.dark .quiz-category-bar {
    background: #374151;
}
.quiz-category-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.8s ease;
}

/* Mode selection cards hover */
.quiz-mode-card {
    transition: all 0.3s ease;
    cursor: pointer;
}
.quiz-mode-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
}
.dark .quiz-mode-card:hover {
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

/* ============================================================
   LEARN PAGE TAB NAVIGATION (top-level 4 pages)
   ============================================================ */
.learn-page-nav {
    scrollbar-width: thin;
}
.learn-page-tab {
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}
.learn-page-tab:hover {
    background-color: rgba(99, 102, 241, 0.05);
}
.learn-page-tab-active {
    border-bottom-color: #6366f1 !important;
    color: #4f46e5 !important;
    background-color: rgba(99, 102, 241, 0.05);
}
.dark .learn-page-tab-active {
    border-bottom-color: #818cf8 !important;
    color: #a5b4fc !important;
    background-color: rgba(129, 140, 248, 0.1);
}

/* ============================================================
   LEARN MODE TAB NAVIGATION (sub-tabs within exercises)
   ============================================================ */
.learn-mode-tab-active {
    border-bottom-color: #6366f1; /* indigo-500 */
    color: #4f46e5;               /* indigo-600 */
}
.dark .learn-mode-tab-active {
    border-bottom-color: #818cf8; /* indigo-400 */
    color: #a5b4fc;               /* indigo-300 */
}

/* ============================================================
   LEARN PAGES — Startguide, Theory, Best Practices, Exercises
   ============================================================ */
.learn-step-card {
    transition: all 0.2s ease;
    border: 1px solid rgb(229, 231, 235);
}
.dark .learn-step-card {
    border-color: rgb(55, 65, 81);
}
.learn-step-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}
.learn-step-done {
    border-color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.05) !important;
}
.dark .learn-step-done {
    border-color: #34d399 !important;
    background-color: rgba(52, 211, 153, 0.08) !important;
}
.learn-step-done .learn-step-number {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: white !important;
}
.learn-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    cursor: pointer;
}
.learn-exercise-card {
    border-radius: 0.75rem;
    border: 2px solid rgb(229, 231, 235);
    padding: 1rem;
    transition: all 0.2s ease;
}
.dark .learn-exercise-card {
    border-color: rgb(55, 65, 81);
}
.learn-exercise-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.learn-theory-card {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid rgb(229, 231, 235);
    transition: box-shadow 0.2s ease;
}
.dark .learn-theory-card {
    border-color: rgb(55, 65, 81);
}
.learn-theory-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Best Practices Domain Tabs */
.bp-tab {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.15s ease;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
}
.bp-tab:hover {
    background-color: rgba(99, 102, 241, 0.08);
}
.bp-tab-active {
    background-color: #6366f1 !important;
    color: white !important;
    border-color: #6366f1;
}
.dark .bp-tab-active {
    background-color: #818cf8 !important;
    color: #1e1b4b !important;
    border-color: #818cf8;
}

/* Difficulty badges */
.difficulty-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    letter-spacing: 0.025em;
}
.difficulty-beginner { background-color: #d1fae5; color: #065f46; }
.difficulty-intermediate { background-color: #fef3c7; color: #92400e; }
.difficulty-advanced { background-color: #fee2e2; color: #991b1b; }
.dark .difficulty-beginner { background-color: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.dark .difficulty-intermediate { background-color: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.dark .difficulty-advanced { background-color: rgba(239, 68, 68, 0.2); color: #fca5a5; }

/* ============================================================
   FLASHCARD FLIP ANIMATION
   ============================================================ */
.flashcard-container {
    perspective: 1000px;
    width: 100%;
    max-width: 560px;
    height: 320px;
    margin: 0 auto;
    cursor: pointer;
}
.flashcard {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(.4,0,.2,1);
    transform-style: preserve-3d;
}
.flashcard-flipped {
    transform: rotateY(180deg);
}
.flashcard-front,
.flashcard-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    overflow-y: auto;
}
.flashcard-front {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border: 2px solid #c7d2fe;
    color: #1e1b4b;
}
.dark .flashcard-front {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    border-color: #4338ca;
    color: #e0e7ff;
}
.flashcard-back {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 2px solid #6ee7b7;
    color: #064e3b;
    transform: rotateY(180deg);
}
.dark .flashcard-back {
    background: linear-gradient(135deg, #064e3b, #065f46);
    border-color: #10b981;
    color: #d1fae5;
}

/* ============================================================
   TRUE / FALSE BUTTONS
   ============================================================ */
.tf-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1.25rem 2rem;
    border-radius: 1rem;
    border: 2px solid #d1d5db;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    color: #1f2937;
    min-width: 140px;
}
.dark .tf-btn {
    background: #1f2937;
    border-color: #4b5563;
    color: #f3f4f6;
}
.tf-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}
.tf-btn-correct {
    border-color: #22c55e !important;
    background: #f0fdf4 !important;
    color: #166534 !important;
    animation: quizFeedbackIn 0.3s ease;
}
.dark .tf-btn-correct {
    background: rgba(34,197,94,0.15) !important;
    color: #86efac !important;
}
.tf-btn-wrong {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    color: #991b1b !important;
    animation: quizFeedbackIn 0.3s ease;
}
.dark .tf-btn-wrong {
    background: rgba(239,68,68,0.15) !important;
    color: #fca5a5 !important;
}
.tf-btn-disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* ════════════════════════════════════════════════════════════════
   POLISH  — mobile & dark-mode refinements
   ════════════════════════════════════════════════════════════════ */

/* ── Text rendering ──────────────────────────────────────────── */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Smooth theme transitions on all key elements ───────────── */
body,
header,
nav,
main,
.mobile-bottom-nav,
.mobile-menu-sheet,
.result-card,
.setting-item,
.data-table th,
.data-table td,
.input-field,
.file-input,
.tab-btn,
.mobile-menu-item,
.mob-nav-btn {
    transition-property: background-color, border-color, color, box-shadow;
    transition-duration: 200ms;
    transition-timing-function: ease;
}

/* ── Only animate lift/hover on devices that actually have hover ── */
@media (hover: none) {
    /* Touch devices: disable translateY lift to prevent stuck hover */
    button:hover:not(:disabled),
    .result-card:hover,
    .metric-card:hover,
    .matrix-cell:hover,
    .theme-option:hover,
    .language-option:hover {
        transform: none !important;
        box-shadow: none !important;
    }
    /* Keep active press feedback */
    button:active:not(:disabled) {
        transform: scale(0.97) !important;
        opacity: 0.85;
    }
    /* Kill all tap highlight colours */
    * {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ── iOS safe-area insets (notch / home-bar) ─────────────────── */
/* env() falls back to 0px so this is safe on all devices.       */
.mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    min-height: 60px;            /* expands naturally instead of clipping */
}
@media (max-width: 640px) {
    body {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }
}
/* Header background fills the status-bar area (iOS standalone)  */
header {
    padding-top: env(safe-area-inset-top, 0px);
}

/* ── Toast: sit above the 60px mobile bottom nav ────────────── */
@media (max-width: 640px) {
    .toast {
        bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 0.75rem) !important;
        left: 0.75rem !important;
        right: 0.75rem !important;
    }
}

/* ── Mobile bottom-nav: active pill indicator ───────────────── */
.mob-nav-btn.mob-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: #6366f1;
}
.dark .mob-nav-btn.mob-active::before {
    background: #818cf8;
}
.mob-nav-btn {
    position: relative; /* needed for ::before */
}

/* ── Focus ring — visible & consistent ──────────────────────── */
:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}
.dark :focus-visible {
    outline-color: #60a5fa;
}

/* ── Dark mode: card depth with shadow rather than just flat bg ─ */
.dark .result-card,
.dark .setting-item {
    background-color: #1e293b;
    border-color: #334155;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
}
.dark .result-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* Dark bg-white cards inside tab content */
.dark .bg-white {
    background-color: #1e293b !important;
    border-color: #334155;
}
.dark .bg-gray-50,
.dark .bg-gray-100 {
    background-color: #0f172a !important;
}

/* ── Dark mode: richer body background ──────────────────────── */
.dark body,
body.dark {
    background-color: #0f172a !important;
}

/* ── Dark mode: softer text on secondary elements ───────────── */
.dark p,
.dark li {
    color: #cbd5e1;
}
.dark h1, .dark h2, .dark h3, .dark h4, .dark h5, .dark h6 {
    color: #f1f5f9;
}
.dark label {
    color: #94a3b8;
}

/* ── Dark mode: input placeholder ───────────────────────────── */
.dark input::placeholder,
.dark textarea::placeholder {
    color: #64748b;
}

/* ── Dark mode: better scrollbar ────────────────────────────── */
.dark ::-webkit-scrollbar-track { background: #0f172a; }
.dark ::-webkit-scrollbar-thumb { background: #334155; border-radius: 6px; border: 2px solid #0f172a; }
.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ── Dark mode: text selection ──────────────────────────────── */
.dark ::selection {
    background: rgba(99, 102, 241, 0.4);
    color: #f1f5f9;
}
::selection {
    background: rgba(59, 130, 246, 0.25);
}

/* ── Dark mode: table row hover ─────────────────────────────── */
.dark .data-table tbody tr:hover {
    background-color: rgba(51, 65, 85, 0.6);
}

/* ── Dark mode: modal / sheet backgrounds ───────────────────── */
.dark .mobile-menu-sheet {
    background: #1e293b;
    border-top: 1px solid #334155;
}
.dark .mobile-menu-item {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
}
.dark .mobile-menu-item:active {
    background: #1e3a5f;
}

/* ── Touch: larger tap targets on mobile ────────────────────── */
@media (max-width: 640px) {
    /* nav buttons always tall enough, home-bar safe area sits below them */
    .mob-nav-btn {
        min-height: 52px;
        padding-bottom: 4px;     /* push label up, space for home-bar gap */
    }
    /* Ensure all icon-only buttons are at least 44×44 */
    #themeToggle,
    #mobileMenuToggle {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ── Overscroll behavior ─────────────────────────────────────── */
html {
    overscroll-behavior-y: contain;
}
.mobile-menu-sheet,
.overflow-y-auto {
    overscroll-behavior: contain;
}

/* ── Prevent layout shift when scrollbar appears/disappears ─── */
html {
    scrollbar-gutter: stable;
}

/* ── Page-enter animation (available globally) ───────────────── */
@keyframes appPageIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0);   }
}

/* ── Installed PWA (display-mode: standalone) — app-shell polish */
@media (display-mode: standalone) {

  /* Landscape notch: push body away from side cutouts            */
  body {
    padding-left:  env(safe-area-inset-left,  0px);
    padding-right: env(safe-area-inset-right, 0px);
  }

  /* Hide any lingering "add to home screen" hints                 */
  .pwa-install-hint { display: none !important; }

  /* Mobile header: slightly taller to feel more native           */
  @media (max-width: 640px) {
    header .container {
      padding-top:    0.625rem;
      padding-bottom: 0.625rem;
    }
  }

  /* Tab panels: subtle fade-in when switching sections           */
  .tab-content, .section-panel {
    animation: appPageIn .2s cubic-bezier(.22,.61,.36,1);
  }

  /* No accidental text selection on nav chrome long-press        */
  header, #mobileBottomNav, #mobileMenuSheet {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Active tab pill: slightly thicker in app mode                */
  .mob-nav-btn.mob-active::before {
    height: 3px;
  }
}
