/* ===== Admin Dashboard — Complete Overhaul ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Poppins:wght@500;600;700&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --sidebar: #243048;
    --sidebar-hover: #2e3d5c;
    --sidebar-active: #A3CDEF;
    --sidebar-text: rgba(255,255,255,0.72);
    --sidebar-width: 240px;
    --header-height: 56px;
    --bg: #EEF4FA;
    --card: #FFFFFF;
    --card-hover: #f6fafd;
    --text: #243048;
    --text-secondary: #4a5770;
    --text-muted: #5b6880;
    --border: #d6e6f5;
    --border-light: #EEF4FA;
    --accent: #243048;
    --accent-light: #EEF4FA;
    --accent-dark: #1a2336;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3d7fbf;
    --info-light: #e3f0fb;
    --radius-sm: 7px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-xl: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
    --transition: 0.15s ease;
    --sky: #A3CDEF;
    --sky-soft: rgba(163,205,239,0.28);
    --font-heading: 'Poppins', 'Inter', sans-serif;
}

/* A position the page is scrolled to (scrollIntoView) lands below the sticky header, not under it */
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 1rem); }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, #243048 0%, #0c1222 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 300;
    transition: transform var(--transition);
    box-shadow: 1px 0 4px rgba(0,0,0,0.15);
    border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    height: 60px;
    padding: 0 1.25rem;
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.03em;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-brand span {
    color: var(--sky);
    margin-left: 0.15rem;
}

.sidebar-brand small {
    font-size: 0.55rem;
    font-weight: 500;
    color: var(--sidebar-text);
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.5;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-section { margin-bottom: 0.15rem; }

.nav-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem 0.35rem;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.nav-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.06);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.12s ease;
    white-space: nowrap;
    position: relative;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
    padding-left: 0.9rem;
    border-left-color: rgba(255,255,255,0.08);
}

.nav-item.active {
    background: rgba(163,205,239,0.14);
    color: var(--sky);
    font-weight: 600;
    border-left-color: var(--sky);
    padding-left: 0.9rem;
}

/* MAIN WRAPPER */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0; /* let wide tables scroll inside instead of widening the page */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOP HEADER */
.top-header {
    height: var(--header-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.breadcrumb strong {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.user-name:hover { text-decoration: underline; }

.user-role {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.logout-btn:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* MAIN CONTENT */
.admin-main {
    padding: 1.5rem;
    flex: 1;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* page-header no longer contains h1 (moved to top-header breadcrumb) */

/* FORM CONTROLS */
.date-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.date-input,
.text-input,
.small-input,
.status-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.7rem;
    font-size: 0.825rem;
    background: var(--card);
    color: var(--text);
    max-width: 100%;
    transition: var(--transition);
    font-family: inherit;
    outline: none;
}

.date-input:focus,
.text-input:focus,
.small-input:focus,
.status-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(36,48,72,0.1);
}

.date-input { min-width: 150px; }
.text-input { min-width: 200px; }
.small-input { width: 90px; }
.full-width { width: 100%; }

/* TABLES */
.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    display: block;
    overflow-x: auto;
}

@media (min-width: 700px) { .admin-table { display: table; } }

.admin-table thead { background: #f8fafc; }

.admin-table th {
    text-align: left;
    padding: 0.65rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.825rem;
    vertical-align: middle;
}

.admin-table tbody tr { transition: var(--transition); }
.admin-table tbody tr:hover { background: #f8fafc; }
.admin-table tbody tr:active { background: #f1f5f9; }

.permissions-cell { max-width: 380px; line-height: 1.45; }
.row-closed { opacity: 0.5; }
.row-full { background: var(--warning-light); }
.row-inactive { opacity: 0.5; }

/* KPI CARDS */
.kpi-grid,
.stats-grid,
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.kpi-card,
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.kpi-card:hover,
.stat-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

.kpi-card span,
.stat-card span {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-card strong,
.stat-card strong {
    font-size: 1.3rem;
    color: var(--text);
    word-break: break-word;
    font-weight: 700;
}

.kpi-card small,
.stat-card small { font-size: 0.7rem; color: var(--text-muted); }

/* CARDS / SECTIONS */
.card-lite,
.detail-section {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.15rem 1.25rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card-lite:hover,
.detail-section:hover { box-shadow: var(--shadow-lg); }

.section-title {
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 0.75rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* LISTS */
.detail-section ul, .card-lite ul, .sop-checklist, .assigned-employees-list {
    list-style: none;
    padding: 0; margin: 0;
}

.detail-section li, .card-lite li {
    padding: 0.3rem 0;
    font-size: 0.825rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.detail-section li:last-child, .card-lite li:last-child { border-bottom: none; }

/* FORMS */
.form-grid { display: grid; gap: 0.85rem; }

.form-grid.two-col { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    max-width: 100%;
}

.inline-form.wrap { flex-wrap: wrap; }

.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.3rem 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0.25rem 0.35rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.checkbox-label:hover { background: var(--accent-light); }
.checkbox { cursor: pointer; accent-color: var(--accent); }

.modal-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.full-span { grid-column: 1 / -1; }

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
}

.btn:hover { background: var(--accent-dark); box-shadow: 0 2px 8px rgba(36,48,72,0.3); }
.btn:active { transform: scale(0.98); }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.75rem; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }

/* Outline buttons come after .btn:hover, so their own hover colours win */
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--accent-light); color: var(--accent-dark); box-shadow: none; }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-outline:hover { background: var(--danger-light); color: var(--danger); box-shadow: none; }

.link { color: var(--accent-dark); text-decoration: none; font-weight: 600; transition: var(--transition); }
.link:hover { color: var(--accent); text-decoration: underline; }

/* ALERTS */
.alert {
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    font-size: 0.825rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-info { background: var(--info-light); color: #2563eb; border-color: #93c5fd; }
.alert-success { background: var(--success-light); color: #16a34a; border-color: #86efac; }
.alert-danger { background: var(--danger-light); color: var(--danger); border-color: #fca5a5; }
.alert-warning { background: var(--warning-light); color: #d97706; border-color: #fcd34d; }

/* A message whose container is off screen (the page is scrolled, or a dialog is open) floats under the header. It is
   fixed, so it takes no room in the page and nothing moves; a click closes it (showAlert in admin-common.js). */
.alert-floating {
    position: fixed;
    top: calc(var(--header-height) + 0.5rem);
    left: 1rem;
    right: 1rem;
    max-width: 720px;
    margin: 0 auto;
    z-index: 1300; /* above the dialogs (1000, the carpet dialogs 1200) */
    box-shadow: var(--shadow-xl);
    overflow-wrap: anywhere;
    cursor: pointer;
}

/* beside the sidebar, centred in the page */
@media (min-width: 861px) {
    body:has(.sidebar) .alert-floating { left: calc(var(--sidebar-width) + 1.5rem); right: 1.5rem; }
}

@media print {
    .alert-floating { display: none; }
}

/* BADGES */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.badge-open { background: var(--success-light); color: #16a34a; }
.badge-closed { background: var(--danger-light); color: var(--danger); }
.badge-full { background: var(--warning-light); color: #d97706; }
.badge-reserved { background: var(--info-light); color: #2563eb; }
.badge-pending { background: var(--warning-light); color: #d97706; }
.badge-confirmed { background: var(--info-light); color: #2563eb; }
.badge-inprogress { background: var(--accent-light); color: var(--accent-dark); }
.badge-cancelled { background: var(--danger-light); color: var(--danger); }
.badge-completed { background: var(--success-light); color: #16a34a; }
.badge-active { background: var(--success-light); color: #16a34a; }
.badge-inactive { background: #f1f5f9; color: #94a3b8; }
.badge-draft { background: #ede9fe; color: #7c3aed; }
.badge-sent { background: var(--info-light); color: #2563eb; }
.badge-partiallypaid { background: var(--warning-light); color: #d97706; }
.badge-paid { background: var(--success-light); color: #16a34a; }
.badge-overdue { background: var(--danger-light); color: var(--danger); }
.badge-writtenoff { background: #f1f5f9; color: #94a3b8; }
.badge-owner { background: #ede9fe; color: #7c3aed; }
.badge-dispatcher { background: var(--info-light); color: #2563eb; }
.badge-cleaner { background: var(--success-light); color: #16a34a; }
.badge-finance { background: var(--warning-light); color: #d97706; }
.badge-client { background: var(--danger-light); color: var(--danger); }
.badge-person { background: var(--info-light); color: #2563eb; }
.badge-business { background: #ede9fe; color: #7c3aed; }
.badge-employee { background: var(--success-light); color: #16a34a; }
.badge-onetime { background: #f1f5f9; color: #64748b; }
.badge-repeatindividual { background: var(--info-light); color: #2563eb; }
.badge-repeatbusiness { background: #ede9fe; color: #7c3aed; }
.badge-protected { background: #ede9fe; color: #7c3aed; }
.badge-info { background: var(--info-light); color: #2563eb; }
.badge-new { background: var(--info-light); color: #2563eb; }
.badge-adminreviewed { background: var(--warning-light); color: #d97706; }
.badge-senttocustomer { background: #ede9fe; color: #7c3aed; }
.badge-rejected { background: var(--danger-light); color: var(--danger); }
.badge-converted { background: #f1f5f9; color: #64748b; }
.badge-expired { background: var(--danger-light); color: var(--danger); }

/* MODALS */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-panel {
    background: var(--card);
    border-radius: var(--radius-lg);
    width: min(860px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.2s ease;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--card);
    border-radius: var(--radius-lg);
    width: min(500px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
}

/* CALENDAR */
.cal-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    background: var(--card);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.cal-view-pills {
    display: flex;
    background: var(--bg);
    padding: 2px;
    border-radius: var(--radius-sm);
    gap: 2px;
}

.cal-view-pills button {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    border-radius: 4px;
}

.cal-view-pills button:hover { background: rgba(36,48,72,0.08); color: var(--accent-dark); }

.cal-view-pills button.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 4px rgba(36,48,72,0.3);
}

.cal-nav { display: flex; align-items: center; gap: 0.5rem; }

.cal-nav-btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.8rem;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-secondary);
    transition: var(--transition);
    font-family: inherit;
    font-weight: 500;
}

.cal-nav-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }

.cal-range-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    min-width: 170px;
    text-align: center;
    background: var(--bg);
    padding: 0.3rem 0.9rem;
    border-radius: 20px;
}

/* Resource Grid */
.resource-grid-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 240px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--card);
    position: relative;
    -webkit-overflow-scrolling: touch;
    isolation: isolate;
    border: 1px solid var(--border);
}

.resource-grid-wrapper::-webkit-scrollbar { height: 6px; width: 6px; }
.resource-grid-wrapper::-webkit-scrollbar-track { background: var(--bg); border-radius: 3px; }
.resource-grid-wrapper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.resource-grid-wrapper::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.resource-grid { border-collapse: collapse; min-width: 100%; table-layout: fixed; }

.resource-col-header {
    padding: 0.45rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid var(--border);
    border-right: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 15;
    background: var(--card);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}

.resource-col-time-header {
    width: 65px; min-width: 65px;
    position: sticky; left: 0; z-index: 25;
    background: var(--bg); color: var(--text-muted);
    font-size: 0.68rem; border-right: 2px solid var(--border);
}

.resource-col-unassigned-header {
    width: 180px; min-width: 180px;
    position: sticky; left: 65px; z-index: 24;
    background: var(--warning-light); color: #d97706;
    border-right: 2px solid #fcd34d;
}

.resource-col-header--free { background: var(--success-light); color: #16a34a; }

.resource-emp-name { font-weight: 600; font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resource-emp-role { font-size: 0.62rem; opacity: 0.55; font-weight: 400; margin-top: 1px; }

.resource-unassigned-badge {
    display: inline-block;
    background: #d97706; color: white;
    border-radius: 10px; padding: 0.08rem 0.4rem;
    font-size: 0.62rem; font-weight: 700;
    margin-left: 0.3rem; vertical-align: middle;
}

.resource-cell {
    padding: 2px;
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    vertical-align: top;
    min-height: 48px;
    width: 180px; min-width: 180px;
}

.resource-cell--time {
    width: 65px; min-width: 65px;
    font-size: 0.68rem; color: var(--text-muted);
    text-align: right; padding: 0.35rem 0.5rem;
    white-space: nowrap; background: var(--bg);
    position: sticky; left: 0; z-index: 10;
    border-right: 2px solid var(--border);
}

.resource-cell--unassigned {
    position: sticky; left: 65px; z-index: 9;
    background: #fffdf5; border-right: 2px solid #fcd34d;
}

.resource-cell--free { background: #fafff9; }

.resource-row--today .resource-cell--time {
    background: var(--accent-light);
    color: var(--accent-dark);
    font-weight: 700;
}

.resource-card {
    display: block;
    border-radius: 4px;
    padding: 0.25rem 0.4rem;
    font-size: 0.7rem;
    margin-bottom: 1px;
    text-decoration: none;
    border-left: 3px solid transparent;
    line-height: 1.3;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.resource-card:hover { filter: brightness(0.92); transform: translateX(1px); }
.resource-card__time { font-size: 0.62rem; opacity: 0.7; margin-bottom: 1px; }
.resource-card__client { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resource-card__meta { font-size: 0.62rem; opacity: 0.65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.resource-card--pending { background: var(--warning-light); border-left-color: var(--warning); color: #78350f; }
.resource-card--confirmed { background: var(--info-light); border-left-color: var(--info); color: #1e3a5f; }
.resource-card--inprogress { background: var(--accent-light); border-left-color: var(--accent); color: #243048; }
.resource-card--completed { background: var(--success-light); border-left-color: var(--success); color: #14532d; }
.resource-card--cancelled { background: #f1f5f9; border-left-color: #94a3b8; color: #475569; }

.resource-chip {
    display: block; border-radius: 3px;
    padding: 0.15rem 0.4rem; font-size: 0.68rem;
    margin-bottom: 1px; text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    cursor: pointer; transition: var(--transition);
}

.resource-chip:hover { filter: brightness(0.92); transform: translateX(1px); }
.resource-chip--pending { background: var(--warning-light); color: #78350f; }
.resource-chip--confirmed { background: var(--info-light); color: #1e3a5f; }
.resource-chip--inprogress { background: var(--accent-light); color: #243048; }
.resource-chip--completed { background: var(--success-light); color: #14532d; }
.resource-chip--cancelled { background: #f1f5f9; color: #475569; }

.resource-count {
    display: inline-block;
    background: var(--accent); color: white;
    border-radius: 10px; padding: 0.12rem 0.45rem;
    font-size: 0.68rem; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: var(--transition);
}

.resource-count:hover { background: var(--accent-dark); transform: scale(1.05); }

.cal-sop-bar { height: 3px; background: var(--border-light); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.cal-sop-bar__fill { height: 100%; background: var(--success); transition: width 0.3s; }

.emp-task-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.9rem 1.1rem;
    margin-bottom: 0.65rem;
    border-left: 4px solid var(--accent);
    transition: var(--transition);
    border: 1px solid var(--border);
    border-left-width: 4px;
}

.emp-task-card:hover { box-shadow: var(--shadow-lg); border-color: var(--accent); }
.emp-task-card--pending { border-left-color: var(--warning); }
.emp-task-card--confirmed { border-left-color: var(--info); }
.emp-task-card--inprogress { border-left-color: var(--info); }
.emp-task-card--completed { border-left-color: var(--success); }
.emp-task-card--cancelled { border-left-color: #94a3b8; }

.emp-task-card__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.3rem; }
.emp-task-card__title { font-weight: 700; font-size: 0.88rem; color: var(--text); }
.emp-task-card__meta { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }
.emp-task-card__actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }

/* TABLE ROW SELECTORS (JS hooks) */
.booking-row, .client-row, .role-row, .service-row, .sop-row, .schedule-row, .user-row { cursor: pointer; }
.role-protected { opacity: 0.55; }

/* PAGINATION */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.4rem; margin-top: 1rem; }
.pagination span {
    padding: 0.3rem 0.7rem; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.78rem; color: var(--text-secondary); font-weight: 500;
}

/* SKELETON */
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, #e2e8f0 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* LOGIN */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #243048 0%, #2e3d5c 100%);
    padding: 1.5rem;
}

.login-card {
    max-width: 400px; width: 100%; margin: 0 auto;
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    padding: 2.25rem 2rem;
    border: 1px solid rgba(255,255,255,0.1);
}

.login-card h1 {
    font-weight: 800; color: var(--text);
    font-size: 1.4rem; margin-bottom: 0.3rem;
    text-align: center; letter-spacing: -0.02em;
}

.login-card .login-subtitle {
    text-align: center; color: var(--text-muted);
    font-size: 0.85rem; margin-bottom: 1.5rem;
}

/* DETAIL SECTIONS */
.detail-grid { display: grid; gap: 0.75rem; }
.detail-grid.two-col { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.825rem;
}

.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-muted); font-weight: 500; }
.detail-row span:last-child { font-weight: 600; text-align: right; }

/* REQUEST DETAIL: the request on the left and the offer on the right on a wide screen, one column below 1200 px */
.request-meta { margin: 0.35rem 0 0; font-size: 0.8rem; color: var(--text-muted); }
.request-layout { display: grid; gap: 0.75rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1200px) { .request-layout { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
.request-notes { white-space: pre-line; font-size: 0.85rem; color: var(--text-secondary); }
#request-carpet-zone, .request-carpet-express { font-size: 0.875rem; }
.request-carpets-scroll { overflow-x: auto; margin-bottom: 1rem; }
.request-carpets-scroll .admin-table { margin-bottom: 0; }
.request-carpets-scroll .nowrap { white-space: nowrap; }
.request-carpets-scroll td:first-child { min-width: 9rem; }
.proposal-line { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.35rem 0; border-bottom: 1px solid var(--border-light); }
.proposal-line-name { flex: 1 1 12rem; font-size: 0.875rem; }
.proposal-no-lines { font-size: 0.825rem; color: var(--text-muted); margin: 0.25rem 0; }
.proposal-add { margin-top: 0.5rem; }
.proposal-estimate-input { min-width: 0; max-width: 12rem; }
.proposal-estimate #proposal-sizes-quote { margin-top: 0.25rem; }
.proposal-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.proposal-actions .btn-danger-outline { margin-left: auto; }

/* FOOTER */
.admin-footer {
    background: var(--card);
    text-align: center;
    padding: 0.75rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: auto;
    border-top: 1px solid var(--border);
}

/* RESPONSIVE */
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .mobile-toggle { display: block; }
    .kpi-grid, .stats-grid, .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .admin-main { padding: 1rem; }
    .page-header h1 { font-size: 1.1rem; }
    .kpi-grid, .stats-grid, .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .user-details { display: none; }
}

/* ── Language Switcher ──────────────────────────── */
#lang-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 0.5rem;
}
.lang-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.6);
    padding: 0.15rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: 0.15s;
    font-family: inherit;
    line-height: 1.4;
}
.lang-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.lang-btn.active { background: var(--sky); color: var(--accent); border-color: var(--sky); }
.header-right #lang-switcher .lang-btn { border-color: var(--border); color: var(--text-muted); }
.header-right #lang-switcher .lang-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

/* ===== Autocomplete Dropdown ===== */
.autocomplete-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    max-height: 240px;
    overflow-y: auto;
}
.autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s;
}
.autocomplete-item:hover { background: var(--accent-light); }
.autocomplete-item.disabled {
    opacity: 0.5;
    cursor: default;
}

/* ===== Chistify brand ===== */
h1, h2, h3, h4, .serif, .page-title, .section-title, .stat-value {
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}
::selection { background: #243048; color: #A3CDEF; }
.brand-logo { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-heading); font-weight: 700; text-decoration: none; }
.brand-logo svg { width: 34px; height: 34px; flex-shrink: 0; }

.sidebar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
}
.sidebar-brand::before {
    content: '';
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%23A3CDEF' stroke-width='6' stroke-linecap='round'%3E%3Ccircle cx='50' cy='50' r='44'/%3E%3Cpath d='M50 22C50 22 63 42 63 52A13 13 0 0 1 37 52C37 42 50 22 50 22Z'/%3E%3Cpath d='M20 72C30 60 40 84 50 72C60 60 70 84 80 72'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

.sidebar-brand { display: flex; color: white; border-bottom: 1px solid var(--sky-soft); }
.btn-primary, .btn { border-radius: var(--radius); }
.stat-card { border-radius: var(--radius-lg); }
.stat-card:hover { border-color: var(--sky); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--sky-soft); }

/* ===== Content translations (HR + EN inputs, missing badge, translations page) ===== */
.lang-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.lang-pair textarea { resize: vertical; }
/* The global box-sizing reset at the top of this file is swallowed by the malformed @import on line 2, so size these explicitly */
.lang-pair .text-input, .tr-edit .text-input, .tr-toolbar .text-input { box-sizing: border-box; }
.lang-label { display: flex; align-items: center; gap: 0.4rem; }
.lang-tag {
    display: inline-block;
    padding: 0 0.4rem;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.6;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--border);
}
.lang-tag-en { background: var(--info-light); color: #1e5a96; border-color: var(--sky); }
.badge-translation-missing {
    background: var(--warning-light);
    color: #b45309;
    border: 1px solid #fcd34d;
    text-transform: none;
    cursor: help;
    vertical-align: middle;
}
.form-hint { font-size: 0.75rem; font-weight: 400; color: var(--text-muted); }

.tr-hint { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 1rem; }
.tr-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tr-tab {
    background: none;
    border: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    padding: 0.6rem 1rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.tr-tab[hidden] { display: none; }
.tr-tab:hover { color: var(--accent); }
.tr-tab.active { color: var(--accent); border-bottom-color: var(--sky); }
.tr-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.tr-toolbar label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.tr-toolbar .tr-search { flex: 1 1 220px; min-width: 0; }
.tr-counter { margin-left: auto; font-size: 0.82rem; font-weight: 700; color: var(--text-secondary); }
.tr-group { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.75rem; overflow: hidden; box-shadow: var(--shadow); }
.tr-group-head { padding: 0.7rem 1rem; font-weight: 700; font-size: 0.9rem; background: var(--accent-light); border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.tr-item-head { padding: 0.45rem 1rem; font-size: 0.76rem; font-weight: 700; color: var(--text-secondary); background: #f8fafc; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.tr-colhead, .tr-row { display: grid; grid-template-columns: 9rem minmax(0, 1fr) minmax(0, 1.25fr); gap: 0.5rem 1rem; padding: 0.7rem 1rem; }
.tr-colhead { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding-top: 0.2rem; padding-bottom: 0.35rem; }
.tr-row { align-items: start; border-top: 1px solid var(--border-light); transition: var(--transition); }
.tr-row--saved { background: #f3fbf7; box-shadow: inset 3px 0 0 var(--success); }
.tr-row[hidden], .tr-item[hidden], .tr-group[hidden] { display: none; }
.tr-field { font-size: 0.8rem; font-weight: 600; color: var(--text); display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; }
.tr-base { font-size: 0.82rem; color: var(--text-secondary); white-space: pre-wrap; overflow-wrap: anywhere; background: #f8fafc; border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 0.4rem 0.65rem; }
.tr-cap { display: none; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.2rem; }
.tr-edit { display: flex; align-items: flex-start; gap: 0.5rem; }
.tr-edit .text-input { flex: 1 1 auto; min-width: 0; width: 100%; }
.tr-edit textarea { resize: vertical; }
.tr-edit .btn { flex: 0 0 auto; }
.tr-edit .btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.tr-error { margin-top: 0.3rem; font-size: 0.75rem; color: var(--danger); }
.tr-status { display: inline-block; text-transform: none; }
.tr-status--missing { background: var(--warning-light); color: #b45309; }
.tr-status--done { background: #f1f5f9; color: var(--text-secondary); }
.tr-status--saved { background: var(--success-light); color: #15803d; }
.tr-status--saved::before { content: '\2713\00a0'; }
@media (max-width: 900px) {
    .tr-colhead { display: none; }
    .tr-row { grid-template-columns: minmax(0, 1fr); }
    .tr-field { flex-direction: row; align-items: center; flex-wrap: wrap; }
    .tr-cap { display: block; }
    .tr-counter { margin-left: 0; width: 100%; }
}
@media (max-width: 700px) {
    .lang-pair { grid-template-columns: minmax(0, 1fr); }
}
