/* Eulumdat Editor Styles */

/* ============================================
   LIGHT THEME (default)
   WCAG AA compliant color contrast ratios
   ============================================ */
:root,
.theme-light {
    /* Base colors */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #475569; /* Darkened from #64748b for 4.5:1 contrast on white */
    --success-color: #16a34a;   /* Darkened from #22c55e for better contrast */
    --warning-color: #d97706;   /* Darkened from #f59e0b for better contrast */
    --error-color: #dc2626;     /* Darkened from #ef4444 for better contrast */

    /* Background and surface */
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --border: #e2e8f0;

    /* Text colors - all meet WCAG AA 4.5:1 on white/light backgrounds */
    --text-primary: #1e293b;    /* ~12:1 contrast on white */
    --text-secondary: #475569;  /* ~7:1 contrast on white (was #64748b ~4.5:1) */
    --text-muted: #64748b;      /* ~4.5:1 contrast on white (was #94a3b8 ~3:1) */

    /* Tab colors - tab-inactive meets 4.5:1 on light backgrounds */
    --tab-active: #2563eb;
    --tab-inactive: #64748b;  /* Darkened from #94a3b8 for 4.5:1 contrast */

    /* Diagram colors - consistent across all visualizations */
    --diagram-bg: #ffffff;
    --diagram-surface: #fafafa;
    --diagram-legend-bg: rgba(255, 255, 255, 0.95);
    --diagram-grid: #e0e0e0;
    --diagram-grid-minor: #f0f0f0;
    --diagram-axis: #c0c0c0;
    --diagram-text: #333333;
    --diagram-text-secondary: #666666;
    --diagram-text-muted: #999999;

    /* C-plane line colors */
    --diagram-c0: #ef4444;    /* Red - C0/C180 */
    --diagram-c90: #3b82f6;   /* Blue - C90/C270 */
    --diagram-c45: #22c55e;   /* Green - C45/C225 */
    --diagram-c135: #f97316;  /* Orange - C135/C315 */

    /* C-plane fill colors (semi-transparent) */
    --diagram-c0-fill: rgba(239, 68, 68, 0.15);
    --diagram-c90-fill: rgba(59, 130, 246, 0.2);
    --diagram-c45-fill: rgba(34, 197, 94, 0.15);
    --diagram-c135-fill: rgba(249, 115, 22, 0.15);

    /* Zone colors (BUG/LCS) */
    --diagram-forward: #22c55e;  /* Green */
    --diagram-back: #3b82f6;     /* Blue */
    --diagram-uplight: #ef4444;  /* Red */

    /* Rating colors */
    --rating-good: #22c55e;
    --rating-ok: #eab308;
    --rating-warn: #f97316;
    --rating-bad: #ef4444;

    /* Rating background colors */
    --rating-bg-good: #dcfce7;
    --rating-bg-ok: #fef9c3;
    --rating-bg-warn: #ffedd5;
    --rating-bg-bad: #fee2e2;

    /* Zone fill colors */
    --zone-fill-good: #ecfdf5;
    --zone-fill-warn: #fef3c7;
    --zone-fill-danger: #fee2e2;
}

/* ============================================
   DARK THEME
   WCAG AA compliant color contrast ratios
   ============================================ */
.theme-dark {
    /* Base colors */
    --primary-color: #60a5fa;   /* Lightened for contrast on dark backgrounds */
    --primary-hover: #3b82f6;
    --secondary-color: #94a3b8;
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --error-color: #f87171;

    /* Background and surface */
    --background: #0f172a;
    --surface: #1e293b;
    --surface-elevated: #334155;
    --border: #475569;          /* Lightened for visibility */

    /* Text colors - all meet WCAG AA 4.5:1 on dark backgrounds */
    --text-primary: #f1f5f9;    /* ~15:1 contrast on #1e293b */
    --text-secondary: #cbd5e1;  /* ~10:1 contrast on #1e293b */
    --text-muted: #94a3b8;      /* ~6:1 contrast on #1e293b (was #64748b ~4:1) */

    /* Tab colors */
    --tab-active: #60a5fa;      /* Lightened to match primary */
    --tab-inactive: #94a3b8;    /* Lightened for 4.5:1 on dark */

    /* Diagram colors - consistent across all visualizations */
    --diagram-bg: #1a1a2e;
    --diagram-surface: #16213e;
    --diagram-legend-bg: rgba(22, 33, 62, 0.95);
    --diagram-grid: #404060;
    --diagram-grid-minor: #2a2a4a;
    --diagram-axis: #606080;
    --diagram-text: #e0e0e0;
    --diagram-text-secondary: #bebebe;
    --diagram-text-muted: #808080;

    /* C-plane line colors (brighter for dark mode) */
    --diagram-c0: #f87171;    /* Red - C0/C180 */
    --diagram-c90: #60a5fa;   /* Blue - C90/C270 */
    --diagram-c45: #4ade80;   /* Green - C45/C225 */
    --diagram-c135: #fb923c;  /* Orange - C135/C315 */

    /* C-plane fill colors (semi-transparent, brighter for dark mode) */
    --diagram-c0-fill: rgba(248, 113, 113, 0.2);
    --diagram-c90-fill: rgba(96, 165, 250, 0.25);
    --diagram-c45-fill: rgba(74, 222, 128, 0.2);
    --diagram-c135-fill: rgba(251, 146, 60, 0.2);

    /* Zone colors (BUG/LCS - matching reference SVG) */
    --diagram-forward: #62c58a;  /* Green */
    --diagram-back: #42b4ff;     /* Blue */
    --diagram-uplight: #f87171;  /* Red */

    /* Rating colors */
    --rating-good: #4ade80;
    --rating-ok: #facc15;
    --rating-warn: #fb923c;
    --rating-bad: #f87171;

    /* Rating background colors (darker versions for dark mode) */
    --rating-bg-good: #166534;
    --rating-bg-ok: #854d0e;
    --rating-bg-warn: #9a3412;
    --rating-bg-bad: #991b1b;

    /* Zone fill colors (darker versions for dark mode) */
    --zone-fill-good: #14532d;
    --zone-fill-warn: #78350f;
    --zone-fill-danger: #7f1d1d;
}

/* Theme toggle button */
.theme-toggle {
    font-size: 1.1rem;
    padding: 0.5rem 0.75rem;
    min-width: auto;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* Global input styling for theme support */
input, select, textarea {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* ============================================
   DASHBOARD VIEW (AEC-style parameter grid)
   ============================================ */

/* Dashboard layout: sidebar + main content */
.dashboard-layout {
    display: grid;
    grid-template-columns: 48px 1fr;
    min-height: 60vh;
    background: var(--background);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Left icon sidebar */
.dashboard-sidebar {
    width: 48px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0;
    gap: 0.5rem;
}

.sidebar-icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar-icon-btn:hover {
    background: var(--background);
    color: var(--primary-color);
}

.sidebar-icon-btn.active {
    color: var(--primary-color);
    background: var(--background);
}

.sidebar-icon-btn.disabled,
.sidebar-icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* Sidebar divider between icon groups */
.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}

/* Zoom overlay (full-screen diagram popup) */
.zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.zoom-overlay-content {
    position: relative;
    width: 85vw;
    max-width: 1000px;
    max-height: 85vh;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 24px;
    overflow: auto;
    cursor: default;
}

.zoom-overlay-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
}

.zoom-overlay-close:hover {
    background: var(--background);
    color: var(--text-primary);
}

.zoom-overlay-diagram {
    min-height: 300px;
}

/* Main dashboard area */
.dashboard-main {
    min-width: 0; /* prevent grid blowout */
    overflow-x: auto;
}

/* Template switcher toolbar */
.dashboard-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
}

.template-select {
    font-size: 0.75rem;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

.template-select:focus {
    border-color: var(--primary-color);
}

/* Parameter columns header bar */
.params-header {
    display: grid;
    grid-template-columns:
        40px                        /* expand arrow */
        minmax(150px, 2fr)          /* Name */
        minmax(70px, 0.8fr)         /* CCT */
        minmax(60px, 0.7fr)         /* Power */
        minmax(80px, 1fr)           /* Lumens */
        minmax(55px, 0.6fr)         /* LOR */
        minmax(80px, 1fr)           /* BUG */
        minmax(50px, 0.5fr)         /* CRI */
        minmax(60px, 0.7fr)         /* Beam */
        40px;                       /* Actions */
    align-items: center;
    min-width: 700px;
    border-bottom: 2px solid var(--border);
    background: var(--surface);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.params-header .params-col {
    padding: 0.6rem 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Luminaire data row (collapsed) */
.luminaire-row {
    display: grid;
    grid-template-columns:
        40px
        minmax(150px, 2fr)
        minmax(70px, 0.8fr)
        minmax(60px, 0.7fr)
        minmax(80px, 1fr)
        minmax(55px, 0.6fr)
        minmax(80px, 1fr)
        minmax(50px, 0.5fr)
        minmax(60px, 0.7fr)
        40px;
    align-items: center;
    min-width: 700px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.85rem;
}

.luminaire-row:hover {
    background: var(--background);
}

.luminaire-row.expanded {
    background: var(--background);
    border-bottom-color: var(--primary-color);
}

.luminaire-row.selected {
    background: color-mix(in srgb, var(--primary-color) 12%, var(--surface));
    border-left: 3px solid var(--primary-color);
}

.luminaire-row.compare-target {
    background: color-mix(in srgb, #22c55e 10%, var(--surface));
    border-left: 3px solid #22c55e;
}

.luminaire-row.selected.compare-target {
    border-left: 3px solid var(--primary-color);
    border-right: 3px solid #22c55e;
}

.luminaire-row .params-col {
    padding: 0.65rem 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.luminaire-row .luminaire-name {
    font-weight: 600;
    color: var(--text-primary);
}

/* Expand arrow */
.params-col-expand {
    display: flex;
    align-items: center;
    justify-content: center;
}

.expand-arrow {
    display: inline-block;
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.expand-arrow.open {
    transform: rotate(90deg);
}

/* Action icons in the row */
.params-col-actions {
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-icon {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.action-icon:hover {
    color: var(--primary-color);
}

/* Expanded detail panel: 4 diagrams side-by-side */
.luminaire-detail {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
}

.luminaire-detail .detail-diagram {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.luminaire-detail .detail-diagram h4 {
    font-size: 0.8rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
    text-align: center;
}

/* Scale SVG diagrams to fit their grid cell */
.luminaire-detail .detail-diagram .polar-diagram,
.luminaire-detail .detail-diagram .cartesian-diagram,
.luminaire-detail .detail-diagram .isolux-diagram,
.luminaire-detail .detail-diagram .isolux-aec-container,
.luminaire-detail .detail-diagram .bug-rating-diagram {
    width: 100%;
    max-width: 100%;
}

.luminaire-detail .detail-diagram svg,
.luminaire-detail .detail-diagram div[inner_html] svg,
.luminaire-detail .detail-diagram > div {
    width: 100%;
    max-width: 100%;
}

/* Responsive: stack diagrams on smaller screens */
@media (max-width: 1200px) {
    .luminaire-detail {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .luminaire-detail {
        grid-template-columns: 1fr;
    }

    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .dashboard-sidebar {
        display: none;
    }
}

/* Dashboard loading and footer */
.dashboard-loading {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.dashboard-footer {
    padding: 0.5rem 1rem;
    text-align: right;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.dashboard-hint {
    opacity: 0.7;
    font-size: 0.7rem;
}

.dashboard-hint kbd {
    display: inline-block;
    padding: 0 0.3em;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.65rem;
    background: var(--background);
}

/* Editor back-to-dashboard bar */
.editor-back-bar {
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.editor-back-bar .btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

.app {
    min-height: 100vh;
    background: var(--background);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app > * {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.app > header {
    padding-top: 1rem;
}

/* Mobile app container */
@media (max-width: 768px) {
    .app > * {
        padding: 0 0.5rem;
    }
}

@media (max-width: 480px) {
    .app > * {
        padding: 0 0.25rem;
    }
}

/* Header */
.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    white-space: nowrap;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* File Menu Dropdown */
.file-menu {
    position: relative;
}

.file-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dropdown-arrow {
    font-size: 0.7em;
    opacity: 0.7;
}

.file-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    padding: 0.25rem 0;
    margin-top: 0.25rem;
}

.file-menu:hover .file-menu-dropdown,
.file-menu:focus-within .file-menu-dropdown {
    display: block;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.menu-item:hover {
    background: var(--background);
}

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* Submenu for templates */
.menu-submenu {
    position: relative;
}

.menu-submenu-toggle {
    cursor: default;
}

.submenu-arrow {
    font-size: 0.7em;
    opacity: 0.7;
}

.menu-submenu-content {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 220px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.25rem 0;
    margin-left: 0.25rem;
}

.menu-submenu:hover .menu-submenu-content {
    display: block;
}

/* Templates dropdown - needs scrolling for many items */
.templates-dropdown {
    max-height: 400px;
    overflow-y: auto;
}

/* Mobile: Full-width dropdown */
@media (max-width: 768px) {
    .file-menu-dropdown {
        position: fixed;
        top: auto;
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
        min-width: auto;
    }

    .menu-submenu-content {
        position: static;
        border: none;
        box-shadow: none;
        margin-left: 1rem;
        padding-left: 0.5rem;
        border-left: 2px solid var(--border);
        max-height: 200px;
    }

    .menu-submenu:hover .menu-submenu-content,
    .menu-submenu .menu-submenu-content {
        display: block;
    }

    .submenu-arrow {
        transform: rotate(90deg);
    }
}

/* Tablet: Start compressing */
@media (max-width: 1100px) {
    .header-actions {
        gap: 0.4rem;
    }

    .header-actions > button,
    .header-actions > select {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }
}

/* Mobile: Stack header */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .header h1 {
        text-align: center;
        font-size: 1.2rem;
        margin-bottom: 0.25rem;
    }

    .header-actions {
        justify-content: center;
        gap: 0.4rem;
    }

    .header-actions > button {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .language-selector-compact {
        min-width: 90px;
        font-size: 0.8rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .header {
        padding: 0.5rem;
        border-radius: 6px;
    }

    .header h1 {
        font-size: 1rem;
    }

    .header-actions {
        gap: 0.3rem;
    }

    .header-actions > button {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }

    .language-selector-compact {
        min-width: 80px;
        font-size: 0.75rem;
    }
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--background);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

/* Main Layout - single column, full width */
.main-content {
    display: block;
    max-width: 100%;
}

/* Panels */
.panel {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.panel-body {
    padding: 1rem;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    background: var(--background);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tab {
    padding: 0.75rem 1.25rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--tab-inactive);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--tab-active);
    border-bottom-color: var(--tab-active);
    font-weight: 500;
}

/* Main tabs (primary navigation) */
.main-tabs {
    background: var(--surface);
    border-bottom: 2px solid var(--border);
}

.main-tabs .tab {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.main-tabs .tab.active {
    border-bottom-color: var(--primary-color);
    border-bottom-width: 3px;
}

/* Sub-tabs (secondary navigation) */
.sub-tabs {
    background: var(--background);
    border-bottom: 1px solid var(--border);
    padding-left: 0.5rem;
}

.sub-tabs .tab {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 400;
    border-bottom-width: 2px;
}

.sub-tabs .tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    padding: 1rem;
}

/* Tablet: Smaller tabs */
@media (max-width: 1024px) {
    .tab {
        padding: 0.6rem 0.9rem;
        font-size: 0.8rem;
    }

    .main-tabs .tab {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .sub-tabs .tab {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
}

/* Mobile: Even smaller tabs, scrollable */
@media (max-width: 768px) {
    .tabs {
        flex-wrap: nowrap;
        gap: 0;
    }

    .tab {
        padding: 0.5rem 0.7rem;
        font-size: 0.75rem;
    }

    .main-tabs .tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .sub-tabs {
        padding-left: 0.25rem;
    }

    .sub-tabs .tab {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }

    .tab-content {
        padding: 0.75rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .main-tabs .tab {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .sub-tabs .tab {
        padding: 0.3rem 0.5rem;
        font-size: 0.65rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .tab {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .tab-content {
        padding: 0.5rem;
    }
}

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

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
    background: var(--surface);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input:read-only {
    background: var(--background);
    color: var(--text-secondary);
}

/* Form hint for accessibility */
.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Checkbox form group */
.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-checkbox label {
    display: inline;
    margin-bottom: 0;
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* Focus visible for keyboard navigation (accessibility) */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Remove default focus outline when using mouse */
:focus:not(:focus-visible) {
    outline: none;
}

/* Skip to content link (accessibility) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 9999;
    text-decoration: none;
    font-weight: 500;
}

.skip-link:focus {
    top: 0;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

/* Info Display */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

/* Mobile: Stack info grid */
@media (max-width: 600px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
}

.info-item {
    padding: 0.5rem;
    background: var(--background);
    border-radius: 4px;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.info-value {
    font-weight: 500;
}

/* Data Table */
.data-table-wrapper {
    display: flex;
    flex-direction: column;
}

.data-table-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.data-table-container {
    overflow: auto;
    max-height: 500px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.data-table {
    width: max-content;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.data-table th,
.data-table td {
    padding: 0.2rem 0.3rem;
    border: 1px solid var(--border);
    text-align: right;
}

.data-table th {
    background: var(--background);
    font-weight: 500;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table .angle-header {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 40px;
}

.data-table .c-angle-header {
    min-width: 45px;
    font-family: 'SF Mono', Monaco, monospace;
}

.data-table .g-angle-header {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--background);
    font-family: 'SF Mono', Monaco, monospace;
    min-width: 40px;
}

.data-table td {
    padding: 0;
}

.data-table .intensity-input {
    width: 45px;
    text-align: right;
    border: none;
    background: transparent;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.75rem;
    padding: 0.2rem 0.3rem;
    color: var(--text-primary);
}

.data-table .intensity-input:focus {
    background: var(--surface-elevated);
    outline: none;
}

.data-table tr:hover td {
    background: var(--background);
}

.data-table tr:hover .intensity-input {
    background: var(--background);
}

/* Diagram Toggle */
.diagram-toggle {
    display: flex;
    gap: 2px;
    background: var(--background);
    padding: 2px;
    border-radius: 6px;
}

.btn-toggle {
    padding: 0.25rem 0.75rem;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-toggle:hover {
    color: var(--text-primary);
}

.btn-toggle.active {
    background: var(--primary-color);
    color: white;
}

/* Responsive diagram toggle */
@media (max-width: 480px) {
    .diagram-toggle {
        gap: 1px;
        padding: 1px;
    }

    .btn-toggle {
        padding: 0.2rem 0.5rem;
        font-size: 0.65rem;
    }
}

/* Polar Diagram */
.polar-diagram {
    width: 100%;
    aspect-ratio: 1;
    background: var(--surface);
    border-radius: 8px;
}

.polar-diagram svg {
    width: 100%;
    height: 100%;
}

/* Cartesian Diagram */
.cartesian-diagram {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
}

.cartesian-diagram svg {
    width: 100%;
    height: auto;
}

/* Validation Messages */
.validation-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
}

.schema-validation-section,
.ldt-validation-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.validation-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Schema Status Cards */
.schema-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

@media (max-width: 600px) {
    .schema-grid {
        grid-template-columns: 1fr;
    }
}

.schema-card {
    padding: 0.75rem;
    border-radius: 6px;
    text-align: center;
    border: 1px solid var(--border);
}

.schema-card.valid {
    background: var(--rating-bg-good);
    border-color: var(--success-color);
}

.schema-card.warning {
    background: var(--rating-bg-warn);
    border-color: var(--warning-color);
}

.schema-card.invalid {
    background: var(--rating-bg-bad);
    border-color: var(--error-color);
}

.schema-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.schema-status {
    font-size: 0.875rem;
    font-weight: 600;
}

.schema-card.valid .schema-status {
    color: var(--success-color);
}

.schema-card.warning .schema-status {
    color: var(--warning-color);
}

.schema-card.invalid .schema-status {
    color: var(--error-color);
}

.schema-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Validation Details */
.validation-details {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.validation-details summary {
    padding: 0.5rem 1rem;
    background: var(--background);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.validation-details summary:hover {
    background: var(--surface-elevated);
}

.validation-details[open] summary {
    border-bottom: 1px solid var(--border);
}

.validation-list {
    padding: 0.5rem;
}

.validation-item {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.validation-item:last-child {
    margin-bottom: 0;
}

.validation-item.warning {
    background: var(--rating-bg-ok);
    color: var(--text-primary);
}

.validation-item.error {
    background: var(--rating-bg-bad);
    color: var(--text-primary);
}

.validation-item.success {
    background: var(--rating-bg-good);
    color: var(--text-primary);
}

.validation-code {
    font-weight: 600;
    font-family: monospace;
    flex-shrink: 0;
    min-width: 80px;
}

.validation-message {
    flex: 1;
}

.validation-icon {
    font-size: 1rem;
    line-height: 1;
}

.validation-summary {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* Legacy schema badge (remove if not used) */
.schema-badge {
    font-family: monospace;
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    min-width: 55px;
    text-align: center;
}

.error-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.tm33-errors {
    margin-top: 0.5rem;
    margin-left: 0.5rem;
}

.tm33-errors summary {
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tm33-errors summary:hover {
    color: var(--text-secondary);
}

.error-details {
    margin-top: 0.5rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border);
}

.validation-item.small {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.7rem;
}

.validation-item.small .validation-code {
    font-size: 0.65rem;
}

/* Lamp Sets */
.lamp-set-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.lamp-set-tabs {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.lamp-set-tab {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--background);
    cursor: pointer;
    font-size: 0.8rem;
}

.lamp-set-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-add-lamp {
    padding: 0.5rem 1rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Direct Ratios */
.ratios-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.ratio-item {
    text-align: center;
}

.ratio-item label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.ratio-item input {
    width: 100%;
    text-align: center;
    padding: 0.25rem;
    font-size: 0.8rem;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: all 0.2s;
    margin-bottom: 1rem;
}

.drop-zone.active {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Tablet: Smaller dropzone */
@media (max-width: 768px) {
    .drop-zone {
        padding: 0.75rem;
    }

    .drop-zone p {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
}

/* Mobile: Hide dropzone (drag & drop not useful on touch devices) */
@media (max-width: 600px) {
    .drop-zone {
        display: none;
    }
}

/* File Info */
.file-info {
    padding: 0.5rem 1rem;
    background: var(--background);
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.file-info strong {
    color: var(--primary-color);
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.mt-1 {
    margin-top: 0.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.hidden {
    display: none;
}

/* Intensity Tab Layout */
.intensity-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.intensity-diagram-section {
    background: var(--background);
    border-radius: 8px;
    padding: 0.75rem;
}

.diagram-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.diagram-title {
    font-weight: 500;
    font-size: 0.9rem;
}

/* Responsive diagram header */
@media (max-width: 600px) {
    .diagram-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .diagram-title {
        font-size: 0.85rem;
    }

    .diagram-controls,
    .text-muted {
        font-size: 0.7rem;
    }
}

.diagram-container {
    display: flex;
    justify-content: center;
    max-width: 400px;
    margin: 0 auto;
}

.intensity-table-section {
    background: var(--background);
    border-radius: 8px;
    padding: 0.75rem;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.table-info {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 2D Diagram Tab */
.diagram-2d-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.diagram-container-large {
    display: flex;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

/* Full-width diagram container */
.diagram-fullwidth {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    background: var(--background);
    border-radius: 8px;
    padding: 1rem;
}

.diagram-fullwidth .polar-diagram,
.diagram-fullwidth .cartesian-diagram {
    width: 100%;
    max-width: 700px;
}

.diagram-fullwidth .polar-diagram svg,
.diagram-fullwidth .cartesian-diagram svg {
    width: 100%;
    height: auto;
}

/* Responsive diagram container */
@media (max-width: 768px) {
    .diagram-fullwidth {
        min-height: 400px;
        padding: 0.5rem;
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    .diagram-fullwidth {
        min-height: 300px;
        padding: 0.25rem;
    }

    .diagram-fullwidth .polar-diagram,
    .diagram-fullwidth .cartesian-diagram {
        max-width: 100%;
    }
}

/* ============================================
   RESPONSIVE SVG DETAIL LEVELS

   These rules work with DetailLevel classes embedded
   in SVGs generated by to_svg_responsive().

   The SVGs contain embedded media queries too, but
   these container-based rules provide additional
   control for the web app.
   ============================================ */

/* Auto-sizing SVG container */
.svg-responsive {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.svg-responsive svg {
    width: 100%;
    height: auto;
    max-height: 100%;
}

/* Container query for auto-adjusting detail levels */
/* Note: Container queries require modern browsers */
@container (max-width: 400px) {
    .svg-responsive svg .detail-full {
        display: none;
    }
}

@container (max-width: 300px) {
    .svg-responsive svg .detail-compact,
    .svg-responsive svg .detail-full {
        display: none;
    }
}

/* Fallback media queries for browsers without container query support */
@media (max-width: 400px) {
    .diagram-fullwidth svg .detail-full,
    .polar-diagram svg .detail-full,
    .cartesian-diagram svg .detail-full {
        display: none;
    }
}

@media (max-width: 300px) {
    .diagram-fullwidth svg .detail-compact,
    .diagram-fullwidth svg .detail-full,
    .polar-diagram svg .detail-compact,
    .polar-diagram svg .detail-full,
    .cartesian-diagram svg .detail-compact,
    .cartesian-diagram svg .detail-full {
        display: none;
    }
}

/* Zoomable diagram with overlay controls */
.diagram-zoomable {
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.diagram-zoomable:active {
    cursor: grabbing;
}

.diagram-zoomable .polar-diagram,
.diagram-zoomable .cartesian-diagram {
    transition: transform 0.1s ease-out;
    transform-origin: center center;
}

/* Diagram controls header */
.diagram-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.zoom-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive zoom hint */
@media (max-width: 600px) {
    .zoom-hint {
        font-size: 0.65rem;
    }
}

/* Diagram Zoom Component */
.diagram-zoom-container {
    position: relative;
    width: 100%;
    min-height: 550px;
    overflow: hidden;
    background: var(--background);
    border-radius: 8px;
    cursor: grab;
}

.diagram-zoom-container:active {
    cursor: grabbing;
}

/* Responsive diagram zoom container */
@media (max-width: 768px) {
    .diagram-zoom-container {
        min-height: 450px;
    }
}

@media (max-width: 480px) {
    .diagram-zoom-container {
        min-height: 350px;
        border-radius: 6px;
    }
}

.diagram-zoom-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: 0 0;
    transition: none;
}

.diagram-zoom-overlay {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 12px;
    color: var(--text-secondary);
}

.zoom-level {
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

.zoom-reset-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: 11px;
    color: var(--text-primary);
    transition: background 0.15s;
}

.zoom-reset-btn:hover {
    background: var(--background);
}

/* Heatmap Tab */
.heatmap-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Spectral Tab */
.spectral-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.spectral-diagram-container {
    width: 100%;
}

.spectral-diagram {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.spectral-diagram svg {
    width: 100%;
    height: auto;
}

.spectral-no-data {
    text-align: center;
    padding: 1rem;
}

.spectral-no-data .sample {
    margin-top: 1rem;
}

.spectral-info {
    text-align: center;
    margin-bottom: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: #22c55e;
    color: white;
}

.badge-info {
    background: #3b82f6;
    color: white;
}

.badge-warning {
    background: #f59e0b;
    color: white;
}

.badge-secondary {
    background: #6b7280;
    color: white;
}

.badge-danger {
    background: #ef4444;
    color: white;
    animation: pulse 2s infinite;
}

.badge-ir {
    background: linear-gradient(135deg, #b91c1c, #7f1d1d);
    color: white;
}

.badge-uv {
    background: linear-gradient(135deg, #7c3aed, #4c1d95);
    color: white;
}

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

.spectral-diagrams-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.diagram-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.diagram-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.diagram-section-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.spectral-diagram,
.greenhouse-diagram {
    width: 100%;
    display: flex;
    justify-content: center;
}

.spectral-diagram svg,
.greenhouse-diagram svg {
    max-width: 100%;
    height: auto;
}

.hint-text {
    text-align: center;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Spectral Sub-tabs */
.spectral-tab-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.spectral-sub-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--surface);
    border-radius: 8px;
    flex-wrap: wrap;
}

.sub-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.sub-tab:hover {
    background: var(--background);
    color: var(--text-primary);
}

.sub-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.sub-tab-badges {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

.spectral-sub-content {
    background: var(--surface);
    border-radius: 8px;
    padding: 1rem;
}

/* SPD Diagram Container */
.spd-diagram-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.diagram-svg {
    width: 100%;
    display: flex;
    justify-content: center;
}

.diagram-svg svg {
    max-width: 100%;
    height: auto;
}

/* TM-30 Summary (inline metrics on SPD tab) */
.tm30-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.tm30-metric-inline {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.tm30-metric-inline .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.tm30-metric-inline .value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* TM-30 CVG Container */
.tm30-cvg-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.tm30-cvg-diagram {
    display: flex;
    justify-content: center;
}

.tm30-cvg-legend {
    text-align: center;
    max-width: 500px;
}

.tm30-cvg-legend p {
    margin: 0.25rem 0;
    font-size: 0.85rem;
}

/* TM-30 Hue Container */
.tm30-hue-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tm30-hue-diagram {
    display: flex;
    justify-content: center;
}

.tm30-hue-details {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
}

.tm30-hue-table {
    border-collapse: collapse;
    font-size: 0.85rem;
}

.tm30-hue-table th,
.tm30-hue-table td {
    padding: 0.35rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.tm30-hue-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-secondary);
}

.tm30-hue-table tbody tr:hover {
    background: var(--background);
}

.tm30-legend {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.tm30-legend p {
    margin: 0.25rem 0;
}

/* TM-30 Report (legacy, can be removed) */
.tm30-report {
    margin-top: 1.5rem;
}

.tm30-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    justify-content: center;
}

.tm30-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.tm30-metric .metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tm30-metric .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.tm30-diagrams {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: flex-start;
}

.tm30-cvg,
.tm30-hue-chart {
    background: var(--surface);
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tm30-cvg svg,
.tm30-hue-chart svg {
    max-width: 100%;
    height: auto;
}

@media (max-width: 900px) {
    .tm30-diagrams {
        flex-direction: column;
        align-items: center;
    }
}

/* ============================================
   SPECTRAL METRICS DISPLAY
   ============================================ */
.spectral-metrics-container {
    padding: 1rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.metric-card h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.metric-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.metric-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Energy Distribution Bars */
.energy-bars,
.par-bars,
.hort-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.energy-row,
.par-row,
.hort-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.energy-label,
.par-label,
.hort-label {
    width: 60px;
    font-size: 0.8rem;
    font-weight: 500;
}

.energy-bar,
.par-bar {
    height: 16px;
    border-radius: 4px;
    min-width: 4px;
    transition: width 0.3s ease;
}

.energy-value,
.par-value,
.hort-value {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

/* Energy bar colors */
.uv-bar {
    background: linear-gradient(90deg, #7c3aed, #4c1d95);
}

.visible-bar {
    background: linear-gradient(90deg, #7c3aed, #3b82f6, #22c55e, #eab308, #ef4444);
}

.ir-bar {
    background: linear-gradient(90deg, #b91c1c, #7f1d1d);
}

/* PAR bar colors */
.par-label.blue { color: #3b82f6; }
.par-label.green { color: #22c55e; }
.par-label.red { color: #ef4444; }

.blue-bar { background: #3b82f6; }
.green-bar { background: #22c55e; }
.red-bar { background: #ef4444; }

/* Warning card */
.warning-card {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #fecaca;
}

.theme-dark .warning-card {
    background: linear-gradient(135deg, #450a0a, #7f1d1d);
    border-color: #991b1b;
}

.warning-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.warning-item.thermal {
    background: rgba(239, 68, 68, 0.1);
}

.warning-item.uv {
    background: rgba(124, 58, 237, 0.1);
}

.warning-icon {
    font-size: 1.25rem;
}

.intensity-heatmap {
    width: 100%;
    max-width: 750px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.intensity-heatmap svg {
    width: 100%;
    height: auto;
    display: block;
}

.intensity-heatmap .no-data {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

/* BUG Rating Tab */
.bug-rating-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bug-rating-container {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.bug-rating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.bug-rating-header h3 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-primary);
}

.bug-rating-edit {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rating-inputs {
    display: flex;
    gap: 0.5rem;
}

.rating-input-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.rating-input-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.rating-input-group input {
    width: 45px;
    padding: 0.35rem 0.5rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    transition: border-color 0.2s;
    background: var(--surface);
    color: var(--text-primary);
}

.rating-input-group input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.rating-input-group input::-webkit-inner-spin-button,
.rating-input-group input::-webkit-outer-spin-button {
    opacity: 1;
}

.bug-rating-value {
    font-size: 1rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 2px solid;
}

.bug-rating-svg-container {
    width: 100%;
    overflow-x: auto;
    background: var(--diagram-bg);
    border-radius: 8px;
    padding: 0.5rem;
}

.bug-rating-svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* LCS View Layout - diagram on left, tables on right in single SVG */
.bug-rating-content.lcs-layout {
    width: 100%;
}

.bug-rating-content.lcs-layout .lcs-svg {
    width: 100%;
    max-width: 510px;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* BUG Rating content layout */
.bug-rating-content {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.bug-rating-diagram {
    flex: 1 1 300px;
    min-width: 280px;
}

.bug-rating-diagram svg {
    width: 100%;
    height: auto;
}

.bug-rating-tables {
    flex: 1 1 250px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bug-rating-footer {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Floodlight Tabs */
.floodlight-vh-tab,
.isolux-tab,
.isocandela-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.isolux-isometric-container {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    padding: 0.5rem;
}

.isolux-isometric-diagram {
    width: 100%;
    min-height: 200px;
}

.isolux-isometric-diagram svg {
    width: 100%;
    height: auto;
}

.isolux-aec-container {
    width: 100%;
}

.isolux-aec-diagram {
    width: 100%;
}

.isolux-aec-diagram svg {
    width: 100%;
    height: auto;
}

.floodlight-vh-container,
.isolux-container,
.isocandela-container {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    padding: 1rem;
}

.floodlight-diagram,
.isolux-diagram,
.isocandela-diagram {
    width: 100%;
    max-width: 750px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
}

.floodlight-diagram svg,
.isolux-diagram svg,
.isocandela-diagram svg {
    width: 100%;
    height: auto;
    display: block;
}

.floodlight-controls,
.isolux-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.control-group input[type="range"] {
    width: 120px;
    accent-color: var(--primary, #3b82f6);
}

.control-value {
    min-width: 3.5rem;
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.nema-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--surface-alt, var(--background));
    border-radius: 6px;
    border: 1px solid var(--border);
}

.nema-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.nema-value {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.nema-details {
    margin-top: 0.75rem;
}

.nema-table {
    width: 100%;
    max-width: 400px;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.nema-table th,
.nema-table td {
    padding: 0.35rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.nema-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.nema-table td {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Cone Diagram Tab */
.cone-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cone-diagram {
    width: 100%;
    aspect-ratio: 5/4;
    background: var(--surface);
    border-radius: 8px;
}

.cone-diagram svg {
    width: 100%;
    height: 100%;
}

.mounting-height-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border-radius: 6px;
    font-size: 0.85rem;
}

.mounting-height-control label {
    color: var(--text-secondary);
    white-space: nowrap;
}

.mounting-height-control input[type="range"] {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 2px;
    cursor: pointer;
}

.mounting-height-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.mounting-height-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.mounting-height-control .value-display {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 50px;
}

@media (max-width: 600px) {
    .mounting-height-control {
        flex-wrap: wrap;
        justify-content: center;
    }

    .mounting-height-control input[type="range"] {
        width: 100%;
        order: 3;
    }
}

/* C-Plane Control */
.c-plane-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border-radius: 6px;
    font-size: 0.85rem;
}

.c-plane-control label {
    color: var(--text-secondary);
    white-space: nowrap;
}

.c-plane-control input[type="range"] {
    width: 160px;
    height: 4px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 2px;
    cursor: pointer;
}

.c-plane-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.c-plane-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.c-plane-control .value-display {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
}

.c-plane-control.symmetric-note {
    justify-content: center;
    font-style: italic;
}

/* Illuminance Data Table */
.illuminance-table-wrapper {
    margin-top: 0.5rem;
}

.illuminance-table-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.illuminance-no-data {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.illuminance-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.illuminance-data-table th {
    text-align: right;
    padding: 0.35rem 0.5rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
}

.illuminance-data-table td {
    text-align: right;
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.illuminance-data-table tbody tr:hover {
    background: var(--surface);
}

.illuminance-data-table th:first-child,
.illuminance-data-table td:first-child {
    text-align: left;
}

@media (max-width: 600px) {
    .c-plane-control {
        flex-wrap: wrap;
        justify-content: center;
    }

    .c-plane-control input[type="range"] {
        width: 100%;
        order: 3;
    }

    .illuminance-data-table {
        font-size: 0.7rem;
    }

    .illuminance-data-table th,
    .illuminance-data-table td {
        padding: 0.25rem 0.3rem;
    }
}

/* 3D Diagram Tab */
.diagram-3d-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.diagram-3d-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    background: var(--background);
    border: 2px dashed var(--border);
    border-radius: 8px;
}

.diagram-3d-placeholder .placeholder-content {
    text-align: center;
    color: var(--text-secondary);
}

.diagram-3d-placeholder svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.diagram-3d-placeholder h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.diagram-3d-placeholder p {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.diagram-3d-placeholder .hint {
    font-size: 0.8rem;
    font-style: italic;
}

/* Validation Tab */
.validation-tab {
    max-width: 900px;
    margin: 0 auto;
}

.validation-section,
.summary-section {
    background: var(--background);
    border-radius: 8px;
    padding: 1rem;
}

.validation-section h3,
.summary-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.info-grid-wide {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .info-grid-wide {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Butterfly Diagram */
.butterfly-diagram {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.butterfly-diagram svg {
    width: 100%;
    height: auto;
    display: block;
}

/* 3D Canvas Container */
.butterfly-3d-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
}

.butterfly-3d-canvas {
    width: 100%;
    height: 600px;
    display: block;
    cursor: grab;
}

.butterfly-3d-canvas:active {
    cursor: grabbing;
}

.butterfly-3d-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    pointer-events: none;
}

.butterfly-3d-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}

.butterfly-3d-controls button {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: 12px;
}

.butterfly-3d-controls button:hover {
    background: var(--background);
}

/* Responsive 3D canvas */
@media (max-width: 768px) {
    .butterfly-3d-canvas {
        height: 450px;
    }

    .butterfly-3d-overlay {
        font-size: 10px;
    }

    .butterfly-3d-controls button {
        padding: 4px 8px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .butterfly-3d-canvas {
        height: 350px;
    }

    .butterfly-3d-controls {
        bottom: 5px;
        right: 5px;
        gap: 3px;
    }

    .butterfly-3d-controls button {
        padding: 3px 6px;
        font-size: 9px;
    }
}

/* Scene container responsive */
.scene-container {
    width: 100%;
    min-height: 400px;
}

@media (max-width: 768px) {
    .scene-container {
        min-height: 350px;
    }

    .scene-controls {
        font-size: 0.7rem;
    }

    .scene-controls p {
        word-break: break-word;
    }
}

@media (max-width: 480px) {
    .scene-container {
        min-height: 280px;
    }
}

/* ============================================
   CALCULATED PHOTOMETRIC SUMMARY
   ============================================ */
.calculated-summary {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
    background: linear-gradient(to bottom, var(--background), transparent);
    padding: 1.5rem;
    border-radius: 8px;
}

.calculated-summary .summary-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calculated-summary .summary-header::before {
    content: "⚡";
    font-size: 0.875rem;
}

.calculated-summary .text-small {
    font-size: 0.75rem;
    margin-bottom: 1rem;
}

.calculated-summary .subsection-header {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px dashed var(--border);
}

.calculated-summary .info-grid-wide {
    background: var(--surface);
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.calculated-summary .info-item {
    background: transparent;
}

.calculated-summary .info-value.mono {
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
    letter-spacing: 0.05em;
}

/* ============================================
   LANGUAGE SELECTOR
   ============================================ */
.language-selector {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 120px;
}

.language-selector:hover {
    border-color: var(--primary-color);
}

.language-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Compact language selector (dropdown style) */
.language-selector-compact {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 100px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 1em;
    padding-right: 1.8rem;
}

.language-selector-compact:hover {
    border-color: var(--primary-color);
}

.language-selector-compact:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Header language selector - styles moved to main header section */

/* ============================================
   ABOUT MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modal-appear 0.2s ease-out;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.about-modal h2 {
    margin: 0 0 0.25rem 0;
    font-size: 1.75rem;
    color: var(--text-primary);
    font-weight: 700;
}

.about-subtitle {
    margin: 0 0 1.25rem 0;
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 500;
}

.about-description {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.about-description p {
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.about-description p:last-child {
    margin-bottom: 0;
}

.about-highlight {
    color: var(--text-primary) !important;
    font-weight: 600;
    margin-top: 0.75rem !important;
}

.about-links {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.about-links a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.about-links a:hover {
    text-decoration: underline;
}

.about-version {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: monospace;
}

.about-modal .btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

/* ============================================
   BIM PANEL STYLES
   TM-32-24 BIM Parameters display
   ============================================ */

.bim-panel {
    padding: 1rem;
    max-width: 900px;
    margin: 0 auto;
}

.bim-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.bim-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.bim-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    background: var(--background);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

.bim-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.bim-groups {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bim-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.bim-group-title {
    margin: 0;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--background);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bim-table {
    width: 100%;
    border-collapse: collapse;
}

.bim-table tr:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.bim-table td {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.bim-key {
    color: var(--text-secondary);
    width: 40%;
}

.bim-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

.bim-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.bim-info {
    margin-top: 1rem;
}

.bim-info p {
    margin: 0;
    font-size: 0.8rem;
}

/* Empty state for BIM panel */
.bim-empty {
    text-align: center;
    padding: 3rem 2rem;
}

.bim-empty-message h3 {
    margin: 0 0 1rem;
    color: var(--text-secondary);
}

.bim-empty-message p {
    margin: 0.5rem 0;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Dark theme adjustments */
.theme-dark .bim-group-title {
    background: var(--surface-elevated);
}

.theme-dark .bim-summary {
    background: var(--surface-elevated);
}

/* Responsive BIM table */
@media (max-width: 600px) {
    .bim-table td {
        display: block;
        width: 100%;
        padding: 0.25rem 1rem;
    }

    .bim-key {
        padding-top: 0.75rem;
        font-size: 0.75rem;
    }

    .bim-value {
        text-align: left;
        padding-bottom: 0.75rem;
    }

    .bim-actions {
        flex-direction: column;
    }
}

/* ========================================
   Compare Panel Styles
   ======================================== */

.compare-panel {
    padding: 1rem;
}

.compare-file-controls {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.compare-file-controls h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
}

.compare-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 1.5rem 1rem;
    text-align: center;
    transition: all 0.2s;
}

.compare-drop-zone.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.compare-drop-zone p {
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
}

.compare-file-b-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

.compare-clear-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.1rem 0.4rem;
    line-height: 1;
    transition: all 0.2s;
}

.compare-clear-btn:hover {
    background: var(--danger, #ef4444);
    color: white;
    border-color: var(--danger, #ef4444);
}

.compare-inputs {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.compare-file-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.compare-file-btn:hover {
    opacity: 0.9;
}

.compare-or {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.compare-template-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    max-width: 300px;
}

.compare-file-b-name {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Similarity badge */
.similarity-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 1rem;
}

.similarity-label {
    font-size: 0.85rem;
    opacity: 0.8;
}

.similarity-value {
    font-size: 1.25rem;
}

.similarity-high {
    background: #dcfce7;
    color: #166534;
}

.similarity-medium {
    background: #fef9c3;
    color: #854d0e;
}

.similarity-low {
    background: #fee2e2;
    color: #991b1b;
}

.theme-dark .similarity-high {
    background: #14532d;
    color: #86efac;
}

.theme-dark .similarity-medium {
    background: #713f12;
    color: #fde68a;
}

.theme-dark .similarity-low {
    background: #7f1d1d;
    color: #fca5a5;
}

/* Compare export buttons */
.compare-export-buttons {
    display: flex;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.compare-export-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    transition: opacity 0.15s;
}

.compare-export-btn:hover:not(:disabled) {
    opacity: 0.85;
}

.compare-export-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.compare-export-btn.secondary {
    background: transparent;
    color: var(--primary-color);
}

.compare-export-btn.secondary:hover {
    background: var(--primary-color);
    color: white;
}

/* Diagram toggle */
.compare-diagram-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.compare-diagram-toggle button {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.compare-diagram-toggle button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Overlay diagram container */
.compare-overlay-diagram {
    margin-bottom: 1.5rem;
    max-width: 600px;
}

.compare-overlay-diagram svg {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Side-by-side diagrams (Heatmap, Butterfly) */
.compare-side-by-side {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.compare-side {
    flex: 1;
    min-width: 0;
}

.compare-side-label {
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.compare-side-svg svg {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

@media (max-width: 768px) {
    .compare-side-by-side {
        flex-direction: column;
    }
}

/* Comparison table */
.compare-table-wrapper {
    overflow-x: auto;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.compare-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.compare-table td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.compare-table .metric-name {
    font-weight: 500;
}

.compare-table .metric-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.compare-table .metric-delta,
.compare-table .metric-percent {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* Delta row colors */
tr.delta-ok td {
    /* no special styling */
}

tr.delta-minor td {
    background: rgba(234, 179, 8, 0.08);
}

tr.delta-minor .metric-delta,
tr.delta-minor .metric-percent {
    color: #ca8a04;
}

tr.delta-moderate td {
    background: rgba(249, 115, 22, 0.08);
}

tr.delta-moderate .metric-delta,
tr.delta-moderate .metric-percent {
    color: #ea580c;
}

tr.delta-major td {
    background: rgba(239, 68, 68, 0.08);
}

tr.delta-major .metric-delta,
tr.delta-major .metric-percent {
    color: #dc2626;
}

/* Dark theme delta colors */
.theme-dark tr.delta-minor td {
    background: rgba(234, 179, 8, 0.12);
}

.theme-dark tr.delta-minor .metric-delta,
.theme-dark tr.delta-minor .metric-percent {
    color: #fbbf24;
}

.theme-dark tr.delta-moderate td {
    background: rgba(249, 115, 22, 0.12);
}

.theme-dark tr.delta-moderate .metric-delta,
.theme-dark tr.delta-moderate .metric-percent {
    color: #fb923c;
}

.theme-dark tr.delta-major td {
    background: rgba(239, 68, 68, 0.12);
}

.theme-dark tr.delta-major .metric-delta,
.theme-dark tr.delta-major .metric-percent {
    color: #f87171;
}

/* Empty state */
.compare-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.compare-empty p:first-child {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

/* Responsive */
@media (max-width: 600px) {
    .compare-inputs {
        flex-direction: column;
        align-items: flex-start;
    }

    .compare-template-select {
        max-width: 100%;
        width: 100%;
    }

    .compare-table {
        font-size: 0.75rem;
    }

    .compare-table th,
    .compare-table td {
        padding: 0.3rem 0.4rem;
    }
}

/* ============================================
   AREA LIGHTING DESIGNER
   ============================================ */
.area-designer {
    padding: 0.5rem;
}

.area-toolbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
}

.area-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.4rem;
}

.area-toolbar-row:last-child {
    margin-bottom: 0;
}

.area-toolbar label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.area-toolbar select,
.area-toolbar input[type="range"] {
    font-size: 0.8rem;
}

.area-toolbar input[type="range"] {
    width: 80px;
}

.area-toolbar span {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 3em;
}

.area-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0.75rem;
}

.area-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.area-sidebar-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
}

.area-sidebar-section h4 {
    margin: 0 0 0.4rem 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.area-preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}

.area-preset-btn {
    padding: 0.3rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    text-align: center;
    line-height: 1;
}

.area-preset-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.area-pole-props {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.area-prop-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.area-prop-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 50px;
}

.area-prop-input {
    width: 60px;
    padding: 0.15rem 0.3rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-primary);
}

.area-prop-unit {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.area-prop-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.area-reset-btn {
    margin-top: 0.3rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
}

.area-reset-btn:hover {
    background: var(--warning-color);
    color: white;
    border-color: var(--warning-color);
}

.area-no-selection {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
}

.area-views {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.area-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
}

.area-panel h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.area-subtitle {
    font-size: 0.7rem;
    font-weight: normal;
    color: var(--text-muted);
}

.area-view-tabs {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    width: fit-content;
    margin-bottom: 0.5rem;
}
.area-view-tab {
    padding: 4px 14px;
    font-size: 12px;
    border: none;
    border-right: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}
.area-view-tab:last-of-type { border-right: none; }
.area-view-tab:hover { background: var(--surface-hover, #eef); }
.area-view-tab.active {
    background: var(--accent, #4488cc);
    color: #fff;
    font-weight: 600;
}

.area-plan-svg svg,
.area-iso-svg svg {
    width: 100%;
    height: auto;
    max-height: 450px;
}

.area-plan-svg {
    user-select: none;
    -webkit-user-select: none;
}

.area-placement-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
}

.area-stats {
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.area-stats-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
}

.area-stats-table td {
    padding: 0.2rem 0.5rem;
    color: var(--text-secondary);
}

.area-stats-table td.val {
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Optimizer */
.area-opt-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.area-prop-input-sm {
    width: 40px !important;
}

.area-share-btn {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.area-share-btn:hover {
    background: var(--primary-color);
    color: white;
}

.area-opt-run-btn {
    margin-top: 0.3rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    text-align: center;
}

.area-opt-run-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

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

.area-opt-results {
    margin-top: 0.4rem;
    max-height: 200px;
    overflow-y: auto;
}

.area-opt-table {
    width: 100%;
    font-size: 0.7rem;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.area-opt-table th {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.15rem 0.2rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.area-opt-table th:first-child {
    text-align: left;
}

.area-opt-table td {
    padding: 0.2rem 0.2rem;
    text-align: right;
    color: var(--text-secondary);
}

.area-opt-table td:first-child {
    text-align: left;
}

.area-opt-row:hover {
    background: var(--surface-elevated);
}

.area-opt-pass td {
    color: var(--success-color);
    font-weight: 600;
}

.area-bay-toggle {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.area-bay-toggle input[type="checkbox"] {
    accent-color: var(--primary-color);
}

/* Height comparison cards */
.area-opt-cards {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.area-opt-card {
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.area-opt-card:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.04);
}

.area-opt-card-selected {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.08);
    box-shadow: 0 0 0 1px var(--primary-color);
}

.area-opt-card-pass .area-opt-card-header {
    color: var(--success-color);
}

.area-overlay-cb {
    width: 14px;
    height: 14px;
    margin: 0 0.2rem 0 0;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.area-opt-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

.area-opt-card-height {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.area-opt-card-pass .area-opt-card-height {
    color: var(--success-color);
}

.area-opt-card-badge {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    background: var(--success-color);
    color: white;
}

.area-opt-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.15rem 0.5rem;
    font-size: 0.7rem;
}

.area-opt-card-stats div {
    display: flex;
    justify-content: space-between;
}

.area-opt-card-lbl {
    color: var(--text-muted);
}

.area-opt-card-stats span:last-child {
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.area-opt-card-footer {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    border-top: 1px solid var(--border);
    padding-top: 0.2rem;
}

/* Export buttons */
.area-export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.area-export-btn {
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.area-export-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.04);
}

.area-export-btn:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.area-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0 0 6px;
}

.area-extra-ldts {
    margin-top: 6px;
}

.area-extra-ldt-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 0;
    font-size: 0.82rem;
}

.area-extra-ldt-idx {
    color: var(--text-muted);
    min-width: 20px;
}

.area-extra-ldt-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.area-extra-ldt-rm {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
    line-height: 1;
}

.area-extra-ldt-rm:hover {
    background: rgba(220, 38, 38, 0.1);
    border-radius: 3px;
}

.area-wall-note {
    background: rgba(217, 119, 6, 0.1);
    border: 1px solid var(--warning-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.82rem;
    margin: 0 8px 4px;
}

@media (max-width: 768px) {
    .area-layout {
        grid-template-columns: 1fr;
    }

    .area-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .area-toolbar-row {
        gap: 0.5rem;
    }
}

/* ============================================
   ZONAL DESIGNER
   ============================================ */
.zonal-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.zonal-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    overflow-y: auto;
}

.zonal-sidebar-section {
    margin-bottom: 16px;
}

.zonal-sidebar-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.zonal-info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 8px;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.zonal-info-grid .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.zonal-view-tabs {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.zonal-view-tab {
    padding: 4px 10px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
}

.zonal-view-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.zonal-view-tab:hover:not(.active) {
    background: var(--surface-elevated);
}

.zonal-panel {
    flex: 1;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    min-height: 0;
}

.zonal-panel h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.zonal-prop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.zonal-prop-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 80px;
}

.zonal-prop-row input[type="range"] {
    flex: 1;
}

.zonal-prop-row input[type="number"],
.zonal-prop-row select {
    background: var(--surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.8rem;
}

.zonal-flux-summary {
    margin-top: 8px;
    font-size: 0.75rem;
}

.zonal-flux-row,
.zonal-flux-bar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.zonal-flux-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.zonal-flux-zone {
    width: 50px;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.zonal-flux-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.zonal-flux-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.zonal-flux-bar-fill.zonal-flux-down {
    background: var(--primary-color);
}

.zonal-flux-bar-fill.zonal-flux-up {
    background: var(--warning-color);
}

.zonal-flux-pct {
    width: 40px;
    text-align: right;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.zonal-flux-val {
    font-weight: 600;
    color: var(--text-primary);
}

.zonal-stats-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
    color: var(--text-primary);
}

.zonal-stats-table td {
    padding: 3px 8px;
    border: 1px solid var(--border);
}

.zonal-stats-table .val {
    font-weight: 600;
    color: var(--primary-color);
}

/* ============================================================================
   Street Design tab — lazy-loaded companion launcher + embedded mount point
   ============================================================================ */

.street-design-tab {
    padding: 1rem;
}

.street-launcher {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.street-launcher-intro {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 720px;
}

.street-launcher-intro h3 {
    margin: 0 0 0.75rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.street-launcher-regions {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
    list-style: disc;
    color: var(--text-primary);
    line-height: 1.8;
}

.street-launcher-regions strong {
    font-weight: 600;
    color: var(--primary-color);
}

.street-launcher-button {
    margin-top: 0.5rem;
}

.street-launcher-button:disabled {
    opacity: 0.6;
    cursor: progress;
}

.street-launcher-error {
    color: var(--danger-color, #a83232);
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
}

/* Mount point — collapsed until the bundle finishes loading. */
.street-root {
    display: none;
}

.street-root.visible {
    display: block;
    margin-top: 1rem;
}

/* Companion app container — styles apply once #street-root is populated
   by eulumdat-wasm-street/src/app.rs. Kept minimal so the host theme
   (dark/light) drives colors. */
.street-root .street-app {
    font-family: inherit;
    color: var(--text-primary);
}

.street-root .street-app fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
    background: var(--surface);
}

.street-root .street-app fieldset legend {
    padding: 0 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.street-root .street-app input[type="number"],
.street-root .street-app input[type="file"],
.street-root .street-app select {
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
}

/* Source panel — shows which luminaire is loaded (from editor vs upload)
   plus the collapsible fallback upload. */
.street-root .street-app .street-source-panel {
    margin: 0.5rem 0 1rem;
}

.street-root .street-app .street-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-size: 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.street-root .street-app .street-source-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted, #888);
    flex-shrink: 0;
}

.street-root .street-app .street-source-badge--editor .dot {
    background: #2d7a2d;
    box-shadow: 0 0 0 3px rgba(45, 122, 45, 0.15);
}

.street-root .street-app .street-source-badge--upload .dot {
    background: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(80, 120, 200, 0.15);
}

.street-root .street-app .street-source-hint {
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

.street-root .street-app .street-source-upload {
    margin-top: 0.5rem;
}

.street-root .street-app .street-source-upload summary {
    cursor: pointer;
    color: var(--text-muted, #888);
    font-size: 0.85rem;
    padding: 0.25rem 0;
    user-select: none;
}

.street-root .street-app .street-source-upload summary:hover {
    color: var(--text-primary);
}

.street-root .street-app .street-upload-row {
    margin-top: 0.5rem;
    padding: 0.5rem 0;
}

/* Plan-view heatmap canvas + toolbar */
.street-root .street-app .street-viz {
    margin: 1rem 0 1.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--background);
}

.street-root .street-app .street-viz-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.street-root .street-app .street-viz-controls {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.street-root .street-app .street-viz-dropdown {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

.street-root .street-app .street-viz-dropdown select {
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.street-root .street-app .street-viz-ratio {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.street-root .street-app .street-viz-ratio input[type="range"] {
    width: 8rem;
    accent-color: var(--primary-color);
}

.street-root .street-app .street-viz-ratio span {
    min-width: 2.5rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted, #888);
}

.street-root .street-app .street-viz-threshold {
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted, #888);
    font-size: 0.78rem;
    white-space: nowrap;
}

.street-root .street-app .street-viz-stats strong {
    color: var(--primary-color);
    font-weight: 600;
}

.street-root .street-app .street-viz-canvas {
    padding: 0.5rem;
}

.street-root .street-app .street-viz-canvas svg {
    width: 100%;
    height: auto;
    display: block;
}

.street-root .street-app .street-placeholder {
    color: var(--text-muted, #888);
    font-style: italic;
    padding: 1rem 0;
}

/* Inline download buttons next to diagram visibility toggles. Small,
 * unobtrusive, theme-aware — they sit beside the toggle so the user
 * can grab the SVG of whatever they're currently looking at without
 * scrolling to the master export panel. */
.street-root .street-app .street-inline-dl {
    margin-left: 0.4rem;
    padding: 0.15rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-muted, #888);
    font-size: 0.78rem;
    cursor: pointer;
    line-height: 1.3;
}
.street-root .street-app .street-inline-dl:hover {
    background: var(--surface-hover, var(--surface));
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ExportsPanel — single row of download buttons at the bottom that
 * mirrors what the inline buttons do for individual diagrams plus
 * adds CSV/JSON of the optimizer set and the full PDF report. */
.street-root .street-app .street-exports {
    margin: 1rem 0 0;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
}
.street-root .street-app .street-exports legend {
    padding: 0 0.4rem;
    color: var(--text-muted, #888);
    font-size: 0.85rem;
}
.street-root .street-app .street-exports-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.3rem;
}
.street-root .street-app .street-exports-row button {
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
}
.street-root .street-app .street-exports-row button:hover:not(:disabled) {
    background: var(--surface-hover, var(--surface));
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.street-root .street-app .street-exports-row button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
