/* ===========================================
   PINTO STYLESHEET — TABLE OF CONTENTS
   ===========================================
    1.  RESET & BASE
    2.  TOP BAR
    3.  SIDEBAR
    4.  RESPONSIVE NAV
    5.  LAYOUT
    6.  CARDS & SECTIONS
    7.  BUTTONS
    8.  FORMS
    9.  TABLES
   10.  MODALS
   11.  CALENDAR
   12.  CALENDAR HEADER CONTROLS
   13.  WEEKLY CALENDAR
   14.  JOB BLOCKS — SHARED STYLES
   15.  WEEKLY JOB BLOCKS
   16.  DAILY JOB BLOCKS
   17.  DAILY CALENDAR UPDATES
   18.  RESPONSIVE STYLES
   19.  SCHEDULE MODAL ENHANCEMENTS
   20.  INVOICES
   21.  SETTINGS
   22.  FORM VALIDATION
   23.  ARCHIVE & ACTIONS
   24.  DETAILS VIEW
   25.  SETTINGS — DAY CONFIG
   26.  STICKY HEADER
   27.  PAGINATION & SEARCH
   28.  DASHBOARD
   =========================================== */

/* ===================
   CSS CUSTOM PROPERTIES
   =================== */
:root {
    /* ── Text ── */
    --color-text: #1e293b;
    --color-text-secondary: #374151;
    --color-text-muted: #6b7280;
    --color-text-placeholder: #9ca3af;
    --color-text-body: #333;
    --color-text-mid: #666;
    --color-text-faint: #888;
    --color-text-faintest: #999;
    --color-text-subtle: #4b5563;
    --color-text-heading: #111827;
    --color-text-deep: #2c3e50;
    --color-near-black: #111;

    /* ── White ── */
    --color-white: #fff;

    /* ── Backgrounds ── */
    --color-bg-body: #f5f5f5;
    --color-bg-surface: #f9fafb;
    --color-bg-alt: #f3f4f6;
    --color-bg-input: #f1f5f9;
    --color-btn-bg: #f0f4fa;
    --color-bg-pale: #f0f0f0;
    --color-bg-faint: #f9f9f9;
    --color-bg-settings: #f8faff;
    --color-topbar-bg: #f0f2f5;
    --color-sidebar-bg: #e8ecf1;

    /* ── Borders ── */
    --color-border: #e5e7eb;
    --color-border-medium: #d1d5db;
    --color-border-subtle: #eee;
    --color-border-input: #ccc;
    --color-border-legacy: #ddd;
    --color-border-row: #eef0f2;
    --color-border-cal: #c6ccd4;
    --color-btn-border: #c8d6e5;

    /* ── Primary link blue (legacy) ── */
    --color-link: #3498db;
    --color-link-hover: #2980b9;
    --color-link-bg: #e8f4fc;

    /* ── Primary action blue ── */
    --color-primary: #2563eb;
    --color-primary-mid: #3b82f6;
    --color-primary-dark: #1d4ed8;
    --color-primary-bg: #eff6ff;
    --color-primary-bg-hover: #eef2ff;
    --color-primary-bg-light: #dbeafe;
    --color-primary-border-light: #93c5fd;

    /* ── Indigo ── */
    --color-indigo: #4f46e5;
    --color-indigo-mid: #6366f1;
    --color-indigo-bg: #e0e7ff;
    --color-sidebar-active: #4f6ef7;

    /* ── Button states ── */
    --color-btn-bg-hover: #e3ebf5;
    --color-btn-active-bg: #d6e4f5;
    --color-btn-active-text: #1e3a5f;
    --color-btn-active-border: #a3bfdb;

    /* ── Overlays / focus rings ── */
    --color-hover-overlay: rgba(0, 0, 0, 0.06);
    --color-focus-ring: rgba(59, 130, 246, 0.15);
    --color-focus-ring-legacy: rgba(52, 152, 219, 0.2);

    /* ── Success ── */
    --color-success: #27ae60;
    --color-success-bright: #22c55e;
    --color-success-dark: #15803d;
    --color-success-text: #155724;
    --color-success-bg: #d4edda;
    --color-success-bg-light: #dcfce7;
    --color-success-border: #c3e6cb;

    /* ── Warning ── */
    --color-warning: #f59e0b;
    --color-warning-text: #856404;
    --color-warning-text-dark: #92400e;
    --color-warning-text-mid: #b45309;
    --color-warning-bg: #fff3cd;
    --color-warning-bg-light: #fef3c7;
    --color-warning-border: #ffeeba;

    /* ── Danger ── */
    --color-danger: #dc2626;
    --color-danger-mid: #ef4444;
    --color-danger-legacy: #c00;
    --color-danger-text: #721c24;
    --color-danger-bg: #f8d7da;
    --color-danger-bg-light: #fee2e2;
    --color-danger-border: #f5c6cb;
    --color-danger-badge: #e74c3c;

    /* ── Info ── */
    --color-info-text: #0c5460;
    --color-info-bg: #d1ecf1;
    --color-info-bg-light: #e8f4fc;
    --color-info-border: #bee5eb;

    /* ── Job status (calendar) ── */
    --color-job-scheduled-bg: #e0edff;
    --color-job-scheduled-text: #1a5276;
    --color-job-hold-bg: #fce4ec;
    --color-job-hold-text: #880e4f;

    /* ── Reports / aging ── */
    --color-aging-30: #ea580c;
}



/* ===================
   RESET & BASE
   =================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg-body);
}

/* ===================
   TOP BAR
   =================== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--color-topbar-bg);
    border-bottom: 1px solid var(--color-border-medium);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    padding: 0 1.25rem 0 0.25rem;
    z-index: 1000;
}

.top-bar .logo {
    display: flex;
    align-items: center;
    gap: 0;
    text-decoration: none;
    flex-shrink: 0;
}

.top-bar-separator {
    color: var(--color-border-medium);
    font-size: 1.5rem;
    font-weight: 300;
    margin: 0 0.75rem;
    user-select: none;
}

.staging-badge {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-warning);
    color: #1a1a1a;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.3rem 1rem;
    border-radius: 999px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1001;
}

.staging-badge.local {
    background: var(--color-indigo-mid);
    color: var(--color-white);
}

.staging-badge.demo {
    background: var(--color-warning);
    color: var(--color-white);
}

.tenant-demo-badge {
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--color-warning-bg-light);
    color: var(--color-warning-text-dark);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    margin-left: 0.25rem;
}

.dev-nav-item-last {
    border-bottom: 1px solid rgba(0,0,0,0.08);
    margin-bottom: 0.25rem;
    padding-bottom: 0.25rem;
}

.top-bar-page-name {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Inter', sans-serif;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: 0.01em;
    pointer-events: none;
}

.top-bar .logo img {
    height: 44px;
}

.top-bar .logo-text {
    font-family: 'Nunito', sans-serif;
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.01em;
    margin-left: -0.75rem;
}

/* Top bar actions (right side) */
.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}

/* Global search — animated inline bar */
.global-search {
    position: relative;
    display: flex;
    align-items: center;
}

.search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    color: var(--color-text-muted);
    font-size: 1.15rem;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.search-toggle:hover {
    background: var(--color-hover-overlay);
    color: var(--color-text);
}

/* Inline expanding search input */
.search-inline {
    display: flex;
    align-items: center;
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: width 0.3s ease, opacity 0.25s ease;
}

.global-search.search-open .search-inline {
    width: 280px;
    opacity: 1;
}

.global-search.search-open .search-toggle {
    display: none;
}

.search-inline-input {
    width: 100%;
    height: 34px;
    padding: 0 0.75rem;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    background: var(--color-white);
    color: var(--color-text-body);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-inline-input::placeholder {
    color: var(--color-text-placeholder);
}

.search-inline-input:focus {
    border-color: var(--color-primary-mid);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

/* Search results dropdown (below inline bar) */
.search-results-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--color-white);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1010;
    min-width: 280px;
}

.global-search.search-open .search-results-dropdown.has-results {
    display: block;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    text-decoration: none;
    color: var(--color-text-body);
    transition: background 0.1s;
    gap: 0.75rem;
    cursor: pointer;
}

.search-result-item:hover,
.search-result-item.active {
    background: var(--color-primary-bg-hover);
}

.search-result-type {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    min-width: 56px;
    text-align: center;
}

.search-result-type.client { background: #e8f5e9; color: #2e7d32; }
.search-result-type.vehicle { background: var(--color-info-bg-light); color: #1565c0; }
.search-result-type.job { background: #fff3e0; color: #e65100; }
.search-result-type.invoice { background: #f3e5f5; color: #7b1fa2; }
.search-result-type.staff { background: var(--color-job-hold-bg); color: #c62828; }

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-subtitle {
    font-size: 0.78rem;
    color: var(--color-text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-no-results {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--color-text-faint);
    font-size: 0.9rem;
}

.search-loading {
    padding: 1.5rem 1rem;
    text-align: center;
    color: #aaa;
    font-size: 0.85rem;
}

/* Nav icon buttons (top bar right side) */
.nav-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.nav-icon-btn:hover {
    background: var(--color-hover-overlay);
    color: var(--color-text);
}

.nav-icon {
    flex-shrink: 0;
}

/* Notification badge */
.notification-wrap {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--color-danger-badge);
    color: var(--color-white);
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

/* User dropdown */
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--color-white);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 1002;
    overflow: hidden;
}

.user-menu-wrap.open .user-dropdown {
    display: block;
}

/* ── Tenant switcher dropdown ── */
.tenant-switcher-wrap { position: relative; }
.tenant-switcher-btn {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.3rem 0.6rem; border-radius: 6px; border: 1px solid var(--color-border);
    background: var(--color-bg-surface); cursor: pointer; font-size: 0.8rem; font-weight: 500;
    color: var(--color-text-secondary); white-space: nowrap; transition: border-color 0.15s, background 0.15s;
}
.tenant-switcher-btn:hover { border-color: var(--color-text-placeholder); background: var(--color-bg-alt); }
.tenant-switcher-btn .nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.tenant-switcher-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.tenant-switcher-caret { flex-shrink: 0; opacity: 0.5; transition: transform 0.15s; }
.tenant-switcher-wrap.open .tenant-switcher-caret { transform: rotate(180deg); }
.tenant-switcher-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 220px; max-height: 320px; overflow-y: auto;
    background: var(--color-white); border: 1px solid var(--color-border); border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12); z-index: 1000;
    padding: 0.35rem 0;
}
.tenant-switcher-wrap.open .tenant-switcher-dropdown { display: block; }
.tenant-switcher-item {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 0.85rem; font-size: 0.82rem; color: var(--color-text-secondary);
    text-decoration: none; transition: background 0.1s;
}
.tenant-switcher-item:hover { background: var(--color-bg-alt); }
.tenant-switcher-item.current { font-weight: 600; color: var(--color-indigo); }
.tenant-check { font-size: 0.7rem; color: var(--color-indigo); margin-left: auto; flex-shrink: 0; }
.tenant-switcher-search {
    display: block; width: calc(100% - 1rem); margin: 0.35rem 0.5rem;
    padding: 0.4rem 0.6rem; border: 1px solid var(--color-border); border-radius: 5px;
    font-size: 0.8rem; outline: none;
}
.tenant-switcher-search:focus { border-color: var(--color-indigo-mid); box-shadow: 0 0 0 2px rgba(99,102,241,0.1); }
.tenant-switcher-divider { height: 1px; background: var(--color-border); margin: 0.25rem 0; }
.tenant-switcher-dev { gap: 0.4rem; font-weight: 500; }
.tenant-switcher-dev svg { flex-shrink: 0; opacity: 0.5; }
.tenant-switcher-empty { padding: 0.6rem 0.85rem; font-size: 0.8rem; color: var(--color-text-placeholder); font-style: italic; }
/* Collapsed sidebar — hide name, show icon only */
.sidebar-collapsed .tenant-switcher-name,
.sidebar-collapsed .tenant-switcher-caret { display: none; }

.user-dropdown-name {
    padding: 0.75rem 1rem 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-body);
    border-bottom: 1px solid var(--color-border-subtle);
}

.user-dropdown a,
.user-dropdown button {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.9rem;
    color: var(--color-text-body);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: var(--color-bg-body);
    color: var(--color-link);
}

.user-dropdown form {
    margin: 0;
    border-top: 1px solid var(--color-border-subtle);
}

/* ===================
   SIDEBAR
   =================== */
.sidebar {
    position: fixed;
    top: 72px;
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border-medium);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 999;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
}

.sidebar ul {
    list-style: none;
    padding: 0.5rem 0.75rem;
}

.sidebar li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    color: var(--color-text-subtle);
    text-decoration: none;
    font-size: 0.95rem;
    white-space: nowrap;
    border-radius: 10px;
    margin-bottom: 2px;
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.sidebar-icon {
    flex-shrink: 0;
}

.sidebar li a:hover {
    background: var(--color-hover-overlay);
    color: var(--color-text);
}

.sidebar li a.active {
    color: var(--color-white);
    font-weight: 600;
    background: var(--color-sidebar-active);
    box-shadow: 0 2px 8px rgba(79, 110, 247, 0.3);
}

.sidebar li a.active svg {
    stroke: var(--color-white);
}

/* Sidebar collapse toggle */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 12px;
    color: var(--color-text-placeholder);
    transition: color 0.15s;
}

.sidebar-toggle:hover {
    color: var(--color-text);
}

.sidebar-toggle-icon {
    transition: transform 0.3s ease;
}

.sidebar-nav-label {
    transition: opacity 0.2s ease;
}

/* Collapsed sidebar — all driven by body.sidebar-collapsed */
body.sidebar-collapsed .sidebar {
    width: 64px;
}

body.sidebar-collapsed .sidebar-toggle {
    justify-content: center;
    padding: 4px 0;
}

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

body.sidebar-collapsed .sidebar-nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar ul {
    padding: 0.5rem 0.5rem;
}

body.sidebar-collapsed .sidebar li a {
    justify-content: center;
    padding: 0.6rem 0;
    gap: 0;
    border-radius: 10px;
}

body.sidebar-collapsed .sidebar-icon {
    width: 27px;
    height: 27px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.2rem;
    font-size: 0.7rem;
    color: var(--color-text-placeholder);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    border-top: 1px solid var(--color-border-medium);
}

.sidebar-footer-text,
.sidebar-footer-copy {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}

.sidebar-footer-short {
    display: none;
    font-size: 0.6rem;
    text-align: center;
}

body.sidebar-collapsed .sidebar-footer {
    padding: 0.8rem 0.5rem;
    align-items: center;
}

body.sidebar-collapsed .sidebar-footer-short {
    display: block;
}

body.sidebar-collapsed main.with-sidebar {
    margin-left: 64px;
}


/* ===================
   RESPONSIVE NAV
   =================== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    main.with-sidebar {
        margin-left: 0;
        padding: 0 1rem 1.5rem;
    }

    .nav-user-name {
        display: none;
    }
}

/* ===================
   LAYOUT
   =================== */
main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

main.with-sidebar {
    max-width: none;
    margin-left: 220px;
    margin-top: 72px;
    padding: 0 4rem 2rem;
    transition: margin-left 0.25s ease;
}

/* Pages without sidebar (login, etc) */
main:not(.with-sidebar) {
    margin-top: 72px;
}

h1 {
    margin-bottom: 1rem;
}

/* ===================
   CONTENT HEADER (full-width fixed bar below top nav)
   =================== */
.content-header {
    position: sticky;
    top: 72px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 4rem 0.75rem 1.25rem;
    margin: 0 -4rem 1.5rem -4rem;
}

/* Remove bottom margin when data-grid follows content-header */
.content-header + .data-grid,
.content-header + .filter-builder + .data-grid {
    margin-top: -1.5rem;
}

.content-header + .filter-builder {
    margin-top: -1.5rem;
    margin-bottom: 1.5rem;
}

.content-header .header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.content-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    white-space: nowrap;
}

.content-header .header-icon {
    display: inline-flex;
    color: var(--color-text-muted);
}

@media (max-width: 768px) {
    .content-header {
        padding: 0.75rem 1rem;
        margin: 0 -1rem 1rem;
    }
}

/* ===================
   PAGE SEARCH (animated in content-header)
   =================== */
.page-search {
    position: relative;
    display: flex;
    align-items: center;
}

.page-search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    color: var(--color-text-muted);
    transition: background 0.15s, color 0.15s;
    padding: 0;
}

.page-search-toggle:hover {
    background: var(--color-hover-overlay);
    color: var(--color-text);
}

.page-search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: width 0.3s ease, opacity 0.25s ease;
    pointer-events: none;
}

.page-search.search-open .page-search-bar {
    width: 320px;
    opacity: 1;
    pointer-events: auto;
}

.page-search.search-open .page-search-toggle {
    visibility: hidden;
}

.page-search-input {
    flex: 1;
    height: 34px;
    padding: 0 0.75rem;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    background: var(--color-white);
    color: var(--color-text-body);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    min-width: 0;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.page-search-input:focus {
    border-color: var(--color-primary-mid);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.page-search-input::placeholder {
    color: var(--color-text-placeholder);
}

.page-search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    color: var(--color-text-placeholder);
    font-size: 1.1rem;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.page-search-close:hover {
    background: var(--color-hover-overlay);
    color: var(--color-text-body);
}

@media (max-width: 768px) {
    .page-search.search-open .page-search-bar {
        width: 200px;
    }
}

/* Legacy page-header (kept for compatibility) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0;
}

/* ===================
   CARDS & SECTIONS
   =================== */
.card,
.settings-section {
    background: var(--color-white);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.card h2,
.settings-section h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

/* ===================
   BUTTONS — One unified style across the entire app
   =================== */
button:not(.toggle-password-btn):not(.nav-mobile-toggle):not(.sidebar-toggle):not(.search-toggle):not(.page-search-toggle):not(.page-search-close):not(.tenant-switcher-btn):not(.row-action-btn):not(.alert-close):not(.cv2-nav-btn):not(.cv2-today-btn):not(.cv2-view-btn):not(.cv2-create-btn):not(.cv2-modal-close):not(.modal-close),
.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0 0.85rem;
    height: 36px;
    border: 1px solid var(--color-btn-border);
    border-radius: 6px;
    background: var(--color-btn-bg);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
}

button:not(.toggle-password-btn):not(.nav-mobile-toggle):not(.sidebar-toggle):not(.search-toggle):not(.page-search-toggle):not(.page-search-close):not(.tenant-switcher-btn):not(.row-action-btn):not(.alert-close):not(.cv2-nav-btn):not(.cv2-today-btn):not(.cv2-view-btn):not(.cv2-create-btn):not(.cv2-modal-close):not(.modal-close):hover,
.btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover,
.toolbar-btn:hover {
    border-color: var(--color-text-placeholder);
    background: var(--color-btn-bg-hover);
}

/* Small button variant — same look, smaller */
.btn-sm {
    height: 30px;
    font-size: 0.8rem;
    padding: 0 0.65rem;
}

/* Active state for toggles and presets — stronger tint of the unified style */
.btn-primary.active,
.btn-secondary.active {
    background: var(--color-btn-active-bg);
    color: var(--color-btn-active-text);
    border-color: var(--color-btn-active-border);
}

/* Filter highlight state */
.toolbar-btn.has-filters {
    border-color: var(--color-primary-mid);
    color: var(--color-primary-mid);
    background: var(--color-primary-bg);
}

/* Toolbar dropdown component */
.toolbar-dropdown {
    display: inline-block;
    position: relative;
}
.toolbar-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    min-width: 150px;
    background: var(--color-white);
    border: 1px solid var(--color-btn-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    overflow: hidden;
}
.toolbar-dropdown-item {
    display: block;
    padding: 8px 14px;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-bottom: 1px solid var(--color-bg-pale);
}
.toolbar-dropdown-item:last-child { border-bottom: none; }
.toolbar-dropdown-item:hover { background: var(--color-btn-bg); }
.toolbar-dropdown-item.active { background: var(--color-btn-bg-hover); font-weight: 600; }

/* Action button — filled blue (save/submit) */
.btn-action {
    background: var(--color-primary-mid);
    color: var(--color-white);
    border-color: var(--color-primary-mid);
}
.btn-action:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-white);
}

/* Danger outline button — soft red */
.btn-danger-soft {
    color: var(--color-danger);
    border-color: #fca5a5;
}
.btn-danger-soft:hover {
    background: #fef2f2;
    border-color: var(--color-danger);
}

/* Inline form (removes block formatting from <form> elements in toolbars) */
.form-inline { display: inline; }

/* Button row — flex group of action buttons */
.btn-row    { display: flex; gap: 0.5rem; }
.btn-row-sm { display: flex; gap: 0.4rem; }

/* Empty-state text with breathing room */
.section-empty { padding: 1rem 0; }

/* Placeholder / nil value text */
.text-placeholder { color: var(--color-text-placeholder); }

/* ===================
   FORMS
   =================== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    width: 100%;
}

/* Search Input with Dropdown */
.search-input-container {
    position: relative;
}

.search-input-container input {
    width: 100%;
}

.search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-white);
    border: 1px solid var(--color-border-input);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.search-dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border-subtle);
    display: flex;
    flex-direction: column;
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover {
    background: var(--color-bg-body);
}

.search-dropdown-title {
    font-weight: bold;
    color: var(--color-text-body);
}

.search-dropdown-sub {
    font-size: 0.85rem;
    color: var(--color-text-mid);
}

.search-dropdown-empty {
    padding: 1rem;
    text-align: center;
    color: var(--color-text-faintest);
}

.search-dropdown-add {
    background: var(--color-bg-surface);
    border-top: 1px solid var(--color-border-legacy);
}

.search-dropdown-add:hover {
    background: #e9ecef;
}

.search-dropdown-add .search-dropdown-title {
    color: var(--color-link);
}

/* New Vehicle Section */
.new-vehicle-section {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-legacy);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.new-vehicle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.new-vehicle-header h4 {
    margin: 0;
    color: var(--color-text-body);
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-link);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}

.btn-link:hover {
    text-decoration: underline;
    background: none;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border-subtle);
}

.required {
    color: var(--color-danger-legacy);
}

.radio-group {
    display: flex;
    gap: 2rem;
    margin-top: 0.5rem;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.radio-item input[type="radio"] {
    width: auto;
    margin: 0;
}

.radio-item span {
    cursor: pointer;
}

/* ===================
   TABLES
   =================== */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-legacy);
}

th {
    background: var(--color-bg-body);
    font-weight: bold;
}

tbody tr:hover {
    background: var(--color-info-bg-light);
}

tr[onclick] {
    cursor: pointer;
}

table a {
    color: var(--color-link);
    text-decoration: none;
}

table a:hover {
    text-decoration: underline;
}

/* ===================
   DATA GRID (full-width table layout)
   =================== */
.data-grid {
    margin: 0 -4rem;
    border-top: 1px solid var(--color-border);
    border-bottom: 2px solid var(--color-border);
}

.data-grid table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 0.9rem;
}

.data-grid th {
    background: var(--color-bg-alt);
    color: var(--color-text-subtle);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.6rem 1rem;
    border-bottom: 2px solid var(--color-border-medium);
    position: sticky;
    top: 72px;  /* below top bar */
    z-index: 50;
}

.data-grid td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--color-border-row);
    color: var(--color-text-body);
}

/* Column width hints — keep columns tight so the "flex" columns (name, client, etc.) get the space */
.data-grid .col-mobile  { width: 120px; white-space: nowrap; text-align: center; }
.data-grid .col-vehicles { width: 70px;  text-align: center; }
.data-grid .col-date    { width: 100px; white-space: nowrap; text-align: center; }
.data-grid .col-amount  { width: 110px; white-space: nowrap; text-align: right; }
.data-grid .col-status  { width: 110px; white-space: nowrap; }
.data-grid .col-rego    { width: 100px; white-space: nowrap; text-align: center; }
.data-grid .col-invoice { width: 100px; white-space: nowrap; text-align: center; }
/* Quote numbers are QUO-YYYYMM-NNNN — 15 chars — so they need more room
   than the 100px col-invoice class, otherwise they wrap onto three lines. */
.data-grid .col-quote   { width: 140px; white-space: nowrap; text-align: left;   }
.data-grid .col-time    { width: 85px;  white-space: nowrap; }
.data-grid .col-duration { width: 90px; white-space: nowrap; }
.data-grid .col-type    { width: 95px;  white-space: nowrap; }
.data-grid .col-year    { width: 65px;  white-space: nowrap; text-align: center; }
/* Utility alignment classes for th and td */
.data-grid .text-center { text-align: center; }
.data-grid .text-right  { text-align: right; }
/* Global alignment and weight utilities */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-semibold { font-weight: 600; }
/* Table total/summary row */
.table-total-row { font-weight: bold; border-top: 2px solid var(--color-text-body); }

.data-grid tbody tr:nth-child(even) {
    background: var(--color-bg-surface);
}

.data-grid tbody tr:nth-child(odd) {
    background: var(--color-white);
}

.data-grid tbody tr:hover {
    background: var(--color-primary-bg-hover);
}

.data-grid tbody tr[onclick] {
    cursor: pointer;
}

.data-grid .empty-row td {
    padding: 3rem 1rem;
    background: var(--color-white);
}

.data-grid .empty-row:hover td {
    background: var(--color-white);
}

/* Empty state — used inside .empty-row td in list pages. Icon + title +
   (optional) subtitle stacked, centered. Kept compact so the table
   doesn't scroll the sidebar off-screen just to say "nothing here." */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
}
.empty-state-icon {
    color: #cbd5e1;
    margin-bottom: 0.25rem;
}
.empty-state-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #475569;
}
.empty-state-subtitle {
    margin: 0;
    font-size: 0.85rem;
    color: #94a3b8;
    max-width: 320px;
}

/* Pagination inside data-grid */
.data-grid .pagination {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
}

/* ── Filter Builder ── */
.filter-builder { margin-bottom: 1rem; }
/* toolbar-btn styles are now in the unified BUTTONS section above */
.filter-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--color-primary-mid); color: var(--color-white);
    font-size: 0.7rem; font-weight: 600;
}
.filter-panel {
    margin-top: 0.75rem; padding: 1rem;
    border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-bg-surface);
}
.filter-row {
    display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem;
}
.filter-row select,
.filter-row input[type="text"],
.filter-row input[type="number"],
.filter-row input[type="date"] {
    height: 34px; padding: 0 0.5rem;
    border: 1px solid var(--color-border-medium); border-radius: 6px;
    font-size: 0.85rem; background: var(--color-white);
}
.filter-row select:focus,
.filter-row input:focus { outline: none; border-color: var(--color-primary-mid); box-shadow: 0 0 0 2px var(--color-focus-ring); }
.filter-row .filter-field { flex: 0 0 160px; }
.filter-row .filter-operator { flex: 0 0 130px; }
.filter-row .filter-value-wrap { flex: 1; display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.filter-row .filter-value { flex: 1; min-width: 80px; }
.filter-between-sep { font-size: 0.8rem; color: var(--color-text-muted); white-space: nowrap; }
.filter-row .filter-remove-btn {
    width: 28px; height: 28px; border: none; background: none;
    color: var(--color-text-placeholder); cursor: pointer; border-radius: 4px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.filter-row .filter-remove-btn:hover { background: var(--color-danger-bg-light); color: var(--color-danger-mid); }
.filter-actions {
    display: flex; align-items: center; gap: 1rem;
    margin-top: 0.75rem; padding-top: 0.75rem;
    border-top: 1px solid var(--color-border); flex-wrap: wrap;
}
.filter-actions .btn-link {
    background: none; border: none; color: var(--color-primary-mid);
    font-size: 0.85rem; cursor: pointer; padding: 0;
}
.filter-actions .btn-link:hover { text-decoration: underline; }
.filter-logic-toggle { display: flex; gap: 0.75rem; font-size: 0.85rem; color: var(--color-text-muted); }
.filter-logic-toggle label { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.filter-btns { margin-left: auto; display: flex; gap: 0.5rem; }
@media (max-width: 768px) {
    .filter-row { flex-wrap: wrap; }
    .filter-row .filter-field, .filter-row .filter-operator { flex: 1 1 45%; }
    .filter-row .filter-value-wrap { flex: 1 1 100%; }
    .filter-actions { flex-direction: column; align-items: flex-start; }
    .filter-btns { margin-left: 0; }
}

/* Bordered variant — full grid lines */
.data-grid.bordered th,
.data-grid.bordered td {
    border: 1px solid var(--color-border);
}

/* Cell helpers */
.data-grid .cell-primary {
    font-weight: 500;
    color: var(--color-text);
}

.data-grid .cell-center {
    text-align: center;
}

.data-grid .cell-danger {
    color: var(--color-danger);
    font-weight: 600;
}

/* Actions column */
.data-grid .actions-col {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

button.row-action-btn,
a.row-action-btn,
.row-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--color-text-muted);
    text-decoration: none;
    cursor: pointer;
    font-size: inherit;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

button.row-action-btn:hover,
a.row-action-btn:hover,
.row-action-btn:hover {
    background: var(--color-indigo-bg);
    color: var(--color-primary-mid);
}

@media (max-width: 768px) {
    .data-grid {
        margin: 0 -1rem;
        overflow-x: auto;
    }

    .data-grid th,
    .data-grid td {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
    }
}

/* ===================
   MODALS
   =================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--color-white);
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-large {
    max-width: 700px;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-mid);
}

.modal-close:hover {
    color: var(--color-text-body);
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}


/* ===================
   SCHEDULE MODAL ENHANCEMENTS
   =================== */

/* Pre-filled schedule info display */
.prefilled-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-info-bg-light);
    border: 2px solid var(--color-link);
    border-radius: 6px;
    margin-bottom: 1rem;
}

.prefilled-badge {
    background: var(--color-link);
    color: var(--color-white);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    text-transform: uppercase;
    white-space: nowrap;
}

.prefilled-details {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    flex: 1;
}

.prefilled-details span {
    font-weight: 600;
    color: var(--color-text-body);
    padding: 0.25rem 0.5rem;
    background: var(--color-white);
    border-radius: 3px;
    font-size: 0.9rem;
}

.prefilled-info .btn-link {
    color: var(--color-link);
    font-size: 0.85rem;
}

/* Duration input wrapper */
.duration-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.duration-input-wrapper input {
    flex: 1;
}

.auto-indicator {
    background: var(--color-success);
    color: var(--color-white);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ===================
   INVOICES
   =================== */
.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.invoice-header h1 {
    margin: 0;
}

.invoice-actions {
    display: flex;
    gap: 0.5rem;
}

.invoice-layout {
    display: grid;
    gap: 1rem;
}

.invoice-details {
    display: flex;
    justify-content: space-between;
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}
.badge-gray {
    background: var(--color-bg-alt);
    color: var(--color-text-muted);
}
.badge-blue {
    background: var(--color-primary-bg);
    color: var(--color-primary);
}

.status-clickable {
    cursor: pointer;
    user-select: none;
}
.status-clickable:hover {
    opacity: 0.8;
}

.status-unpaid {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.status-paid {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.status-partially_paid {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.status-overdue {
    background: var(--color-danger-border);
    color: var(--color-danger-text);
}

.status-scheduled {
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.status-in_progress {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.status-completed {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.status-cancelled {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.status-draft {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

/* Draft invoice banner */
.draft-banner {
    background: var(--color-warning-bg);
    border: 1px solid #ffc107;
    color: var(--color-warning-text);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

/* Invoice totals bar */
.invoice-totals-bar {
    display: flex;
    gap: 2rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg-surface);
    border-radius: 6px;
    margin-bottom: 1rem;
}

.totals-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.totals-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.totals-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-deep);
}

.totals-paid {
    color: var(--color-success);
}

.totals-due {
    color: #c0392b;
}

/* Add item / record payment sub-section */
.add-item-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border-subtle);
}

.add-item-section h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: #555;
}

.add-item-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.add-item-form select,
.add-item-form input {
    padding: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

/* Inline items editor (invoices, quotes) */
.items-editor-wrap {
    overflow-x: auto;
}
.items-editor {
    width: 100%;
    border-collapse: collapse;
}
.items-editor th {
    text-align: left;
    padding: 0.5rem 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
    border-bottom: 1px solid var(--color-border-subtle);
}
.items-editor td {
    padding: 0.35rem 0.4rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--color-border-subtle);
}
.items-editor select,
.items-editor input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.35rem 0.5rem;
    font-size: 0.9rem;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    font-family: inherit;
}
.items-editor tfoot td {
    border-bottom: none;
    padding-top: 0.6rem;
}
.items-editor .row-remove {
    background: none;
    border: none;
    color: #b91c1c;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.4rem;
    border-radius: 4px;
}
.items-editor .row-remove:hover {
    background: #fee2e2;
}
.items-dirty-indicator {
    font-size: 0.85rem;
    color: #c2410c;
}

.invoice-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.invoice-actions-left, .invoice-actions-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.invoice-items {
    width: 100%;
}

.service-tasks {
    margin: 0.25rem 0 0 1rem;
    padding: 0;
    font-size: 0.85rem;
    color: var(--color-text-mid);
}

.service-tasks li {
    list-style: disc;
}

.remove-link {
    color: var(--color-danger-legacy);
    text-decoration: none;
    font-size: 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

/* Password visibility toggle inside input */
.toggle-password-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.labour-form .form-row {
    align-items: flex-end;
}

.invoice-totals table {
    margin-left: auto;
    width: auto;
}

.invoice-totals td {
    padding: 0.5rem 1rem;
    text-align: right;
}

.invoice-totals .total-row {
    border-top: 2px solid var(--color-text-body);
    font-size: 1.1rem;
}

/* ===================
   SETTINGS
   =================== */
.settings-links {
    list-style: none;
}

.settings-links li {
    margin-bottom: 0.5rem;
}

.settings-links a {
    color: var(--color-text-body);
    text-decoration: none;
    font-weight: bold;
}

.settings-links a:hover {
    text-decoration: underline;
}

/* ===================
   FORM VALIDATION
   =================== */
.field-error {
    color: var(--color-danger-legacy);
    font-size: 0.85rem;
    display: block;
    margin-top: 0.25rem;
}

input.input-error,
select.input-error,
textarea.input-error {
    border-color: var(--color-danger-legacy);
}

/* ===================
   ARCHIVE & ACTIONS
   =================== */
.page-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toggle-archived {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.archived-row {
    opacity: 0.5;
    background: var(--color-bg-faint);
}

a.delete-link {
    color: var(--color-danger-legacy);
}

/* ===================
   DETAILS VIEW
   =================== */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.detail-item.full-width {
    grid-column: 1 / -1;
}

/* Flat profile field labels: uppercase, small, bold, gray. Matches the
   look that vehicles/clients had inline, now shared across all detail
   views (staff, jobs, vehicles, clients, quotes header). */
.detail-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-mid);
    margin-bottom: 0.15rem;
}

.detail-value {
    font-size: 0.9rem;
    color: var(--color-text-body);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    margin: 0;
}

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    border: 1px solid var(--color-warning-border);
}

.alert-error {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border: 1px solid var(--color-danger-border);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-border);
}

.alert-info {
    background: var(--color-info-bg);
    color: var(--color-info-text);
    border: 1px solid var(--color-info-border);
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    padding: 0;
    margin-left: 1rem;
    line-height: 1;
}

.alert-close:hover {
    opacity: 0.7;
}

.flash-messages {
    margin-bottom: 1rem;
}


/* ===================
   SETTINGS - DAY CONFIG
   =================== */
.day-config {
    border: 1px solid var(--color-border-legacy);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--color-bg-faint);
}

.day-header {
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.checkbox-label strong {
    font-size: 1.1rem;
    color: var(--color-text-body);
}

/* ===================
   STICKY HEADER
   =================== */
.sticky-header {
    background: var(--color-white);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    position: sticky;
    top: 72px;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.sticky-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sticky-header-top h1 {
    margin: 0;
}

.sticky-header h1 {
    margin: 0 0 1rem 0;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.sticky-header + .card {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    padding-top: 0;
}

.sticky-header + .card thead th {
    position: sticky;
    top: 0;
    background-color: var(--color-bg-body);
    z-index: 10;
    box-shadow: inset 0 -1px 0 var(--color-border-legacy);
}

.sticky-header + .card thead {
    position: relative;
    z-index: 11;
}

.header-search {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    width: 250px;
}

.header-search:focus {
    outline: none;
    border-color: var(--color-link);
    box-shadow: 0 0 0 2px var(--color-focus-ring-legacy);
}

.header-filter {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    background: var(--color-white);
    cursor: pointer;
}

.header-filter:focus {
    outline: none;
    border-color: var(--color-link);
    box-shadow: 0 0 0 2px var(--color-focus-ring-legacy);
}

.header-controls .btn-primary {
    margin-left: auto;
}

/* ===================
   PAGINATION & SEARCH
   =================== */

/* Search form */
.table-search-form {
    margin-bottom: 1rem;
}

.search-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-input-wrapper {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.search-input {
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-link);
    box-shadow: 0 0 0 2px var(--color-focus-ring-legacy);
}

.filter-wrapper {
    min-width: 150px;
}

.filter-select {
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    background: var(--color-white);
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-link);
    box-shadow: 0 0 0 2px var(--color-focus-ring-legacy);
}

.search-btn {
    padding: 0.5rem 1.5rem;
}

.clear-btn {
    padding: 0.5rem 1rem;
}

/* Sortable headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

th.sortable.text-center a,
th.sortable.col-date a,
th.sortable.col-vehicles a,
th.sortable.col-year a,
th.sortable.col-rego a,
th.sortable.col-invoice a,
th.sortable.col-mobile a { justify-content: center; }

th.sortable.text-right a,
th.sortable.col-amount a { justify-content: flex-end; }

th.sortable:hover {
    background: #e8e8e8;
}

th.sortable.sorted {
    background: var(--color-info-bg-light);
}

.sort-arrow {
    width: 10px;
    height: 6px;
    flex-shrink: 0;
    transition: transform 0.15s;
}

th.sortable.sorted.asc .sort-arrow {
    transform: rotate(180deg);
}

.sort-icon {
    font-size: 0.7rem;
    opacity: 0.8;
}

.sort-icon.inactive {
    opacity: 0.3;
    font-size: 0.6rem;
}

/* Pagination */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border-subtle);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    color: var(--color-text-mid);
    font-size: 0.9rem;
}

.pagination {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.pagination-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border-legacy);
    background: var(--color-white);
    color: var(--color-text-body);
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.pagination-btn:hover:not(.disabled):not(.active) {
    background: var(--color-bg-pale);
    border-color: var(--color-border-input);
}

.pagination-btn.active {
    background: var(--color-btn-active-bg);
    color: var(--color-btn-active-text);
    border-color: var(--color-btn-active-border);
}

.pagination-btn.disabled {
    color: var(--color-border-input);
    cursor: not-allowed;
}

.pagination-ellipsis {
    padding: 0.4rem 0.5rem;
    color: var(--color-text-faintest);
}

/* File Upload Styling */
.file-upload-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.current-file-preview {
    margin-bottom: 0.5rem;
}

.logo-preview {
    max-width: 150px;
    max-height: 80px;
    border: 1px solid var(--color-border-legacy);
    border-radius: 4px;
    padding: 4px;
    background: var(--color-bg-faint);
}

.current-file-name {
    color: var(--color-text-mid);
    font-size: 0.85rem;
}

.no-preview {
    color: var(--color-text-faintest);
    font-size: 0.85rem;
    font-style: italic;
}

.file-input {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--color-bg-pale);
    border: 1px solid var(--color-border-legacy);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-text-body);
    transition: all 0.2s;
}

.file-input-label:hover {
    background: #e0e0e0;
    border-color: var(--color-border-input);
}

.file-name {
    font-size: 0.85rem;
    color: var(--color-success);
    font-weight: 500;
}

/* Settings Page Layout */
/* ── Settings Layout ── */
.settings-layout {
    display: flex;
    align-items: stretch;
    margin: -1.5rem -4rem -2rem;
    border-top: 1px solid var(--color-border);
    height: calc(100vh - 126px);
    overflow: hidden;
}

.settings-sidebar {
    width: 220px;
    min-width: 220px;
    height: 100%;
    overflow-y: auto;
    background: var(--color-bg-settings);
    border-right: 1px solid var(--color-border);
    padding: 1.25rem 0 2rem;
    flex-shrink: 0;
}

.settings-sidebar ul.settings-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.settings-nav li {
    display: block;
}

.settings-nav-link {
    display: block;
    padding: 0.38rem 1.25rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.83rem;
    font-weight: 400;
    border-left: 3px solid transparent;
    transition: background 0.12s, color 0.12s;
}

.settings-nav-link:hover {
    background: var(--color-primary-bg-hover);
    color: var(--color-primary);
    border-left-color: var(--color-primary-border-light);
}

.settings-nav-link.active {
    background: var(--color-primary-bg);
    color: var(--color-primary-dark);
    border-left-color: var(--color-primary);
    font-weight: 600;
}

/* ── Settings Content ── */
.settings-content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 2.5rem 3rem 4rem;
    min-width: 0;
}

.settings-panel {
    display: none;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 2rem;
}

.settings-panel.active {
    display: block;
}

.settings-panel h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    color: var(--color-text-heading);
    border: none;
    padding: 0;
}

.settings-panel > p.text-muted:first-of-type,
.settings-panel > form > p.text-muted:first-of-type {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.settings-panel h3 {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.settings-panel hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 1.5rem 0;
}

.settings-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.settings-section-header h2 {
    margin: 0;
    padding: 0;
    border: none;
}

/* ── Settings Tables (match data-grid theme) ── */
.settings-panel table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.settings-panel table th {
    background: var(--color-bg-alt);
    color: var(--color-text-subtle);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.6rem 1rem;
    border-bottom: 2px solid var(--color-border-medium);
    text-align: left;
}

.settings-panel table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--color-border-row);
    color: var(--color-text-body);
}

.settings-panel table tbody tr:nth-child(even) {
    background: var(--color-bg-surface);
}

.settings-panel table tbody tr:nth-child(odd) {
    background: var(--color-white);
}

.settings-panel table tbody tr:hover {
    background: var(--color-primary-bg-hover);
}

.settings-panel table td a {
    color: var(--color-primary);
    font-weight: 500;
}

/* ── Day Config Cards (Work Hours) ── */
.day-config {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--color-white);
    transition: box-shadow 0.15s;
}

.day-config:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.day-header {
    margin-bottom: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--color-link);
}

.checkbox-label strong {
    font-size: 1rem;
    color: var(--color-text);
}

/* ── Logo & File Upload ── */
.logo-upload-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.logo-display {
    flex-shrink: 0;
    width: 120px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-surface);
    overflow: hidden;
}

.logo-placeholder {
    font-size: 0.75rem;
    color: var(--color-text-placeholder);
    font-style: italic;
}

.logo-controls {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.current-file-preview {
    flex-shrink: 0;
}

.logo-preview {
    max-width: 120px;
    max-height: 68px;
    border: none;
    border-radius: 6px;
    padding: 4px;
    background: var(--color-white);
}

.file-input {
    display: none;
}

.file-input-label {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: all 0.15s;
}

.file-input-label:hover {
    background: #e2e8f0;
    border-color: var(--color-text-placeholder);
}

.file-name {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ── Manage Section Cards ── */
.manage-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.manage-link-card {
    display: block;
    padding: 1.25rem;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.manage-link-card:hover {
    background: var(--color-primary-bg-hover);
    border-color: #c7d2fe;
    transform: translateY(-2px);
}

.manage-link-card strong {
    display: block;
    color: var(--color-text);
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.manage-link-card span {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* ── Responsive Settings ── */
@media (max-width: 768px) {
    .settings-layout {
        display: block;
        margin: -1.5rem -1rem -2rem;
    }

    .settings-sidebar {
        position: static;
        width: 100%;
        min-width: 0;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        padding: 0.5rem 0;
    }

    .settings-sidebar ul.settings-nav {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
    }

    .settings-nav li {
        flex-shrink: 0;
    }

    .settings-nav-link {
        white-space: nowrap;
        padding: 0.6rem 1rem;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .settings-nav-link.active {
        border-left: none;
        border-bottom-color: var(--color-primary);
    }

    .settings-content {
        padding: 1.5rem 1rem;
    }

    .settings-panel {
        padding: 1.25rem;
    }
}

/* ===================
   DASHBOARD
   =================== */

.dashboard {
    max-width: 1600px;
    margin: 0 auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.dashboard-header h1 {
    margin: 0;
}

.quick-actions {
    display: flex;
    gap: 0.75rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-white);
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 4px solid var(--color-link);
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-card.stat-warning {
    border-left-color: #f39c12;
}

.stat-card.stat-success {
    border-left-color: var(--color-success);
}

.stat-card.stat-danger {
    border-left-color: var(--color-danger-badge);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text-body);
    line-height: 1;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--color-text-mid);
    margin-top: 0.25rem;
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--color-text-faintest);
    margin-top: 0.25rem;
}

/* Dashboard Calendar Card */
.dashboard > .card {
    display: flex;
    flex-direction: column;
}

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

.card-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.calendar-nav-inline {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-arrow {
    color: var(--color-link);
    text-decoration: none;
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
}

.nav-arrow:hover {
    color: var(--color-link-hover);
}

.current-date {
    font-weight: 500;
    color: var(--color-text-body);
}

.today-highlight {
    color: var(--color-link);
}

.dashboard-calendar-wrapper {
    flex: 1;
    overflow: hidden;
}

.dashboard-calendar-iframe {
    width: 100%;
    height: 550px;
    border: none;
    display: block;
}

.dashboard-daily .calendar-scroll {
    height: 500px;
}

.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border-subtle);
    text-align: center;
}

.card-footer a {
    color: var(--color-link);
    text-decoration: none;
    font-size: 0.9rem;
}

.card-footer a:hover {
    text-decoration: underline;
}

/* Dashboard calendar job links */
.dashboard-daily .calendar-job {
    text-decoration: none;
    color: inherit;
}

.dashboard-daily .calendar-job:hover {
    filter: brightness(0.95);
}

/* Responsive Dashboard */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .quick-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .calendar-nav-inline {
        flex-wrap: wrap;
        justify-content: center;
    }

    .current-date {
        order: -1;
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }
}

/* ===================
   DASHBOARD V2
   =================== */

/* Dashboard action buttons — inherit unified style, icon-only on small screens */
.dv2-action-btn {
    /* inherits unified button style */
}

.dv2-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

@media (max-width: 1000px) {
    .dv2-label { display: none; }
    .dv2-action-btn { padding: 0.4rem 0.5rem; }
}

/* Stats bar — slim row between header and calendar */
.dv2-stats-bar {
    display: flex;
    /* -1.5rem top cancels content-header bottom margin; -4rem sides = edge-to-edge */
    margin: -1.5rem -4rem 0;
    background: var(--color-bg-settings);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid #dde3f0;
}
.dv2-stat {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1.5rem;
    text-decoration: none;
    color: inherit;
    border-right: 1px solid var(--color-border);
    transition: background 0.15s;
}
.dv2-stat:last-child { border-right: none; }
.dv2-stat:hover { background: var(--color-primary-bg-hover); }
.dv2-stat-val {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    line-height: 1;
}
.dv2-stat-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.dv2-stat-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
}
.dv2-stat-sub {
    font-size: 0.68rem;
    color: var(--color-text-placeholder);
}
.dv2-stat-warn .dv2-stat-val { color: var(--color-warning-text-mid); }
.dv2-stat-danger .dv2-stat-val { color: var(--color-danger); }

/* Inlined calendar — edge-to-edge, fills viewport below content-header
   + stats bar. The calendar partial brings its own .cv2-toolbar and
   .cv2-container; the wrapper provides the height envelope and resets
   the calendar's own margin-escapes (the wrapper already handles them). */
.dv2-cal-wrap {
    margin: 0 -4rem -2rem;
    /* 72px topbar + ~54px content-header + ~52px stats bar ≈ 178px */
    height: calc(100vh - 178px);
    display: flex;
    flex-direction: column;
}
.dv2-cal-wrap .cv2-toolbar,
.dv2-cal-wrap .cv2-container {
    margin: 0;
}
.dv2-cal-wrap .cv2-container {
    flex: 1;
    height: auto;
}

/* Search — sits left of buttons; bar expands leftward (right: 0 anchor) so buttons are never touched */
.dv2-search {
    position: relative;
}

/* Override page-search-bar to expand leftward from the toggle position */
.dv2-search .page-search-bar {
    right: 0;
    left: auto;
}

/* Results dropdown — anchored to the right edge of the toggle, expands leftward */
.dv2-search-drop {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 360px;
    background: var(--color-white);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.16);
    border: 1px solid var(--color-border);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
}
.dv2-search-drop.has-results { display: block; }

.dv2-search-result {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    text-decoration: none;
    color: var(--color-near-black);
    border-bottom: 1px solid var(--color-bg-alt);
    transition: background 0.1s;
}
.dv2-search-result:hover { background: var(--color-primary-bg-hover); }
.dv2-search-result:last-child { border-bottom: none; }

.dv2-search-title {
    font-size: 0.88rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dv2-search-sub {
    font-size: 0.78rem;
    color: var(--color-text-placeholder);
    text-align: right;
    white-space: nowrap;
}

.dv2-search-empty {
    padding: 1.25rem;
    text-align: center;
    color: var(--color-text-placeholder);
    font-size: 0.88rem;
}

/* ===================
   REPORTS
   =================== */

/* Summary cards grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: var(--color-white);
    padding: 1.25rem;
    border-radius: 8px;
    text-align: center;
}

.summary-card .summary-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
}

.summary-card .summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-deep);
}

.summary-card .summary-sub {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}
.summary-card .summary-sub.overdue { color: var(--color-danger-mid); }

.summary-value.green { color: var(--color-success-bright); }
.summary-value.red { color: var(--color-danger-mid); }
.summary-value.dark-red { color: var(--color-danger); }
.summary-value.blue { color: var(--color-primary-mid); }
.summary-value.muted { color: var(--color-text-muted); }

/* Report sticky header — single row: title left, nav+export right */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.report-header h1 {
    margin: 0;
    white-space: nowrap;
}

/* Report header title row (title + year selector inline) */
.header-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title-row h1 {
    margin: 0;
}

.year-selector {
    margin: 0;
    display: flex;
    align-items: center;
}

.year-selector select {
    padding: 0.4rem 0.6rem;
    font-family: inherit;
    font-size: 0.95rem;
    border-radius: 4px;
    border: 1px solid var(--color-border-input);
    background: var(--color-white);
    cursor: pointer;
}

/* Report nav tabs */
.report-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Report nav active/hover inherits from unified button + .active state */

/* Report layout grid (e.g. outstanding table + aging chart) */
.report-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.report-grid-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Chart container */
.chart-container {
    position: relative;
    margin-bottom: 1rem;
}

.chart-container.chart-350 { height: 350px; }
.chart-container.chart-300 { height: 300px; }
.chart-container.chart-250 { height: 250px; }

/* Aging indicators */
.aging-current { color: var(--color-success-bright); font-weight: 600; }
.aging-30 { color: var(--color-aging-30); font-weight: 600; }
.aging-60 { color: var(--color-warning); font-weight: 600; }
.aging-90 { color: var(--color-danger-mid); font-weight: 600; }
.aging-90-plus { color: var(--color-danger); font-weight: 600; }

.aging-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: middle;
}

.aging-dot.current { background: var(--color-success-bright); }
.aging-dot.days-30 { background: var(--color-warning); }
.aging-dot.days-60 { background: var(--color-aging-30); }
.aging-dot.days-90 { background: var(--color-danger-mid); }
.aging-dot.days-90-plus { background: var(--color-danger); }

/* Date range presets */
.preset-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-left: 1px solid var(--color-border-legacy);
    padding-left: 1rem;
}

/* Responsive reports */
@media (max-width: 900px) {
    .report-grid {
        grid-template-columns: 1fr;
    }

    .report-grid-half {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .report-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .report-nav {
        flex-wrap: wrap;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .preset-bar {
        border-left: none;
        border-top: 1px solid var(--color-border-legacy);
        padding-left: 0;
        padding-top: 0.5rem;
    }
}


/* ═══════════════════════════════════════════════════════════
   Calendar v2 — Custom Interactive Calendar
   ═══════════════════════════════════════════════════════════ */

/* Escape main padding on all sides so the calendar grid is truly edge-to-edge */
.cv2-container {
    padding: 0;
    margin: 0 -4rem -2rem;
    height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Calendar v2 Toolbar ── */
/* Mirrors .content-header: escapes main padding, sticky, full-width */
.cv2-toolbar {
    position: sticky;
    top: 72px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    padding: 0.6rem 4rem 0.6rem 1.25rem;
    margin: 0 -4rem 0;
}
.cv2-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cv2-toolbar-center {
    flex: 1;
    text-align: center;
}
.cv2-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Nav arrows */
.cv2-nav-arrows {
    display: inline-flex;
    border: 1px solid var(--color-border-cal);
    border-radius: 6px;
    overflow: hidden;
}
.cv2-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: var(--color-white);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background 0.12s;
    padding: 0;
}
.cv2-nav-btn svg,
.cv2-create-btn svg {
    display: block;
    flex-shrink: 0;
}
.cv2-nav-btn:first-child {
    border-right: 1px solid var(--color-border-cal);
}
.cv2-nav-btn:hover {
    background: var(--color-bg-input);
}

/* Today button */
.cv2-today-btn {
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--color-border-cal);
    border-radius: 6px;
    background: var(--color-white);
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}
.cv2-today-btn:hover {
    background: var(--color-bg-input);
}

/* Date label */
.cv2-date-label {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

/* View toggle */
.cv2-view-toggle {
    display: inline-flex;
    border: 1px solid var(--color-border-cal);
    border-radius: 6px;
    overflow: hidden;
}
.cv2-view-btn {
    padding: 6px 16px;
    height: 34px;
    border: none;
    background: var(--color-white);
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.cv2-view-btn:not(:last-child) {
    border-right: 1px solid var(--color-border-cal);
}
.cv2-view-btn.active {
    background: #3b4a5e;
    color: var(--color-white);
}
.cv2-view-btn:hover:not(.active) {
    background: var(--color-bg-input);
}

/* Create job button */
.cv2-create-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: var(--color-link);
    color: var(--color-white);
    cursor: pointer;
    transition: background 0.12s;
}
.cv2-create-btn:hover {
    background: var(--color-link-hover);
}

/* ── Daily View ── */
.cv2-daily {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top: 1px solid var(--color-border);
    background: var(--color-white);
}

.cv2-grid-header {
    display: flex;
    border-bottom: 2px solid var(--color-border);
    background: var(--color-bg-surface);
    position: sticky;
    top: 0;
    z-index: 20;
}
.cv2-time-gutter-header {
    width: 60px;
    min-width: 60px;
    border-right: 1px solid var(--color-border);
}
.cv2-bay-header {
    flex: 1;
    min-width: 0;
    padding: 10px 4px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text-secondary);
    border-right: 1px solid var(--color-border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cv2-bay-header:last-child {
    border-right: none;
}

.cv2-grid-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}
.cv2-grid-scroll {
    display: flex;
    position: relative;
    border-bottom: 2px solid #cbd5e1; /* end-of-day boundary */
}

/* Time gutter */
.cv2-time-gutter {
    width: 60px;
    min-width: 60px;
    position: relative;
    border-right: 1px solid var(--color-border);
    background: var(--color-bg-surface);
}
.cv2-time-label {
    position: absolute;
    left: 0;
    right: 0;
    text-align: right;
    padding-right: 8px;
    font-size: 11px;
    color: var(--color-text-muted);
    transform: translateY(-7px);
    user-select: none;
}

/* Bay columns */
.cv2-bays-container {
    flex: 1;
    display: flex;
    position: relative;
}
.cv2-bay-col {
    flex: 1;
    min-width: 0;
    position: relative;
    border-right: 1px solid var(--color-border);
}
.cv2-bay-col:last-child {
    border-right: none;
}
.cv2-bay-col.cv2-drop-target {
    background: rgba(37, 99, 235, 0.06);
}

/* Hour rows */
.cv2-hour-row {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid var(--color-border);
    cursor: pointer;
}
.cv2-hour-row:hover {
    background: rgba(37, 99, 235, 0.04);
}
.cv2-working {
    background: var(--color-white);
}
.cv2-non-working {
    background: var(--color-bg-surface);
}
.cv2-half-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 1px dashed #d0d0d0;
    pointer-events: none;
}

/* Now indicator */
.cv2-now-line {
    position: absolute;
    left: 60px;
    right: 0;
    height: 2px;
    background: var(--color-danger-mid);
    z-index: 50;
    pointer-events: none;
}
.cv2-now-line::before {
    content: '';
    position: absolute;
    left: -5px;
    top: -4px;
    width: 10px;
    height: 10px;
    background: var(--color-danger-mid);
    border-radius: 50%;
}

/* ── Job Cards ── */
.cv2-job-card {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 5px;
    padding: 2px 5px;
    font-size: 11px;
    overflow: hidden;
    cursor: grab;
    user-select: none;
    z-index: 10;
    transition: box-shadow 0.15s, filter 0.12s;
    box-sizing: border-box;
    /* Centre content both axes */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.cv2-job-card:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.22);
    filter: brightness(1.06);
    z-index: 20;
}
.cv2-job-card:active {
    cursor: grabbing;
}

/* All text lines fill card width so ellipsis works */
.cv2-card-rego,
.cv2-card-vehicle,
.cv2-card-time,
.cv2-card-items {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}
.cv2-card-rego {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.03em;
}
.cv2-card-items {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
}
.cv2-card-time {
    font-size: 11px;
    opacity: 0.7;
}
.cv2-card-vehicle {
    font-size: 11px;
    opacity: 0.75;
}

/* Responsive: sm = rego only, md = rego + items + time, lg = all */
.cv2-job-card[data-size="sm"] .cv2-card-vehicle,
.cv2-job-card[data-size="sm"] .cv2-card-time,
.cv2-job-card[data-size="sm"] .cv2-card-items {
    display: none;
}
.cv2-job-card[data-size="md"] .cv2-card-vehicle {
    display: none;
}

/* Resize handle */
.cv2-resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 6px;
    cursor: ns-resize;
    border-radius: 0 0 4px 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.cv2-job-card:hover .cv2-resize-handle {
    opacity: 1;
    background: rgba(0,0,0,0.15);
}
.cv2-job-card.cv2-resizing {
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Ghost card during drag */
.cv2-ghost {
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    pointer-events: none;
}

/* ── Weekly View ── */
.cv2-weekly {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border-top: 1px solid var(--color-border);
    background: var(--color-white);
}

/* Fixed header row */
.cv2-week-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border);
}
.cv2-week-day-header {
    padding: 10px 8px;
    text-align: center;
    background: var(--color-bg-surface);
    border-right: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.15s;
}
.cv2-week-day-header:last-child {
    border-right: none;
}
.cv2-week-day-header:hover {
    background: var(--color-border);
}
.cv2-week-day-header.cv2-today {
    background: var(--color-primary-bg);
}
.cv2-week-day-header.cv2-selected {
    background: var(--color-job-scheduled-bg);
}
.cv2-week-day-name {
    display: block;
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-weight: 500;
}
.cv2-week-day-num {
    display: inline-block;
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-heading);
    margin-top: 2px;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 50%;
}
.cv2-today-num {
    background: var(--color-primary);
    color: var(--color-white);
}

/* Scrollable body */
.cv2-week-body-scroll {
    flex: 1;
    overflow-y: auto;
}
.cv2-week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    min-height: 100%;
}
.cv2-week-day {
    border-right: 1px solid var(--color-border);
    padding: 4px;
    min-height: 0;
}
.cv2-week-day:last-child {
    border-right: none;
}
.cv2-week-day.cv2-today {
    background: #fafcff;
}
.cv2-week-day.cv2-selected {
    background: var(--color-bg-alt);
}
.cv2-week-day.cv2-disabled-day {
    background: var(--color-bg-surface);
    opacity: 0.6;
}
.cv2-week-empty {
    padding: 12px 8px;
    text-align: center;
    font-size: 12px;
    color: var(--color-text-placeholder);
}
.cv2-week-job {
    padding: 5px 7px;
    margin-bottom: 4px;
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    transition: box-shadow 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.cv2-week-job:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.cv2-week-job-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cv2-week-job-time {
    font-weight: 600;
    margin-right: 4px;
}
.cv2-week-job-bay {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.6;
}
.cv2-week-job-rego {
    font-weight: 700;
    margin-right: 4px;
}
.cv2-week-job-vehicle {
    font-size: 10px;
    opacity: 0.7;
}

/* ── Calendar v2 Modal (fallback) ── */
.cv2-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cv2-modal-content {
    background: var(--color-white);
    border-radius: 12px;
    width: 90%;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.cv2-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}
.cv2-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.cv2-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.cv2-modal-close:hover {
    color: var(--color-near-black);
}
.cv2-modal-body {
    padding: 20px;
}

/* ── Job Details Modal (polished) ── */
.cv2-d-error {
    color: var(--color-danger-legacy);
    padding: 20px;
    text-align: center;
}
.cv2-d-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}
.cv2-d-title-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cv2-d-rego {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text-heading);
    letter-spacing: 0.5px;
}
.cv2-d-vehicle {
    font-size: 14px;
    color: var(--color-text-muted);
    font-weight: 400;
}

/* Status badges */
.cv2-d-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
.cv2-st-scheduled  { background: var(--color-job-scheduled-bg); color: var(--color-job-scheduled-text); }
.cv2-st-progress   { background: var(--color-warning-bg); color: var(--color-warning-text); }
.cv2-st-completed  { background: var(--color-success-bg); color: var(--color-success-text); }
.cv2-st-invoiced   { background: var(--color-info-bg); color: var(--color-info-text); }
.cv2-st-cancelled  { background: var(--color-bg-body); color: var(--color-text-mid); }
.cv2-st-hold       { background: var(--color-job-hold-bg); color: var(--color-job-hold-text); }

/* Details grid */
.cv2-d-grid {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
}
.cv2-d-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.cv2-d-row:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}
.cv2-d-cell {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.cv2-d-cell:first-child {
    border-right: 1px solid var(--color-border);
}
.cv2-d-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-placeholder);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 5px;
}
.cv2-d-label svg {
    opacity: 0.5;
    flex-shrink: 0;
}
.cv2-d-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-heading);
}
.cv2-d-select {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-heading);
    padding: 4px 8px;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    background: var(--color-white);
    cursor: pointer;
    width: 100%;
    margin-top: 2px;
}
.cv2-d-select:focus {
    outline: none;
    border-color: var(--color-primary-mid);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

/* Notes */
.cv2-d-notes {
    margin-bottom: 16px;
}
.cv2-d-notes .cv2-d-label {
    margin-bottom: 6px;
}
.cv2-d-notes-text {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Invoice row */
.cv2-d-invoice-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 16px;
}
.cv2-d-invoice-row svg {
    color: var(--color-text-muted);
    flex-shrink: 0;
}
.cv2-d-invoice-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    flex: 1;
}
.cv2-d-invoice-none {
    font-size: 13px;
    color: var(--color-danger-mid);
    flex: 1;
}

/* Status change section */
.cv2-d-status-section {
    margin-bottom: 16px;
}
.cv2-d-status-section .cv2-d-label {
    margin-bottom: 8px;
}
.cv2-d-status-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.cv2-d-status-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}
.cv2-d-status-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}
.cv2-d-status-btn:active {
    transform: translateY(0);
}

/* Action buttons */
.cv2-d-actions {
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}
/* Calendar detail buttons — inherit unified button style */
.cv2-d-btn,
.cv2-d-btn-primary,
.cv2-d-btn-outline,
.cv2-d-btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 0.85rem;
    height: 36px;
    border: 1px solid var(--color-btn-border);
    border-radius: 6px;
    background: var(--color-btn-bg);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
}
.cv2-d-btn:hover,
.cv2-d-btn-primary:hover,
.cv2-d-btn-outline:hover,
.cv2-d-btn-danger:hover {
    border-color: var(--color-text-placeholder);
    background: var(--color-btn-bg-hover);
}

/* Status dropdown (clickable badge) */
.cv2-d-status-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    position: relative;
}
.cv2-d-status-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--color-text-placeholder);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cv2-d-badge-clickable {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    font-family: inherit;
    transition: box-shadow 0.15s, transform 0.1s;
}
.cv2-d-badge-clickable:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    transform: translateY(-1px);
}
.cv2-d-badge-clickable svg {
    opacity: 0.5;
    transition: transform 0.15s;
}
.cv2-d-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 150px;
    padding: 4px;
    z-index: 100;
    display: none;
}
.cv2-d-dropdown.cv2-d-dropdown-open {
    display: block;
}
.cv2-d-dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.1s;
}
.cv2-d-dropdown-item:hover {
    opacity: 0.85;
}
/* Colour each dropdown item like its badge */
.cv2-d-dropdown-item.cv2-st-scheduled  { color: var(--color-job-scheduled-text); }
.cv2-d-dropdown-item.cv2-st-scheduled:hover  { background: var(--color-job-scheduled-bg); }
.cv2-d-dropdown-item.cv2-st-progress   { color: var(--color-warning-text); }
.cv2-d-dropdown-item.cv2-st-progress:hover   { background: var(--color-warning-bg); }
.cv2-d-dropdown-item.cv2-st-completed  { color: var(--color-success-text); }
.cv2-d-dropdown-item.cv2-st-completed:hover  { background: var(--color-success-bg); }
.cv2-d-dropdown-item.cv2-st-invoiced   { color: var(--color-info-text); }
.cv2-d-dropdown-item.cv2-st-invoiced:hover   { background: var(--color-info-bg); }
.cv2-d-dropdown-item.cv2-st-cancelled  { color: var(--color-text-mid); }
.cv2-d-dropdown-item.cv2-st-cancelled:hover  { background: var(--color-bg-body); }
.cv2-d-dropdown-item.cv2-st-hold       { color: var(--color-job-hold-text); }
.cv2-d-dropdown-item.cv2-st-hold:hover       { background: var(--color-job-hold-bg); }

/* Job items table */
.cv2-d-items-section {
    margin-bottom: 16px;
}
.cv2-d-items-section .cv2-d-label {
    margin-bottom: 8px;
}
.cv2-d-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}
.cv2-d-items-table thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
}
.cv2-d-items-table tbody td {
    padding: 8px 12px;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-bg-pale);
}
.cv2-d-items-table tbody tr:last-child td {
    border-bottom: none;
}
.cv2-d-items-table tfoot td {
    padding: 8px 12px;
    border-top: 2px solid var(--color-border);
    font-weight: 600;
    color: var(--color-text-heading);
}
.cv2-d-items-table .cv2-d-items-right {
    text-align: right;
}
.cv2-d-items-total-label {
    font-weight: 600;
    color: var(--color-text-muted);
}
.cv2-d-items-total {
    font-weight: 700;
    font-size: 14px;
}
.cv2-d-items-empty {
    color: var(--color-text-placeholder);
    font-size: 13px;
    font-style: italic;
    margin: 0;
    padding: 12px 14px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
}
.cv2-d-item-new td {
    background: #f0fdf4;
}
.cv2-d-item-remove {
    background: none;
    border: none;
    color: var(--color-danger-mid);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    font-weight: 700;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.cv2-d-item-remove:hover {
    opacity: 1;
}
/* Add Item row */
.cv2-d-add-item {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
    flex-wrap: wrap;
}
.cv2-d-add-select {
    padding: 6px 8px;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    font-size: 13px;
    background: var(--color-white);
    min-width: 80px;
}
.cv2-d-add-ref {
    flex: 1;
    min-width: 120px;
}
.cv2-d-add-input {
    padding: 6px 8px;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    font-size: 13px;
    width: 72px;
}
.cv2-d-add-qty {
    width: 52px;
}
.cv2-d-btn-add {
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-btn-border);
    border-radius: 6px;
    background: var(--color-btn-bg);
    color: var(--color-text-secondary);
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}
.cv2-d-btn-add:hover {
    border-color: var(--color-text-placeholder);
    background: var(--color-btn-bg-hover);
}

/* ===================
   HELP PAGE
   =================== */

.help-layout {
    display: flex;
    align-items: stretch;
    margin: -1.5rem -4rem -2rem;
    border-top: 1px solid var(--color-border);
    height: calc(100vh - 126px);
    overflow: hidden;
}

/* Sidebar — fills layout height, scrolls independently */
.help-nav {
    width: 220px;
    min-width: 220px;
    height: 100%;
    overflow-y: auto;
    background: var(--color-bg-settings);
    border-right: 1px solid var(--color-border);
    padding: 1.25rem 0 2rem;
    flex-shrink: 0;
}

.help-nav-group {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--color-text-placeholder);
    padding: 0.6rem 1.25rem 0.25rem;
    border-top: 1px solid #e8ecf2;
    margin-top: 0.25rem;
}

.help-nav-group:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0.25rem;
}

.help-nav-link {
    display: block;
    padding: 0.38rem 1.25rem;
    font-size: 0.83rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.12s, color 0.12s;
}

.help-nav-link:hover {
    background: var(--color-primary-bg-hover);
    color: var(--color-primary);
    border-left-color: var(--color-primary-border-light);
}

.help-nav-link.active {
    background: var(--color-primary-bg);
    color: var(--color-primary-dark);
    border-left-color: var(--color-primary);
    font-weight: 600;
}

/* Main content area — scrolls independently. Centred with a wider cap
   so the right-hand whitespace on big screens is balanced rather than
   leaving everything pushed to the left of a half-empty page. */
.help-body {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 2.5rem 3rem 4rem;
    min-width: 0;
    max-width: 1100px;
    margin: 0 auto;
}

.help-section {
    margin-bottom: 0;
    scroll-margin-top: 140px;
}

.help-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0.55rem;
    margin: 0 0 1.25rem;
}

.help-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 1.5rem 0 0.5rem;
}

.help-section p {
    font-size: 0.9rem;
    color: var(--color-text-subtle);
    line-height: 1.7;
    margin: 0 0 0.75rem;
}

.help-section ul,
.help-section ol {
    font-size: 0.9rem;
    color: var(--color-text-subtle);
    line-height: 1.7;
    padding-left: 1.4rem;
    margin: 0 0 0.75rem;
}

.help-section li {
    margin-bottom: 0.35rem;
}

.help-section a {
    color: var(--color-primary);
    text-decoration: none;
}

.help-section a:hover {
    text-decoration: underline;
}

/* Step indicators */
.help-step {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    align-items: flex-start;
}

.help-step-num {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-white);
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.help-step-text {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.65;
}

/* Callout boxes */
.help-tip {
    background: #f0f9ff;
    border-left: 3px solid #0ea5e9;
    padding: 0.7rem 1rem;
    border-radius: 0 6px 6px 0;
    margin: 0.75rem 0;
    font-size: 0.87rem;
    color: #0369a1;
    line-height: 1.6;
}

.help-warn {
    background: #fffbeb;
    border-left: 3px solid var(--color-warning);
    padding: 0.7rem 1rem;
    border-radius: 0 6px 6px 0;
    margin: 0.75rem 0;
    font-size: 0.87rem;
    color: var(--color-warning-text-dark);
    line-height: 1.6;
}

/* Status badge row */
.help-status-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin: 0.5rem 0 0.75rem;
}

/* Inline tags */
.help-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.help-tag-blue   { background: var(--color-primary-bg-light); color: var(--color-primary-dark); }
.help-tag-green  { background: var(--color-success-bg-light); color: var(--color-success-dark); }
.help-tag-amber  { background: var(--color-warning-bg-light); color: var(--color-warning-text-mid); }
.help-tag-red    { background: var(--color-danger-bg-light); color: #b91c1c; }
.help-tag-gray   { background: var(--color-bg-alt); color: var(--color-text-subtle); }
.help-tag-purple { background: #ede9fe; color: #6d28d9; }

/* Section divider */
.help-divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2.5rem 0;
}

/* Coming Soon placeholder (notifications page, future feature stubs) */
.coming-soon {
    max-width: 520px;
    margin: 3rem auto 4rem;
    padding: 2.5rem 2rem;
    text-align: center;
    background: var(--color-bg-settings);
    border: 1px solid var(--color-border);
    border-radius: 10px;
}
.coming-soon-icon {
    color: #E63946;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}
.coming-soon h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 0.75rem;
}
.coming-soon p {
    color: var(--color-text-subtle);
    line-height: 1.65;
    margin: 0 0 1.5rem;
}

/* Per-section "Print section" button injected into each H2 by help.html JS.
   Sits at the right edge of the heading, subtle when idle, picks up the
   brand red on hover. */
.help-section h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.help-section-print-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--color-text-subtle);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.help-section-print-btn:hover {
    color: #E63946;
    border-color: #f3aab0;
    background: #fff5f5;
}
.help-section-print-btn svg {
    flex-shrink: 0;
}

/* Print: only the section the user clicked Print on is sent to the
   printer. Everything else on the page (app chrome, sidebar nav, the
   other help sections) is hidden. */
@media print {
    @page {
        size: A4;
        margin: 16mm 14mm;
    }

    /* Hide app chrome and anything tagged no-print. */
    .top-bar,
    .sidebar,
    .help-nav,
    .content-header,
    .no-print {
        display: none !important;
    }
    main.with-sidebar,
    main {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .help-layout {
        display: block;
        margin: 0;
        height: auto;
        overflow: visible;
        border-top: none;
    }
    .help-body {
        display: block;
        height: auto;
        max-width: 100%;
        overflow: visible;
        padding: 0;
        margin: 0;
    }

    /* Single-section mode (set by the print-this-section button): hide
       every section except the one tagged .printing. */
    body.printing-single-section .help-section:not(.printing) {
        display: none !important;
    }
    body.printing-single-section .help-divider {
        display: none !important;
    }

    /* Section styling that survives in print. */
    .help-section h2 {
        display: block;
        font-family: 'Helvetica Neue', Arial, sans-serif;
        font-size: 20pt;
        font-weight: 800;
        color: #E63946;
        border-bottom: 3px solid #E63946;
        padding-bottom: 0.35rem;
        margin: 0 0 1rem;
    }
    .help-section h3 {
        color: #2B2D42;
        font-size: 12pt;
        margin: 0.9rem 0 0.35rem;
        break-after: avoid;
        page-break-after: avoid;
    }
    .help-section p,
    .help-section li {
        font-size: 10.5pt;
        color: #1f2937;
        line-height: 1.55;
    }
    .help-divider {
        display: none;
    }
    .help-tip,
    .help-warn,
    .help-step,
    .help-status-row {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .help-tag {
        font-size: 7.5pt;
        padding: 0.1rem 0.45rem;
    }
    .help-section a {
        color: #E63946;
        text-decoration: none;
    }
    .help-tip {
        background: #f0f9ff;
        border-left: 3px solid #0ea5e9;
        color: #075985;
    }
    .help-warn {
        background: #fffbeb;
        border-left: 3px solid #b45309;
        color: #92400e;
    }
    html, body {
        background: #fff;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}


/* Nav badge */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--color-danger);
    color: var(--color-white);
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    margin-left: auto;
}

/* File drop zone */
.file-drop-zone {
    border: 2px dashed var(--color-border-medium);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}

.file-drop-zone.drag-over {
    border-color: var(--color-primary);
    background: var(--color-primary-bg);
}

.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.file-drop-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.file-drop-label svg { color: var(--color-text-placeholder); }
.file-drop-label small { font-size: 0.75rem; color: var(--color-text-placeholder); }

.file-list { margin-top: 0.75rem; }
.file-list-item { font-size: 0.82rem; color: var(--color-text-secondary); padding: 0.2rem 0; }
.file-list-warn { font-size: 0.8rem; color: var(--color-danger); margin-top: 0.25rem; }

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4rem 2rem;
    color: var(--color-text-placeholder);
    font-size: 0.9rem;
    gap: 0.5rem;
}

.dev-kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 0.75rem;
    font-size: 0.82rem;
}

.dev-kv dt {
    color: var(--color-text-placeholder);
    white-space: nowrap;
}

.dev-kv dd {
    color: var(--color-text-secondary);
    margin: 0;
    word-break: break-all;
}

/* Developer monospace */
.dev-mono {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8em;
    background: var(--color-bg-alt);
    padding: 0.1em 0.35em;
    border-radius: 3px;
}

/* API key badges */
.dev-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2em 0.55em;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-active   { background: var(--color-success-bg-light); color: var(--color-success-dark); }
.badge-inactive { background: var(--color-bg-alt); color: var(--color-text-muted); }

/* Developer button styles are defined inline in developer/panel.html */
