/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    /* Brand Colors */
    --primary: #1428a0;
    --primary-light: #f0f4ff;
    --secondary: #6c757d;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    
    /* UI Colors */
    --bg-body: #f4f6f8;
    --bg-card: #ffffff;
    --text-main: #212529;
    --text-muted: #8795a1;
    --border: #e9ecef;
    
    /* Shadows & Spacing */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --radius: 12px;
    --nav-width: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

body { background-color: var(--bg-body); color: var(--text-main); display: flex; height: 100vh; overflow: hidden; }

/* =========================================
   2. SIDEBAR
   ========================================= */
.sidebar {
    width: var(--nav-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    transition: all 0.3s ease;
    z-index: 100;
}
.brand { font-size: 20px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.brand span { color: var(--text-main); }
.nav-item { display: flex; align-items: center; padding: 12px 16px; color: var(--secondary); text-decoration: none; border-radius: var(--radius); margin-bottom: 8px; transition: 0.2s; font-weight: 500; }
.nav-item.active, .nav-item:hover { background-color: var(--primary-light); color: var(--primary); }
.nav-item i { margin-right: 12px; width: 20px; text-align: center; }

/* =========================================
   3. MAIN CONTENT
   ========================================= */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; width: 100%; }

.header { height: 70px; background: var(--bg-card); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; flex-shrink: 0; }
.search-bar { display: flex; align-items: center; background: var(--bg-body); padding: 10px 16px; border-radius: 50px; width: 400px; border: 1px solid transparent; transition: 0.2s; }
.search-bar:focus-within { border-color: var(--primary); background: #fff; }
.search-bar input { border: none; background: transparent; outline: none; width: 100%; margin-left: 10px; }
.user-profile { display: flex; align-items: center; gap: 16px; }
.avatar { width: 40px; height: 40px; background: #ddd; border-radius: 50%; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* =========================================
   4. DASHBOARD
   ========================================= */
/* =========================================
   4. DASHBOARD
   ========================================= */
.dashboard-container { padding: 32px; overflow-y: auto; height: 100%; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }

/* FIXED: Changed from repeat(4, 1fr) to repeat(5, 1fr) and reduced gap */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(5, 1fr); 
    gap: 12px; 
    margin-bottom: 32px; 
}

/* FIXED: Reduced padding to fit more cards in one row */
.stat-card { 
    background: var(--bg-card); 
    padding: 16px; 
    border-radius: var(--radius); 
    border: 1px solid var(--border); 
    box-shadow: var(--shadow-sm); 
    min-width: 0; /* Prevents overflow */
}

/* FIXED: Smaller font sizes for better fit */
.stat-card h3 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.stat-card p { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* =========================================
   5. TABLES & BADGES
   ========================================= */
.table-container { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { text-align: left; padding: 16px 24px; color: var(--text-muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
td { padding: 16px 24px; border-top: 1px solid var(--border); vertical-align: middle; }
.device-info { display: flex; flex-direction: column; }
.device-name { font-weight: 600; color: var(--text-main); }
.device-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.badge { padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; display: inline-block; }
.status-new { background: #e3f2fd; color: #1565c0; }
.status-repair { background: #fff3e0; color: #ef6c00; }
.status-ready { background: #e8f5e9; color: #2e7d32; }

/* =========================================
   6. BUTTONS & FORMS
   ========================================= */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    border: none;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(20, 40, 160, 0.2);
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-primary:hover { transform: translateY(-2px); }

.btn-secondary {
    background: #e9ecef;
    color: var(--text-main);
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}
.btn-secondary:hover { background: #dde2e6; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-cancel {
    background: transparent;
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

/* Form Inputs */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 14px; color: var(--text-main); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
    transition: 0.2s; background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary); outline: none;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checkbox-group { display: flex; align-items: center; gap: 10px; }
.checkbox-group input { width: auto; }

/* =========================================
   7. WIZARD MODAL
   ========================================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}

/* General modal content style */
.modal-content {
    background-color: #ffffff !important; /* Forces white background */
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
    color: #333333; /* Ensures text is dark */
}

.wizard-modal {
    background: white;
    /* INCREASED SIZE */
    width: 850px; 
    height: 750px; 
    max-width: 95%;
    max-height: 90vh;
    
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
#wizardForm {
    display: flex;
    flex-direction: column;
    height: 100%; /* Fills the modal */
    overflow: hidden;
}

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

.wizard-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbfc;
}
.wizard-header h2 { font-size: 18px; margin: 0; font-weight: 700; color: var(--primary); }
.step-indicator { font-size: 13px; color: var(--text-muted); font-weight: 600; background: var(--bg-body); padding: 4px 12px; border-radius: 20px; }

.wizard-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    background: white;
    flex-shrink: 0; /* Prevents footer from squishing */
}
.nav-buttons { display: flex; gap: 12px; }

/* Wizard Steps */
.step-content {
    display: none;
    padding: 30px 40px; /* More breathing room */
    flex: 1;            /* Pushes the footer to the very bottom */
    overflow-y: auto;   /* Scrollbar appears here if content is too long */
}
.step-content.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); }}

/* Category Cards */
.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cat-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    position: relative;
    background: white;
}
.cat-card:hover { border-color: var(--primary); background: var(--primary-light); }
.cat-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.cat-card i { font-size: 28px; color: var(--secondary); margin-bottom: 12px; display: block; transition: 0.2s; }
.cat-card span { font-size: 14px; font-weight: 600; display: block;}
.cat-card input:checked + i { color: var(--primary); transform: scale(1.1); }
.cat-card:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

/* Search Results Mock */
.search-wrapper { position: relative; }
.search-results {
    display: none;
    position: absolute; 
    top: 100%; 
    left: 0; 
    width: 100%;
    background: white; 
    border: 1px solid var(--border);
    border-radius: 8px; 
    box-shadow: var(--shadow-md); 
    z-index: 1000;
    margin-top: 4px;
    
    /* THE FIX: Ensure it has room to breathe */
    max-height: 300px; 
    min-height: 100px; /* Forces it to show at least a bit of area */
    overflow-y: auto;
}
.result-item { padding: 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.result-item:hover { background: var(--primary-light); }
.result-item:last-child { border-bottom: none; }

/* Mobile */
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .wizard-modal { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
    .step-content { padding: 20px; }
    .category-grid { grid-template-columns: repeat(2, 1fr); }
    /* Fix sidebar overlay on mobile */
    .sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 90; display: none; backdrop-filter: blur(2px); }
    /* Hide search bar on mobile */
    .search-bar { display: none; }
    /* Show menu button */
    #mobileMenuBtn { display: block !important; }
}

/* Tablet */
@media (max-width: 1024px) {
    :root { --nav-width: 0px; }
    .sidebar { position: fixed; left: -280px; top: 0; height: 100%; width: 260px; box-shadow: 4px 0 24px rgba(0,0,0,0.1); }
    .sidebar.active { left: 0; }
    .sidebar-overlay.active { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Custom Toggle Buttons */
.toggle-container { display: flex; gap: 10px; }
.toggle-btn {
    flex: 1; border: 1px solid var(--border); padding: 10px;
    text-align: center; border-radius: 8px; cursor: pointer; transition: 0.2s;
}
.toggle-btn:has(input:checked) {
    background: var(--primary); color: white; border-color: var(--primary);
}
.toggle-btn input { display: none; }

/* Product Preview Image */
#product-preview img {
    max-width: 150px; border-radius: 8px; border: 1px solid var(--border);
    margin-bottom: 5px;
}
/* =========================================
   8. TICKET VIEW & TEXTAREA ENHANCEMENTS
   ========================================= */
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    resize: vertical;
    transition: 0.2s;
    background: #fff;
}

textarea:focus { 
    border-color: var(--primary); 
    outline: none; 
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Specific styling for the Ticket View Page to match your draft */
#ticketViewPage .stat-card {
    height: 100%;
}

#ticketViewPage .device-meta p {
    margin-bottom: 8px;
}

#ticketViewPage strong {
    color: var(--secondary);
    width: 110px;
    display: inline-block;
}
/* Expansion for the SO, Parts, and Billing boxes */
#ticketViewPage .stats-grid .stat-card {
    min-height: 350px; /* Adjust this value to make the blue boxes taller */
    display: flex;
    flex-direction: column;
}

#ticketViewPage #viewPartsList {
    flex: 1;
    overflow-y: auto;
}

/* Technician Avatar in Header */
.tech-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 50px;
    cursor: pointer;
    transition: 0.2s;
}
.tech-badge:hover { background: var(--primary-light); border-color: var(--primary); }
.tech-badge img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary); }
.tech-badge span { font-weight: 700; font-size: 14px; color: var(--primary); }

/* Status Specific Buttons */
.btn-pending { background: #ffc107; color: #212529; box-shadow: 0 4px 12px rgba(255, 193, 7, 0.2); }
.btn-pending:hover { background: #e0a800; }

/* --- Tab Highlighting --- */
.btn-tab.active {
    background-color: #1428a0 !important;
    color: white !important;
}

/* --- Larger Modal Fix --- */
#partsModal > div {
    width: 95% !important;
    max-width: 1200px !important;
    height: 90vh !important;
    display: flex;
    flex-direction: column;
    background: white;
    padding: 30px;
    border-radius: 12px;
}

/* --- Scrollable area for the added parts list --- */
.parts-cart-container {
    flex-grow: 1;
    overflow-y: auto;
    margin-top: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    min-height: 300px;
}

/* --- Search results dropdown styling --- */
#partLookupResults {
    position: absolute;
    z-index: 1000;
    background: white;
    width: 100%;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    border-radius: 0 0 8px 8px;
    max-height: 400px;
    overflow-y: auto;
}

.pdf-link {
    color: #1428a0;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 700;
}
.pdf-link:hover {
    color: #ff6d00;
}

/* Modern Settings Tabs */
.settings-tab-container {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 2px;
}

.settings-tab {
    background: transparent;
    border: none;
    padding: 12px 20px;
    font-weight: 600;
    color: var(--secondary);
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: 0.2s;
    position: relative;
    font-size: 14px;
}

.settings-tab:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.settings-tab.active {
    color: var(--primary);
    background: transparent;
}

.settings-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

#settingsPage {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start; /* Keeps content at the top */
}

/* User Management Section Tweaks */
.settings-section {
    width: 100%;
    clear: both;
}

.search-results {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow-md);
    margin-top: 5px;
    max-height: 250px;
    overflow-y: auto;
}

.result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.result-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}
/* Modern Customer Search Results */
#masterCustResults {
    background: white !important;
    z-index: 999999 !important; /* Ensure it stays above everything */
    position: relative;
    display: block;
    border: 1px solid var(--border);
}

#masterCustResults .result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#masterCustResults .result-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

#masterCustResults .result-item strong {
    color: var(--primary);
}

/* Modernizing the Checkbox Switch */
.cust-toggle-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary-light);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #d0d7ff;
}

#c_goliat {
    width: 22px;
    height: 22px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Custom Modal Inputs for Customers */
#custModal select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}


/* Force settings to the top and prevent overlapping */
#settingsPage {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Keeps items at the top */
}

.settings-section {
    width: 100%;
    flex: 1; /* Allows the section to fill the space properly */
}
/* Modern Action Buttons */
.btn-action-edit {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid #d0d7ff;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
}

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

.btn-action-remove {
    background: #fff0f0;
    color: var(--danger);
    border: 1px solid #ffd0d0;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-action-remove:hover {
    background: var(--danger);
    color: white;
}
/* --- SEARCH MODAL FIX --- */
#searchSelectionModal {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999; /* Higher than everything else */
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

#searchSelectionModal > div {
    background: white;
    width: 550px;
    max-height: 80vh;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-result-row {
    padding: 15px 25px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: 0.2s;
}

.search-result-row:hover {
    background: var(--primary-light);
}

/* =========================================
   MESSAGING SETTINGS
   ========================================= */
.msg-type-tabs {
    display: flex;
    gap: 8px;
    background: #f0f2f5;
    padding: 4px;
    border-radius: 10px;
    width: fit-content;
}
.msg-type-tab {
    padding: 8px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.2s;
}
.msg-type-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(20, 40, 160, 0.25);
}

.msg-status-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.msg-status-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.msg-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #f8f9fb;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
}
.msg-channels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}
.msg-channel {
    padding: 16px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.msg-channel:last-child {
    border-right: none;
}
.msg-channel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.msg-channel-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}
.msg-channel-label i {
    font-size: 14px;
    color: var(--primary);
}

/* Toggle switch */
.msg-toggle {
    position: relative;
    width: 38px;
    height: 20px;
}
.msg-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.msg-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 20px;
    transition: 0.3s;
}
.msg-toggle-slider:before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}
.msg-toggle input:checked + .msg-toggle-slider {
    background: var(--success);
}
.msg-toggle input:checked + .msg-toggle-slider:before {
    transform: translateX(18px);
}

.msg-editor-area {
    display: none;
    flex-direction: column;
    gap: 8px;
}
.msg-editor-area.visible {
    display: flex;
}
.msg-editor-area input,
.msg-editor-area textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
}
.msg-editor-area textarea {
    min-height: 70px;
}
.msg-editor-area label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Tags */
.msg-tag-ref {
    background: var(--primary-light);
    border: 1px solid #d0d8f0;
    border-radius: 10px;
    padding: 14px 18px;
}
.msg-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.msg-tag {
    background: white;
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: 0.15s;
    color: var(--primary);
    font-weight: 600;
}
.msg-tag:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.msg-save-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* =========================================
   TICKET ICON BUTTONS (msg log, comments)
   ========================================= */
.ticket-icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--text-muted);
    transition: 0.2s;
    position: relative;
}
.ticket-icon-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}
.ticket-icon-btn.has-unread {
    color: var(--primary);
    border-color: var(--primary);
    animation: unread-pulse 2s infinite;
}
@keyframes unread-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(20,40,160,0.2); }
    50% { box-shadow: 0 0 0 6px rgba(20,40,160,0); }
}
.comment-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* =========================================
   MESSAGE LOG MODAL
   ========================================= */
.msg-log-entry {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fafbfc;
    font-size: 13px;
}

/* =========================================
   COMMENTS MODAL
   ========================================= */
.comments-tabs {
    display: flex;
    gap: 0;
}
.comment-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}
.comment-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.comment-tab:hover {
    color: var(--primary);
}
.comment-bubble {
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.5;
}
.comment-tech {
    background: #f0fdf4;
    border-left: 3px solid var(--success);
}
.comment-customer {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}
.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.comment-author {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
}
.comment-date {
    font-size: 11px;
    color: var(--text-muted);
}
.comment-body {
    white-space: pre-wrap;
    color: #333;
}

/* =========================================
   ACCESSORY BROWSER GRID
   ========================================= */
.acc-item-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 4px;
    overflow-y: auto;
    max-height: 55vh;
}
.acc-grid-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: 0.2s;
    background: white;
    display: flex;
    flex-direction: column;
}
.acc-grid-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(20,40,160,0.12);
    transform: translateY(-2px);
}
.acc-grid-img {
    width: 100%;
    height: 130px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}
.acc-grid-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.acc-grid-noimg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.acc-grid-info {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}
.acc-grid-info:hover {
    background: var(--primary-light);
}
.acc-grid-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
    word-wrap: break-word;
    line-height: 1.3;
}
.acc-grid-meta {
    font-size: 11px;
    color: var(--text-muted);
}

/* Queue unread badge */
.queue-comment-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 8px;
    vertical-align: middle;
}

/* =========================================
   REPEAT REPAIR BANNER
   ========================================= */
.repeat-repair-alert {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 16px;
}
.repeat-repair-header {
    font-size: 14px;
    color: #856404;
    margin-bottom: 8px;
}
.repeat-repair-header i {
    margin-right: 6px;
    color: #e0a800;
}
.repeat-repair-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.repeat-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #eed075;
    border-radius: 8px;
    text-decoration: none;
    color: var(--primary);
    font-size: 12px;
    transition: 0.2s;
}
.repeat-link:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(20,40,160,0.12);
}
.repeat-link span {
    color: #666;
}

/* =========================================
   PRINT DROPDOWN
   ========================================= */
.print-dropdown-wrap {
    position: relative;
}
.print-dropdown {
    position: absolute;
    top: 42px;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 220px;
    overflow: hidden;
}
.print-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
}
.print-dropdown button:hover {
    background: var(--primary-light);
    color: var(--primary);
}
.print-dropdown button i {
    width: 18px;
    text-align: center;
    color: var(--primary);
}