/* ============================================
   Phase 1 — Design System Foundation
   Amstel Steel brand palette, animations,
   utility classes, and global styles.
   ============================================ */

/* ============================================
   Brand CSS Custom Properties
   ============================================ */
:root {
    /* Brand palette */
    --amstel-blue-primary: #03338F;
    --amstel-blue-light: #5B7FBF;
    --amstel-blue-dark: #001B47;
    --amstel-charcoal: #2D2D2D;
    --amstel-blue: #03338F;
    --amstel-teal: #00897B;

    /* Semantic colors */
    --color-error: #0B5CAD;
    --color-warning: #5B7FBF;
    --color-info: #03338F;
    --color-success: #00897B;

    /* Surfaces — light mode defaults */
    --surface-light: #FAFAFA;
    --surface-dark: #1E1E2E;
    --bg-light: #F5F5F7;
    --bg-dark: #141420;
    --drawer-dark: #1A1A2A;
    --appbar-dark: #0F0F1A;

    /* Glass effect */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-blur: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
    --shadow-lift: 0 8px 20px rgba(0, 0, 0, 0.12);
    --shadow-brand: 0 4px 16px rgba(3, 51, 143, 0.18);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Typography */
    --font-heading: 'Inter', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    --font-body: 'Inter', 'Roboto', 'Helvetica', 'Arial', sans-serif;
}

/* Dark mode overrides
   NOTE: use .theme-dark (Linx document theme). MudBlazor's .mud-theme-dark is a
   Color.Dark utility class, not a page-level theme wrapper. */
.theme-dark {
    --glass-bg: rgba(30, 30, 46, 0.72);
    --glass-border: rgba(255, 255, 255, 0.08);
}

/* Full-height shell so the main window background follows dark tokens */
html, body, #app {
    height: 100%;
}

.app-shell {
    min-height: 100%;
    background-color: var(--lxc-bg, var(--lx-bg-primary, var(--mud-palette-background, #F3F4F6)));
}

html.theme-dark,
html.theme-dark body {
    background-color: var(--lxc-bg, #141420);
    color: var(--lxc-ink, #E2E8F0);
}

/* ============================================
   Base / Reset
   ============================================ */
h1:focus {
    outline: none;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none; /* shown by Blazor JS when a render exception occurs */
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: var(--amstel-blue-dark);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

/* ============================================
   Micro-Animation Keyframes
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulse-ring {
    0%   { transform: scale(0.9); opacity: 0.6; }
    70%  { transform: scale(1.15); opacity: 0; }
    100% { transform: scale(1.15); opacity: 0; }
}

@keyframes lift-hover {
    from { transform: translateY(0); box-shadow: var(--shadow-sm); }
    to   { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
}

/* ============================================
   Animation Utility Classes
   ============================================ */
.fade-in {
    animation: fadeIn var(--transition-normal) ease both;
}

.slide-up {
    animation: slideUp var(--transition-slow) ease both;
}

.scale-in {
    animation: scaleIn var(--transition-normal) ease both;
}

/* Staggered children: add .stagger-children to parent */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }
.stagger-children > *:nth-child(7) { animation-delay: 360ms; }
.stagger-children > *:nth-child(8) { animation-delay: 420ms; }

/* ============================================
   Page Transition
   ============================================ */
.page-transition {
    animation: fadeInUp 300ms ease;
}

/* ============================================
   Skeleton Loader
   ============================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--mud-palette-background-grey, #e0e0e0) 25%,
        var(--mud-palette-surface, #f5f5f5) 50%,
        var(--mud-palette-background-grey, #e0e0e0) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

.theme-dark .skeleton {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.06) 25%,
        rgba(255,255,255,0.12) 50%,
        rgba(255,255,255,0.06) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.full { width: 100%; }

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
}

/* ============================================
   Glass Card Utility
   ============================================ */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

/* ============================================
   Glass AppBar
   ============================================ */
.glass-appbar {
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.theme-dark .glass-appbar {
    background: rgba(15, 15, 26, 0.78) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.glass-appbar .mud-typography {
    color: var(--amstel-charcoal);
}

.theme-dark .glass-appbar .mud-typography {
    color: #E0E0E0;
}

.glass-appbar .mud-icon-button {
    color: var(--amstel-charcoal) !important;
}

.theme-dark .glass-appbar .mud-icon-button {
    color: #E0E0E0 !important;
}

/* AppBar logo */
.appbar-logo {
    height: 30px;
    width: auto;
    margin-right: 8px;
    flex-shrink: 0;
}

.appbar-title {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: 1.15rem;
    white-space: nowrap;
}

@media (max-width: 599px) {
    .glass-appbar .mud-toolbar {
        min-height: 52px;
        padding-left: 4px !important;
        padding-right: 4px !important;
        flex-wrap: nowrap;
        gap: 0;
    }

    .glass-appbar .mud-icon-button {
        width: 36px;
        height: 36px;
        padding: 6px;
        flex: 0 0 36px;
        margin: 0 !important;
    }

    .appbar-logo {
        height: 24px !important;
        max-width: 82px;
        object-fit: contain;
        margin: 0 3px 0 1px !important;
    }

    .appbar-title {
        margin-left: 0 !important;
        font-size: 0.88rem !important;
        line-height: 1;
        flex: 0 0 auto;
    }

    .header-signin {
        min-width: 0 !important;
        padding: 4px 6px !important;
        white-space: nowrap;
        font-size: 0.75rem !important;
        line-height: 1;
    }

    .header-signin .mud-button-start-icon {
        display: none;
    }

    .appbar-user-control {
        gap: 2px !important;
        white-space: nowrap;
    }

    .appbar-user-control .mud-avatar {
        width: 30px !important;
        height: 30px !important;
    }
}

@media (max-width: 359px) {
    .appbar-logo {
        height: 21px !important;
        max-width: 70px;
    }

    .appbar-title {
        font-size: 0.78rem !important;
    }

    .header-signin {
        padding-left: 4px !important;
        padding-right: 4px !important;
        font-size: 0.7rem !important;
    }
}

/* ============================================
   Stat Card
   ============================================ */
.stat-card {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lift);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--amstel-blue-primary), var(--amstel-blue-light));
}

.stat-card .stat-value {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    margin-top: 2px;
}

.stat-card .stat-icon {
    opacity: 0.12;
    position: absolute;
    right: 12px;
    bottom: 8px;
    font-size: 3rem;
}

/* Stat card accent color variants */
.stat-card--primary::before { background: linear-gradient(90deg, var(--amstel-blue-primary), var(--amstel-blue-light)); }
.stat-card--blue::before   { background: linear-gradient(90deg, var(--amstel-blue), #4a9af5); }
.stat-card--teal::before   { background: linear-gradient(90deg, var(--amstel-teal), #26a69a); }
.stat-card--amber::before  { background: linear-gradient(90deg, var(--color-warning), var(--amstel-blue-light)); }

/* ============================================
   Wizard Step Indicator
   ============================================ */
.wizard-step-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wizard-step-indicator .step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mud-palette-text-disabled, #bdbdbd);
    transition: all var(--transition-normal);
}

.wizard-step-indicator .step-dot.active {
    width: 24px;
    border-radius: 4px;
    background: var(--amstel-blue-primary);
}

.wizard-step-indicator .step-dot.completed {
    background: var(--amstel-teal);
}

/* ============================================
   Nav Menu Enhancements
   ============================================ */
.nav-brand-bar {
    height: 3px;
    background: linear-gradient(90deg, var(--amstel-blue-primary), var(--amstel-blue-light), transparent);
    margin-bottom: 4px;
    border-radius: 0 0 2px 2px;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 16px 16px 4px;
    opacity: 0.5;
}

/* Animated nav items */
.amstel-nav .mud-nav-link {
    border-left: 3px solid transparent;
    margin: 1px 8px;
    border-radius: 0 8px 8px 0;
    transition: background-color var(--transition-fast),
                border-color var(--transition-fast),
                padding-left var(--transition-fast);
}

.amstel-nav .mud-nav-link:hover {
    background-color: var(--mud-palette-action-default-hover, rgba(0,0,0,0.04));
    border-left-color: var(--amstel-blue-light);
    padding-left: 20px;
}

.amstel-nav .mud-nav-link.active {
    background-color: rgba(3, 51, 143, 0.08);
    border-left-color: var(--amstel-blue-primary);
    font-weight: 600;
}

.theme-dark .amstel-nav .mud-nav-link.active {
    background-color: rgba(3, 51, 143, 0.15);
}

/* Admin section highlight */
.admin-section {
    position: relative;
    margin-top: 4px;
    padding-top: 4px;
}

.admin-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 16px;
    height: 1px;
    background: linear-gradient(90deg, var(--amstel-blue-primary) 0%, transparent 100%);
    opacity: 0.3;
}

.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(3, 51, 143, 0.12);
    color: var(--amstel-blue-primary);
}

.theme-dark .admin-badge {
    background: rgba(91, 127, 191, 0.18);
    color: var(--amstel-blue-light);
}

/* Pending count dot */
.nav-count-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 9px;
    background: var(--amstel-blue-primary);
    color: #fff;
    padding: 0 5px;
    margin-left: auto;
}

/* Mini drawer (rail mode) */
.mini-drawer .mud-nav-link .mud-nav-link-text {
    display: none;
}

.mini-drawer .mud-nav-group-text {
    display: none;
}

.mini-drawer .nav-section-label {
    display: none;
}

.mini-drawer .admin-badge {
    display: none;
}

/* ============================================
   Quote Manager Responsive Styles
   ============================================ */

/* Quote Details Panel */
.quote-details-panel {
    height: 100%;
}

.quote-header {
    background-color: var(--mud-palette-background-grey);
    border-radius: 8px;
}

/* Door Cards */
.door-card {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
    border-radius: 10px;
}

.door-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-brand);
    border-color: var(--amstel-blue-light);
}

/* Sidebar Drawer */
.sidebar-drawer {
    border-right: 1px solid var(--mud-palette-divider);
}

.sidebar-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-drawer .h-100 {
    height: 100%;
}

.sidebar-drawer .overflow-auto {
    overflow-y: auto;
}

/* ============================================
   Quote Manager Sidebar Layout
   ============================================ */
.qm-wrapper {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 120px);
    margin: -16px -24px;
    position: relative;
}

.qm-sidebar {
    width: 320px;
    min-width: 320px;
    flex-shrink: 0;
    border-right: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.12));
    transition: width var(--transition-slow), min-width var(--transition-slow), opacity var(--transition-normal);
    overflow: hidden;
}

.qm-sidebar--collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    border-right: none;
}

.qm-content {
    flex: 1;
    min-width: 0;
    padding: 16px 24px;
}

.qm-expand-btn {
    position: absolute;
    left: 4px;
    top: 8px;
    z-index: 1;
}

@media (max-width: 960px) {
    .qm-sidebar {
        width: 280px;
        min-width: 280px;
    }
}

/* Tree View */
.job-quote-tree-view .tree-item {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 2px 0;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.job-quote-tree-view .tree-item:hover {
    background-color: var(--mud-palette-background-grey);
}

.job-quote-tree-view .tree-item.selected {
    background-color: rgba(3, 51, 143, 0.08);
    border-left: 3px solid var(--amstel-blue-primary);
}

.theme-dark .job-quote-tree-view .tree-item.selected {
    background-color: rgba(3, 51, 143, 0.15);
}

/* Door Configuration Wizard */
.door-wizard-overlay {
    overflow: hidden;
}

.door-wizard-container {
    display: flex;
    flex-direction: column;
}

.door-type-card, .model-card {
    cursor: pointer;
    transition: all var(--transition-normal);
    border-radius: 10px;
}

.door-type-card:hover, .model-card:hover {
    border-color: var(--amstel-blue-primary) !important;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.door-type-card.selected, .model-card.selected {
    border-color: var(--amstel-blue-primary) !important;
    border-width: 2px;
    background-color: rgba(3, 51, 143, 0.06);
}

.theme-dark .door-type-card.selected,
.theme-dark .model-card.selected {
    background-color: rgba(3, 51, 143, 0.12);
}

/* Mobile Responsiveness */
@media (max-width: 599px) {
    /* Phone breakpoint - matches MudBlazor's xs */

    .quote-header {
        padding: 12px !important;
    }

    .quote-header .d-flex {
        flex-direction: column;
        gap: 8px;
    }

    .door-card .mud-card-actions {
        flex-direction: column;
        gap: 4px;
    }

    .door-card .mud-card-actions .mud-button {
        width: 100%;
    }

    /* Sticky action buttons on mobile */
    .mobile-actions-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: var(--mud-palette-surface);
        padding: 12px;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
        z-index: 100;
        display: flex;
        gap: 8px;
        justify-content: center;
    }

    .mobile-pricing-bar {
        background-color: var(--mud-palette-surface);
    }
}

@media (min-width: 600px) and (max-width: 959px) {
    /* Tablet breakpoint - matches MudBlazor's sm/md */

    .quote-header {
        padding: 16px !important;
    }

    .door-card {
        margin-bottom: 12px;
    }
}

@media (min-width: 960px) {
    /* Desktop breakpoint - matches MudBlazor's md and up */

    .mobile-actions-bar {
        display: none;
    }
}

/* Quote Comparison Modal */
.quote-comparison-card {
    min-height: 300px;
}

.quote-comparison-card .mud-card-content {
    max-height: 60vh;
    overflow-y: auto;
}

/* ============================================
   Rich Tooltip Component
   ============================================ */
.rich-tooltip-container .mud-tooltip-root {
    display: inline-flex;
}

.rich-tooltip {
    padding: 4px;
    text-align: left;
    animation: fadeIn 150ms ease both;
}

.rich-tooltip-media {
    margin-bottom: 8px;
    line-height: 0;
    border-radius: 6px;
    overflow: hidden;
}

.rich-tooltip-media img {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
}

.rich-tooltip-title {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
    margin-bottom: 4px;
    color: var(--mud-palette-white, #fff);
}

.rich-tooltip-description {
    font-size: 0.8rem;
    line-height: 1.4;
    opacity: 0.9;
    color: var(--mud-palette-white, #fff);
}

/* Print styles */
@media print {
    .sidebar-drawer,
    .mobile-actions-bar,
    .mud-appbar {
        display: none !important;
    }

    .quote-details-panel {
        padding: 20px;
    }
}

/* ============================================
   Track Preview Canvas
   ============================================ */
.track-preview-shell {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    overflow: hidden;
}

.track-preview-toolbar {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 8px 10px;
    background: rgba(0,0,0,0.2);
}

.track-preview-canvas {
    background: linear-gradient(180deg, rgba(10,10,12,0.85), rgba(20,20,24,0.85));
    height: 360px;
    width: 100%;
    touch-action: none;
    cursor: grab;
}

.track-preview-canvas:active {
    cursor: grabbing;
}

.track-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.junction-marker { cursor: pointer; }
.junction-marker:hover circle { filter: drop-shadow(0 0 6px rgba(255,235,59,0.7)); }

/* ============================================
   Utility: Status Colors
   ============================================ */
.status-draft    { color: var(--mud-palette-text-secondary); }
.status-pending  { color: var(--color-warning); }
.status-accepted { color: var(--color-success); }
.status-rejected { color: var(--color-error); }

/* ============================================
   Dashboard — Hero Banner
   ============================================ */
.hero-banner {
    background: linear-gradient(135deg,
        rgba(3, 51, 143, 0.06) 0%,
        rgba(26, 115, 232, 0.04) 100%);
    border: 1px solid rgba(3, 51, 143, 0.08);
    border-radius: 14px;
}

.theme-dark .hero-banner {
    background:
        linear-gradient(135deg,
            rgba(77, 163, 255, 0.10) 0%,
            rgba(26, 115, 232, 0.04) 100%),
        var(--lxc-surface, #1A2332);
    border-color: rgba(91, 127, 191, 0.18);
}

.hero-title {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    opacity: 0.75;
}

.hero-cta {
    border-radius: 10px !important;
    padding: 10px 28px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 14px rgba(3, 51, 143, 0.25);
    transition: box-shadow var(--transition-normal), transform var(--transition-normal) !important;
}

.hero-cta:hover {
    box-shadow: 0 6px 20px rgba(3, 51, 143, 0.35);
    transform: translateY(-1px);
}

/* ============================================
   Dashboard — Quick Action Cards
   ============================================ */
.quick-action-card {
    border-radius: 12px;
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.quick-action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--mud-palette-primary);
}

/* ============================================
   Dashboard — Feature Cards
   ============================================ */
.feature-card {
    border-radius: 12px;
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--amstel-blue-primary), var(--amstel-blue));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.feature-card:hover::before {
    opacity: 1;
}

/* ============================================
   Landing — Unauthenticated Hero
   ============================================ */
.landing-hero {
    background: linear-gradient(135deg,
        rgba(3, 51, 143, 0.05) 0%,
        rgba(26, 115, 232, 0.03) 50%,
        rgba(0, 137, 123, 0.03) 100%);
    border: 1px solid rgba(3, 51, 143, 0.06);
    border-radius: 16px;
}

.theme-dark .landing-hero {
    background:
        linear-gradient(135deg,
            rgba(77, 163, 255, 0.08) 0%,
            rgba(26, 115, 232, 0.04) 50%,
            rgba(0, 137, 123, 0.03) 100%),
        var(--lxc-surface, #1A2332);
    border-color: rgba(91, 127, 191, 0.16);
}

.landing-title {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* ============================================
   Phase 3 — Quote Manager Polish
   ============================================ */

/* Sidebar search field */
.qm-search-field .mud-input-outlined {
    border-radius: 8px;
}

.qm-new-job-btn {
    border-radius: 8px !important;
}

/* Quotes table card */
.qm-quotes-table-card {
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    border-radius: 12px;
}

.qm-quotes-table tr {
    transition: background-color var(--transition-fast);
}

/* Empty state */
.qm-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
}

/* ============================================
   Quote Manager Job List
   ============================================ */
.job-quote-tree-view .tree-list {
    padding: 0;
}

.tree-job-item {
    border-radius: 8px;
    margin: 2px 4px;
    transition: background-color var(--transition-fast);
}

.tree-job-item:hover {
    background-color: var(--mud-palette-action-default-hover, rgba(0,0,0,0.04));
}

.tree-job-item.tree-item-selected {
    background-color: rgba(3, 51, 143, 0.06);
}

.theme-dark .tree-job-item.tree-item-selected {
    background-color: rgba(3, 51, 143, 0.12);
}

/* ============================================
   Quote Details — Hero Header
   ============================================ */
.quote-hero-header {
    border-radius: 12px;
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    position: relative;
    overflow: hidden;
}

.quote-hero-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

/* Status-based header gradient */
.quote-hero--draft::before          { background: linear-gradient(90deg, #9e9e9e, #bdbdbd); }
.quote-hero--pendingapproval::before { background: linear-gradient(90deg, #03338F, #5B7FBF); }
.quote-hero--senttocustomer::before  { background: linear-gradient(90deg, var(--color-warning), var(--amstel-blue-light)); }
.quote-hero--accepted::before        { background: linear-gradient(90deg, var(--color-success), #4db6ac); }
.quote-hero--rejected::before        { background: linear-gradient(90deg, var(--amstel-blue-dark), var(--amstel-blue-light)); }

/* Stat item row */
.quote-stat-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    background: var(--mud-palette-background, #f5f5f5);
    border-radius: 8px;
}

.theme-dark .quote-stat-item {
    background: rgba(255,255,255,0.04);
}

/* Status banner */
.quote-status-banner {
    border-radius: 8px;
}

/* ============================================
   Door Card — Gradient Top Border by Status
   ============================================ */
.door-card {
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    position: relative;
    overflow: hidden;
}

.door-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.door-card--configured::before { background: linear-gradient(90deg, var(--color-success), #4db6ac); }
.door-card--partial::before    { background: linear-gradient(90deg, var(--color-warning), var(--amstel-blue-light)); }
.door-card--empty::before      { background: linear-gradient(90deg, #9e9e9e, #bdbdbd); }

/* ============================================
   Comparison Modal — Enhancements
   ============================================ */
.quote-comparison-card {
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    border-radius: 12px;
}

.quote-comparison-card .mud-card-content {
    max-height: 60vh;
    overflow-y: auto;
}

.comparison-best {
    border-color: var(--color-success) !important;
    box-shadow: 0 0 0 1px var(--color-success);
}

.comparison-door-row:last-child {
    border-bottom: none !important;
}

.comparison-summary-table {
    border-radius: 8px;
    overflow: hidden;
}

/* ================================================
   PHASE 4 — Door Configuration Wizards
   ================================================ */

/* --- 4.1 / 4.5 Wizard Overlay & AppBar --- */
.wizard-appbar-gradient {
    background: linear-gradient(135deg, #03338F 0%, #001B47 100%) !important;
}

.wizard-step-content {
    animation: fadeIn 0.3s ease-out;
    border-radius: 12px;
}

.wizard-nav-buttons {
    padding: 16px 0;
}

/* --- Pricing Sidebar Glass --- */
.wizard-pricing-sidebar {
    background: var(--glass-bg, rgba(255,255,255,0.06));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    height: 100%;
    overflow-y: auto;
}

.wizard-pricing-card {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    border-radius: 12px;
    transition: box-shadow 0.3s ease;
}

.wizard-pricing-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.wizard-pricing-total {
    font-size: 1.75rem;
    font-weight: 700;
    color: #03338F;
    transition: transform 0.3s ease;
}

.wizard-pricing-line-item {
    padding: 4px 0;
    border-bottom: 1px dashed var(--mud-palette-lines-default, rgba(0,0,0,0.06));
}

.wizard-pricing-line-item:last-child {
    border-bottom: none;
}

.wizard-door-info-table td {
    padding: 6px 8px;
}

/* --- Mobile pricing bar --- */
.mobile-pricing-bar {
    background: var(--glass-bg, rgba(255,255,255,0.06));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--glass-border, rgba(255,255,255,0.08));
}

/* --- 4.2 TrackPreviewCanvas Blueprint --- */
.track-preview-shell {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.08));
}

.track-preview-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--mud-palette-surface);
    border-bottom: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.08));
    flex-wrap: wrap;
}

.track-preview-toolbar .zoom-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    background: var(--mud-palette-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}

.track-preview-canvas {
    position: relative;
    width: 100%;
    height: 350px;
    background: #0d1b2a;
    cursor: grab;
    overflow: hidden;
}

.track-preview-canvas:active {
    cursor: grabbing;
}

/* Blueprint grid pattern */
.track-preview-canvas .track-svg {
    width: 100%;
    height: 100%;
}

/* Wide, transparent SVG targets make the track editable without requiring a
   pixel-perfect click/tap on a dimension label or curve handle. */
.track-edit-hitbox {
    cursor: pointer;
    pointer-events: stroke;
    touch-action: manipulation;
}

/* The sliding wizard is a full-screen layer (z-index: 20000). Its editor
   dialogs are rendered by the app-level MudDialogProvider, so use a higher
   dialog/popover layer while that wizard is open. */
body:has(.wiz-overlay) {
    --mud-zindex-dialog: 20100;
    --mud-zindex-popover: 20100;
}

/* SVG segment styling (no CSS filter — inline stroke attrs used instead for perf) */

/* Animated dash for segments */
@keyframes dashFlow {
    to { stroke-dashoffset: -20; }
}

.track-seg-animated {
    stroke-dasharray: 8 4;
    animation: dashFlow 1.5s linear infinite;
}

/* Dimension label pills */
.track-dimension-label {
    fill: rgba(255,255,255,0.9);
    font-size: 10px;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
}

.track-dimension-pill {
    fill: rgba(0,0,0,0.6);
    rx: 8;
    ry: 8;
}

/* Start/End markers — no drop-shadow filter (perf) */
.track-marker-start,
.track-marker-end {
    /* glow handled by the halo circle instead of CSS filter */
}

/* Junction markers redesign */
.junction-marker {
    cursor: pointer;
    transition: transform 0.15s ease;
}

.junction-marker:hover {
    transform: scale(1.2);
}

.junction-marker-ring {
    fill: none;
    stroke: #5B9DFF;
    stroke-width: 2;
    opacity: 0.4;
}

/* Pocket visualization — no CSS filter for perf */
.track-pocket-path {
    stroke: #5B9DFF;
    stroke-width: 2;
    fill: rgba(91,157,255,0.15);
}

/* Canvas subtle border glow (no ::after overlay — avoids SVG interaction issues) */

/* --- 4.3 IntersectionTrackDesigner --- */
.track-stats-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.track-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 16px;
    background: var(--mud-palette-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}

.track-stat-chip--secondary {
    background: var(--color-secondary);
}

.track-stat-chip--info {
    background: var(--mud-palette-info);
}

.angle-preset-chip {
    min-width: 48px;
    text-align: center;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.angle-preset-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.segment-list-item {
    border-radius: 8px;
    margin-bottom: 4px;
    transition: background 0.15s ease;
    border: 1px solid transparent;
}

.segment-list-item:hover {
    background: var(--mud-palette-action-default-hover);
}

.segment-list-item--selected {
    border-color: var(--mud-palette-primary);
    background: rgba(3, 51, 143, 0.05);
}

.segment-label-mono {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
}

/* Pocket indicator icons */
.pocket-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(91,157,255,0.12);
    color: #0B5CAD;
    font-size: 0.75rem;
    font-weight: 600;
}

/* --- 4.3b Curved-intersection track workbench (native wizard CSS) ---
   Canvas-first layout: a thin control rail + canvas + action bar on desktop,
   a fixed canvas with a tabbed control area on mobile. Rendered inside
   .wiz-overlay so the wizard design-system variables cascade in. */
.itd-host { margin-top: 12px; }

.itd {
    display: grid;
    gap: 14px;
    grid-template-columns: clamp(248px, 28%, 272px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 94px;
    grid-template-areas:
        "rail stage"
        "rail segments";
    height: clamp(420px, calc(100dvh - 300px), 640px);
    min-height: 420px;
}
.itd, .itd * { box-sizing: border-box; }
.itd button, .itd input { font-family: var(--font-sans); }
.itd-rail { grid-area: rail; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }
.itd-stage { grid-area: stage; min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--canvas-bg); display: flex; flex-direction: column; }
.itd-canvaswrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.itd-segments { grid-area: segments; background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.itd-tabbar { display: none; }

/* Canvas fills the stage instead of the component's own fixed height */
.itd-stage .track-preview-shell { flex: 1 1 auto; min-height: 0; border: none; border-radius: 0; display: flex; flex-direction: column; }
.itd-stage .track-preview-canvas { flex: 1 1 auto; height: auto; min-height: 0; }
.itd-stage .track-preview-toolbar.is-compact { flex: 0 0 auto; flex-wrap: nowrap; gap: 3px; padding: 6px 8px; }
.itd-stage .track-preview-zoom-controls { display: inline-flex; align-items: center; flex: 0 0 auto; }
.itd-stage .track-preview-toolbar.is-compact .mud-icon-button { padding: 6px; }
.itd-stage .track-preview-toolbar.is-compact .zoom-badge { padding: 2px 8px; white-space: nowrap; }
.itd-stage .track-preview-radius-field { flex: 0 0 142px; width: 142px; min-width: 118px; max-width: 142px; height: 42px; margin-left: 4px; padding: 13px 8px 2px; position: relative; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg-input); }
.itd-stage .track-preview-radius-field > span { position: absolute; top: 3px; left: 8px; color: var(--fg-4); font-family: var(--font-mono); font-size: 9px; line-height: 1; letter-spacing: .06em; text-transform: uppercase; pointer-events: none; }
.itd-stage .track-preview-radius-select { width: 100%; height: 25px; padding: 0 20px 0 0; appearance: auto; border: 0; outline: 0; background: transparent; color: var(--fg); font-size: 13px; cursor: pointer; }
.itd-stage .track-preview-radius-field:focus-within { border-color: var(--accent-border); box-shadow: 0 0 0 2px var(--accent-bg); }
.itd-stage .track-preview-segment-count { flex: 0 0 auto; min-width: 28px; justify-content: center; }

/* Control panels */
.itd-panel { background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.itd-panel-head { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--fg-2); }
.itd-panel-head svg { width: 15px; height: 15px; color: var(--accent); }
.itd-panel-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.itd-add-grid { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 8px; align-items: end; }
.itd-add-grid > * { min-width: 0; }
.itd .itd-add-grid .num-input { height: 34px !important; min-height: 34px; max-height: 34px; }
.itd-add-actions { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 8px; align-items: center; }

/* Quick-angle chips */
.itd-anglechips { display: flex; flex-wrap: nowrap; gap: 5px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.itd-anglechips::-webkit-scrollbar { display: none; }
.itd-chip { flex: 0 0 auto; height: 26px; min-width: 40px; padding: 0 8px; border-radius: 100px; border: 1px solid var(--line); background: var(--bg-input); color: var(--fg-2); font-family: var(--font-mono); font-size: 11px; font-weight: 600; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.itd-chip:hover { border-color: var(--line-strong); color: var(--fg); }
.itd-chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.wiz-overlay .segment.itd-dirseg { width: 100%; }
.wiz-overlay .segment.itd-dirseg button { flex: 1; justify-content: center; }
.wiz-overlay .itd .itd-addbtn { width: 100%; justify-content: center; height: 34px; padding: 0 8px; }
.itd-error { font-size: 12px; color: var(--status-rejected); background: var(--status-rejected-bg); border: 1px solid var(--status-rejected-border); border-radius: 6px; padding: 8px 10px; }

/* Pocket toggles */
.itd-toggle-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.itd-toggle { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 7px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-input); color: var(--fg-2); font-size: 12px; font-weight: 500; cursor: pointer; text-align: left; }
.itd-toggle:hover { border-color: var(--line-strong); }
.itd-toggle-dot { width: 28px; height: 16px; border-radius: 100px; background: var(--line-strong); position: relative; flex: 0 0 auto; transition: background .15s; }
.itd-toggle-dot::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; }
.itd-toggle.is-on { border-color: var(--accent); color: var(--fg); }
.itd-toggle.is-on .itd-toggle-dot { background: var(--accent); }
.itd-toggle.is-on .itd-toggle-dot::after { transform: translateX(12px); }

/* Per-side pocket shape + curve direction */
.itd-pocketdetail { margin-top: 10px; }
.wiz-overlay .segment.itd-shapeseg,
.wiz-overlay .segment.itd-pocketdir { width: 100%; }
.wiz-overlay .segment.itd-shapeseg button,
.wiz-overlay .segment.itd-pocketdir button { flex: 1; justify-content: center; }
.itd-pocketdir { margin-top: 6px; }

/* Action bar: stats + segment list */
.itd-segments-bar { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.itd-stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.itd-stat { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 100px; background: var(--bg-input); border: 1px solid var(--line); font-family: var(--font-mono); font-size: 10px; color: var(--fg-3); white-space: nowrap; }
.itd-stat b { color: var(--fg); font-weight: 700; }
.itd-stat--warn b { color: var(--accent); }
.itd-stat--info b { color: var(--status-accepted); }
.itd-stat-actions { display: flex; gap: 6px; }
.wiz-overlay .itd .itd-del { color: var(--status-rejected); }

.itd-empty { padding: 12px; text-align: center; font-size: 12px; color: var(--fg-4); }
.itd-seglist { display: flex; gap: 6px; padding: 7px 8px; overflow-x: auto; overflow-y: hidden; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; overscroll-behavior-inline: contain; touch-action: pan-x; }
.itd-seglist::-webkit-scrollbar { display: block; height: 6px; }
.itd-seglist::-webkit-scrollbar-track { background: transparent; }
.itd-seglist::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 100px; }
.itd-segrow { flex: 0 0 auto; min-width: 210px; display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 7px; border: 1px solid var(--line-soft); cursor: pointer; }
.itd-segrow:hover { background: var(--bg-hover); }
.itd-segrow.is-selected { border-color: var(--accent-border); background: var(--accent-bg); }
.itd-segbadge { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: #fff; }
.itd-segbadge.is-straight { background: var(--status-pending, #3b82f6); }
.itd-segbadge.is-curve { background: var(--accent); }
.itd-seglabel { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.itd-segactions { display: flex; gap: 0; flex: 0 0 auto; }

/* Motor-control cards: full-height product image at left, with quantity controls. */
.wiz-overlay .motor-control-card { display: grid; grid-template-columns: minmax(0,1fr) auto; min-height: 104px; padding: 0; overflow: hidden; text-align: left; cursor: default; }
.motor-control-card-row { display: grid; grid-template-columns: 104px minmax(0,1fr); align-items: stretch; width: 100%; min-height: 102px; }
.motor-control-image { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 100%; padding: 8px; background: var(--bg-input); border-right: 1px solid var(--line); overflow: hidden; }
.motor-control-image img { display: block; width: 100%; height: 100%; min-height: 86px; object-fit: contain; }
.motor-control-image svg { width: 30px; height: 30px; }
.motor-control-copy { min-width: 0; padding: 12px; text-align: left; align-self: center; }
.motor-control-title { color: var(--fg); font-size: 13px; font-weight: 600; line-height: 1.3; text-align: left; }
.motor-control-copy .operator-item-desc { text-align: left; }
.motor-control-stepper { display: grid; grid-template-columns: 32px 32px 32px; align-self: center; align-items: center; height: 32px; margin: 0 12px; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; }
.motor-control-stepper-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; background: var(--bg-input); color: var(--fg); cursor: pointer; font: 600 18px/1 var(--font-sans); }
.motor-control-stepper-button:hover:not(:disabled) { background: var(--accent-bg); color: var(--accent); }
.motor-control-stepper-button:disabled { color: var(--fg-3); cursor: not-allowed; }
.motor-control-stepper-value { display: grid; place-items: center; height: 32px; border-inline: 1px solid var(--line); color: var(--fg); font-size: 13px; font-weight: 600; }

@media (max-width: 480px) {
    .motor-control-card-row { grid-template-columns: 88px minmax(0,1fr); min-height: 92px; }
    .motor-control-image img { min-height: 74px; }
    .motor-control-copy { padding: 10px; }
}

/* Compact setup strip above the workbench */
.itd-step-head { align-items: center; margin-bottom: 12px; }
.itd-step-head .icon-blob { width: 32px; height: 32px; }
.itd-step-head h2 { font-size: 20px; }
.layout-track-mode { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; padding: 8px 10px; background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px; }
.layout-track-mode .field-label { padding-bottom: 9px; }
.wiz-overlay .layout-track-mode .segment { width: min(100%, 430px); }
.wiz-overlay .layout-track-mode .segment button { flex: 1; justify-content: center; }
.itd-setup { background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.itd-setup-grid { display: grid; grid-template-columns: 1.4fr .8fr 1fr; gap: 10px; align-items: end; }
.itd-setup-grid > * { min-width: 0; }
.wiz-overlay .itd-setup-grid .segment { width: 100%; }
.wiz-overlay .itd-setup-grid .segment button { flex: 1; justify-content: center; padding-left: 6px; padding-right: 6px; }

/* --- 4.3c Architectural drawing AI import and engineer review --- */
.ai-drawing-import { margin-top: 10px; border: 1px solid var(--accent-border); border-radius: 10px; background: linear-gradient(135deg,var(--accent-bg),var(--bg-panel) 48%); overflow: hidden; }
.ai-drawing-import.is-expanded { box-shadow: 0 12px 30px rgba(15,23,42,.08); }
.ai-drawing-trigger { width: 100%; min-height: 58px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: transparent; color: var(--fg); text-align: left; cursor: pointer; }
.ai-drawing-trigger:hover { background: var(--bg-hover); }
.ai-drawing-trigger strong,.ai-drawing-trigger small { display: block; }
.ai-drawing-trigger strong { font-size: 13px; }
.ai-drawing-trigger small { margin-top: 2px; color: var(--fg-3); font-size: 11px; }
.ai-drawing-mark { width: 34px; height: 34px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--accent); color: var(--accent-contrast); }
.ai-drawing-mark svg { width: 20px; height: 20px; }
.ai-drawing-chevron { width: 18px; height: 18px; color: var(--fg-3); transition: transform .15s; }
.ai-drawing-import.is-expanded .ai-drawing-chevron { transform: rotate(180deg); }
.ai-drawing-body { padding: 12px; border-top: 1px solid var(--accent-border); background: var(--bg-panel); }
.ai-drawing-state { display: flex; align-items: center; gap: 8px; min-height: 48px; color: var(--fg-3); font-size: 12px; }
.ai-drawing-upload-grid { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: end; }
.ai-drawing-file { display: block; width: 100%; padding: 8px; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--bg-input); color: var(--fg-2); font-size: 12px; }
.ai-drawing-file::file-selector-button { margin-right: 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-panel); color: var(--fg); cursor: pointer; }
.ai-drawing-file-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--fg-3); font-size: 11px; }
.ai-drawing-file-meta strong { max-width: min(520px,70vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); }
.wiz-overlay .ai-drawing-analyze { min-width: 154px; justify-content: center; }
.ai-drawing-privacy { margin: 10px 0 0; color: var(--fg-4); font-size: 10px; line-height: 1.45; }
.ai-spinner { width: 14px; height: 14px; flex: 0 0 auto; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.ai-drawing-alert { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; line-height: 1.45; }
.ai-drawing-alert.is-error { color: var(--status-rejected); background: var(--status-rejected-bg); border-color: var(--status-rejected-border); }
.ai-drawing-alert.is-warning { color: var(--fg-2); background: var(--accent-bg); border-color: var(--accent-border); }
.ai-drawing-alert ul { margin: 2px 0 0 18px; padding: 0; }
.ai-review-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.ai-review-head h3 { margin: 2px 0 3px; font-size: 16px; }
.ai-review-head .muted { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-review-kicker { color: var(--accent); font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ai-confidence-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ai-confidence { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 100px; background: var(--bg-input); color: var(--fg-3); font-family: var(--font-mono); font-size: 9px; }
.ai-confidence b { font-size: 10px; }
.ai-confidence.is-high b { color: var(--status-accepted); }
.ai-confidence.is-medium b { color: var(--accent); }
.ai-confidence.is-low b { color: var(--status-rejected); }
.ai-review-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.ai-review-card { border: 1px solid var(--line); border-radius: 9px; background: var(--bg-panel); overflow: hidden; }
.ai-review-card-head { min-height: 35px; display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-bottom: 1px solid var(--line); color: var(--fg-2); font-size: 11px; font-weight: 700; }
.ai-review-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding: 9px; }
.ai-review-fields label,.ai-pocket-card label { display: flex; flex-direction: column; gap: 4px; color: var(--fg-3); font-size: 9px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.ai-review-fields input,.ai-review-fields select,.ai-pocket-card input,.ai-pocket-card select,.ai-segment-table input,.ai-segment-table select { width: 100%; height: 32px; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg-input); color: var(--fg); font-family: var(--font-mono); font-size: 11px; }
.ai-review-evidence { padding: 0 9px 8px; color: var(--fg-4); font-size: 9px; line-height: 1.4; }
.ai-review-evidence b { color: var(--fg-3); }
.ai-pocket-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding: 0 9px 9px; }
.ai-pocket-card { display: grid; gap: 6px; padding: 7px; border: 1px solid var(--line-soft); border-radius: 7px; background: var(--bg-input); }
.ai-pocket-card .ai-pocket-enabled { flex-direction: row; align-items: center; gap: 6px; color: var(--fg-2); text-transform: none; }
.ai-pocket-enabled input { width: 14px; height: 14px; }
.ai-segments-card { margin-top: 10px; }
.ai-segment-table-wrap { overflow-x: auto; }
.ai-segment-table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 10px; }
.ai-segment-table th { padding: 6px; color: var(--fg-4); font-size: 8px; letter-spacing: .04em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.ai-segment-table td { padding: 5px 6px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.ai-segment-table input { min-width: 92px; }
.ai-segment-table select { min-width: 126px; }
.ai-segment-evidence { min-width: 180px; max-width: 320px; color: var(--fg-4); line-height: 1.35; }
.ai-review-details { margin-top: 9px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-input); color: var(--fg-3); font-size: 10px; }
.ai-review-details summary { color: var(--fg-2); font-weight: 700; cursor: pointer; }
.ai-review-details ul { margin: 7px 0 0 18px; padding: 0; }
.ai-observed-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 6px; margin-top: 8px; }
.ai-observed-grid div { display: flex; flex-direction: column; gap: 2px; padding: 6px; border-radius: 6px; background: var(--bg-panel); }
.ai-observed-grid span { color: var(--fg-4); font-size: 8px; text-transform: uppercase; }
.ai-observed-grid strong { color: var(--fg-2); font-size: 10px; }
.ai-review-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 10px; }
.ai-review-actions > span { margin-right: auto; max-width: 620px; }

/* Mobile: canvas pinned within the wizard scroller + tabbed controls below. */
@media (min-width: 768px) and (max-width: 1024px) {
    .itd { height: clamp(400px, calc(100dvh - 360px), 560px); }
}

@media (max-width: 767px) {
    .layout-track-mode { display: block; }
    .layout-track-mode .field-label { padding: 0 0 6px; }
    .wiz-overlay .layout-track-mode .segment { width: 100%; }
    .itd-setup-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .ai-review-grid { grid-template-columns: minmax(0,1fr); }
    .itd {
        display: flex; flex-direction: column; gap: 0; min-height: 0;
        height: auto;
        --itd-canvas-h: clamp(240px, 32dvh, 280px);
    }
    .itd-rail { display: contents; }
    .itd-stage {
        order: 1; position: sticky; top: 0; z-index: 3;
        height: var(--itd-canvas-h); min-height: var(--itd-canvas-h);
        border-radius: 10px; box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
    }
    .itd-tabbar {
        order: 2; position: sticky; top: var(--itd-canvas-h); z-index: 2;
        display: flex; gap: 4px; padding: 8px 0; background: var(--bg);
    }
    .itd-tabbar button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-input); color: var(--fg-3); font-size: 13px; font-weight: 600; cursor: pointer; }
    .itd-tabbar button svg { width: 15px; height: 15px; }
    .itd-tabbar button.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
    .itd-tabcount { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 100px; background: rgba(255, 255, 255, 0.25); font-size: 11px; font-weight: 700; }
    .itd-add, .itd-options, .itd-segments { order: 3; margin-top: 10px; }
    .itd-seglist { overflow-x: auto; overflow-y: hidden; }
    .itd-segrow { min-width: min(250px, calc(100vw - 58px)); }
    .itd:not(.itd--tab-add) .itd-add { display: none; }
    .itd:not(.itd--tab-options) .itd-options { display: none; }
    .itd:not(.itd--tab-segments) .itd-segments { display: none; }
}

@media (max-width: 420px) {
    .itd-stage .track-preview-toolbar.is-compact { padding-left: 5px; padding-right: 5px; }
    .itd-stage .track-preview-radius-field { flex-basis: 124px; width: 124px; min-width: 108px; max-width: 124px; }
    .itd-stage .track-preview-toolbar.is-compact .zoom-badge { padding-left: 6px; padding-right: 6px; }
    .ai-drawing-upload-grid { grid-template-columns: minmax(0,1fr); }
    .wiz-overlay .ai-drawing-analyze { width: 100%; }
    .ai-review-fields,.ai-pocket-grid { grid-template-columns: minmax(0,1fr); }
    .ai-review-head,.ai-review-actions { align-items: stretch; flex-direction: column; }
}

/* --- 4.4 PostLockConfigurator --- */
.postlock-card {
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    border-radius: 12px;
    transition: box-shadow 0.2s ease;
}

.postlock-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.postlock-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    margin-bottom: 12px;
}

.postlock-qty-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    padding: 2px 8px;
    border-radius: 12px;
    background: #03338F;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.lock-code-display {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--mud-palette-background-grey, rgba(0,0,0,0.04));
    font-size: 0.75rem;
    font-family: 'Roboto Mono', monospace;
}

/* --- 4.6 RollingModelCard --- */
.rolling-model-card {
    position: relative;
    border: 2px solid transparent;
    border-radius: 12px;
    transition: all 0.25s ease;
    overflow: hidden;
}

.rolling-model-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border-color: var(--mud-palette-primary-lighten, rgba(3, 51, 143, 0.2));
}

.rolling-model-card.selected {
    border-color: #03338F;
    box-shadow: 0 0 0 1px #03338F, 0 4px 16px rgba(3, 51, 143, 0.15);
}

.rolling-model-card .model-image-container {
    background: linear-gradient(135deg, var(--mud-palette-background) 0%, var(--mud-palette-background-grey) 100%);
    border-radius: 8px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.rolling-model-card .model-image-container img {
    transition: transform 0.3s ease;
}

.rolling-model-card:hover .model-image-container img {
    transform: scale(1.05);
}

.rolling-model-card .model-check-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #03338F;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scaleIn 0.2s ease-out;
    box-shadow: 0 2px 8px rgba(3, 51, 143, 0.3);
}

/* --- 4.7 BuyoutDoorWizard --- */
.buyout-wizard-container {
    border-radius: 12px !important;
    overflow: hidden;
}

.buyout-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.buyout-section-header .section-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(3,51,143,0.1);
    color: var(--amstel-blue-primary);
}

.buyout-total-card {
    border-radius: 12px;
    border: 2px solid var(--mud-palette-primary);
    background: linear-gradient(135deg, rgba(3,51,143,0.03) 0%, rgba(3,51,143,0.08) 100%);
}

.buyout-total-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.buyout-total-row--grand {
    padding-top: 8px;
    margin-top: 8px;
    border-top: 2px solid var(--mud-palette-primary);
}

/* --- 4.8 PricingPanel --- */
.pricing-panel {
    border-radius: 12px;
    border: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
    overflow: hidden;
}

.pricing-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: linear-gradient(135deg, rgba(3,51,143,0.03) 0%, rgba(3,51,143,0.08) 100%);
    border-bottom: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,0.06));
}

.pricing-total-display {
    text-align: center;
    padding: 20px 16px;
}

.pricing-total-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--amstel-blue-primary);
    line-height: 1.2;
}

.pricing-breakdown-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    color: var(--mud-palette-primary);
    font-size: 0.8rem;
    font-weight: 600;
    transition: color 0.15s ease;
}

.pricing-breakdown-toggle:hover {
    color: var(--amstel-blue-primary);
}

.pricing-breakdown-section {
    animation: fadeIn 0.25s ease-out;
    padding: 0 16px 16px;
}

.pricing-line-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--mud-palette-lines-default, rgba(0,0,0,0.06));
}

.pricing-line-item:last-child {
    border-bottom: none;
}

.pricing-line-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--mud-palette-primary);
    margin-top: 4px;
    transition: width 0.5s ease-out;
}

.pricing-generate-btn {
    margin: 0 16px 16px;
}

/* Dark mode adjustments for Phase 4 */
.theme-dark .track-preview-canvas {
    background: #0a1628;
}

.theme-dark .postlock-card {
    border-color: rgba(255,255,255,0.08);
}

.theme-dark .buyout-total-card {
    background: linear-gradient(135deg, rgba(3,51,143,0.06) 0%, rgba(3,51,143,0.12) 100%);
}

.theme-dark .rolling-model-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.theme-dark .segment-list-item--selected {
    background: rgba(3,51,143,0.1);
}
