/* ========================================================
   SmartOrder — 3D Technology Services
   Automated Change Order System
   Design System & Styles
   ======================================================== */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-card: #16161f;
    --bg-elevated: #1c1c28;
    --bg-hover: #22222e;
    --bg-input: #1a1a26;
    --border: #2a2a3a;
    --border-focus: #0EA5E9;
    --text-primary: #f0f0f5;
    --text-secondary: #9898b0;
    --text-muted: #686880;
    --accent-cyan: #0EA5E9;
    --accent-gold: #F5C542;
    --accent-green: #22C55E;
    --accent-red: #EF4444;
    --accent-orange: #F59E0B;
    --accent-purple: #A855F7;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #333348;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #44445a;
}

/* === HEADER === */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    background: linear-gradient(135deg, #0d0d15, #14141e);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-mark {
    width: auto;
    height: 48px;
    display: flex;
    align-items: center;
}

.header-logo-img {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.header-titles h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-gold), #FFD700, var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.header-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-green);
}

.badge-icon {
    font-size: 0.9rem;
}

.btn-header {
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #0EA5E9, #0284C7);
    color: white;
}

.btn-header:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.3);
}

.btn-header.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-header.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

/* === GENERATE BUTTON === */
.btn-generate {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #22C55E, #16A34A);
    color: white;
    box-shadow: 0 2px 12px rgba(34, 197, 94, 0.3);
    letter-spacing: 0.3px;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(34, 197, 94, 0.45);
}

.btn-generate:active {
    transform: translateY(0);
}

/* === FLOATING ACTION BAR === */
.floating-action-bar {
    position: fixed;
    bottom: 0;
    left: 240px;
    right: 0;
    background: linear-gradient(135deg, #111118, #1a1a26);
    border-top: 1px solid var(--border);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 99;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.fab-stats {
    display: flex;
    align-items: center;
    gap: 24px;
}

.fab-count {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.fab-count strong {
    color: var(--accent-cyan);
    font-size: 1.1rem;
}

.fab-total {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.fab-btn {
    padding: 12px 32px;
    font-size: 1rem;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 2px 12px rgba(34, 197, 94, 0.3);
    }

    50% {
        box-shadow: 0 4px 24px rgba(34, 197, 94, 0.55);
    }
}

/* === QUICK START BAR === */
.quick-start-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 32px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.08), rgba(34, 197, 94, 0.08));
    border-bottom: 1px solid var(--border);
}

.qs-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.qs-step strong {
    color: var(--accent-green);
}

.qs-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-cyan);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    flex-shrink: 0;
}

.qs-arrow {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* === LAYOUT === */
#app-layout {
    display: flex;
    height: calc(100vh - 64px);
}

/* === SIDEBAR === */
#sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#sidebar-nav {
    padding: 12px 8px;
    flex: 1;
}

.nav-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    padding: 16px 12px 6px;
    text-transform: uppercase;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    position: relative;
}

.nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-btn.active {
    background: rgba(14, 165, 233, 0.12);
    color: var(--accent-cyan);
    font-weight: 600;
}

.nav-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-cyan);
}

.nav-icon {
    font-size: 1rem;
    width: 22px;
    text-align: center;
}

.nav-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-count {
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
    color: var(--text-muted);
}

.nav-btn.active .nav-count {
    background: rgba(14, 165, 233, 0.2);
    color: var(--accent-cyan);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stat-row span:last-child {
    font-weight: 700;
    color: var(--accent-gold);
}

/* === MAIN CONTENT === */
#main-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 28px 32px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-secondary), transparent);
}

.panel-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.panel-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.panel-header-left h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.panel-header-right {
    display: flex;
    align-items: center;
}

.system-stats {
    display: flex;
    gap: 16px;
}

.sys-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.sys-stat strong {
    font-size: 1rem;
    color: var(--accent-cyan);
    font-weight: 700;
}

.panel-body {
    padding: 24px 32px;
}

/* === FORMS === */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* === COMPANY CARD === */
.company-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
}

.company-logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.company-logo-placeholder {
    width: 280px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #fefefe;
    padding: 10px;
}

.company-logo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.btn-sm {
    padding: 6px 16px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-sans);
}

.btn-sm:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* === FILE UPLOAD === */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 60px 32px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-cyan);
    background: rgba(14, 165, 233, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    filter: grayscale(0.5);
}

.upload-zone h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.upload-zone p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.btn-primary {
    padding: 10px 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #0EA5E9, #0284C7);
    color: white;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.3);
}

.uploaded-files-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.uploaded-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.uploaded-file-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.uploaded-file-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.uploaded-file-size {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--accent-red);
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.6;
    transition: var(--transition);
}

.btn-remove:hover {
    opacity: 1;
}

/* === CATALOG CONTROLS === */
.catalog-controls {
    margin-bottom: 20px;
}

.search-box {
    position: relative;
    margin-bottom: 14px;
}

.catalog-search {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

.catalog-search:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    opacity: 0.5;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-tab {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.filter-tab:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.filter-tab.active {
    background: var(--accent-cyan);
    color: white;
    border-color: var(--accent-cyan);
}

/* === CATALOG GRID === */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px;
    margin-bottom: 24px;
}

.catalog-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.catalog-item:hover {
    border-color: var(--accent-cyan);
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.catalog-item.added {
    border-color: var(--accent-green);
    background: rgba(34, 197, 94, 0.05);
}

.catalog-item.added::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-green);
    background: rgba(34, 197, 94, 0.15);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cat-name {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
    padding-right: 24px;
}

.cat-part {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.cat-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.cat-price {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.cat-labor {
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.cat-category-badge {
    font-size: 0.6rem;
    padding: 2px 8px;
    background: rgba(14, 165, 233, 0.1);
    color: var(--accent-cyan);
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* === SELECTED ITEMS TABLE === */
.selected-items-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}

.selected-items-section h3 {
    font-size: 1rem;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--accent-cyan);
    color: white;
    padding: 2px 10px;
    border-radius: 10px;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.items-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

.items-table tbody tr:hover {
    background: var(--bg-hover);
}

.items-table input[type="number"] {
    width: 70px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    text-align: center;
}

.items-table input[type="number"]:focus {
    border-color: var(--accent-cyan);
    outline: none;
}

.ext-price {
    font-weight: 700;
    color: var(--accent-gold);
}

/* === LABOR CONFIG === */
.labor-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.config-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: var(--transition);
}

.config-card:hover {
    border-color: rgba(14, 165, 233, 0.3);
}

.config-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.config-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.rate-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rate-prefix,
.rate-suffix {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.rate-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--accent-gold);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    transition: var(--transition);
    outline: none;
}

.rate-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.rate-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
}

.rate-select:focus {
    border-color: var(--accent-cyan);
}

.neca-reference {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}

.neca-reference h3 {
    font-size: 1rem;
    margin-bottom: 10px;
}

.neca-reference p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.reference-note {
    margin-top: 14px;
    padding: 12px 16px;
    background: rgba(14, 165, 233, 0.06);
    border-left: 3px solid var(--accent-cyan);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* === SUMMARY === */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    transition: var(--transition);
}

.summary-card:hover {
    border-color: rgba(14, 165, 233, 0.3);
}

.summary-card.highlight {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(245, 197, 66, 0.1));
    border-color: var(--accent-gold);
    grid-column: 1 / -1;
}

.summary-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.summary-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
}

.summary-card.highlight .summary-value {
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.summary-breakdown {
    margin-bottom: 28px;
}

.summary-breakdown h3 {
    font-size: 1rem;
    margin-bottom: 14px;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.summary-table th {
    text-align: left;
    padding: 12px 14px;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.summary-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.summary-table tfoot td {
    border-top: 2px solid var(--accent-cyan);
    padding-top: 14px;
    font-size: 0.95rem;
}

/* === SIGNATURE === */
.signature-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}

.signature-block h3 {
    font-size: 1rem;
    margin-bottom: 20px;
}

.sig-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.sig-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sig-line {
    height: 60px;
    border-bottom: 2px solid var(--text-secondary);
    margin-bottom: 4px;
}

.sig-box p {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.sig-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.sig-fields input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.82rem;
}

.sig-fields input:focus {
    border-color: var(--accent-cyan);
    outline: none;
}

/* === CODES & STANDARDS === */
.standards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.standard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: var(--transition);
}

.standard-card:hover {
    border-color: rgba(14, 165, 233, 0.3);
}

.standard-card h4 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--accent-cyan);
}

.standard-card .std-org {
    font-size: 0.7rem;
    color: var(--accent-gold);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.standard-card p {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.standard-card .std-applies {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.std-tag {
    font-size: 0.6rem;
    padding: 2px 8px;
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent-purple);
    border-radius: 8px;
    font-weight: 600;
}

/* === TOAST === */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease, slideOut 0.3s ease 2.5s forwards;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 360px;
}

.toast.success {
    background: var(--accent-green);
    color: white;
}

.toast.info {
    background: var(--accent-cyan);
    color: white;
}

.toast.warning {
    background: var(--accent-orange);
    color: #1a1a00;
}

.toast.error {
    background: var(--accent-red);
    color: white;
}

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

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* === SCOPE CONTAINER === */
.scope-container {
    max-width: 900px;
}

.scope-container textarea {
    font-family: var(--font-sans);
    line-height: 1.6;
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    #sidebar {
        width: 200px;
        min-width: 200px;
    }

    .catalog-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    #sidebar {
        display: none;
    }

    .panel-body {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .sig-grid {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* === PRINT === */
@media print {
    body {
        background: white;
        color: #000;
        overflow: visible;
    }

    #sidebar,
    .toast-container,
    .btn-header,
    .header-badge,
    .catalog-controls,
    .catalog-grid,
    .btn-remove,
    .btn-sm,
    .btn-primary,
    .upload-zone,
    .nav-section-label,
    #btn-browse-files,
    .filter-tabs {
        display: none !important;
    }

    #app-layout {
        display: block;
        height: auto;
    }

    #main-content {
        overflow: visible;
    }

    .panel {
        display: block !important;
        break-inside: avoid;
    }

    .panel-header {
        background: none;
        border-bottom: 2px solid #000;
    }

    .panel-header h2,
    .panel-header-left h2 {
        color: #000;
        font-size: 1.2rem;
    }

    #app-header {
        background: white;
        border-bottom: 2px solid #000;
        box-shadow: none;
        position: static;
    }

    .header-titles h1 {
        background: none;
        -webkit-text-fill-color: #000;
        font-size: 1.6rem;
    }

    .items-table th,
    .summary-table th {
        background: #f0f0f0;
        color: #000;
        border-bottom: 2px solid #000;
    }

    .items-table td,
    .summary-table td {
        color: #000;
        border-bottom: 1px solid #ccc;
    }

    .ext-price {
        color: #000;
    }

    .summary-card {
        background: #f8f8f8;
        border: 1px solid #ccc;
    }

    .summary-value,
    .summary-card.highlight .summary-value {
        color: #000;
        -webkit-text-fill-color: #000;
        background: none;
    }

    .signature-block {
        background: white;
        border: 1px solid #ccc;
    }

    .sig-line {
        border-bottom: 2px solid #000;
    }

    .form-group input,
    .form-group textarea {
        border: none;
        background: transparent;
        color: #000;
    }

    .company-card {
        background: white;
        border: 1px solid #ccc;
    }

    .config-card,
    .neca-reference,
    .standard-card {
        display: none;
    }

    .selected-items-section {
        background: white;
        border: 1px solid #ccc;
    }
}

/* ========================================================
   CHANGE ORDER DOCUMENT STYLES
   ======================================================== */

.co-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.co-section:last-of-type {
    border-bottom: none;
}

.co-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.co-section-desc {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-style: italic;
    font-size: 0.88rem;
}

/* ── Header Grid ── */
.co-header-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 24px;
    padding: 20px 24px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

.co-header-from,
.co-header-to,
.co-header-meta {
    min-width: 0;
}

.co-header-from h4,
.co-header-to h4 {
    color: var(--accent-cyan);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.co-header-from p,
.co-header-to p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.7;
    word-break: break-word;
}

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

.co-meta-table td {
    padding: 5px 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.co-meta-table td:first-child {
    white-space: nowrap;
    color: var(--text-secondary);
    width: 42%;
    padding-right: 12px;
}

/* ── Scope Narrative ── */
.co-scope-block {
    margin-bottom: 20px;
}

.co-scope-block h4 {
    font-size: 0.92rem;
    color: var(--accent-gold);
    margin-bottom: 8px;
    font-weight: 600;
}

.co-scope-text {
    background: var(--bg-elevated);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-cyan);
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
    font-size: 0.9rem;
}

.co-scope-block ul {
    padding-left: 24px;
    list-style: disc;
}

.co-scope-block li {
    padding: 4px 0;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 0.88rem;
}

/* ── Standards Table ── */
.co-standards-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    table-layout: fixed;
}

.co-standards-table th {
    background: var(--bg-elevated);
    color: var(--accent-cyan);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

.co-standards-table th:nth-child(1) {
    width: 55%;
}

.co-standards-table th:nth-child(2) {
    width: 15%;
}

.co-standards-table th:nth-child(3) {
    width: 30%;
}

.co-standards-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
    word-break: break-word;
}

.co-standards-table small {
    color: var(--text-secondary);
    display: block;
    margin-top: 4px;
}

.co-standards-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* ── Line Item Tables ── */
.co-system-section {
    margin-bottom: 28px;
}

.co-system-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(245, 197, 66, 0.1), transparent);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-gold);
}

.co-line-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.8rem;
}

/* Column widths for 10-column layout */
.co-line-table th:nth-child(1) {
    width: 4%;
}

/* # */
.co-line-table th:nth-child(2) {
    width: 24%;
}

/* Description */
.co-line-table th:nth-child(3) {
    width: 10%;
}

/* Part # */
.co-line-table th:nth-child(4) {
    width: 5%;
}

/* Unit */
.co-line-table th:nth-child(5) {
    width: 9%;
}

/* Unit Price */
.co-line-table th:nth-child(6) {
    width: 5%;
}

/* Qty */
.co-line-table th:nth-child(7) {
    width: 11%;
}

/* Material Ext */
.co-line-table th:nth-child(8) {
    width: 8%;
}

/* Labor Hrs */
.co-line-table th:nth-child(9) {
    width: 11%;
}

/* Labor Cost */
.co-line-table th:nth-child(10) {
    width: 13%;
}

/* Line Total */

.co-line-table th {
    background: var(--bg-elevated) !important;
    font-size: 0.68rem;
    padding: 8px 6px;
    white-space: nowrap;
    text-align: left;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    letter-spacing: 0.3px;
}

.co-line-table th.text-right {
    text-align: right;
}

.co-line-table td {
    padding: 7px 6px;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.co-line-table td:nth-child(2) {
    white-space: normal;
    word-break: break-word;
}

.co-line-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.co-line-table tbody tr:hover {
    background: rgba(14, 165, 233, 0.05);
}

.co-part-num {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary) !important;
}

.text-right {
    text-align: right !important;
}

.co-line-table tfoot td {
    border-top: 2px solid var(--accent-cyan);
    border-bottom: none;
}

.co-system-subtotal td {
    background: rgba(14, 165, 233, 0.06) !important;
    font-weight: 600;
    padding: 10px 6px;
    color: var(--text-primary);
}

/* ── Financial Summary ── */
.co-financials-table {
    width: 100%;
    max-width: 560px;
    margin-left: auto;
    border-collapse: collapse;
}

.co-financials-table td {
    padding: 7px 14px;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.co-financials-table td:first-child {
    color: var(--text-secondary);
    text-align: left;
    white-space: nowrap;
}

.co-financials-table td:last-child {
    text-align: right;
    font-family: var(--font-mono);
    color: var(--text-primary);
    min-width: 120px;
}

.co-fin-separator td {
    border-bottom: 2px solid var(--accent-cyan) !important;
    padding-bottom: 12px;
    font-weight: 600;
}

.co-fin-total td {
    font-size: 1.05rem !important;
    border-top: 3px double var(--accent-gold) !important;
    border-bottom: none !important;
    padding-top: 14px;
    color: var(--accent-gold) !important;
    font-weight: 700;
}

/* ── Terms ── */
.co-terms {
    padding: 16px 20px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.co-terms p {
    padding: 5px 0 5px 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
    position: relative;
}

.co-terms p::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--accent-cyan);
}

/* ── Print Styles for CO Document ── */
@media print {
    .co-header-grid {
        grid-template-columns: 1fr 1fr 1fr;
        background: white;
        border: 1px solid #ccc;
        padding: 12px;
    }

    .co-header-from h4,
    .co-header-to h4 {
        color: #000;
    }

    .co-section-title {
        color: #0066cc;
        border-color: #0066cc;
    }

    .co-system-title {
        color: #333;
        background: #f5f5f5;
        border-color: #333;
    }

    .co-scope-text {
        background: #f9f9f9;
        border-color: #0066cc;
        color: #000;
    }

    .co-scope-block h4 {
        color: #333;
    }

    .co-standards-table th {
        background: #f0f0f0;
        color: #000;
    }

    .co-standards-table td {
        color: #000;
    }

    .co-line-table th {
        background: #f0f0f0 !important;
        color: #000;
    }

    .co-line-table td {
        color: #000;
    }

    .co-part-num {
        color: #666 !important;
    }

    .co-system-subtotal td {
        background: #e8f4fd !important;
        border-color: #0066cc;
    }

    .co-financials-table td {
        color: #000;
    }

    .co-fin-total td {
        color: #000 !important;
        border-color: #333 !important;
    }

    .co-terms {
        background: #f9f9f9;
        border-color: #ccc;
    }

    .co-terms p {
        color: #333;
    }

    .co-terms p::before {
        color: #0066cc;
    }

    .co-section {
        page-break-inside: avoid;
    }

    .co-system-section {
        page-break-inside: avoid;
    }
}