:root {
    --primary: #1e293b; --primary-hover: #0f172a; --accent: #3b82f6; --accent-hover: #2563eb;
    --danger: #ef4444; --success: #10b981; --bg-body: #f1f5f9; --bg-card: #ffffff;
    --text-main: #0f172a; --text-muted: #64748b; --border: #e2e8f0; --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

html { font-size: 16px; }
body, html { margin: 0; padding: 0; font-family: 'Inter', sans-serif; background-color: var(--bg-body); color: var(--text-main); height: 100%; overflow-x: hidden; }
/* Only apply zoom on larger screens - mobile stays at normal scale */
@media (min-width: 1024px) {
    body { zoom: 0.8; }
}
* { box-sizing: border-box; max-width: 100%; }
img, video, iframe { max-width: 100%; height: auto; }
button { font-family: inherit; }
input, select, textarea { max-width: 100%; }

/* --- ANIMATED LOGIN BACKGROUND --- */
@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- PULSE ANIMATION FOR NOTIFICATION BADGES --- */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

#login-overlay {
    background: linear-gradient(-45deg, #0f172a, #1e293b, #3b82f6, #1e1b4b);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

/* LAYOUT */
.app-layout { display: flex; min-height: 100vh; position: relative; }
.sidebar { background-color: var(--primary); color: white; padding: 20px; display: flex; flex-direction: column; position: fixed; width: 260px; height: 100%; z-index: 1000; top: 0; left: 0; transition: transform 0.3s ease-in-out; overflow-y: auto; }
.main-content { margin-left: 260px; padding: 40px; width: calc(100% - 260px); display: flex; flex-direction: column; align-items: center; transition: 0.3s; }
.content-container { width: 100%; max-width: 1000px; margin: 0 auto; }

/* SCROLLABLE LISTS */
.scrollable-list { overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent; padding-right: 5px; margin-left: 5px; border-left: 2px solid rgba(255,255,255,0.05); }
#saved-quotes-list { max-height: 35vh; }
#staff-quotes-list { max-height: 25vh; }

/* UTILS */
body.ex-vat-active .price-badge,
body.ex-vat-active .price-unit,
body.ex-vat-active .price-line-total,
body.ex-vat-active #total-price-ex-vat-display {
    color: var(--danger) !important;
}
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* COMPONENTS */
.brand { font-size: 1.4em; font-weight: 700; margin-bottom: 25px; display: flex; align-items: center; gap: 5px; color: white; letter-spacing: -0.5px; flex-shrink: 0; }
.nav-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; flex-shrink: 0; }
.nav-label { font-size: 0.75em; text-transform: uppercase; color: #94a3b8; font-weight: 600; margin-bottom: 5px; letter-spacing: 0.5px; }
.nav-btn { background: transparent; border: none; color: #cbd5e1; text-align: left; padding: 10px 12px; border-radius: var(--radius); cursor: pointer; transition: 0.2s; font-size: 0.95em; display: flex; align-items: center; gap: 10px; width: 100%; }
.nav-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-btn.active { background: var(--accent); color: white; font-weight: 600; box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); }

.top-bar { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 1000px; margin-bottom: 30px; }
.view-controls { display: flex; gap: 5px; background: white; padding: 4px; border-radius: var(--radius); box-shadow: var(--shadow); margin-left: auto; }
.toggle-btn { border: 1px solid transparent; background: transparent; padding: 6px 12px; font-size: 0.85em; cursor: pointer; border-radius: 4px; color: var(--text-muted); font-weight: 500; }
.toggle-btn:hover { color: var(--primary); background: #f8fafc; }
.toggle-btn.active { background: #e0f2fe; color: var(--accent); border-color: #bae6fd; font-weight: 600; }

.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 25px; margin-bottom: 25px; border: 1px solid var(--border); }
.card-title { font-size: 1.2em; font-weight: 600; color: var(--primary); margin: 0; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

.search-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.search-input { width: 100%; padding: 18px 25px; padding-right: 140px; border: 2px solid var(--border); border-radius: 50px; font-size: 1.1em; transition: 0.2s; box-shadow: var(--shadow); outline: none; color: var(--text-main); background-color: white; }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2); }
.search-btn-main { position: absolute; right: 8px; top: 8px; bottom: 8px; background: var(--primary); color: white; border: none; padding: 0 30px; border-radius: 50px; font-weight: 600; cursor: pointer; transition: 0.2s; font-size: 1em; }

.item-list { list-style: none; padding: 0; margin: 0; }

/* --- NEW LIST ROW STYLING --- */
.list-row { display: grid; gap: 15px; padding: 16px 20px; border-bottom: 1px solid var(--border); background: white; transition: background 0.2s; align-items: center; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #f8fafc; }

/* Search Results Layout */
.search-row { grid-template-columns: 1fr auto auto; }

/* Cart Items Layout */
.cart-row { grid-template-columns: 20px 1fr auto auto; cursor: default; }
.cart-row.dragging { opacity: 0.5; background: #f1f5f9; border: 2px dashed var(--accent); }

/* Typography & Elements */
.item-name { font-weight: 600; color: var(--text-main); font-size: 1.05em; margin-bottom: 4px; line-height: 1.2; }
.model-number { font-size: 0.75em; color: #94a3b8; font-weight: 400; margin-bottom: 3px; letter-spacing: 0.02em; }
.item-meta { font-size: 0.85em; color: var(--text-muted); display: flex; gap: 10px; align-items: center; }

.price-badge { background: #f1f5f9; color: var(--primary); padding: 4px 8px; border-radius: 6px; font-weight: 600; font-size: 0.9em; white-space: nowrap; }
.cost-tag { color: var(--danger); font-size: 0.85em; font-weight: 600; }
.vat-tag { font-size: 0.75em; color: var(--text-muted); font-weight: 500; text-transform: uppercase; }

.drag-handle { color: #cbd5e1; cursor: grab; font-size: 1.2em; display: flex; align-items: center; justify-content: center; user-select: none; }
.drag-handle:hover { color: var(--accent); }
.price-separator { color: var(--border); }
.price-line-total { color: var(--primary); font-weight: 600; }

/* Linked Items - Settings Page */
.link-manager-layout { display: grid; grid-template-columns: 1fr 1.3fr; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; height: 75vh; }
.link-panel-items { border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.link-item-list { overflow-y: auto; flex: 1; }
.link-item-entry { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background 0.12s; display: flex; align-items: center; gap: 10px; }
.link-item-entry:hover { background: #f8fafc; }
.link-item-entry.active { background: #e0f2fe; }
.link-item-entry input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; accent-color: var(--primary); }
.link-item-entry-content { flex: 1; min-width: 0; }
.link-item-entry-name { font-size: 0.88em; font-weight: 500; color: var(--text-main); line-height: 1.3; }
.link-item-entry-meta { font-size: 0.72em; color: #94a3b8; margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.link-item-entry-count { background: var(--primary); color: white; font-size: 0.7em; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.link-batch-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding: 4px 0; }
.link-select-all-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.82em; font-weight: 500; color: var(--text-muted); user-select: none; }
.link-select-all-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.link-selected-count { font-size: 0.78em; color: var(--primary); font-weight: 600; }
.link-panel-editor { display: flex; flex-direction: column; overflow: hidden; }
.link-editor-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); text-align: center; padding: 30px; }
.link-editor-header { padding: 14px 16px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; }
.link-editor-header-name { font-weight: 700; font-size: 1em; margin-bottom: 2px; }
.link-editor-header-model { font-size: 0.8em; opacity: 0.85; }
.link-editor-links { flex: 1; overflow-y: auto; }
.link-editor-link-row { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid #f1f5f9; gap: 10px; }
.link-editor-link-row:hover { background: #fafbfd; }
.link-editor-link-info { flex: 1; min-width: 0; }
.link-editor-link-name { font-size: 0.88em; font-weight: 500; color: var(--text-main); }
.link-editor-link-model { font-size: 0.72em; color: #94a3b8; }
.link-search-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); max-height: 200px; overflow-y: auto; z-index: 100; list-style: none; padding: 0; margin: 0; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.link-search-dropdown li { padding: 8px 12px; cursor: pointer; font-size: 0.9em; border-bottom: 1px solid #f1f5f9; }
.link-search-dropdown li:hover { background: #f1f5f9; }
.link-search-dropdown li .link-dd-model { font-size: 0.75em; color: #94a3b8; }

/* Linked Items - Suggestion Popup */
.linked-items-popup { position: fixed; top: 20px; right: 20px; min-width: 260px; max-width: 400px; width: auto; background: white; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.15); border: 1px solid var(--border); z-index: 9999; animation: slideDownPopup 0.3s ease; overflow: hidden; }
.linked-popup-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--primary); color: white; font-weight: 600; font-size: 0.9em; }
.linked-popup-body { padding: 8px; max-height: 250px; overflow-y: auto; }
.linked-popup-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; margin-bottom: 4px; transition: background 0.15s; }
.linked-popup-item:hover { background: #f8fafc; }
.linked-popup-item-info { flex: 1; min-width: 0; }
.linked-popup-item-name { font-size: 0.85em; font-weight: 500; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linked-popup-item-meta { font-size: 0.72em; color: #94a3b8; }
.linked-popup-add { background: var(--accent); color: white; border: none; padding: 4px 10px; border-radius: 6px; font-size: 0.8em; font-weight: 600; cursor: pointer; white-space: nowrap; margin-left: 8px; }
.linked-popup-add:hover { background: var(--primary); }
@keyframes slideDownPopup { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Linked items badge on search results */
.has-links-badge { font-size: 0.7em; color: var(--accent); margin-left: 6px; cursor: help; position: relative; display: inline-block; }
.has-links-badge:hover .links-tooltip { display: block; }
.links-tooltip { display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--text-main, #1e293b); color: white; border-radius: 8px; padding: 8px 0; min-width: 180px; max-width: 260px; z-index: 1000; box-shadow: 0 4px 16px rgba(0,0,0,0.18); font-size: 1.15em; white-space: normal; text-align: left; }
.links-tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--text-main, #1e293b); }
.links-tooltip-title { font-weight: 700; font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 12px 6px; opacity: 0.7; border-bottom: 1px solid rgba(255,255,255,0.15); margin-bottom: 4px; }
.links-tooltip-item { padding: 3px 12px; line-height: 1.4; font-weight: 400; }

.cart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 30px; align-items: start; }

.btn { padding: 10px 20px; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; font-size: 0.95em; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-sm { padding: 6px 12px; font-size: 0.85em; }
.btn-primary { background: var(--accent); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text-main); }

/* --- UPDATED QUANTITY CONTROLS --- */
.qty-controls { display: flex; align-items: center; background: white; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; min-width: 110px; }
.qty-btn { background: #f8fafc; border: none; padding: 10px 14px; cursor: pointer; color: var(--text-main); font-weight: bold; font-size: 1.1em; flex-shrink: 0; }
.qty-btn:active { background: #e2e8f0; }
/* Quantity Input Style */
.qty-input { width: 50px; text-align: center; border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border); font-weight: 600; font-size: 1em; padding: 5px; -moz-appearance: textfield; appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input:focus { outline: none; background: #eff6ff; }

.totals-grid { display: grid; grid-template-columns: 1fr auto; gap: 12px; margin-top: 25px; padding-top: 25px; border-top: 2px dashed var(--border); }
.total-row { display: flex; justify-content: flex-end; align-items: center; gap: 20px; color: var(--text-muted); font-size: 1em; }
.grand-total { font-size: 1.6em; font-weight: 800; color: var(--primary); margin-top: 10px; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(4px); z-index: 2000; display: none; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s ease; }
.modal-overlay.open { display: flex; opacity: 1; }
.modal-box { background: white; width: 90%; max-width: 450px; border-radius: 12px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); padding: 40px; transform: scale(0.95); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.modal-overlay.open .modal-box { transform: scale(1); }

.input-group { margin-bottom: 20px; }
.input-group label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 0.9em; color: var(--text-main); }
.form-input { width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; font-size: 1em; transition: 0.2s; color: var(--text-main); }
.form-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3); }

.toast { position: fixed; bottom: 30px; right: 30px; background: var(--primary); color: white; padding: 16px 24px; border-radius: 50px; font-weight: 500; box-shadow: var(--shadow); transform: translateY(100px); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 3000; display: flex; align-items: center; gap: 12px; }
.toast.show { transform: translateY(0); }

.badge { background: #e2e8f0; padding: 2px 8px; border-radius: 12px; font-size: 0.75em; font-weight: 600; color: var(--text-muted); }
.badge-admin { background: #e0e7ff; color: #4338ca; }

/* ADMIN PANEL LAYOUT */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; border-top: 1px solid var(--border); padding-top: 20px; }

.admin-tab-btn.active { color: var(--accent) !important; border-bottom-color: var(--accent) !important; background: #f8fafc !important; }

.login-logo { height: 120px; margin-bottom: 20px; object-fit: contain; }

/* USER TABLE RESPONSIVE */
.user-table { width: 100%; border-collapse: collapse; }
.user-table th { text-align: left; padding: 12px 15px; color: var(--text-muted); font-size: 0.85em; background: #f1f5f9; }
.user-table td { padding: 12px 15px; border-bottom: 1px solid var(--border); }
.u-actions { text-align: right; }
.u-actions button + button { margin-left: 5px; }

@media (max-width: 768px) {
    .user-table thead { display: none; }
    .user-table tr { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 15px; border-bottom: 1px solid var(--border); }
    .user-table td { padding: 0; border: none; }
    .u-name { grid-column: 1; font-weight: 600; font-size: 1.1em; color: var(--primary); }
    .u-role { grid-column: 2; text-align: right; }
    .u-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 5px; }
    .u-actions button { flex: 1; justify-content: center; margin-left: 0; }
}

/* INVENTORY TABLE */
.inv-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.inv-table th { text-align: left; padding: 10px; background: #f1f5f9; color: var(--text-muted); position: sticky; top: 0; }
.inv-table td { padding: 10px; border-bottom: 1px solid var(--border); }

/* VAN STOCK STATUS */
.status-dot { height: 12px; width: 12px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.status-red { background-color: var(--danger); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
.status-orange { background-color: #f59e0b; box-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }
.status-green { background-color: var(--success); box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.status-gray { background-color: var(--text-muted); }

/* TIMESHEET */
.ts-input { padding: 6px; border: 1px solid var(--border); border-radius: 4px; width: 100%; }
.ts-row.weekend { background-color: #f8fafc; }

/* --- MOBILE RESPONSIVENESS --- */
.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 900; display: none; backdrop-filter: blur(2px); }
.mobile-menu-btn { display: none; background: transparent; border: none; font-size: 1.5em; cursor: pointer; color: var(--text-main); margin-right: 15px; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); } 
    .sidebar.open { transform: translateX(0); } 
    .main-content { margin-left: 0; width: 100%; padding: 12px; }
    .mobile-menu-btn { display: block; }
    .sidebar-overlay.active { display: block; }
    .mobile-close-btn { display: block !important; }
    .cart-grid { grid-template-columns: 1fr !important; gap: 20px; }
    .top-bar { margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
    .user-welcome { display: none; } 
    .search-input { padding: 12px 15px; padding-right: 90px; font-size: 1em; }
    .search-btn-main { padding: 0 20px; font-size: 0.9em; top: 5px; bottom: 5px; right: 5px; }
    
    /* Cards mobile */
    .card { padding: 15px; margin-bottom: 15px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    
    /* Admin Mobile Fixes */
    .action-grid { grid-template-columns: 1fr !important; } /* Stack Admin grid */
    .modal-overlay { align-items: flex-start !important; padding: 20px 0; overflow-y: auto; }
    .modal-box { width: 95% !important; max-height: none !important; padding: 20px !important; margin: auto; margin-bottom: 50vh; }
    .modal-box.edit-user-modal-box { padding: 0 !important; }
    .qty-controls { min-width: 100px; }
    
    /* List rows mobile */
    .list-row { padding: 12px; gap: 10px; }
    .search-row { grid-template-columns: 1fr; gap: 12px; }
    .cart-row { grid-template-columns: 1fr; gap: 10px; }
    .cart-row .drag-handle { display: none; }
    
    /* Item details stacking */
    .item-details { width: 100%; }
    .item-meta { flex-wrap: wrap; }
    
    /* Price and controls on mobile */
    .price-display { width: 100%; justify-content: space-between; }
    .qty-controls { width: 100%; justify-content: center; }
    
    /* Totals */
    .totals-grid { grid-template-columns: 1fr; }
    .total-row { justify-content: space-between; }
    .grand-total { font-size: 1.3em; }
    
    /* View controls */
    .view-controls { width: 100%; justify-content: center; }
    .toggle-btn { padding: 8px 10px; font-size: 0.8em; }
    
    /* Timesheet mobile */
    #globalMandatoryForm { grid-template-columns: 1fr !important; }
    #globalMandatoryForm > div:last-child { flex-direction: column; }
    #globalMandatoryForm .btn { width: 100%; }
    
    /* TS calendar controls */
    #ts-calendar-view .card > div:first-child { flex-direction: column; text-align: center; }
    #ts-calendar-view .card > div:first-child > div { flex: unset !important; width: 100%; }
    #ts-calendar-view .card > div:first-child > div:last-child { text-align: center !important; }
    
    /* TS stats grid */
    #ts-calendar-view .card > div[style*="grid-template-columns"] { grid-template-columns: 1fr 1fr !important; gap: 10px !important; font-size: 0.85em; }
    
    /* TS controls row */
    #ts-controls > div { flex-direction: column; align-items: stretch !important; }
    #ts-controls .input-group { flex-direction: column !important; align-items: stretch !important; }
    #ts-controls .input-group input { width: 100% !important; }
    #ts-controls > div > div:last-child { flex-direction: column; }
    #ts-controls .btn { width: 100%; }
    
    /* Holiday request form */
    #holidayRequestForm { padding: 15px; }
    
    /* Tables mobile scroll */
    .inv-table { font-size: 0.8em; }
    .inv-table th, .inv-table td { padding: 8px 6px; white-space: nowrap; }
    
    /* Section headers */
    .content-container h1 { font-size: 1.6em !important; }
    .content-container p { font-size: 0.95em !important; }
    
    /* Van stock controls */
    #van-stock-user-controls > div { flex-direction: column; }
    #van-stock-user-controls .search-wrapper { width: 100%; }
    #van-stock-user-controls .btn { width: 100%; }
    
    /* Van stock tabs */
    #van-stock-section .flex-between { flex-direction: column; gap: 15px; }
    #van-stock-section .flex-between > div { width: 100%; justify-content: center; }
    
    /* Linked items settings - stack on mobile */
    .link-manager-layout { grid-template-columns: 1fr !important; min-height: auto; max-height: none; }
    .link-panel-items { border-right: none; border-bottom: 1px solid var(--border); max-height: 250px; }
    .link-panel-editor { min-height: 300px; }
    .linked-items-popup { width: calc(100vw - 20px); right: 10px; bottom: 10px; }

    /* Saved quotes section */
    #saved-quotes-section .card-header { flex-direction: column; gap: 10px; }
    #saved-quotes-section .card-header > div { width: 100%; }
    #saved-quotes-section select { width: 100%; }
    
    /* Quote header in cart */
    #quote-header-section { flex-direction: column !important; gap: 12px !important; }
    #quote-header-section input { width: 100% !important; }
    
    /* Quote actions */
    .quote-actions { flex-direction: column !important; }
    .quote-actions .btn { width: 100%; }
    
    /* Compliance section */
    #compliance-section .card > div[style*="grid"] { grid-template-columns: 1fr !important; }
    
    /* Compliance Dashboard - Tablet */
    #ts-compliance-dashboard .card:first-child > div {
        flex-direction: column !important;
        gap: 16px !important;
    }
    #ts-compliance-dashboard .card:first-child > div > div:first-child {
        text-align: center;
    }
    #ts-compliance-dashboard .card:first-child > div > div:last-child {
        flex-direction: column !important;
        width: 100% !important;
        gap: 12px !important;
    }
    #ts-compliance-dashboard .compliance-header {
        display: none !important;
    }
    #ts-compliance-dashboard > div:nth-child(2) {
        grid-template-columns: 1fr !important;
    }
    .compliance-stats-row {
        display: flex !important;
        justify-content: center !important;
        gap: 12px !important;
    }
    .compliance-engineer-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding: 16px !important;
        border-radius: 10px !important;
        margin: 8px !important;
        border: 1px solid var(--border) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    .compliance-engineer-row > div:first-child {
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border);
    }
    .compliance-status-pills {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    .compliance-status-pills > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    .compliance-status-pills > div::before {
        display: block !important;
        font-size: 0.7em !important;
        font-weight: 600 !important;
        color: var(--text-muted) !important;
        text-transform: uppercase !important;
        margin-bottom: 6px !important;
    }
    .compliance-status-pills > div:nth-child(1)::before { content: 'Timesheet'; }
    .compliance-status-pills > div:nth-child(2)::before { content: 'Expenses'; }
    .compliance-status-pills > div:nth-child(3)::before { content: 'Van Check'; }
    .compliance-action button {
        width: 100% !important;
        padding: 12px 16px !important;
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
        color: white !important;
        border: none !important;
    }
    
    /* ================================================ */
    /* TIMESHEET TABLE MOBILE - CARD LAYOUT */
    /* ================================================ */
    #timesheet-table { font-size: 0.85em; }
    #timesheet-table thead { display: none; }
    #timesheet-table tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 10px;
        background: white;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    #timesheet-table tbody tr.weekend { 
        background: #f8fafc; 
        border-color: #e2e8f0;
    }
    #timesheet-table tbody tr[style*="fee2e2"] { 
        background: #fee2e2 !important; 
        border-color: #fecaca;
    }
    #timesheet-table tbody td {
        padding: 4px 0 !important;
        border: none !important;
        display: flex;
        flex-direction: column;
    }
    #timesheet-table tbody td::before {
        content: attr(data-label);
        font-size: 0.7em;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        margin-bottom: 3px;
    }
    #timesheet-table tbody td:first-child {
        grid-column: 1 / -1;
        font-weight: 600;
        font-size: 1.1em;
        border-bottom: 1px solid var(--border);
        padding-bottom: 8px !important;
        margin-bottom: 4px;
        flex-direction: row;
        align-items: center;
    }
    #timesheet-table tbody td:first-child::before { display: none; }
    #timesheet-table .ts-input {
        padding: 10px;
        font-size: 1em;
        border-radius: 6px;
    }
    /* Adjust column widths for Date and Status */
    #timesheet-table th:nth-child(1), #timesheet-table td:nth-child(1) { width: 120px; } /* Date column wider */
    #timesheet-table th:nth-child(2), #timesheet-table td:nth-child(2) { width: 100px; } /* Status column narrower */
    #timesheet-table tbody td:last-child {
        /* Hours field - make prominent */
        background: #f0f9ff;
        padding: 8px !important;
        border-radius: 6px;
        align-items: center;
        justify-content: center;
    }
    
    /* ================================================ */
    /* EXPENSES TABLE MOBILE - CARD LAYOUT */
    /* ================================================ */
    .card:has(#expenses-list) table thead { display: none; }
    #expenses-list { border-collapse: separate; border-spacing: 0; }
    #expenses-list tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 10px;
        background: white;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    #expenses-list td {
        padding: 4px 0 !important;
        border: none !important;
        display: flex;
        flex-direction: column;
    }
    #expenses-list td::before {
        content: attr(data-label);
        font-size: 0.7em;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        margin-bottom: 3px;
    }
    #expenses-list td:nth-child(2) {
        /* Description - full width */
        grid-column: 1 / -1;
    }
    #expenses-list td:last-child {
        grid-column: 1 / -1;
        margin-top: 8px;
        flex-direction: row;
        justify-content: flex-end;
    }
    #expenses-list td:last-child::before { display: none; }
    
    /* Expense form mobile */
    #expenseForm {
        grid-template-columns: 1fr !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .main-content { padding: 8px; }
    .card { padding: 12px; }
    
    /* Even smaller fonts */
    .content-container h1 { font-size: 1.4em !important; }
    .item-name { font-size: 0.95em; }
    .btn { padding: 8px 14px; font-size: 0.85em; }
    .btn-sm { padding: 6px 10px; font-size: 0.8em; }
    
    /* Stats grid single column */
    #ts-calendar-view .card > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    
    /* User cards tighter */
    .user-card { padding: 10px 12px; }
    .user-card-avatar { width: 36px; height: 36px; font-size: 0.85em; }
    .user-card-name { font-size: 0.9em; }
    .user-card-meta { font-size: 0.75em; }
    .user-badge { font-size: 0.7em; padding: 3px 8px; }
    .user-action-btn { padding: 5px 8px; font-size: 0.75em; }
    
    /* Toast mobile */
    .toast { left: 10px; right: 10px; bottom: 10px; }
    
    /* =============================================== */
    /* EXTRA SMALL SCREEN ADJUSTMENTS */
    /* =============================================== */
    
    /* Van Stock Request - Mobile Cards */
    .van-stock-mobile .inv-table { display: none; }
    .van-stock-card-list { display: block; }
    
    /* Tighter timesheet on very small screens */
    #timesheet-table { font-size: 0.75em; }
    #timesheet-table .ts-input { padding: 8px; }
    
    /* Tighter expense cards on very small screens */
    #expenses-list tr { padding: 10px; }
    
    /* ================================================ */
    /* COMPLIANCE DASHBOARD - MOBILE REDESIGN */
    /* ================================================ */
    
    /* Header Card - Stack everything vertically */
    #ts-compliance-dashboard .card:first-child {
        padding: 16px !important;
    }
    #ts-compliance-dashboard .card:first-child > div {
        flex-direction: column !important;
        gap: 16px !important;
        align-items: stretch !important;
    }
    #ts-compliance-dashboard .card:first-child > div > div:first-child {
        text-align: center;
    }
    #ts-compliance-dashboard .card:first-child > div > div:first-child h2 {
        font-size: 1.3em !important;
    }
    /* Month/Year selector row */
    #ts-compliance-dashboard .card:first-child > div > div:last-child {
        flex-direction: column !important;
        width: 100% !important;
        gap: 12px !important;
    }
    /* The selectors container */
    #ts-compliance-dashboard .card:first-child > div > div:last-child > div:first-child {
        width: 100% !important;
        justify-content: center !important;
    }
    #ts-compliance-dashboard .card:first-child select {
        flex: 1;
        min-width: unset !important;
    }
    /* Stats boxes row - side by side */
    .compliance-stats-row {
        display: flex !important;
        flex-direction: row !important;
        gap: 10px !important;
        width: 100% !important;
    }
    .compliance-stats-row > div {
        flex: 1 !important;
        min-width: unset !important;
        padding: 10px 12px !important;
    }
    .compliance-stats-row > div > div:first-child {
        font-size: 1.3em !important;
    }
    
    /* Summary progress cards - stack on mobile */
    #ts-compliance-dashboard > div:nth-child(2) {
        grid-template-columns: 1fr !important;
    }
    
    /* Engineer List Card - Hide table header */
    #ts-compliance-dashboard .compliance-header {
        display: none !important;
    }
    
    /* Engineer rows - convert to cards */
    .compliance-engineer-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding: 16px !important;
        border-radius: 10px !important;
        margin: 8px !important;
        border: 1px solid var(--border) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    /* Engineer name row */
    .compliance-engineer-row > div:first-child {
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border);
    }
    /* Status pills container - convert from display:contents to grid */
    .compliance-status-pills {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        width: 100% !important;
    }
    .compliance-status-pills > div {
        text-align: center !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    /* Status pill label */
    .compliance-status-pills > div::before {
        display: block !important;
        font-size: 0.65em !important;
        font-weight: 600 !important;
        color: var(--text-muted) !important;
        text-transform: uppercase !important;
        margin-bottom: 6px !important;
        letter-spacing: 0.3px !important;
    }
    .compliance-status-pills > div:nth-child(1)::before { content: 'Timesheet'; }
    .compliance-status-pills > div:nth-child(2)::before { content: 'Expenses'; }
    .compliance-status-pills > div:nth-child(3)::before { content: 'Van Check'; }
    /* Make status pills smaller on mobile */
    .compliance-status-pills > div > div {
        padding: 5px 8px !important;
        font-size: 0.7em !important;
    }
    /* Action button - full width */
    .compliance-action {
        margin-top: 4px !important;
    }
    .compliance-action button {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 0.9em !important;
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
        color: white !important;
        border: none !important;
    }
    .compliance-action button:hover {
        background: linear-gradient(135deg, #334155 0%, #475569 100%) !important;
    }
    /* Pending badge position on mobile */
    .compliance-action {
        position: relative !important;
    }
    .compliance-action span[style*="position: absolute"] {
        top: -4px !important;
        right: 8px !important;
    }
    
    /* Expense controls mobile */
    #expense-controls > div,
    #checklist-controls > div {
        flex-direction: column !important;
        gap: 12px !important;
    }
    #expense-controls .input-group,
    #checklist-controls .input-group {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100%;
    }
    #expense-controls .input-group input,
    #checklist-controls .input-group input {
        width: 100% !important;
    }
    #expense-controls > div > div:last-child,
    #checklist-controls > div > div:last-child {
        flex-direction: column;
    }
    #expense-controls .btn,
    #checklist-controls .btn {
        width: 100%;
    }
}

/* BANK HOLIDAY STYLING */
.day-bh { background-color: #dcfce7 !important; position: relative; }
.day-bh::after { content: 'BH'; position: absolute; top: 2px; right: 4px; font-size: 0.6em; font-weight: bold; color: #15803d; }

/* GLOBAL TABLE RESPONSIVE WRAPPER */
.table-responsive { 
    width: 100%; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
}

/* Word breaking for long text */
.item-name, .item-meta, td { 
    word-wrap: break-word; 
    overflow-wrap: break-word;
}

/* ========================================= */
/* USER MANAGEMENT STYLES */
/* ========================================= */

.admin-modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: grid;
    place-items: center;
    font-size: 1.2em;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.modal-close-btn {
    background: #f1f5f9;
    border: none;
    font-size: 1.3em;
    cursor: pointer;
    color: #64748b;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

/* Stats Row */
.user-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.user-stat-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.user-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.1em;
}

.user-stat-info {
    display: flex;
    flex-direction: column;
}

.user-stat-value {
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1.1;
}

.user-stat-label {
    font-size: 0.8em;
    color: #6b7280;
}

/* Filter Bar */
.user-filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.user-search-wrapper {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.user-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.9em;
}

.user-search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95em;
    transition: all 0.2s;
    background: white;
}

.user-search-input:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.user-filter-select {
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95em;
    background: white;
    cursor: pointer;
    min-width: 130px;
}

.user-filter-select:focus {
    border-color: #3b82f6;
    outline: none;
}

/* User List */
.user-list-container {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    max-height: 340px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.user-list-empty {
    padding: 40px 20px;
    text-align: center;
    color: #6b7280;
}

/* User Card */
.user-card {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
    gap: 14px;
}

.user-card:last-child {
    border-bottom: none;
}

.user-card:hover {
    background: #f8fafc;
}

.user-card-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    color: #4338ca;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.95em;
    flex-shrink: 0;
}

.user-card-avatar.admin {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #b45309;
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    font-weight: 600;
    font-size: 0.95em;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-card-name .you-tag {
    font-weight: 400;
    font-size: 0.8em;
    color: #6b7280;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}

.user-card-meta {
    font-size: 0.82em;
    color: #6b7280;
    margin-top: 2px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.user-card-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.user-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.user-badge.role-admin {
    background: #fef3c7;
    color: #b45309;
}

.user-badge.role-user {
    background: #e0e7ff;
    color: #4338ca;
}

.user-badge.has-timesheet {
    background: #d1fae5;
    color: #047857;
}

.user-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.user-action-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: white;
    font-size: 0.82em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-action-btn:hover {
    background: #f8fafc;
    border-color: #d1d5db;
}

.user-action-btn.danger {
    color: #dc2626;
    border-color: #fecaca;
}

.user-action-btn.danger:hover {
    background: #fef2f2;
}

/* Add User Section */
.add-user-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
}

.add-user-toggle {
    width: 100%;
    padding: 14px 18px;
    background: white;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s;
}

.add-user-toggle:hover {
    background: #f8fafc;
}

.add-user-toggle-icon {
    font-size: 0.9em;
}

.add-user-form-container {
    padding: 0 18px 18px;
    border-top: 1px solid #f1f5f9;
}

.add-user-form-container.hidden {
    display: none;
}

.add-user-form {
    padding-top: 16px;
}

.add-user-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.add-user-field label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.add-user-field .form-input {
    padding: 10px 12px;
}

.add-user-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.user-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.95em;
}

.user-checkbox-label:hover {
    background: #f1f5f9;
}

.user-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Edit User Modal */
.edit-user-modal-box {
    max-width: 480px;
    padding: 0 !important;
    overflow: hidden;
}

.edit-user-header {
    padding: 18px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    color: #4338ca;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.95em;
}

.edit-user-form {
    padding: 20px;
}

.edit-section {
    margin-bottom: 20px;
}

.edit-section-title {
    font-size: 0.85em;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.edit-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.edit-field {
    margin-bottom: 12px;
}

.edit-field label {
    display: block;
    font-size: 0.85em;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.edit-field .form-input {
    padding: 10px 12px;
}

.edit-user-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

@media (max-width: 600px) {
    .user-stats-row {
        grid-template-columns: 1fr;
    }
    
    .user-filter-bar {
        flex-direction: column;
    }
    
    .user-filter-select {
        width: 100%;
    }
    
    .user-card {
        flex-wrap: wrap;
    }
    
    .user-card-badges {
        width: 100%;
        margin-top: 6px;
    }
    
    .user-card-actions {
        width: 100%;
        margin-top: 8px;
    }
    
    .user-card-actions .user-action-btn {
        flex: 1;
        justify-content: center;
    }
    
    .add-user-row {
        grid-template-columns: 1fr;
    }
    
    .edit-row {
        grid-template-columns: 1fr;
    }
    
    /* Admin modal mobile */
    .admin-modal-header {
        padding: 14px 16px;
    }
    
    .admin-header-icon {
        width: 36px;
        height: 36px;
        font-size: 1em;
    }
    
    #admin-modal > .modal-box {
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
    
    #admin-modal > .modal-box > div:last-child {
        padding: 12px !important;
    }
    
    .user-list-container {
        max-height: 45vh;
    }
    
    .user-stat-card {
        padding: 10px 12px;
    }
    
    .user-stat-value {
        font-size: 1.2em;
    }
    
    .user-stat-label {
        font-size: 0.75em;
    }
    
    /* Edit user modal mobile */
    .edit-user-modal-box {
        width: 100% !important;
        max-width: 100% !important;
        height: auto;
        max-height: 95vh !important;
        border-radius: 12px !important;
        margin: 10px;
    }
    
    .edit-user-header {
        padding: 14px 16px;
    }
    
    .edit-user-form {
        padding: 16px;
    }
    
    .edit-user-avatar {
        width: 38px;
        height: 38px;
        font-size: 0.9em;
    }
    
    /* Login modal mobile */
    #login-overlay .modal-box {
        padding: 25px !important;
        width: 95% !important;
        max-width: 380px !important;
    }
    
    #login-overlay .login-logo {
        height: 80px;
    }
    
    #login-overlay h2 {
        font-size: 1.5em !important;
    }
    
    /* Signature modal mobile */
    #signature-modal .modal-box {
        width: 95% !important;
    }
    
    #signature-pad {
        max-width: 100%;
        height: auto !important;
    }
    
    /* Bank holidays modal mobile */
    #bank-holidays-modal .modal-box {
        max-height: 85vh !important;
    }
    
    /* Alert/Confirm modals mobile */
    #custom-alert-modal .modal-box,
    #custom-confirm-modal .modal-box {
        width: 90% !important;
        max-width: 350px !important;
    }
}

/* ========================================
   DISCONTINUED ITEMS
   ======================================== */

.discontinued-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    margin-top: 8px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px dashed #f59e0b;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    color: #92400e;
    letter-spacing: 0.3px;
}

.discontinued-row {
    display: flex !important;
    align-items: center;
    gap: 12px;
    background: #fef2f2 !important;
    border-left: 4px solid var(--danger) !important;
    opacity: 0.9;
}

.discontinued-row:hover {
    background: #fee2e2 !important;
}

.discontinued-name {
    text-decoration: line-through;
    color: var(--text-muted) !important;
}

.discontinued-badge {
    display: inline-block;
    background: var(--danger);
    color: white;
    font-size: 0.65em;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 2px;
}

.discontinued-replace-old {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px 16px;
}

.replace-result-row {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.replace-result-row:hover {
    background: #f0f9ff;
    border-color: var(--primary);
}

/* ============================================================
   DOCUMENTS SECTION
   ============================================================ */

/* --- Breadcrumb --- */
.doc-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9em;
}
.doc-breadcrumb-item {
    color: var(--accent);
    cursor: pointer;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}
.doc-breadcrumb-item:hover {
    background: rgba(59, 130, 246, 0.08);
}
.doc-breadcrumb-separator {
    color: var(--text-muted);
    font-size: 0.85em;
    user-select: none;
}
.doc-breadcrumb-current {
    color: var(--text-main);
    font-weight: 600;
    cursor: default;
}
.doc-breadcrumb-current:hover {
    background: transparent;
}

/* --- Document Browser Grid --- */
.doc-browser {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    min-height: 200px;
}

/* --- Empty State --- */
.doc-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.doc-empty-icon {
    font-size: 3em;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* --- Folder Card --- */
.doc-folder-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 140px;
    position: relative;
}
.doc-folder-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}
.doc-folder-card .doc-folder-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
    line-height: 1;
}
.doc-folder-card .doc-folder-name {
    font-weight: 600;
    font-size: 0.9em;
    color: var(--text-main);
    word-break: break-word;
    line-height: 1.3;
}
.doc-folder-card .doc-folder-count {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-top: 6px;
}

/* --- File Card --- */
.doc-file-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 140px;
    position: relative;
}
.doc-file-card:hover {
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.12);
    transform: translateY(-2px);
}
.doc-file-card .doc-file-icon {
    font-size: 2.2em;
    margin-bottom: 10px;
    color: #ef4444;
    line-height: 1;
}
.doc-file-card .doc-file-name {
    font-weight: 500;
    font-size: 0.85em;
    color: var(--text-main);
    word-break: break-word;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.doc-file-card .doc-file-size {
    font-size: 0.7em;
    color: var(--text-muted);
    margin-top: 6px;
}

/* --- PDF Viewer --- */
.doc-viewer-container {
    margin-top: 10px;
}
.doc-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
    gap: 12px;
    flex-wrap: wrap;
}
.doc-viewer-title {
    font-weight: 600;
    font-size: 0.95em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 120px;
}
.doc-viewer-search {
    flex: 0 1 auto;
}
.doc-search-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 3px 6px;
}
.doc-search-bar input {
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 0.85em;
    width: 160px;
    padding: 4px 6px;
}
.doc-search-bar input::placeholder {
    color: rgba(255,255,255,0.5);
}
#doc-search-info {
    font-size: 0.75em;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
    min-width: 40px;
    text-align: center;
}
.doc-search-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 2px 5px;
    font-size: 0.8em;
    border-radius: 3px;
    line-height: 1;
}
.doc-search-btn:hover {
    color: white;
    background: rgba(255,255,255,0.2);
}
.doc-viewer-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.doc-viewer-actions .btn {
    color: white !important;
    border-color: rgba(255,255,255,0.4) !important;
    background: rgba(255,255,255,0.12) !important;
    font-size: 0.8em;
    padding: 6px 12px;
}
.doc-viewer-actions .btn:hover {
    background: rgba(255,255,255,0.25) !important;
    border-color: rgba(255,255,255,0.7) !important;
}
.doc-viewer-body {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
    background: #404040;
}
.doc-viewer-pages {
    width: 100%;
    height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    gap: 12px;
}
.doc-page-wrapper {
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    background: white;
}
.doc-page-wrapper canvas {
    display: block;
}
/* PDF.js text layer */
.doc-text-layer {
    position: absolute;
    top: 0; left: 0;
    right: 0; bottom: 0;
    overflow: hidden;
    opacity: 0.25;
    line-height: 1;
}
.doc-text-layer > span {
    color: transparent;
    position: absolute;
    white-space: pre;
    transform-origin: 0% 0%;
    cursor: text;
}
.doc-text-layer > span::selection {
    background: rgba(0, 0, 255, 0.4);
}
.doc-text-layer .doc-search-highlight {
    background-color: rgba(255, 210, 0, 0.6);
    border-radius: 2px;
    color: transparent;
}
.doc-text-layer .doc-search-highlight.active {
    background-color: rgba(255, 127, 0, 0.8);
}
.doc-viewer-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: rgba(255,255,255,0.7);
    font-size: 1.1em;
}

/* --- Admin Document Management Layout --- */
.doc-admin-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    height: 65vh;
}
.doc-admin-tree-panel {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fafbfc;
}
.doc-admin-tree {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
}
.doc-admin-content-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.doc-admin-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

/* --- Admin Tree Items --- */
.doc-tree-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.9em;
    gap: 8px;
    margin-bottom: 2px;
    user-select: none;
}
.doc-tree-item:hover {
    background: rgba(59, 130, 246, 0.08);
}
.doc-tree-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    font-weight: 600;
}
.doc-tree-item .doc-tree-icon {
    font-size: 1.1em;
    flex-shrink: 0;
}
.doc-tree-item .doc-tree-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doc-tree-item .doc-tree-count {
    font-size: 0.75em;
    color: var(--text-muted);
    background: var(--bg-body);
    padding: 1px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}
.doc-tree-item .doc-tree-actions {
    display: none;
    gap: 2px;
    flex-shrink: 0;
}
.doc-tree-item:hover .doc-tree-actions {
    display: flex;
}
.doc-tree-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85em;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s;
}
.doc-tree-action-btn:hover {
    opacity: 1;
    background: rgba(0,0,0,0.06);
}
.doc-tree-children {
    padding-left: 20px;
}
.doc-tree-toggle {
    font-size: 0.7em;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.2s;
    color: var(--text-muted);
}
.doc-tree-toggle.open {
    transform: rotate(90deg);
}

/* --- Admin Header --- */
.doc-admin-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: white;
}
.doc-admin-header h4 {
    margin: 0;
    font-size: 1.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- Upload Area --- */
.doc-admin-upload-area {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.doc-upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafbfc;
}
.doc-upload-dropzone:hover,
.doc-upload-dropzone.dragover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.04);
}
.doc-upload-dropzone.dragover {
    background: rgba(59, 130, 246, 0.08);
}
.doc-upload-icon {
    font-size: 2em;
    margin-bottom: 8px;
}

/* --- Admin Files List --- */
.doc-admin-files {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
}
.doc-admin-file-row {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.15s;
    gap: 10px;
    border: 1px solid transparent;
}
.doc-admin-file-row:hover {
    background: #f8fafc;
    border-color: var(--border);
}
.doc-admin-file-icon {
    font-size: 1.5em;
    flex-shrink: 0;
    color: #ef4444;
}
.doc-admin-file-info {
    flex: 1;
    min-width: 0;
}
.doc-admin-file-name {
    font-weight: 500;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doc-admin-file-meta {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-top: 2px;
}
.doc-admin-file-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.doc-admin-file-actions .btn {
    font-size: 0.75em;
    padding: 4px 8px;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .doc-browser {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
    .doc-folder-card, .doc-file-card {
        padding: 16px 12px;
        min-height: 110px;
    }
    .doc-folder-card .doc-folder-icon { font-size: 2em; }
    .doc-file-card .doc-file-icon { font-size: 1.8em; }
    .doc-viewer-pages { height: 60vh; }
    .doc-search-bar input { width: 110px; }
    .doc-admin-layout {
        grid-template-columns: 1fr !important;
        height: auto;
    }
    .doc-admin-tree-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 250px;
    }
    .doc-admin-content-panel {
        min-height: 400px;
    }
    .doc-viewer-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    .doc-viewer-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
