/* ==========================================================================
   CSS variables & Core setup
   ========================================================================== */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #60a5fa;
    --primary-color-rgb: 59, 130, 246;

    --bg-main: #060913;
    --bg-panel: #111827;
    --bg-sidebar: #0a0f1d;
    --bg-sidebar-hover: #1f2937;
    --bg-sidebar-active: #3b82f6;

    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-light: #f3f4f6;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --success-text: #22c55e;

    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --danger-text: #fca5a5;
    
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --warning-text: #fef08a;

    --font-heading: 'Inter', 'Kanit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', 'Kanit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

/* Hide spin-buttons for all number inputs to prevent clipping right-aligned text */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

body.dashboard-body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==========================================================================
   Typography & Base Components
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary-color { color: var(--primary-color); }
.font-bold { font-weight: 600; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    text-decoration: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

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

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger-outline {
    background-color: transparent;
    border-color: #fca5a5;
    color: var(--danger);
}
.btn-danger-outline:hover {
    background-color: var(--danger-light);
    border-color: var(--danger);
}

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

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-panel);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-icon:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger-icon {
    color: var(--danger);
    border-color: #fee2e2;
}
.btn-danger-icon:hover {
    background-color: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* ==========================================================================
   Login Interface overlay style
   ========================================================================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    transition: opacity var(--transition-normal);
}

.login-card {
    background-color: var(--bg-panel);
    padding: 36px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.login-logo {
    display: flex;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 2rem;
    margin-bottom: 24px;
}
.login-logo .logo-bold {
    font-weight: 800;
    color: var(--primary-color);
}
.login-logo .logo-light {
    font-weight: 300;
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}
.login-header h2 {
    font-size: 1.4rem;
    color: var(--text-main);
    margin-bottom: 6px;
}
.login-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.login-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ==========================================================================
   Header Style
   ========================================================================== */
.app-header {
    background-color: var(--bg-sidebar);
    color: white;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    z-index: 999;
    box-shadow: var(--shadow-sm);
}

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

.header-logo {
    display: flex;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    letter-spacing: -0.5px;
}

.header-logo .logo-bold {
    font-weight: 800;
    color: #60a5fa;
}

.header-logo .logo-light {
    font-weight: 300;
    margin-left: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-actions .btn-outline {
    color: white;
    border-color: #334155;
}
.header-actions .btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: white;
    color: white;
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.btn-lang {
    background: none;
    border: none;
    color: #94a3b8;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--transition-fast);
    outline: none;
}

.btn-lang:hover {
    color: white;
}

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

/* Hide switcher on print */
@media print {
    .lang-switcher {
        display: none !important;
    }
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #cbd5e1;
    border-left: 1px solid #334155;
    padding-left: 16px;
}
.user-profile b {
    color: white;
}

/* ==========================================================================
   Layout Main
   ========================================================================== */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
/* Sidebar (Hidden in new UX/UI redesign) */
.app-sidebar {
    display: none !important;
}

/* ----------------------------------------------------
   Project Selector Dropdown in Header
   ---------------------------------------------------- */
.project-selector-container {
    position: relative;
    display: inline-block;
}

.project-selector-btn {
    background-color: #1e293b;
    color: white;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-fast);
    outline: none;
    min-width: 220px;
    max-width: 340px;
    text-align: left;
    font-size: 0.9rem;
}

.project-selector-btn:hover {
    background-color: var(--bg-sidebar-hover);
    border-color: #475569;
}

.project-selector-btn i {
    color: #94a3b8;
}

.project-selector-btn span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-selector-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 380px;
    background-color: var(--bg-sidebar);
    border: 1px solid #334155;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: dropdownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.project-selector-dropdown.active {
    display: flex;
}

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

.project-selector-dropdown .dropdown-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #1e293b;
    background-color: #0f172a;
}

.project-selector-dropdown .dropdown-header span {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.project-selector-dropdown .dropdown-search {
    padding: 10px 16px;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #1e293b;
}

.project-selector-dropdown .dropdown-search i {
    color: #64748b;
    font-size: 0.9rem;
}

.project-selector-dropdown .dropdown-search input {
    background: none;
    border: none;
    color: white;
    width: 100%;
    outline: none;
    font-size: 0.875rem;
}

.project-selector-dropdown .dropdown-search input::placeholder {
    color: #475569;
}

.project-selector-dropdown .dropdown-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Dropdown Project Item */
.dropdown-item-project {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: #cbd5e1;
    text-decoration: none;
    background-color: transparent;
    border: none;
    text-align: left;
    width: 100%;
}

.dropdown-item-project:hover {
    background-color: var(--bg-sidebar-hover);
    color: white;
}

.dropdown-item-project.active {
    background-color: var(--primary-color);
    color: white;
}

.dropdown-item-project-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
    padding-right: 12px;
}

.dropdown-item-project-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item-project-client {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item-project.active .dropdown-item-project-client {
    color: #bfdbfe;
}

.dropdown-item-project-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.dropdown-item-project-price {
    font-size: 0.8rem;
    font-weight: 600;
    color: #cbd5e1;
}

.dropdown-item-project.active .dropdown-item-project-price {
    color: white;
}

/* ----------------------------------------------------
   Export Dropdown inside workspace
   ---------------------------------------------------- */
.export-dropdown-container {
    position: relative;
    display: inline-block;
}

.export-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 950;
    display: none;
    flex-direction: column;
    padding: 6px 0;
    min-width: 240px;
    animation: dropdownFadeIn 0.15s ease forwards;
}

.export-dropdown-menu.active {
    display: flex;
}

.export-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.export-dropdown-menu .dropdown-item:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.export-dropdown-menu .dropdown-item i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
}

.badge-rev {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: #1e293b;
    color: #94a3b8;
    border: 1px solid #334155;
    text-transform: uppercase;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.dropdown-item-project.active .badge-rev {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
}

.sidebar-header h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
}

.sidebar-header .btn-icon {
    background-color: #1e293b;
    color: white;
    border-color: #334155;
    width: 28px;
    height: 28px;
}
.sidebar-header .btn-icon:hover {
    background-color: var(--primary-color);
}

.project-list {
    flex: 1;
    padding: 10px;
}

.project-item {
    display: block;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.project-item:hover {
    background-color: var(--bg-sidebar-hover);
    color: white;
}

.project-item.active {
    background-color: var(--primary-color);
    color: white;
}

.project-item h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-item p {
    font-size: 0.75rem;
    color: #64748b;
}
.project-item.active p {
    color: #bfdbfe;
}

.project-item-meta {
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
}

.project-item-price {
    font-weight: 600;
    color: white;
}

.project-item-margin {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.1);
}

.project-item.active .project-item-margin {
    background-color: rgba(0, 0, 0, 0.15);
}

/* App Main Content */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--bg-main);
    padding: 24px;
}

/* Empty State */
.empty-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    color: var(--text-muted);
}

.empty-icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}
.empty-icon-wrapper i {
    font-size: 2.2rem;
    color: #94a3b8;
}

.empty-workspace h2 {
    color: var(--text-main);
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.empty-workspace p {
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Active Project Workspace */
.project-workspace {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.project-meta-header {
    background-color: var(--bg-panel);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.project-info-left h1 {
    font-size: 1.6rem;
    color: var(--text-main);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.project-info-left p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.project-info-left p i {
    margin-right: 6px;
}

.project-info-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.project-info-actions .btn {
    height: 34px;
    min-width: 172px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Dashboard Summary Cards */
.summary-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.stat-card {
    background-color: var(--bg-panel);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.cost .stat-icon {
    background-color: #f1f5f9;
    color: #475569;
}
.quote .stat-icon {
    background-color: #eff6ff;
    color: var(--primary-color);
}

.stat-details {
    flex: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-details h2 {
    font-size: 1.55rem;
    margin: 4px 0;
    letter-spacing: -0.5px;
}

.stat-breakdown {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.stat-breakdown .divider {
    color: #cbd5e1;
}

.stat-breakdown b {
    font-weight: 500;
    color: var(--text-main);
}

/* Profit and Loss Card dynamic styling */
.stat-card.profit.profit-state {
    border-left: 4px solid var(--success);
}
.stat-card.profit.profit-state .stat-icon {
    background-color: var(--success-light);
    color: var(--success);
}
.stat-card.profit.profit-state h2 {
    color: var(--success);
}

.stat-card.profit.loss-state {
    border-left: 4px solid var(--danger);
    background-color: #fffafb;
}
.stat-card.profit.loss-state .stat-icon {
    background-color: var(--danger-light);
    color: var(--danger);
}
.stat-card.profit.loss-state h2 {
    color: var(--danger);
}

/* Sub-sections Container */
.sections-container-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}

.sections-container-header h2 {
    font-size: 1.25rem;
}

/* Individual Subsection Panel */
.subsection-panel {
    background-color: var(--bg-panel);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    overflow: hidden;
}

.subsection-header {
    background-color: #f8fafc;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.subsection-title-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.subsection-title-area h3 {
    font-size: 1.05rem;
    color: var(--text-main);
}

.subsection-badge-count {
    font-size: 0.75rem;
    background-color: #e2e8f0;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.subsection-summary-info {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.85rem;
}

.sub-sum-cost b { color: var(--text-main); }
.sub-sum-quote b { color: var(--primary-color); }
.sub-sum-profit.profit b { color: var(--success); }
.sub-sum-profit.loss b { color: var(--danger); }

.subsection-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 1px solid var(--border-color);
    padding-left: 16px;
    margin-left: 8px;
}

/* Takeoff Table styling */
.takeoff-table-wrapper {
    overflow-x: auto;
    width: 100%;
}

.takeoff-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.takeoff-table th {
    background-color: #ffffff;
    color: var(--text-muted);
    font-weight: 500;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.takeoff-table td {
    padding: 8px 8px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.takeoff-table tbody tr:hover {
    background-color: #fafbfd;
}

/* Product Thumbnail Card */
.product-thumb-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-thumbnail {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border-color);
    background-color: #f8fafc;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.product-thumbnail:hover {
    transform: scale(1.08);
    border-color: var(--primary-color);
}

.thumbnail-placeholder {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background-color: #f1f5f9;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 1px dashed #cbd5e1;
}

/* Details Cell */
.product-details-cell .prod-title {
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 2px;
}

.product-details-cell .prod-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Inputs in Table */
.takeoff-table input[type="number"] {
    width: 72px;
    padding: 5px 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: right;
    transition: border var(--transition-fast);
}

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

.takeoff-table input[type="number"].qty-input {
    width: 54px;
    text-align: center;
    font-weight: 600;
    background-color: var(--primary-light);
    border-color: #bfdbfe;
    color: var(--primary-color);
}

.takeoff-table input[type="number"].qty-input:focus {
    background-color: white;
}

.takeoff-table input[type="number"].discount-input {
    width: 48px;
    text-align: center;
}

/* Right align numbers */
.text-right {
    text-align: right;
}

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

/* Empty Subsection state */
.empty-section-state {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-bottom: 1px dashed var(--border-color);
}
.empty-section-state i {
    font-size: 1.8rem;
    margin-bottom: 8px;
    color: #cbd5e1;
}

/* Subsection Footer */
.subsection-footer {
    padding: 14px 20px;
    background-color: #fafbfc;
    display: flex;
    justify-content: space-between;
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    background-color: var(--bg-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform var(--transition-normal);
}

.modal-container form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-large .modal-container {
    max-width: 1100px;
    height: 85vh;
}
.modal-large .modal-body {
    overflow-x: hidden;
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--text-main);
}

.modal-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.modal-close-btn:hover {
    background-color: #f1f5f9;
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Styling */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background-color: white;
    transition: border var(--transition-fast), box-shadow var(--transition-fast);
}

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

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

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

.grid-2-col {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 24px;
}

/* ==========================================================================
   Catalog Explorer & Manager styles
   ========================================================================== */
.explorer-body, .catalog-manager-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.explorer-filter-bar, .manager-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background-color: #f8fafc;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.explorer-filter-bar button, .manager-top-bar button {
    flex-shrink: 0 !important;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.search-input-wrapper {
    position: relative;
    flex: 1.5;
    min-width: 250px;
    max-width: 450px;
}

.search-input-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-input-wrapper input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.search-input-wrapper input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background-color: white;
    cursor: pointer;
    appearance: none;
    min-width: 150px;
    transition: all var(--transition-fast);
}
.select-wrapper select:hover {
    border-color: #cbd5e1;
}
.select-wrapper select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.select-wrapper::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.7rem;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
}

.explorer-table-wrapper {
    flex: 1;
    overflow: auto;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.data-table th {
    background-color: #f8fafc;
    padding: 12px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

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

/* Catalog Manager Table: fixed proportional columns so it always fits its
   container width instead of forcing a horizontal scrollbar */
#modal-catalog-manager .data-table {
    table-layout: fixed;
    font-size: 0.8rem;
}

#modal-catalog-manager .data-table th,
#modal-catalog-manager .data-table td {
    overflow-wrap: break-word;
}

#modal-catalog-manager .data-table th:nth-child(1),
#modal-catalog-manager .data-table td:nth-child(1) {
    width: 5%;
}

#modal-catalog-manager .data-table th:nth-child(2),
#modal-catalog-manager .data-table td:nth-child(2) {
    width: 8%;
}

#modal-catalog-manager .data-table th:nth-child(3),
#modal-catalog-manager .data-table td:nth-child(3) {
    width: 8%;
}

#modal-catalog-manager .data-table th:nth-child(4),
#modal-catalog-manager .data-table td:nth-child(4) {
    width: 33% !important;
    min-width: 0 !important; /* Override general .data-table 320px min-width */
}

#modal-catalog-manager .data-table th:nth-child(5),
#modal-catalog-manager .data-table td:nth-child(5) {
    width: 8%;
}

#modal-catalog-manager .data-table th:nth-child(6),
#modal-catalog-manager .data-table td:nth-child(6) {
    width: 8%;
}

#modal-catalog-manager .data-table th:nth-child(7),
#modal-catalog-manager .data-table td:nth-child(7) {
    width: 10%;
}

#modal-catalog-manager .data-table th:nth-child(8),
#modal-catalog-manager .data-table td:nth-child(8) {
    width: 10%;
}

#modal-catalog-manager .data-table th:nth-child(9),
#modal-catalog-manager .data-table td:nth-child(9) {
    width: 3%;
}

#modal-catalog-manager .data-table th:nth-child(10),
#modal-catalog-manager .data-table td:nth-child(10) {
    width: 7%;
    white-space: nowrap;
}

/* Give the catalog manager modal more room on larger screens */
#modal-catalog-manager .modal-container {
    max-width: 1300px;
}

#modal-catalog-manager .data-table td:nth-child(10) .row-actions {
    display: flex;
    justify-content: center;
    gap: 4px;
}

#modal-catalog-manager .data-table td:nth-child(10) .btn-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

/* Upload Image Preview UI */
.image-upload-preview-container {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-top: 6px;
}

.image-preview-box {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-md);
    border: 1.5px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #f8fafc;
    position: relative;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.image-preview-box:hover,
.image-preview-box:focus {
    border-color: var(--primary-color);
    background-color: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.image-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-box .placeholder-icon {
    font-size: 2rem;
    color: #cbd5e1;
}

.upload-btn-wrapper {
    flex: 1;
}

/* PDF upload container styling */
.pdf-upload-container {
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* PDF spec file styling link */
.pdf-spec-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background-color: #fef2f2;
    border: 1px solid #fee2e2;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.pdf-spec-link:hover {
    background-color: #fee2e2;
    border-color: #fca5a5;
    transform: scale(1.05);
}

/* ==========================================================================
   A4 simulated document sheet and editor
   ========================================================================== */
.a4-sheet {
    position: relative;
    background-color: white;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
    min-height: 297mm;
    display: flex;
    flex-direction: column;
    color: #0f172a;
    font-family: var(--font-body);
}

.a4-sheet [contenteditable="true"] {
    padding: 4px 8px;
    border: 1px dashed transparent;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.a4-sheet [contenteditable="true"]:hover {
    border-color: var(--border-hover);
    background-color: #fafbfc;
}

.a4-sheet [contenteditable="true"]:focus {
    border-color: var(--primary-color);
    background-color: white;
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

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

.proposal-summary-table th {
    font-weight: 600;
    color: #000;
    padding: 10px;
    border-bottom: 2px solid #1e293b;
}

.proposal-summary-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

/* ==========================================================================
   Image Lightbox
   ========================================================================== */
.lightbox-container {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.lightbox-container img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-md);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 3px solid white;
}

.lightbox-close-btn {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background-color: #1e293b;
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.active {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon {
    color: var(--success);
    font-size: 1.1rem;
}

.toast-icon.error {
    color: var(--danger);
}

/* ==========================================================================
   PRINT LAYOUT STYLES & MEDIA PRINT RULES
   ========================================================================== */
.print-only-header, .print-only-footer {
    display: none;
}

@media print {
    /* Hide screen UI */
    .app-header, 
    .app-sidebar, 
    .project-meta-header, 
    .sections-container-header, 
    .subsection-actions,
    .btn, 
    .toast,
    .modal-overlay:not(#modal-proposal-editor),
    .takeoff-table th:last-child,
    .takeoff-table td:last-child {
        display: none !important;
    }

    body.dashboard-body {
        background-color: #ffffff;
        color: #000000;
        height: auto;
        overflow: visible;
        display: block;
    }

    .app-container {
        display: block;
    }

    .app-main {
        display: block;
        padding: 0;
        overflow: visible;
        background-color: transparent;
    }

    .project-workspace {
        display: block;
        gap: 0;
    }

    /* Print Document Containers styling */
    .print-only-header {
        display: block;
        margin-bottom: 20px;
    }

    .print-header-grid {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .print-company-logo h2 {
        font-size: 1.3rem;
        color: #1e293b;
        margin-bottom: 4px;
    }

    .print-company-logo p {
        font-size: 0.8rem;
        color: #475569;
        margin-bottom: 2px;
    }

    .print-doc-title {
        text-align: right;
    }

    .print-doc-title h1 {
        font-size: 1.8rem;
        margin-bottom: 6px;
        color: #1e293b;
    }

    .print-doc-title p {
        font-size: 0.85rem;
        color: #475569;
    }

    .print-divider {
        border: none;
        border-top: 2px solid #1e293b;
        margin: 14px 0;
    }

    .print-project-details {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        font-size: 0.9rem;
        background-color: #f8fafc;
        padding: 12px;
        border-radius: 4px;
        border: 1px solid #cbd5e1;
        margin-bottom: 20px;
    }

    .print-project-details p {
        margin: 0;
    }

    #print-project-desc-line {
        grid-column: span 2;
    }

    /* Table changes for printing */
    .subsection-panel {
        box-shadow: none;
        border: 1px solid #94a3b8;
        border-radius: 0;
        margin-bottom: 30px;
        page-break-inside: avoid;
    }

    .subsection-header {
        background-color: #f1f5f9;
        border-bottom: 1px solid #94a3b8;
        padding: 10px 14px;
    }

    .subsection-title-area h3 {
        font-size: 0.95rem;
        font-weight: 700;
    }

    .subsection-badge-count {
        display: none;
    }

    .takeoff-table th {
        background-color: #f8fafc;
        border-bottom: 2px solid #475569;
        color: #000000;
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .takeoff-table td {
        padding: 6px 10px;
        border-bottom: 1px solid #cbd5e1;
        font-size: 0.78rem;
    }

    /* Convert input fields to plain text for print */
    .takeoff-table input[type="number"].table-number-input {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        text-align: right;
        font-weight: 500;
        width: auto;
        color: #000;
        -webkit-appearance: none;
        -moz-appearance: textfield;
        appearance: none;
    }
    .takeoff-table input[type="number"].table-number-input::-webkit-outer-spin-button,
    .takeoff-table input[type="number"].table-number-input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    /* Print Footer structure */
    .print-only-footer {
        display: block;
        margin-top: 30px;
        page-break-inside: avoid;
    }

    .print-totals-grid {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 40px;
    }

    .totals-col-left {
        flex: 1.2;
        font-size: 0.8rem;
        color: #475569;
    }

    .signature-line {
        margin-top: 20px;
        text-align: center;
        width: 250px;
    }
    .signature-line .preparer-sig-only {
        display: none;
    }
    .signature-line p {
        margin-bottom: 6px;
    }

    .totals-col-right {
        flex: 0.8;
    }

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

    .print-summary-table td {
        padding: 6px 10px;
        border-bottom: 1px solid #e2e8f0;
    }

    .print-summary-table .highlight-row {
        font-weight: 700;
        font-size: 0.95rem;
        border-top: 2px solid #1e293b;
        border-bottom: 2px double #1e293b;
        background-color: #f8fafc;
    }

    .print-summary-table .highlight-row-profit {
        font-weight: 700;
        color: #047857;
        background-color: #ecfdf5;
        border-bottom: 2px solid #047857;
    }

    /* ==========================================================
       Print Mode: Quotation Layout (Client-Facing, Hidden Costs)
       ========================================================== */
    body.print-mode-quotation .takeoff-table th:nth-child(5), /* Free Issue Checkbox */
    body.print-mode-quotation .takeoff-table td:nth-child(5),
    body.print-mode-quotation .takeoff-table th:nth-child(6), /* Cost Material */
    body.print-mode-quotation .takeoff-table td:nth-child(6),
    body.print-mode-quotation .takeoff-table th:nth-child(7), /* Cost Labor */
    body.print-mode-quotation .takeoff-table td:nth-child(7),
    body.print-mode-quotation .takeoff-table th:nth-child(11), /* Net Cost / Total Cost */
    body.print-mode-quotation .takeoff-table td:nth-child(11),
    body.print-mode-quotation .takeoff-table th:nth-child(13), /* Profit */
    body.print-mode-quotation .takeoff-table td:nth-child(13) {
        display: none !important;
    }

    body.print-mode-quotation .summary-cards-grid,
    body.print-mode-quotation .subsection-summary-info .sub-sum-cost,
    body.print-mode-quotation .subsection-summary-info .sub-sum-profit {
        display: none !important;
    }

    body.print-mode-quotation .internal-only {
        display: none !important;
    }

    /* ==========================================================
       Print Mode: BOM Layout (Internal-Facing, Costs & Profit)
       ========================================================== */
    body.print-mode-bom .takeoff-table th:nth-child(5), /* Free Issue Checkbox */
    body.print-mode-bom .takeoff-table td:nth-child(5),
    body.print-mode-bom .takeoff-table th:nth-child(8), /* Price Material */
    body.print-mode-bom .takeoff-table td:nth-child(8),
    body.print-mode-bom .takeoff-table th:nth-child(9), /* Price Labor */
    body.print-mode-bom .takeoff-table td:nth-child(9),
    body.print-mode-bom .takeoff-table th:nth-child(10), /* Discount */
    body.print-mode-bom .takeoff-table td:nth-child(10),
    body.print-mode-bom .takeoff-table th:nth-child(12), /* Total Sale */
    body.print-mode-bom .takeoff-table td:nth-child(12),
    body.print-mode-bom .takeoff-table th:nth-child(13), /* Profit */
    body.print-mode-bom .takeoff-table td:nth-child(13) {
        display: none !important;
    }

    body.print-mode-bom .summary-cards-grid,
    body.print-mode-bom .subsection-summary-info .sub-sum-quote,
    body.print-mode-bom .subsection-summary-info .sub-sum-profit,
    body.print-mode-bom .totals-col-right,
    body.print-mode-bom .print-note,
    body.print-mode-bom .signature-line .approver-sig-only {
        display: none !important;
    }

    body.print-mode-bom .signature-line .preparer-sig-only {
        display: block !important;
    }

    /* ==========================================================
       Print Mode: Free Issue Layout (Client-Supplied Material Report)
       ========================================================== */
    body.print-mode-free-issue .takeoff-table th:nth-child(5), /* Free Issue Checkbox */
    body.print-mode-free-issue .takeoff-table td:nth-child(5),
    body.print-mode-free-issue .takeoff-table th:nth-child(6), /* Cost Material */
    body.print-mode-free-issue .takeoff-table td:nth-child(6),
    body.print-mode-free-issue .takeoff-table th:nth-child(7), /* Cost Labor */
    body.print-mode-free-issue .takeoff-table td:nth-child(7),
    body.print-mode-free-issue .takeoff-table th:nth-child(8), /* Price Material */
    body.print-mode-free-issue .takeoff-table td:nth-child(8),
    body.print-mode-free-issue .takeoff-table th:nth-child(9), /* Price Labor */
    body.print-mode-free-issue .takeoff-table td:nth-child(9),
    body.print-mode-free-issue .takeoff-table th:nth-child(10), /* Discount */
    body.print-mode-free-issue .takeoff-table td:nth-child(10),
    body.print-mode-free-issue .takeoff-table th:nth-child(11), /* Total Cost */
    body.print-mode-free-issue .takeoff-table td:nth-child(11),
    body.print-mode-free-issue .takeoff-table th:nth-child(12), /* Total Quote */
    body.print-mode-free-issue .takeoff-table td:nth-child(12),
    body.print-mode-free-issue .takeoff-table th:nth-child(13), /* Profit */
    body.print-mode-free-issue .takeoff-table td:nth-child(13) {
        display: none !important;
    }

    body.print-mode-free-issue .summary-cards-grid,
    body.print-mode-free-issue .subsection-summary-info,
    body.print-mode-free-issue #print-totals-summary {
        display: none !important;
    }

    body.print-mode-free-issue .takeoff-table tbody tr:not(.free-issue-row) {
        display: none !important;
    }

    body.print-mode-free-issue .subsection-panel:not(:has(.free-issue-row)) {
        display: none !important;
    }

    /* ==========================================================
       Print Mode: Proposal Letter Layout (Custom editable page)
       ========================================================== */
    body.print-mode-proposal {
        background-color: white !important;
        color: black !important;
    }
    
    body.print-mode-proposal .a4-sheet {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        min-height: auto !important;
    }
    
    body.print-mode-proposal .a4-sheet [contenteditable="true"] {
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
    }

    body.print-mode-proposal .modal-header,
    body.print-mode-proposal .modal-footer {
        display: none !important;
    }
    
    body.print-mode-proposal #modal-proposal-editor {
        display: block !important;
        position: static !important;
        background: white !important;
        opacity: 1 !important;
        z-index: auto !important;
    }
    
    body.print-mode-proposal #modal-proposal-editor .modal-container {
        max-width: 100% !important;
        height: auto !important;
        box-shadow: none !important;
        transform: none !important;
        border: none !important;
        border-radius: 0 !important;
    }
    
    body.print-mode-proposal #modal-proposal-editor .modal-body {
        background-color: white !important;
        padding: 0 !important;
        overflow: visible !important;
    }
}

/* Responsive Grid adjustment */
@media (max-width: 1024px) {
    .summary-cards-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .app-container {
        flex-direction: column;
        overflow-y: auto;
    }
    
    .app-sidebar {
        width: 100% !important;
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid #1e293b;
    }
    
    .app-main {
        overflow-y: visible;
        padding: 16px;
    }
    
    .project-meta-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .project-info-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .sections-container-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .sections-container-header h2 {
        text-align: center;
    }
    
    .subsection-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .subsection-summary-info {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }
    
    .subsection-actions {
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding-top: 10px;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        height: auto;
        padding: 12px 16px;
        gap: 10px;
        align-items: stretch;
    }
    
    .header-logo {
        justify-content: center;
    }
    
    .header-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
    }
    
    .user-profile {
        border-left: none;
        padding-left: 0;
    }
    
    .modal-container {
        width: 95vw !important;
        max-height: 95vh !important;
        margin: 10px auto;
    }
}

/* Make the product description column spacious and easy to read */
.takeoff-table th:nth-child(2),
.takeoff-table td:nth-child(2),
.data-table th:nth-child(3),
.data-table td:nth-child(3),
.data-table th:nth-child(4),
.data-table td:nth-child(4) {
    min-width: 320px !important;
}

/* ==========================================================================
   Role User UI Masking
   ========================================================================== */
body.role-user .takeoff-table th:nth-child(6),
body.role-user .takeoff-table td:nth-child(6),
body.role-user .takeoff-table th:nth-child(7),
body.role-user .takeoff-table td:nth-child(7),
body.role-user .takeoff-table th:nth-child(8),
body.role-user .takeoff-table td:nth-child(8),
body.role-user .takeoff-table th:nth-child(9),
body.role-user .takeoff-table td:nth-child(9),
body.role-user .takeoff-table th:nth-child(10),
body.role-user .takeoff-table td:nth-child(10),
body.role-user .takeoff-table th:nth-child(11),
body.role-user .takeoff-table td:nth-child(11),
body.role-user .takeoff-table th:nth-child(12),
body.role-user .takeoff-table td:nth-child(12),
body.role-user .takeoff-table th:nth-child(13),
body.role-user .takeoff-table td:nth-child(13),
body.role-user .takeoff-table th:nth-child(14),
body.role-user .takeoff-table td:nth-child(14) {
    display: none !important;
}

body.role-user .data-table th:nth-child(6),
body.role-user .data-table td:nth-child(6),
body.role-user .data-table th:nth-child(7),
body.role-user .data-table td:nth-child(7) {
    display: none !important;
}

body.role-user #modal-rfq-detail .data-table th:nth-child(5),
body.role-user #modal-rfq-detail .data-table td:nth-child(5),
body.role-user #modal-rfq-detail .data-table th:nth-child(6),
body.role-user #modal-rfq-detail .data-table td:nth-child(6),
body.role-confidential #modal-rfq-detail .data-table th:nth-child(5),
body.role-confidential #modal-rfq-detail .data-table td:nth-child(5),
body.role-confidential #modal-rfq-detail .data-table th:nth-child(6),
body.role-confidential #modal-rfq-detail .data-table td:nth-child(6) {
    display: table-cell !important;
}

body.role-user .subsection-summary-info .sub-sum-cost,
body.role-user .subsection-summary-info .sub-sum-quote,
body.role-user .subsection-summary-info .sub-sum-profit {
    display: none !important;
}

body.role-user .stat-card.cost,
body.role-user .stat-card.quote,
body.role-user .stat-card.profit {
    display: none !important;
}

/* Role Confidential UI Masking (Sees selling prices, hides costs/profits) */
body.role-confidential .takeoff-table th:nth-child(6),
body.role-confidential .takeoff-table td:nth-child(6),
body.role-confidential .takeoff-table th:nth-child(7),
body.role-confidential .takeoff-table td:nth-child(7),
body.role-confidential .takeoff-table th:nth-child(11),
body.role-confidential .takeoff-table td:nth-child(11),
body.role-confidential .takeoff-table th:nth-child(13),
body.role-confidential .takeoff-table td:nth-child(13) {
    display: none !important;
}

body.role-confidential .data-table th:nth-child(6),
body.role-confidential .data-table td:nth-child(6),
body.role-confidential .data-table th:nth-child(7),
body.role-confidential .data-table td:nth-child(7) {
    display: none !important;
}

body.role-confidential .subsection-summary-info .sub-sum-cost,
body.role-confidential .subsection-summary-info .sub-sum-profit {
    display: none !important;
}

body.role-confidential .stat-card.cost,
body.role-confidential .stat-card.profit {
    display: none !important;
}

/* Contractor specific visibility overrides (allows them to fill proposal rates) */
body.role-contractor .takeoff-table th:nth-child(8),
body.role-contractor .takeoff-table td:nth-child(8),
body.role-contractor .takeoff-table th:nth-child(9),
body.role-contractor .takeoff-table td:nth-child(9),
body.role-contractor .takeoff-table th:nth-child(12),
body.role-contractor .takeoff-table td:nth-child(12) {
    display: table-cell !important;
}

body.role-contractor .subsection-summary-info .sub-sum-quote {
    display: inline !important;
}

body.role-contractor .stat-card.quote {
    display: block !important;
}

#modal-rfq-detail .data-table input.table-number-input {
    width: 100% !important;
    max-width: 250px !important;
    padding: 4px 6px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    text-align: right !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

#modal-rfq-detail .data-table th:nth-child(2),
#modal-rfq-detail .data-table td:nth-child(2) {
    min-width: 320px !important;
}

#modal-rfq-detail .data-table th:nth-child(3),
#modal-rfq-detail .data-table td:nth-child(3),
#modal-rfq-detail .data-table th:nth-child(4),
#modal-rfq-detail .data-table td:nth-child(4),
#modal-rfq-detail .data-table th:nth-child(5),
#modal-rfq-detail .data-table td:nth-child(5),
#modal-rfq-detail .data-table th:nth-child(6),
#modal-rfq-detail .data-table td:nth-child(6),
#modal-rfq-detail .data-table th:nth-child(7),
#modal-rfq-detail .data-table td:nth-child(7) {
    min-width: 0 !important;
}

/* ==========================================================================
   Admin Panel Tab & Forms Styles
   ========================================================================== */
.admin-panel-tabs .tab-btn {
    color: var(--text-muted);
    font-size: 1rem;
    transition: all var(--transition-fast);
}
.admin-panel-tabs .tab-btn:hover {
    color: var(--primary-color);
}
.admin-panel-tabs .tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color) !important;
}

.supervisors-list-wrapper label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
}
.supervisors-list-wrapper label:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
}
.supervisors-list-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ==========================================================================
   Revisions & Comparison Modal UI
   ========================================================================== */
#modal-revisions .modal-container {
    max-width: 1280px;
    width: 95vw;
    height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.revisions-modal-body {
    flex: 1;
    display: flex;
    gap: 24px;
    overflow: hidden;
    padding: 24px;
    background-color: var(--bg-main);
}

.revisions-sidebar {
    width: 340px;
    border-right: 1px solid var(--border-color);
    padding-right: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-panel);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.revisions-sidebar h4 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.revisions-list-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

/* Custom scrollbar for revisions list */
.revisions-list-container::-webkit-scrollbar {
    width: 6px;
}
.revisions-list-container::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.revision-card {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-panel);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.revision-card:hover {
    border-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.revision-card.active {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.1);
}

.revision-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.revision-card-num {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary-color);
    background-color: var(--primary-light);
    padding: 2px 8px;
    border-radius: 12px;
}

.revision-card.active .revision-card-num {
    background-color: var(--primary-color);
    color: #ffffff;
}

.revision-card-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.revision-card-author {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.revision-card-summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    word-break: break-word;
    border-top: 1px dashed var(--border-color);
    padding-top: 8px;
}

.revisions-comparison {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-panel);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.comparison-control-bar {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
    background-color: var(--bg-main);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

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

.comparison-selector-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comparison-select {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-panel);
    color: var(--text-main);
    min-width: 180px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.15s ease;
}

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

.comparison-arrow {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 20px;
}

.comparison-table-section {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.comparison-table-section h4 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Custom Diff formatting styling */
.diff-old {
    text-decoration: line-through;
    color: var(--danger-text);
    background-color: var(--danger-light);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: Consolas, monospace;
}
.diff-new {
    color: var(--success-text);
    background-color: var(--success-light);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: Consolas, monospace;
}
.diff-tag-added {
    color: var(--success-text);
    background-color: var(--success-light);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: Consolas, monospace;
    font-weight: 600;
}
.diff-removed-label {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Specific styling for revisions comparison table sizing & word wrapping */
.revisions-compare-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.revisions-compare-table th,
.revisions-compare-table td {
    word-wrap: break-word !important;
    word-break: break-word !important;
    white-space: normal !important;
    vertical-align: top !important; /* Align text at top for better reading */
}

/* Optimal column proportions for comparison */
.revisions-compare-table th:nth-child(1),
.revisions-compare-table td:nth-child(1) {
    width: 18% !important;
}

.revisions-compare-table th:nth-child(2),
.revisions-compare-table td:nth-child(2) {
    width: 35% !important;
}

.revisions-compare-table th:nth-child(3),
.revisions-compare-table td:nth-child(3) {
    width: 15% !important;
}

.revisions-compare-table th:nth-child(4),
.revisions-compare-table td:nth-child(4) {
    width: 32% !important;
}

/* Premium Form Card */
.form-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s, box-shadow 0.2s;
}

.form-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.form-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 0;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-card-title i {
    color: var(--primary-color);
}

/* Hide pagination controls since we are showing all items on a single page */
#explorer-pagination-container,
#manager-pagination-container {
    display: none !important;
}

/* Add shadow styling for Add Catalog Product button */
#btn-add-catalog-product {
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2) !important;
}
#btn-add-catalog-product:hover {
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3) !important;
}

/* ==========================================================================
   Project Document Vault & File Explorer Styles
   ========================================================================== */
#modal-project-docs .modal-body {
    display: flex;
    overflow: hidden;
}

.docs-sidebar {
    width: 250px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

@media (min-width: 1200px) {
    .docs-sidebar {
        width: 300px;
    }
}

@media (max-width: 768px) {
    #modal-project-docs .modal-body {
        flex-direction: column;
    }

    .docs-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color);
    }
}

.docs-folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    user-select: none;
}

.docs-folder-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.docs-folder-item.active {
    background: var(--primary-color);
    color: white;
    font-weight: 500;
}

.docs-folder-item.active i {
    color: white !important;
}

.docs-folder-item .folder-delete-btn {
    display: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px;
}

.docs-folder-item.active:hover .folder-delete-btn {
    display: inline-block;
}

.docs-folder-item .folder-delete-btn:hover {
    color: white;
}

.docs-dropzone.dragover {
    border-color: var(--primary-color) !important;
    background-color: rgba(67, 97, 238, 0.08) !important; /* light shade of primary-color */
    box-shadow: 0 0 10px rgba(67, 97, 238, 0.1);
}

.docs-table-wrapper tr.file-row:hover {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

.docs-table-wrapper tr.folder-row {
    cursor: pointer;
}

.docs-table-wrapper tr.folder-row:hover {
    background-color: rgba(0, 0, 0, 0.04) !important;
}

/* Document Vault Table Specific Layout */
.docs-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.docs-table th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.docs-table th:nth-child(1),
.docs-table td:nth-child(1) {
    width: 44% !important;
}

.docs-table th:nth-child(2),
.docs-table td:nth-child(2) {
    width: 8% !important;
    text-align: right !important;
}

.docs-table th:nth-child(3),
.docs-table td:nth-child(3) {
    width: 15% !important;
    min-width: 0 !important; /* Override general .data-table 320px min-width */
}

.docs-table th:nth-child(4),
.docs-table td:nth-child(4) {
    width: 14% !important;
}

.docs-table th:nth-child(5),
.docs-table td:nth-child(5) {
    width: 11% !important;
}

.docs-table th:nth-child(6),
.docs-table td:nth-child(6) {
    width: 8% !important;
    text-align: center !important;
}

/* Document Vault Modal Width Layout */
#modal-project-docs .modal-container {
    max-width: 1400px !important;
    width: 90% !important;
}

/* ==========================================
   Project Progress Styles
   ========================================== */
.progress-timeline-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.progress-form-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.progress-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-panel);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

.progress-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.progress-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.progress-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.progress-meta-item {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.progress-meta-item.datetime {
    font-weight: 700;
    color: var(--text-main);
}

.progress-meta-item.creator {
    font-weight: 500;
}

.progress-meta-item.system-badge {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 12px;
}

.progress-card-actions {
    display: flex;
    gap: 6px;
}

.progress-card-body-wrapper {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.progress-card-body-wrapper.no-image {
    display: block;
}

.progress-card-left-col {
    flex: 0 0 240px;
    width: 240px;
}

.progress-card-image-box {
    text-align: center;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.progress-card-img {
    width: 100%;
    max-height: 240px;
    border-radius: var(--radius-sm);
    cursor: zoom-in;
    display: block;
    object-fit: cover;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.progress-card-img:hover {
    opacity: 0.95;
    transform: scale(1.01);
}

.progress-card-img-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 600;
    text-align: center;
}

.progress-card-right-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.progress-card-section {
    font-size: 0.95rem;
}

.progress-card-section-label {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.progress-card-section-content {
    color: var(--text-main);
    line-height: 1.5;
    word-break: break-word;
}

/* Image Dropzone Hovering */
.progress-image-dropzone.hover {
    border-color: var(--primary-color) !important;
    background-color: rgba(37, 99, 235, 0.05) !important;
}

/* Voice input styling */
.textarea-voice-wrapper textarea {
    padding-right: 36px !important;
}

.btn-voice-input {
    outline: none;
    border-radius: 50% !important;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-voice-input:hover {
    color: var(--danger) !important;
    background-color: rgba(239, 68, 68, 0.1) !important;
}

/* Print progress report styling */
@media print {
    body.print-mode-progress {
        background-color: white !important;
        color: black !important;
    }
    
    body.print-mode-progress .app-container,
    body.print-mode-progress .print-only-header,
    body.print-mode-progress #print-totals-summary,
    body.print-mode-progress .modal-overlay {
        display: none !important;
    }
    
    body.print-mode-progress #print-progress-report-container {
        display: block !important;
        background: white !important;
        color: black !important;
        padding: 20px !important;
    }
    
    .print-progress-header {
        border-bottom: 2px solid #334155;
        padding-bottom: 12px;
        margin-bottom: 25px;
    }
    
    .print-progress-title {
        font-size: 1.6rem;
        font-weight: 700;
        color: #1e293b;
        margin: 0;
    }
    
    .print-progress-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        font-size: 0.85rem;
        color: #475569;
        margin-top: 8px;
    }
    
    .print-progress-system-section {
        margin-bottom: 30px;
        page-break-inside: avoid;
    }
    
    .print-progress-system-title {
        font-size: 1.15rem;
        font-weight: 700;
        color: #0f172a;
        background-color: #f1f5f9;
        padding: 6px 12px;
        border-left: 4px solid #3b82f6;
        margin-bottom: 15px;
        border-bottom: 1px solid #cbd5e1;
    }
    
    .print-progress-card {
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        padding: 15px;
        margin-bottom: 15px;
        page-break-inside: avoid;
        background: #ffffff;
    }
    
    .print-progress-card-meta {
        font-size: 0.8rem;
        color: #64748b;
        margin-bottom: 10px;
        display: flex;
        justify-content: space-between;
        border-bottom: 1px dashed #e2e8f0;
        padding-bottom: 6px;
    }
    
    .print-progress-card-body {
        display: flex;
        gap: 20px;
    }
    
    .print-progress-card-image {
        flex: 0 0 250px;
        max-width: 250px;
    }
    
    .print-progress-card-img {
        width: 100%;
        max-height: 180px;
        object-fit: contain;
        border-radius: 4px;
        border: 1px solid #cbd5e1;
    }
    
    .print-progress-card-img-title {
        font-size: 0.75rem;
        color: #64748b;
        text-align: center;
        margin-top: 4px;
        font-weight: 600;
    }
    
    .print-progress-card-details {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .print-progress-card-section {
        font-size: 0.85rem;
    }
    
    .print-progress-card-section-label {
        font-weight: 700;
        color: #475569;
        margin-bottom: 2px;
    }
    
    .print-progress-card-section-content {
        color: #0f172a;
        white-space: pre-wrap;
    }
}

/* Mobile UX/UI Optimization for Project Progress Modal */
@media (max-width: 768px) {
    #modal-project-progress .modal-body {
        flex-direction: column !important;
        overflow-y: auto !important;
        padding: 10px !important;
        gap: 15px !important;
    }
    
    #modal-project-progress .modal-container {
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
    
    /* Toggle panel visibility to show only one at a time on mobile */
    #modal-project-progress.form-open .progress-timeline-panel {
        display: none !important;
    }
    
    #modal-project-progress:not(.form-open) .progress-form-panel {
        display: none !important;
    }
    
    #modal-project-progress.form-open .progress-form-panel {
        display: flex !important;
        flex: 1 !important;
        width: 100% !important;
    }
    
    /* Optimize buttons bar inside timeline */
    #modal-project-progress .progress-timeline-panel > div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    
    #modal-project-progress .progress-timeline-panel > div:first-child > div {
        display: flex !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    #modal-project-progress .progress-timeline-panel > div:first-child > div > button {
        flex: 1 !important;
        justify-content: center !important;
        padding: 10px 8px !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
    }

    /* Optimize camera preview layout on mobile */
    #progress-camera-container {
        max-height: 250px !important;
    }
    
    /* Optimize cards in timeline for mobile */
    .progress-card {
        padding: 12px !important;
        margin-bottom: 12px !important;
    }
    
    .progress-card-img {
        max-height: 200px !important;
        width: 100% !important;
        object-fit: contain !important;
    }
}

/* FAT Report Manager Styling */
.fat-report-list-item {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.25s ease-in-out;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.fat-report-list-item:hover {
    border-color: #cbd5e1 !important;
    background-color: #f8fafc !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.fat-report-list-item.active {
    border-color: #cbd5e1 !important;
    background-color: #eff6ff !important;
    box-shadow: inset 4px 0 0 var(--primary-color), var(--shadow-sm);
}
.fat-report-list-item .btn-delete-fat {
    opacity: 0;
    visibility: hidden;
}
.fat-report-list-item:hover .btn-delete-fat {
    opacity: 1;
    visibility: visible;
}

/* Test Script Manager Styling */
.test-script-list-item {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.25s ease-in-out;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.test-script-list-item:hover {
    border-color: #cbd5e1 !important;
    background-color: #f8fafc !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.test-script-list-item.active {
    border-color: #cbd5e1 !important;
    background-color: #eff6ff !important;
    box-shadow: inset 4px 0 0 var(--primary-color), var(--shadow-sm);
}

.btn-delete-fat {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.btn-delete-fat:hover {
    background-color: var(--danger-light);
    color: var(--danger) !important;
}

/* Custom Premium Checkbox Buttons */
.fat-check-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.fat-check-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    color: #94a3b8;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.fat-check-btn.pass:hover {
    border-color: #34d399;
    color: #34d399;
    background-color: #ecfdf5;
}
.fat-check-btn.fail:hover {
    border-color: #f87171;
    color: #f87171;
    background-color: #fef2f2;
}

.fat-chk-pass:checked + .fat-check-btn.pass {
    border-color: var(--success) !important;
    background-color: var(--success) !important;
    color: white !important;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
    transform: scale(1.05);
}
.fat-chk-fail:checked + .fat-check-btn.fail {
    border-color: var(--danger) !important;
    background-color: var(--danger) !important;
    color: white !important;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
    transform: scale(1.05);
}

/* Fix Checklist Table columns and wrap text */
#table-fat-items {
    table-layout: fixed;
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0;
}
#table-fat-items tr {
    transition: background-color 0.15s ease;
}
#table-fat-items tbody tr:hover {
    background-color: #f8fafc !important;
}
#table-fat-items td {
    white-space: normal !important;
    word-break: break-word !important;
    vertical-align: middle !important;
    padding: 14px 12px !important;
    border-bottom: 1px solid #f1f5f9;
    border-left: none !important;
    border-right: none !important;
}
#table-fat-items th {
    padding: 14px 12px !important;
    background-color: #f1f5f9 !important;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
    border-left: none !important;
    border-right: none !important;
}

/* Metadata Card Styles */
.fat-meta-card {
    background: white;
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.02);
    padding: 20px 24px 12px 24px;
    margin-bottom: 20px;
    transition: box-shadow 0.3s ease, padding-bottom 0.2s ease;
}
.fat-meta-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04), 0 2px 5px rgba(0, 0, 0, 0.03);
}
.fat-meta-card h4 {
    margin-top: 0 !important;
    margin-bottom: 15px !important;
    font-size: 1.05rem;
    font-weight: 600;
    color: #334155 !important;
}
.fat-meta-card h4 i {
    color: var(--primary-color);
    background-color: #eff6ff;
    padding: 6px;
    border-radius: 6px;
}
.fat-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.fat-meta-grid .form-group {
    margin-bottom: 0 !important;
}
.fat-meta-grid label {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}
.fat-meta-grid input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: border-color 0.2s;
    background-color: #fafafa;
}
.fat-meta-grid input:focus {
    border-color: var(--primary-color);
    background-color: white;
    outline: none;
}
.fat-meta-grid input:disabled {
    background-color: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

/* Style table input fields */
.fat-input-remarks {
    width: 100%;
    height: 36px !important;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #fafafa;
    transition: all 0.2s;
}
.fat-input-remarks:focus {
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}
.fat-input-remarks:disabled {
    background-color: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

/* Formal PDF-Style Preview Styles */
.a4-preview-page {
    background: white;
    width: 100%;
    max-width: 820px;
    margin: 0 auto 30px auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.02);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 25px 40px;
    font-family: "TH Sarabun New", "Angsana New", "Segoe UI", sans-serif;
    color: #000;
    line-height: 1.15;
}

.formal-input {
    border: 1px dashed transparent !important;
    background: transparent !important;
    width: 100%;
    height: 100%;
    min-height: 22px;
    padding: 1px 4px;
    font-family: inherit;
    font-size: 15px;
    color: inherit;
    transition: all 0.15s ease;
}
.formal-input:hover {
    border-color: #cbd5e1 !important;
    background: #f8fafc !important;
}
.formal-input:focus {
    border-color: var(--primary-color) !important;
    background: white !important;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    border-radius: 4px;
}
.formal-input:disabled {
    cursor: not-allowed;
    background: transparent !important;
    border-color: transparent !important;
}

.print-chk-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 2px solid #000;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    background: #fff;
    transition: all 0.15s ease;
    vertical-align: middle;
}
.print-chk-label:hover {
    border-color: var(--primary-color);
    background: #f1f5f9;
}
.print-chk-label input {
    display: none;
}
.print-chk-label span {
    display: none;
    font-weight: bold;
    font-size: 15px;
    color: #000;
    line-height: 1;
}
.print-chk-label input:checked + span {
    display: flex;
    align-items: center;
    justify-content: center;
}

.formal-checklist-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    margin-bottom: 10px;
    font-family: "TH Sarabun New", sans-serif;
    color: #000;
}
.formal-checklist-table th, .formal-checklist-table td {
    border: 1px solid #000 !important;
    padding: 2px 4px !important;
    text-align: left;
    vertical-align: middle;
}
.formal-checklist-table th {
    background: #f2f2f2 !important;
    font-weight: bold;
    text-align: center;
    color: #000 !important;
    font-size: 15px !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* Explicit Overrides to bypass legacy #table-fat-items settings in .a4-preview-page */
.a4-preview-page #table-fat-items {
    border-collapse: collapse !important;
    width: 100% !important;
}
.a4-preview-page #table-fat-items td {
    white-space: normal !important;
    word-break: break-word !important;
    vertical-align: middle !important;
    padding: 2px 4px !important;
    border: 1px solid #000 !important;
    border-bottom: 1px solid #000 !important;
    background-color: transparent;
}
.a4-preview-page #table-fat-items tr[style*="background:#f2f2f2"] td,
.a4-preview-page #table-fat-items tr[style*="background: rgb(242, 242, 242)"] td {
    background-color: #f2f2f2 !important;
}
.a4-preview-page #table-fat-items th {
    padding: 4px 4px !important;
    background-color: #f2f2f2 !important;
    color: #000 !important;
    font-size: 15px !important;
    font-weight: bold !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    border: 1px solid #000 !important;
}

/* Responsive styles for FAT Report Manager Modal (PC, Tablet, Mobile) */
@media (max-width: 991px) {
    #modal-project-fat .modal-container {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    #modal-project-fat .modal-body {
        flex-direction: column !important;
        overflow: hidden !important;
    }
    #modal-project-fat .fat-sidebar {
        width: 100% !important;
        min-width: 0 !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color);
        max-height: 80px !important;
        padding: 8px 15px !important;
        flex-shrink: 0 !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
        overflow: hidden !important;
        background: #f8fafc;
    }
    #modal-project-fat .fat-sidebar [data-i18n="fat_report_list_label"] {
        display: none !important; /* Hide list label to save precious screen space */
    }
    #modal-project-fat #btn-new-fat-trigger {
        margin-bottom: 0 !important;
        width: auto !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        padding: 8px 14px !important;
    }
    #modal-project-fat #fat-reports-list-container {
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        gap: 10px !important;
        flex: 1 !important;
        height: 100% !important;
        align-items: center !important;
        padding-bottom: 0 !important;
    }
    #modal-project-fat .fat-report-list-item {
        min-width: 200px !important;
        max-width: 250px !important;
        height: 52px !important; /* Fixed height for horizontal cards */
        margin-bottom: 0 !important;
        padding: 6px 12px !important;
        flex-direction: column !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        gap: 2px !important;
    }
    #modal-project-fat .fat-report-list-item div {
        margin-top: 0 !important;
        font-size: 0.7rem !important;
    }
    #modal-project-fat .fat-report-list-item span {
        font-size: 0.8rem !important;
    }
    #modal-project-fat .fat-report-list-item .btn-delete-fat {
        opacity: 1 !important;
        visibility: visible !important;
    }
    #modal-project-fat .fat-main-content {
        padding: 12px !important;
        overflow: auto !important;
    }
    #modal-project-fat .modal-footer {
        padding: 10px 15px !important;
    }

    /* Responsive Test Script styling */
    #modal-project-test-script .test-script-sidebar {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        max-height: 90px !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        gap: 10px !important;
        padding: 10px 16px !important;
        align-items: center !important;
        padding-bottom: 0 !important;
    }
    #modal-project-test-script .test-script-list-item {
        min-width: 200px !important;
        max-width: 250px !important;
        height: 52px !important;
        margin-bottom: 0 !important;
        padding: 6px 12px !important;
        flex-direction: column !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        gap: 2px !important;
    }
    #modal-project-test-script .test-script-list-item div {
        margin-top: 0 !important;
        font-size: 0.7rem !important;
    }
    #modal-project-test-script .test-script-list-item span {
        font-size: 0.8rem !important;
    }
    #modal-project-test-script .test-script-main-content {
        padding: 12px !important;
        overflow: auto !important;
    }
    #modal-project-test-script .modal-footer {
        padding: 10px 15px !important;
    }

    .a4-preview-page {
        min-width: 750px !important; /* Keep readable size on small screens */
        padding: 15px 25px !important;
    }
}

@media (max-width: 767px) {
    #modal-project-fat .fat-sidebar {
        max-height: 70px !important;
        padding: 6px 10px !important;
    }
    #modal-project-fat #btn-new-fat-trigger {
        font-size: 0.75rem !important;
        padding: 6px 10px !important;
    }
    #modal-project-fat .fat-report-list-item {
        min-width: 170px !important;
        height: 48px !important;
    }
    #modal-project-fat .fat-main-content {
        padding: 6px !important;
    }

    /* Responsive Test Script styling */
    #modal-project-test-script .test-script-sidebar {
        max-height: 70px !important;
        padding: 6px 10px !important;
    }
    #modal-project-test-script .test-script-list-item {
        min-width: 170px !important;
        height: 48px !important;
    }
    #modal-project-test-script .test-script-main-content {
        padding: 6px !important;
    }
}

/* ==========================================================================
   Product Detail Modal Responsive & Visual Enhancement (Mobile, Tablet, PC)
   ========================================================================== */

/* Main modal container custom sizing & centering */
.product-detail-container {
    max-width: 860px !important;
    width: 92vw;
    max-height: 88vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
}

.modal-title-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-title-area h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-title-area .modal-subtitle {
    margin-top: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Tab Navigation inside Modal */
.product-detail-tabs {
    display: flex;
    gap: 4px;
    background-color: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
    overflow-x: auto;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    -ms-overflow-style: none; /* Hide scrollbar for IE/Edge */
    position: sticky;
    top: 0;
    z-index: 50;
}

.product-detail-tabs::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
}

.tab-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
    border: 1px solid transparent;
}

.tab-item:hover {
    color: var(--primary-color);
    background-color: #eff6ff;
}

.tab-item.active {
    color: var(--primary-color);
    background-color: #eff6ff;
    border-color: rgba(37, 99, 235, 0.15);
}

.tab-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    transition: all var(--transition-fast);
}

.tab-item.active .tab-dot {
    background-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.product-detail-body {
    padding: 24px;
    overflow-y: auto;
    scroll-behavior: smooth;
    background-color: #f8fafc;
}

/* Enhancing Cards in Form */
.product-detail-body .form-card {
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    background: var(--bg-panel);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.product-detail-body .form-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

.title-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary-color);
    font-size: 0.9rem;
}

.product-detail-body .form-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-main);
    padding-bottom: 12px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

/* Grids Setup */
.form-grid-responsive-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-grid-responsive-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.form-grid-responsive-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.card-last-row {
    margin-bottom: 0 !important;
}

/* Media upload area styling */
.media-upload-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.image-preview-container {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    outline: none;
    margin: 0 auto 12px;
    background-color: var(--bg-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.image-preview-container:focus, .image-preview-container:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.image-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.image-upload-wrapper, .pdf-upload-wrapper {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    margin-bottom: 12px;
    background-color: #fafbfc;
    transition: all var(--transition-fast);
}

.image-upload-wrapper:hover, .pdf-upload-wrapper:hover {
    border-color: var(--primary-color);
    background-color: #f0f7ff;
}

.media-btn-group {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.media-btn-group button {
    flex: 1;
}

.media-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 8px 0 0;
}

.media-url-label {
    margin-top: 12px;
}

.pdf-status-container {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 12px 0;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pdf-main-icon {
    font-size: 2.2rem;
    margin-bottom: 6px;
}

.pdf-status-text {
    font-weight: 500;
}

.quote-upload-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    background-color: #f8fafc;
}

.quote-status-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quote-icon {
    font-size: 1.1rem;
}

/* Supplier section web button align */
.supplier-website-btn-group {
    display: flex;
    align-items: flex-end;
}

.supplier-web-wrapper {
    width: 100%;
}

.supplier-web-wrapper a {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Footer elements styling */
.product-detail-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: #ffffff;
}

.btn-save-detail {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1d4ed8 100%);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.25);
    color: white;
}

.btn-save-detail:hover {
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

/* ==========================================================================
   Responsive Breakpoints for the product detail modal
   ========================================================================== */

/* Tablet viewports (Landscape/Portrait max 1024px) */
@media (max-width: 1024px) {
    .product-detail-container {
        max-width: 780px !important;
        max-height: 92vh;
    }
}

/* Medium device viewports (Tablet vertical & Small laptop max 768px) */
@media (max-width: 768px) {
    .product-detail-container {
        max-width: 95vw !important;
        max-height: 94vh;
    }
    
    .form-grid-responsive-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small mobile devices (max 600px) - Convert to full screen wizard experience */
@media (max-width: 600px) {
    .product-detail-container {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0;
        margin: 0;
    }
    
    .product-detail-body {
        padding: 16px;
    }
    
    .product-detail-body .form-card {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: var(--radius-sm);
    }

    .form-grid-responsive-2, .form-grid-responsive-3, .form-grid-responsive-4, .media-upload-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .supplier-website-btn-group {
        align-items: stretch;
        margin-top: -4px;
    }
    
    .supplier-web-wrapper a {
        height: 40px;
    }
    
    .product-detail-footer {
        padding: 12px 16px;
        flex-direction: column-reverse;
        gap: 8px;
    }
    
    .product-detail-footer button {
        width: 100%;
    }
    
    .tab-label {
        display: none; /* Hide text on mobile tabs to save screen space */
    }
    
    .tab-item {
        padding: 8px 12px;
    }
}

/* Ultra small mobile screen adjustment */
@media (max-width: 360px) {
    .product-detail-tabs {
        padding: 8px 10px;
    }
    
    .tab-item {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

/* ==========================================
   Internal Chat Custom Styles (Stickers, Emojis, Highlights, Images)
   ========================================== */

/* Emoji popover styling */
.chat-emoji-popover {
    border: 1px solid var(--border-color);
    background-color: var(--bg-panel);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.emoji-tab-btn {
    border: none;
    background: transparent;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.emoji-tab-btn:hover {
    color: var(--text-main);
}

.emoji-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.popover-content-pane span.emoji-item {
    font-size: 1.4rem;
    cursor: pointer;
    transition: transform 0.1s ease;
    user-select: none;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.popover-content-pane span.emoji-item:hover {
    transform: scale(1.2);
    background-color: var(--bg-hover);
}

.popover-content-pane span.sticker-item {
    font-size: 2.2rem;
    cursor: pointer;
    transition: transform 0.15s ease;
    user-select: none;
    padding: 6px;
    border-radius: var(--radius-md);
}

.popover-content-pane span.sticker-item:hover {
    transform: scale(1.15);
    background-color: var(--bg-hover);
}

/* Highlight style for chat message search */
.chat-highlight {
    background-color: #fef08a !important; /* light yellow */
    color: #1e293b !important; /* dark slate */
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Chat Image styling */
.chat-image-preview {
    max-width: 100%;
    border-radius: var(--radius-md);
    transition: opacity 0.2s ease;
}

.chat-image-preview:hover {
    opacity: 0.95;
}

/* Hide background and shadow for sticker message bubble */
.chat-sticker-bubble {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Premium Modern Chat Input Composer Bar */
.modal-container form#form-chat-send {
    display: flex !important;
    flex-direction: row !important;
    flex: none !important;
    overflow: visible !important;
    gap: 10px;
    padding: 14px 20px !important;
    background-color: var(--bg-panel) !important;
    border-top: 1px solid var(--border-color) !important;
    align-items: center !important;
}

/* Make image & emoji buttons icon-only and minimal */
#form-chat-send button.btn-outline {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    font-size: 1.25rem !important;
    padding: 8px !important;
    height: 40px !important;
    width: 40px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s, color 0.2s !important;
    cursor: pointer !important;
    box-shadow: none !important;
}

#form-chat-send button.btn-outline:hover {
    background: var(--bg-hover) !important;
    color: var(--primary-color) !important;
}

/* Beautiful modern rounded text input */
#form-chat-send #chat-message-input {
    border-radius: 24px !important;
    border: 1px solid var(--border-color) !important;
    background-color: var(--bg-hover) !important;
    padding: 10px 18px !important;
    height: 40px !important;
    font-size: 0.92rem !important;
    outline: none !important;
    transition: border-color 0.2s, background-color 0.2s !important;
}

#form-chat-send #chat-message-input:focus {
    border-color: var(--primary-color) !important;
    background-color: var(--bg-panel) !important;
}

/* Premium circular send button */
#form-chat-send button.btn-primary {
    background: var(--primary-color) !important;
    border: none !important;
    color: white !important;
    border-radius: 50% !important;
    height: 40px !important;
    width: 40px !important;
    min-width: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2) !important;
    transition: transform 0.2s, background-color 0.2s !important;
    cursor: pointer !important;
}

#form-chat-send button.btn-primary:hover {
    background: var(--primary-dark, #1d4ed8) !important;
    transform: scale(1.05) !important;
}

#form-chat-send button.btn-primary:active {
    transform: scale(0.95) !important;
}

/* Customize Left Conversations Panel items */
.chat-conversations-panel {
    background-color: var(--bg-panel) !important;
}

#chat-conversations-list {
    border-top: 1px solid var(--border-color) !important;
}

.chat-conversations-list-item:hover {
    background-color: var(--bg-hover) !important;
}

/* Emoji Popover bottom adjustment for larger composer */
#chat-emoji-popover {
    bottom: 68px !important;
    left: 20px !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
}

/* Online status indicator dot */
.online-status-dot {
    width: 10px;
    height: 10px;
    background-color: #10b981; /* green */
    border: 2px solid var(--bg-panel);
    border-radius: 50%;
    position: absolute;
    bottom: 0;
    right: 0;
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.4);
    z-index: 2;
}

/* Flashing recording dot animation */
.recording-dot {
    animation: flash-recording-dot 1s infinite alternate;
}

@keyframes flash-recording-dot {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0.3;
        transform: scale(0.85);
    }
}

/* Style for mic button specifically */
#btn-chat-mic {
    color: var(--text-muted) !important;
}
#btn-chat-mic.recording-active {
    color: #ef4444 !important;
    background-color: #fee2e2 !important;
}

/* Adjust avatar relative wrapper for online dot placement */
.chat-avatar-wrapper {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   B2B Skylog Dark Theme Overrides & Mobile Responsive Cards
   ========================================================================== */

/* Active System accordion outline */
.section-card.active-system {
    border: 1.5px solid var(--primary-light) !important;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

/* Clean rounded white boxes for product spool thumbnails in takeoff list */
.product-thumb-cell, .prod-thumb {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #ffffff !important; /* Force clean crisp white background for images */
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    overflow: hidden;
    margin: 0 auto;
}

.product-thumb-cell img, .prod-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.product-thumb-cell i, .prod-thumb i {
    color: #475569 !important;
}

/* Hardcoded light background overrides for dark mode */
.app-header {
    background-color: var(--bg-panel) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.stat-card.cost .stat-icon {
    background-color: var(--primary-glow) !important;
    color: var(--primary-light) !important;
}

.stat-card.quote .stat-icon {
    background-color: var(--primary-glow) !important;
    color: var(--primary-light) !important;
}

.stat-card.profit .stat-icon {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: var(--success-text) !important;
}

.stat-card {
    background-color: var(--bg-panel) !important;
    border-color: var(--border-color) !important;
}

.modal-content, .modal-container {
    background-color: var(--bg-panel) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
}

.form-control, input, select, textarea {
    background-color: var(--bg-canvas) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
}

.docs-sidebar, .fat-sidebar, .test-script-sidebar {
    background-color: var(--bg-sidebar) !important;
    border-right: 1px solid var(--border-color) !important;
}

.docs-main, .fat-main-content, .test-script-main-content {
    background-color: var(--bg-canvas) !important;
}

.takeoff-table th {
    background-color: rgba(0, 0, 0, 0.25) !important;
    color: var(--text-muted) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.takeoff-table td {
    border-bottom: 1px solid var(--border-color) !important;
}

.takeoff-table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.02) !important;
}

.empty-section-state {
    color: var(--text-muted) !important;
}

.project-selector-dropdown {
    background-color: var(--bg-panel) !important;
    border: 1px solid var(--border-color) !important;
}

.dropdown-header {
    border-bottom: 1px solid var(--border-color) !important;
}

.dropdown-search {
    border-bottom: 1px solid var(--border-color) !important;
}

.dropdown-list .project-item:hover {
    background-color: var(--bg-sidebar-hover) !important;
}

.dropdown-list .project-item.active {
    background-color: var(--primary-glow) !important;
}

/* Mobile Takeoff Cards List */
.takeoff-mobile-cards-list {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.mobile-section-header-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    grid-column: 1 / -1; /* Span full grid width */
}

.mobile-item-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

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

.mobile-item-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.mobile-item-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.88rem;
}

.mobile-qty-badge-btn {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--primary-light);
    color: var(--primary-light);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    margin-top: 4px;
    max-width: fit-content;
}

.mobile-item-pricing {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    justify-content: center;
}

.mobile-item-pricing .price-lbl {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.mobile-item-pricing .price-val {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Responsive overrides to hide desktop table, show grid cards, and add safe area paddings */
@media (max-width: 1024px) {
    /* Responsive auto grid layout for stats cards deck instead of forcing 1fr column on iPad landscape */
    .summary-cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .takeoff-table {
        display: none !important;
    }
    .takeoff-mobile-cards-list {
        display: grid !important;
    }
    .project-meta-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    .project-info-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
    }
    .app-main {
        padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)) !important;
    }
    .modal-overlay {
        padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)) !important;
        box-sizing: border-box;
    }
    .modal-container {
        width: 100% !important;
        max-height: calc(100% - 32px) !important;
        margin: auto !important;
    }
}

/* ==========================================================================
   iPad Split-Pane & iPhone Bottom Navigation Styles
   ========================================================================== */

/* Mobile Bottom Navigation Bar (iPhone View) */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    display: none; /* Hidden on desktop */
    grid-template-columns: repeat(4, 1fr);
    z-index: 999;
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: content-box;
}

.mobile-nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.mobile-nav-tab i {
    font-size: 1.25rem;
}

.mobile-nav-tab.active {
    color: var(--primary-light);
}

/* iPad Split-Pane Layout */
@media (min-width: 768px) and (max-width: 1024px) {
    .project-workspace-split-container {
        display: grid !important;
        grid-template-columns: 300px 1fr !important;
        gap: 20px !important;
        align-items: start;
    }
    
    .project-sections-list {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        max-height: calc(100vh - 240px);
        overflow-y: auto !important;
        border-right: 1px solid var(--border-color);
        padding-right: 16px;
    }
    
    /* Make system accordions act as split view sidebar items */
    .project-sections-list .subsection-panel {
        cursor: pointer;
        transition: var(--transition-normal);
        border: 1px solid var(--border-color);
    }
    
    .project-sections-list .subsection-panel:hover {
        border-color: var(--border-hover);
        background-color: rgba(255,255,255,0.01);
    }
    
    .project-sections-list .subsection-panel.active-system {
        border: 1.5px solid var(--primary-light) !important;
        background-color: var(--primary-glow) !important;
    }
    
    /* Hide the takeoff tables inside left sidebar list */
    .project-sections-list .subsection-panel .takeoff-table-wrapper {
        display: none !important;
    }
    
    /* Reveal the right split panel */
    .ipad-active-system-detail {
        display: block !important;
        background-color: var(--bg-panel);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        padding: 20px;
        min-height: calc(100vh - 240px);
        max-height: calc(100vh - 240px);
        overflow-y: auto;
    }
}

/* Show bottom navigation bar and spacing on phone screens */
@media (max-width: 600px) {
    .mobile-bottom-nav {
        display: grid !important;
    }
    
    body.dashboard-body {
        padding-bottom: 60px !important; /* Safety room for fixed bottom bar */
    }
    
    /* Hide sidebar and print layouts on mobile */
    .app-sidebar {
        display: none !important;
    }
}



