/* Modern SaaS CRM Design System for Florette Relocations */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #0d9488;
    --background: #f8fafc;
    --sidebar-bg: #ffffff;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #eff6ff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --row-odd: #f0f9ff; /* Light Blue */
    --row-even: #fff1f2; /* Light Pink */
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

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

.global-brand-header {
    background-color: #c20e1a; /* Florette Red */
    color: #ffffff;
    text-align: center;
    padding: 12px 0;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 2000;
}

.app-main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%;
}


/* Modal Read-Only state */
.modal-read-only input, 
.modal-read-only select, 
.modal-read-only textarea {
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: #475569 !important;
    cursor: default !important;
}

/* Sidebar Wrapper */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Collapse Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 20px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.sidebar-toggle span {
    font-size: 16px;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.sidebar.collapsed .sidebar-toggle span {
    transform: rotate(180deg);
}

/* Logo Section */
.sidebar-header {
    padding: 24px;
    height: 100px; /* Adjusted to be slightly smaller than 120px but bigger than 90px */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sidebar-logo-img {
    max-height: 100%; /* Reset to fit within container */
    max-width: 100%; /* Reset to fit within container */
    object-fit: contain;
    transition: transform 0.3s;
}

.sidebar.collapsed .sidebar-logo-img {
    transform: scale(0.6);
}

/* Nav Menu */
.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 8px;
}

.nav-item {
    width: 100%;
    padding: 8px 12px; /* Reduced from 10px */
    display: flex;
    align-items: center;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.85rem; /* Reduced from 0.95rem */
    position: relative;
    transition: background 0.2s;
    user-select: none;
    text-decoration: none;
    margin-bottom: 1px;
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
}

.nav-item.active {
    background-color: var(--sidebar-active);
    font-weight: 700;
}

/* Left Indicator Bar for Active Item */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 4px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.nav-icon {
    min-width: 24px;
    margin-right: 12px;
    color: var(--text-muted);
}

.nav-item.active .nav-icon {
    color: var(--primary);
}

.nav-label {
    flex: 1;
    transition: opacity 0.2s;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .dropdown-arrow {
    opacity: 0;
    pointer-events: none;
}

.dropdown-arrow {
    font-size: 18px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.nav-group.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Sub-menu */
.sub-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding-left: 36px;
}

.nav-group.open .sub-menu {
    max-height: 200px;
}

.sub-item {
    padding: 6px 14px; /* Slightly tighter padding */
    font-size: 0.75rem; /* Reduced from 0.85rem */
    color: var(--text-muted);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    margin-right: 12px;
}

.sub-item:hover {
    color: var(--primary);
    background-color: var(--sidebar-hover);
}

.sub-item.active {
    color: var(--primary);
    font-weight: 700;
    background-color: var(--sidebar-active);
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Restored Header */
.header {
    height: 70px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
}

.header-center h1 {
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-main);
}

.header-right {
    display: flex;
    gap: 16px;
}

/* Action Buttons */
.btn-action {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Dashboard Content */
.content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* Reusing previous components styles but adjusting for new layout */
.widgets-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.widget-card { background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow-sm); border-left: 4px solid #ddd; }
.widget-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 800; /* Bold */
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}
.widget-main {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}
.widget-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.pipeline-section { background: white; padding: 20px; border-radius: var(--radius); margin-bottom: 24px; box-shadow: var(--shadow-sm); }
.table-container { 
    display: flex;
    flex-direction: column;
    max-height: 60vh; 
    border-radius: var(--radius); 
    box-shadow: var(--shadow-sm); 
    background: white; 
    margin-bottom: 24px; 
    position: relative; 
    overflow: hidden; 
}
.table-container .toolbar {
    padding: 16px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 20;
    background: #f8fafc; /* subtle delineation */
}
.table-wrapper {
    flex: 1;
    overflow-y: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; table-layout: fixed; }
.data-table thead th { position: sticky; top: 0; z-index: 10; background: white; cursor: pointer; user-select: none; border-bottom: 2px solid var(--border); font-weight: 800; color: var(--text-muted); padding: 12px 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Force column distributions to avoid colspan explosion in the first column */
.data-table th:nth-child(1) { width: 12%; }
.data-table th:nth-child(2) { width: 18%; }
.data-table th:nth-child(3) { width: 14%; }
.data-table th:nth-child(4) { width: 12%; }
.data-table th:nth-child(5) { width: 12%; }
.data-table th:nth-child(6) { width: 12%; }
.data-table th:nth-child(7) { width: 10%; }
.data-table th:nth-child(8) { width: 10%; }
.data-table thead th:hover { background: #f8fafc; color: var(--primary); }
.data-table thead th.active-col { background: #eff6ff; color: var(--primary); border-bottom: 2px solid var(--primary); }
.sort-icon { display: inline-block; margin-left: 6px; font-size: 14px; vertical-align: middle; color: #cbd5e1; }
.sort-icon.active { color: var(--primary); font-weight: bold; }
.data-table th, .data-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background 0.2s; }

.data-table tbody tr:nth-child(odd) { background-color: var(--row-odd); }
.data-table tbody tr:nth-child(even) { background-color: var(--row-even); }
.data-table tbody tr:hover { background-color: #f1f5f9 !important; }
.data-table tbody tr.highlighted, .data-table tbody tr.service-highlighted { background-color: #dbeafe !important; outline: 2px solid var(--primary); }

.data-table tbody tr.service-row td { background-color: transparent; border-bottom: none; padding: 0; }
.data-table tbody tr.service-row:hover td { background-color: transparent !important; }

/* Inset Service Panel */
.service-panel {
    background: #f8fafc;
    border-radius: 12px;
    margin: 8px 16px 16px 40px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    transition: all 0.3s ease;
}
.service-panel:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}
.service-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}
.service-panel-left {
    display: flex;
    align-items: center;
    gap: 15px;
}
.service-panel-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.service-panel-actions {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}
.service-panel:hover .service-panel-actions {
    opacity: 1;
}
.service-panel-pipeline-wrapper {
    width: 100%;
    padding: 10px 0;
    border-top: 1px dashed var(--border);
}


.status-pill { padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; display: inline-block; }
.status-booked { background: #dcfce7; color: #166534; }
.status-pending { background: #ffedd5; color: #9a3412; }
.status-lost { background: #fee2e2; color: #991b1b; }

.action-icons { display: flex; gap: 12px; justify-content: flex-end; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.data-table tr:hover .action-icons { opacity: 1; pointer-events: auto; }
.action-icon { cursor: pointer; color: var(--text-muted); transition: color 0.2s; font-size: 18px !important; }
.action-icon:hover { color: var(--primary); }
.action-icon.delete:hover { color: var(--lost); }

/* Floating Register Button */
#floating-register {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    cursor: grab;
    z-index: 9999;
    user-select: none;
    transition: transform 0.2s, background 0.2s;
}

#floating-register:active { cursor: grabbing; transform: scale(0.95); }
#floating-register:hover { background: var(--primary-hover); transform: translateY(-2px); }

/* Search & Filter Toolbar */
.toolbar { display: flex; gap: 16px; margin-bottom: 20px; align-items: center; }
.search-container { flex: 1; position: relative; }
.search-container .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 20px; }
.search-container .reset-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #ef4444; font-size: 20px; cursor: pointer; display: none; }
.search-input { width: 100%; padding: 10px 40px 10px 40px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; outline: none; transition: all 0.2s; background: white; }
.search-input:focus { border-color: var(--primary); }
.search-input.active-search { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); background: #f8fafc; }
.filter-select { padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: white; font-size: 0.9rem; outline: none; cursor: pointer; }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
    position: relative;
    padding: 32px;
    animation: modalSlide 0.3s ease-out;
}

/* Red Branding Header for Modals */
.modal-brand-header {
    background-color: #c20e1a; /* Florette Company Red */
    color: white;
    text-align: center;
    padding: 16px;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 2.5px;
    margin: -32px -32px 24px -32px; /* Negative margin to span full width of padded modal */
    text-transform: uppercase;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-close {
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* Form Styling */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.field-group.full {
    grid-column: span 2;
}

.field-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.field-group input, 
.field-group select {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.uppercase-input {
    text-transform: uppercase;
}

.field-group input:focus, 
.field-group select:focus {
    border-color: var(--primary);
}

.field-group input[readonly] {
    background: #f8fafc;
    color: var(--text-muted);
}

.section-title {
    grid-column: span 2;
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 12px 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.modal-footer {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.btn-modal {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-modal-save {
    background: var(--primary);
    color: white;
    border: none;
}

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

.btn-modal-cancel {
    background: white;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-modal-cancel:hover {
    background: #f1f5f9;
}

/* Details Modal Specifics */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 32px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.detail-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    padding: 4px 0;
}

.detail-value .status-pill {
    margin-left: 0;
}

/* Enhanced Row Highlight */
tr.highlighted {
    background-color: var(--sidebar-active) !important;
    border-left: 4px solid var(--primary);
}

tr.highlighted td:first-child {
    padding-left: 12px;
}

/* ── Services Module ────────────────────────────────────────────────────── */

/* Service sub-row */
tr.service-row td {
    background: linear-gradient(to right, #f0f7ff, #fafafa);
    border-left: 4px solid #bfdbfe;
    padding: 7px 10px 7px 32px;
    font-size: 0.82rem;
}

tr.service-row:hover td {
    background: linear-gradient(to right, #dbeafe, #f0f7ff);
    cursor: pointer;
}

tr.service-highlighted td {
    background: linear-gradient(to right, #dbeafe, #eff6ff) !important;
    border-left: 4px solid #3b82f6 !important;
}

/* Service cell layout */
.service-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.service-mode-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.service-brief {
    font-weight: 600;
    color: #1e293b;
}

.service-meta {
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 7px;
    border-radius: 8px;
    white-space: nowrap;
}

/* Expand/collapse toggle */
.expand-toggle {
    transition: transform 0.2s ease;
    display: inline-block;
}

/* ── Shipment Pipeline ──────────────────────────────────────────────────── */
.pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 10px 28px 12px 28px;
    background: linear-gradient(to right, #f8fafc, #f0f7ff);
    border-top: 1px solid #e2e8f0;
    overflow-x: auto;
    flex-wrap: nowrap;
}

.pipeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 80px;
    flex: 1;
}

/* Connector line between steps */
.pipeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 14px;
    left: calc(50% + 14px);
    width: calc(100% - 28px);
    height: 3px;
    background: #e2e8f0;
    z-index: 0;
    transition: background 0.3s ease;
}

.pipeline-step.done:not(:last-child)::after {
    background: linear-gradient(to right, #22c55e, #16a34a);
}

.pipeline-step.active:not(:last-child)::after {
    background: linear-gradient(to right, #3b82f6, #e2e8f0);
}

/* Step icon circle */
.pipeline-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
    transition: all 0.25s ease;
    border: 2px solid transparent;
}

/* Done: green */
.pipeline-step.done .pipeline-icon {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 2px 8px rgba(34,197,94,0.35);
}

/* Active: blue pulse */
.pipeline-step.active .pipeline-icon {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 2px 12px rgba(59,130,246,0.45);
    animation: pulse-ring 1.8s ease infinite;
}

@keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
    70%  { box-shadow: 0 0 0 6px rgba(59,130,246,0); }
    100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}

/* Upcoming: grey */
.pipeline-step.upcoming .pipeline-icon {
    background: #f1f5f9;
    color: #94a3b8;
    border: 2px solid #e2e8f0;
}

/* Step label */
.pipeline-label {
    font-size: 0.65rem;
    font-weight: 600;
    margin-top: 5px;
    text-align: center;
    letter-spacing: 0.02em;
}

.pipeline-step.done     .pipeline-label { color: #16a34a; }
.pipeline-step.active   .pipeline-label { color: #2563eb; font-weight: 800; }
.pipeline-step.upcoming .pipeline-label { color: #94a3b8; }

/* Pipeline in service modal (top section) */
.pipeline-modal {
    padding: 14px 28px 16px;
    background: linear-gradient(to right, #f0f7ff, #f8fafc);
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 16px;
}

.pipeline-modal .pipeline {
    padding: 0;
    background: none;
    border: none;
}

/* Multi-select Building Access */
.multi-select-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.multi-select-container label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    background: white;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: all 0.2s;
}

.multi-select-container label:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.multi-select-container input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Modal Content Adjustments */
#svc-modal .modal-content {
    background: #ffffff;
}

#svc-modal .section-title {
    margin-top: 20px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #f1f5f9;
}


/* Reports Module Styles */
.report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
}
.report-row:hover {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}
.report-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}
.report-actions {
    display: flex;
    gap: 12px;
}
.report-actions .btn-action {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 6px;
}
.report-actions .material-icons {
    font-size: 16px;
}

/* ── Hamburger Button (Mobile Only) ──────────────────────────────────────── */
.hamburger-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-main);
    align-items: center;
    justify-content: center;
}

/* ── Mobile Sidebar Overlay ──────────────────────────────────────────────── */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.5);
    backdrop-filter: blur(2px);
    z-index: 900;
}

.mobile-overlay.active { display: block; }

/* ── Role-based visibility ─────────────────────────────────────────────── */
.admin-only { display: none; } /* Hidden until role is confirmed as admin */

/* ── Mobile Media Queries ────────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Show hamburger, hide sidebar toggle pin */
    .hamburger-btn { display: flex; }
    .sidebar-toggle { display: none; }

    /* Sidebar becomes a floating overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s;
        width: var(--sidebar-width) !important;
        box-shadow: 4px 0 20px rgba(0,0,0,0.2);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Layout: sidebar no longer takes space */
    .app-main-layout { display: block; }
    .main-wrapper { width: 100%; }

    /* Reduce content padding */
    .content { padding: 16px; }

    /* Widgets: 2 columns on mobile */
    .widgets-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 16px;
    }

    /* Modals: near full-screen */
    .modal-content {
        width: 95%;
        padding: 20px;
        border-radius: 16px;
        max-height: 95vh;
    }

    .modal-brand-header {
        margin: -20px -20px 20px -20px;
        font-size: 1rem;
        padding: 14px;
    }

    /* Single column forms on mobile */
    .form-grid {
        grid-template-columns: 1fr;
    }

    .field-group.full {
        grid-column: span 1;
    }

    .section-title {
        grid-column: span 1;
    }

    /* Table: smaller text, horizontal scroll enabled */
    .data-table { font-size: 0.75rem; }
    .data-table th, .data-table td { padding: 8px 10px; }
    .table-wrapper { -webkit-overflow-scrolling: touch; }

    /* Toolbar: stack vertically */
    .toolbar { flex-direction: column; gap: 10px; }
    .filter-select { width: 100%; }

    /* Service panel: tighten indent on mobile */
    .service-panel { margin: 8px 8px 12px 16px; padding: 14px; }

    /* Pipeline: smaller icons */
    .pipeline { padding: 10px 8px; }
    .pipeline-step { min-width: 56px; }
    .pipeline-label { font-size: 0.6rem; }
    .pipeline-icon { width: 26px; height: 26px; font-size: 0.8rem; }

    /* Always show service actions on mobile (no hover needed) */
    .service-panel-actions { opacity: 1; position: static; margin-top: 10px; }
    .action-icons { opacity: 1; pointer-events: auto; }

    /* Header: tighter padding */
    .header { padding: 0 12px; height: 60px; }

    /* Brand header: slightly smaller */
    .global-brand-header { font-size: 13px; padding: 10px 0; }

    /* Modal footer: stack buttons */
    .modal-footer { flex-direction: column; gap: 10px; }

    /* ── TABLE: Hide secondary columns on mobile ────────────────────────────
       Keep: Col 1 (ID), Col 2 (Name), Col 7 (Status), Col 8 (Actions)
       Hide: Col 3 (Account), Col 4 (From), Col 5 (To), Col 6 (Sales)     */
    .data-table th:nth-child(3),
    .data-table td:nth-child(3),
    .data-table th:nth-child(4),
    .data-table td:nth-child(4),
    .data-table th:nth-child(5),
    .data-table td:nth-child(5),
    .data-table th:nth-child(6),
    .data-table td:nth-child(6) {
        display: none;
    }

    /* Make remaining columns fill space */
    .data-table th:nth-child(1) { width: 30%; }
    .data-table th:nth-child(2) { width: 40%; }
    .data-table th:nth-child(7) { width: 20%; }
    .data-table th:nth-child(8) { width: 10%; }

    /* Name cell: truncate long names instead of wrapping */
    .data-table td:nth-child(2) {
        max-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Floating Register Button: always fixed on mobile, show label */
    #floating-register {
        bottom: 20px;
        right: 16px;
        padding: 14px 20px;
        font-size: 0.95rem;
        cursor: pointer; /* remove grab cursor on touch */
        position: fixed !important; /* ensure it stays on screen */
    }
}

/* Tablet: 2-3 column widgets */
@media (min-width: 769px) and (max-width: 1024px) {
    .widgets-grid { grid-template-columns: repeat(3, 1fr); }
    .content { padding: 16px; }
}
