/* ── MOBILE RESPONSIVE ──
   Keep the mobile header and bottom tab bar on the same breakpoint. The
   641–768px band used to show the legacy horizontal header with mobile tabs. */
@media (max-width: 768px) {

    .main-wrap {
        padding: 76px 8px 40px;
    }
    .job-header { padding: 14px 14px; }
    .job-body { padding: 0 14px 18px; }

    /* Filter bar — 2-col on mobile: search (left) + filter icon (right).
       Dropdowns expand below when the icon is tapped. */
    .filter-bar {
        padding: 8px 10px;
        margin-bottom: 10px;
    }
    .filter-bar-row {
        flex-wrap: wrap;
        gap: 6px;
        align-items: center;
    }
    .filter-search-wrap {
        flex: 1 1 auto;
        min-width: 0;
    }
    .filter-search {
        font-size: 13px;
        padding: 8px 10px 8px 64px;
    }
    .filter-search-count {
        left: 28px;
        font-size: 10px;
        padding: 1px 6px;
    }

    /* On mobile the toggle replaces the inline dropdowns */
    .filter-toggle-btn { display: inline-flex; }
    .filter-clear { display: none; }

    .filter-dropdowns {
        display: none;
        flex: 0 0 100%;
        flex-wrap: wrap;
        margin-left: 0;
        margin-top: 4px;
        gap: 6px;
    }
    .filter-dropdowns.filter-dropdowns-open {
        display: flex;
    }
    .filter-select {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 12px;
        padding: 7px 22px 7px 8px;
    }

    /* Stats bar — 2x2 grid on mobile */
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 14px;
    }
    .stat-card {
        padding: 12px 14px;
    }
    .stat-value {
        font-size: 22px;
    }

    /* Job body — tighter padding on mobile */
    .job-body {
        padding: 0 12px 16px;
    }

    /* Tables — only scroll non-stacking ones; stacked variants flow naturally */
    .section-block {
        overflow-x: auto;
    }
    .data-table:not(.data-table-stack) {
        min-width: 500px;
    }
    .data-table.data-table-stack {
        min-width: 0;
    }
    /* Anything inside a section body must wrap to the card width */
    .section-card-body,
    .section-card-body table,
    .section-card-body .section-block {
        max-width: 100%;
    }

    /* Action panel */
    .action-panel {
        padding: 12px 14px;
    }
    .action-toggle {
        gap: 8px;
        flex-wrap: wrap;
    }
    .action-summary {
        flex: 1 1 auto;
        font-size: 11px;
    }
    .action-item {
        font-size: 12px;
        padding: 5px 0;
    }

    .inline-edit-grid {
        grid-template-columns: 1fr;
    }

    .confirm-modal-box {
        width: 92vw;
        padding: 20px 14px 18px;
    }
    .confirm-modal-box .data-table {
        font-size: 11px;
    }
    .confirm-modal-box .data-table th,
    .confirm-modal-box .data-table td {
        padding: 4px 3px;
    }

    /* Header */
    .site-header {
        padding: 0 14px;
        height: 52px;
    }
    .header-brand {
        font-size: 16px;
    }
    .header-logo {
        height: 28px;
    }
    .header-brand-group {
        gap: 8px;
    }
    .header-nav-desktop {
        display: none !important;
    }
    .header-nav-mobile {
        display: flex !important;
        align-items: center;
        gap: 10px;
    }
    .header-right {
        gap: 8px;
    }
    .header-page-title {
        display: block;
    }
    .header-icon-btn {
        width: 36px;
        height: 36px;
    }
    .header-icon-btn svg { width: 17px; height: 17px; }
    .header-date, .header-sub-bar {
        display: none;
    }
    .header-divider {
        display: none;
    }
    .site-header {
        position: fixed;
    }

    /* iOS-style light header — translucent glass to match the floating
       bottom tab bar. Light theme + mobile only. Dark theme keeps the
       navy header from 01-base.css. */
    html:not([data-theme="dark"]) .site-header {
        background: rgba(255, 255, 255, 0.88);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 1px solid rgba(60, 60, 67, 0.12);
        box-shadow: none;
    }
    html:not([data-theme="dark"]) .site-header .header-brand,
    html:not([data-theme="dark"]) .site-header .header-page-title {
        color: #1C1C1E;
    }
    html:not([data-theme="dark"]) .site-header .header-brand span {
        color: #6E6E73;
    }
    html:not([data-theme="dark"]) .site-header .header-icon-btn {
        background: rgba(120, 120, 128, 0.08);
        border-color: rgba(60, 60, 67, 0.12);
        color: #1C1C1E;
    }
    html:not([data-theme="dark"]) .site-header .header-icon-btn:hover,
    html:not([data-theme="dark"]) .site-header .header-icon-btn:focus-visible {
        background: rgba(120, 120, 128, 0.16);
        border-color: rgba(60, 60, 67, 0.20);
    }
    html:not([data-theme="dark"]) .site-header .header-icon-badge {
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.88);
    }

    .new-job-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    .import-job-btn {
        padding: 4px 10px;
        font-size: 12px;
    }
}

/* ── Analytics Panel ────────────────────────────────────────────────────── */

#analytics-panel {
    margin: 0 16px 16px;
}
.analytics-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 16px;
    background: var(--navy);
    color: #fff;
    border-radius: 10px 10px 0 0;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    user-select: none;
}
.analytics-header:hover { opacity: 0.9; }
.analytics-toggle-arrow {
    font-size: 12px;
    width: 16px;
    text-align: center;
}
.analytics-title { letter-spacing: 0.5px; text-transform: uppercase; }

.analytics-body {
    background: var(--white);
    border: 1px solid var(--gray-1);
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 16px;
}
/* ── Map View ────────────────────────────────────────────────────────────── */

#map-panel {
    margin: 0 16px 16px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--gray-1);
}
#map-container {
    height: 400px;
    width: 100%;
}
.map-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-1);
}
.map-controls-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: var(--navy);
    font-weight: 500;
}
.map-event-tooltip {
    font-family: 'DM Sans', sans-serif !important;
    font-size: 10px !important;
    line-height: 1.3 !important;
    padding: 3px 6px !important;
    background: #FFF8E1 !important;
    color: #1B3350 !important;
    border: 1px solid #C0392B !important;
    border-radius: 4px !important;
    white-space: nowrap !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15) !important;
}
/* Driver-friendly popup: dark glass bg, big job number, huge address line,
   and 2x2 action tiles. Designed for glanceable use at arm's length. */
.leaflet-popup.map-popup-wrapper .leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 4px;
    background: rgba(15, 26, 44, 0.45);
    -webkit-backdrop-filter: blur(16px) saturate(1.15);
    backdrop-filter: blur(16px) saturate(1.15);
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow: 0 12px 30px rgba(0,0,0,0.38);
    color: #fff;
}
.leaflet-popup.map-popup-wrapper .leaflet-popup-tip {
    background: rgba(15, 26, 44, 0.45);
    box-shadow: none;
}
.leaflet-popup.map-popup-wrapper .leaflet-popup-content {
    margin: 11px 13px 10px;
    font-family: 'DM Sans', sans-serif;
    line-height: 1.25;
    color: #fff;
}
.leaflet-popup.map-popup-wrapper .leaflet-popup-close-button {
    top: 4px !important;
    right: 6px !important;
    width: 22px !important;
    height: 22px !important;
    font-size: 18px !important;
    color: rgba(255,255,255,0.85) !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    padding: 0 !important;
    line-height: 22px !important;
}
.map-popup-head {
    font-family: 'Bebas Neue', 'DM Sans', sans-serif;
    font-size: 22px;
    letter-spacing: 0.8px;
    color: #fff;
    margin-bottom: 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.map-popup-address {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.map-popup-city {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    margin-bottom: 7px;
}
.map-popup-event {
    display: flex;
    flex-direction: column;
    margin: 0 0 7px;
    padding: 7px 9px;
    background: rgba(192, 57, 43, 0.22);
    border-left: 3px solid #E74C3C;
    border-radius: 6px;
}
.map-popup-event-when {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #FFB4A8;
}
.map-popup-event-title {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    margin-top: 1px;
}
.map-popup-tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}
.map-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 11px 7px;
    min-height: 52px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    background: rgba(41, 104, 166, 0.9);
    color: #fff !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.14);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.08s, box-shadow 0.2s, background 0.2s;
}
.map-tile:active {
    transform: scale(0.96);
}
.map-tile-icon {
    font-size: 20px;
    line-height: 1;
}
.map-tile-label {
    font-size: 11px;
    letter-spacing: 0.3px;
}
.map-tile-nav { background: rgba(41, 104, 166, 0.9); }
.map-tile-call { background: rgba(39, 174, 96, 0.9); }
.map-tile-job  { background: rgba(27, 51, 80, 0.9); }
.map-tile-disabled {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5) !important;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none;
}

/* Mobile: still compact — just nudge text up slightly for readability. */
@media (max-width: 768px) {
    .leaflet-popup.map-popup-wrapper .leaflet-popup-content {
        margin: 12px 14px 11px;
    }
    .map-popup-head { font-size: 25px; }
    .map-popup-address { font-size: 15px; }
    .map-popup-city { font-size: 12px; }
    .map-tile {
        padding: 13px 7px;
        min-height: 59px;
    }
    .map-tile-icon { font-size: 22px; }
    .map-tile-label { font-size: 11px; }
    .leaflet-popup.map-popup-wrapper .leaflet-popup-close-button {
        width: 26px !important;
        height: 26px !important;
        font-size: 20px !important;
        line-height: 26px !important;
    }
}

.map-event-tooltip::before {
    border-right-color: #C0392B !important;
}
@media (max-width: 600px) {
    #map-panel { margin: 0 8px 12px; }
    #map-container { height: 300px; }
}

/* Analytics date range */
.analytics-range-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.analytics-range-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 500;
    padding: 5px 12px;
    border: 1px solid var(--gray-2);
    border-radius: 16px;
    background: var(--white);
    color: var(--navy);
    cursor: pointer;
    transition: all 0.15s;
}
.analytics-range-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}
.analytics-range-btn.active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

/* P&L summary bar */
.pnl-summary-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.pnl-item {
    flex: 1;
    min-width: 100px;
    background: var(--white);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
    box-shadow: var(--shadow);
}
.pnl-label {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    text-transform: uppercase;
    color: var(--gray-3);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.pnl-value {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--navy);
}
.pnl-expense { color: var(--red); }
.pnl-profit { color: var(--green); }

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.chart-card {
    background: var(--white);
    border-radius: 10px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}
.chart-card canvas {
    width: 100%;
    height: 220px;
    max-height: 220px;
}
.chart-card-title {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--navy);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Collection gauge */
.gauge-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}
.gauge-ring {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gauge-inner {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.gauge-pct {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 28px;
    color: var(--navy);
    line-height: 1;
}
.gauge-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    color: var(--gray-3);
    text-transform: uppercase;
}
.gauge-details { width: 100%; }
.gauge-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: var(--navy);
    padding: 3px 0;
}
.gauge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Balance table */
.balance-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
}
.balance-table th {
    text-align: left;
    color: var(--gray-3);
    font-weight: 500;
    padding: 4px 8px;
    border-bottom: 1px solid var(--gray-1);
    font-size: 11px;
    text-transform: uppercase;
}
.balance-table td {
    padding: 6px 8px;
    color: var(--navy);
    border-bottom: 1px solid var(--gray-1);
}
.bal-job { font-weight: 600; width: 50px; }
.bal-client { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bal-amount { font-weight: 600; color: var(--red); text-align: right; white-space: nowrap; }
.bal-pct {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
}
.bal-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--gray-1);
    border-radius: 3px;
    overflow: hidden;
}
.bal-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.balance-empty {
    text-align: center;
    padding: 24px;
    color: var(--gray-3);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
}

/* ── New Job photo list ──────────────────────────────────────────────────── */

.new-job-photos-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.new-job-photo-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.new-job-photo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--gray-bg);
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
}
.new-job-photo-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    background: #ddd;
    flex-shrink: 0;
}
.new-job-photo-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #888;
    background: #e3e3e3;
}
.new-job-photo-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.new-job-photo-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--navy);
}
.new-job-photo-cover-badge {
    background: transparent;
    border: 0;
    padding: 0 4px 0 0;
    margin: 0;
    color: #B0B5BD;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}
.new-job-photo-cover-badge.is-cover {
    color: #E1A209;
}
.new-job-photo-cover-badge:hover {
    color: #E1A209;
}
.new-job-photo-cat-select {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    padding: 2px 6px;
    border: 1px solid var(--gray-border, #d0d0d0);
    border-radius: 4px;
    background: #fff;
    color: var(--navy);
    max-width: 140px;
}
.new-job-photo-remove {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    font-weight: 600;
    padding: 4px 6px;
    flex-shrink: 0;
}

.photo-cat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 0;
}
.photo-cat-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 8px;
    border: 1px solid var(--gray-2);
    border-radius: 8px;
    background: var(--white);
    color: var(--navy);
    cursor: pointer;
}
.photo-cat-btn:hover, .photo-cat-btn:active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

/* ── Photos section ──────────────────────────────────────────────────────── */

.photo-path-hint {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--gray-3);
    padding: 2px 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Send Now button ─────────────────────────────────────────────────────── */

.send-now-btn {
    background: var(--green) !important;
    font-weight: 600;
}
.send-now-btn:hover { opacity: 0.9; }

/* ── Compliance Check Results ────────────────────────────────────────────── */

.compliance-summary {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: var(--gray-3);
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-1);
    margin-bottom: 12px;
}
.compliance-findings {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.compliance-row {
    display: flex;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
}
.compliance-pass { background: #f0fdf4; }
.compliance-warning { background: #fffbeb; }
.compliance-fail { background: #fef2f2; }
.compliance-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.compliance-item { font-weight: 600; font-size: 13px; color: var(--navy); }
.compliance-detail { font-size: 12px; color: var(--gray-3); margin-top: 2px; line-height: 1.4; }

/* ── Expenses & Profitability ────────────────────────────────────────────── */

.profitability-row {
    display: flex;
    gap: 24px;
    padding: 8px 0 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: var(--navy);
    flex-wrap: wrap;
}
.profitability-row strong { font-weight: 600; }
.expense-table { font-size: 12px; }
.expense-table th { font-size: 11px; }
.expense-amt { font-weight: 600; text-align: right; white-space: nowrap; }
.expense-cat {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    background: var(--gray-1);
    color: var(--navy);
    white-space: nowrap;
}

/* ── Payments & Billing dashboard ───────────────────────────────────────── */

.payments-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.payments-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 4px 0 14px;
}

.payments-summary-tile {
    border: 1px solid var(--gray-1);
    border-radius: 12px;
    background: rgba(246, 248, 251, 0.72);
    padding: 12px 14px;
}

.payments-summary-tile span {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--gray-3);
    margin-bottom: 5px;
}

.payments-summary-tile strong {
    display: block;
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 15px;
    color: var(--text);
}

.payment-card-list {
    display: grid;
    gap: 10px;
}

.payment-row-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, auto);
    gap: 16px;
    align-items: start;
    border: 1px solid var(--gray-1);
    border-radius: 12px;
    background: var(--white);
    padding: 13px 14px;
}

.payment-row-main {
    min-width: 0;
}

.payment-row-title {
    color: var(--navy);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
}

.payment-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 4px;
    color: var(--gray-3);
    font-size: 12px;
}

.payment-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.payment-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border: 1px solid rgba(41, 104, 166, 0.24);
    border-radius: 999px;
    background: rgba(41, 104, 166, 0.08);
    color: var(--blue);
    padding: 3px 9px;
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.payment-chip-action {
    border-color: rgba(31, 157, 85, 0.28);
    background: rgba(31, 157, 85, 0.10);
    color: var(--green);
}

.payment-row-amounts {
    display: grid;
    grid-template-columns: repeat(2, minmax(82px, auto));
    gap: 14px;
    text-align: right;
}

.payment-row-amounts span {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--gray-3);
    margin-bottom: 3px;
}

.payment-row-amounts strong,
.payment-row-amounts .amt-pending {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.payment-schedule-card-list {
    display: grid;
    gap: 10px;
}
.payment-schedule-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
    border: 1px solid var(--gray-1);
    border-radius: 12px;
    background: var(--white);
    padding: 13px 14px;
}
.payment-schedule-main {
    min-width: 0;
}
.payment-schedule-note {
    margin-top: 8px;
    border-left: 3px solid rgba(31, 157, 85, 0.28);
    padding: 6px 9px;
    border-radius: 8px;
    background: rgba(31, 157, 85, 0.06);
    color: var(--text-lt);
    font-size: 12.5px;
    line-height: 1.45;
}
.payment-schedule-amount {
    min-width: 110px;
    text-align: right;
}
.payment-schedule-amount span {
    display: block;
    color: var(--gray-3);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin-bottom: 3px;
}
.payment-schedule-amount strong {
    color: var(--navy);
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.payment-subtitle,
.finance-subtitle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}

.finance-action-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.profitability-row-compact {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 8px 0 12px;
}

.profitability-row-compact span {
    display: grid;
    gap: 3px;
    border: 1px solid var(--gray-1);
    border-radius: 10px;
    background: rgba(246, 248, 251, 0.62);
    padding: 9px 10px;
}

.profitability-row-compact em {
    color: var(--gray-3);
    font-size: 10px;
    font-style: normal;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.profitability-row-compact strong {
    color: var(--navy);
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 13px;
}

.finance-details {
    border: 1px solid var(--gray-1);
    border-radius: 12px;
    background: rgba(246, 248, 251, 0.45);
    margin: 10px 0;
    overflow: hidden;
}

.finance-details summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 13px;
    color: var(--navy);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.finance-details summary::-webkit-details-marker {
    display: none;
}

.finance-details summary::after {
    content: '⌄';
    color: var(--gray-3);
    transition: transform 0.16s ease;
}

.finance-details[open] summary::after {
    transform: rotate(180deg);
}

.finance-details summary span {
    color: var(--gray-3);
    font-size: 12px;
    font-weight: 600;
}

.hours-summary-tile {
    display: grid;
    gap: 4px;
    border: 1px solid var(--gray-1);
    border-radius: 12px;
    background: rgba(246, 248, 251, 0.70);
    padding: 11px 13px;
    margin-bottom: 10px;
}
.hours-summary-tile span {
    color: var(--gray-3);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}
.hours-summary-tile strong {
    color: var(--navy);
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 16px;
}
.hours-card-list {
    display: grid;
    gap: 10px;
}
.hours-card-row {
    border: 1px solid var(--gray-1);
    border-radius: 12px;
    background: var(--white);
    padding: 13px 14px;
    box-shadow: 0 6px 18px rgba(15, 27, 45, 0.05);
}
.hours-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}
.hours-card-date {
    color: var(--navy);
    font-weight: 750;
    line-height: 1.25;
}
.hours-card-hours {
    color: var(--navy);
    font-family: 'DM Mono', ui-monospace, monospace;
    font-weight: 800;
    white-space: nowrap;
}
.hours-card-notes {
    margin-top: 7px;
    color: var(--text-lt);
    font-size: 12.5px;
    line-height: 1.45;
}
.hours-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.hours-card-action {
    min-width: 80px;
    justify-content: center;
}

.finance-details .data-table {
    border: 0;
    border-top: 1px solid var(--gray-1);
    border-radius: 0;
    box-shadow: none;
}

[data-theme="dark"] .payments-summary-tile,
[data-theme="dark"] .payment-row-card,
[data-theme="dark"] .payment-schedule-card,
[data-theme="dark"] .hours-summary-tile,
[data-theme="dark"] .hours-card-row,
[data-theme="dark"] .profitability-row-compact span,
[data-theme="dark"] .finance-details {
    background: rgba(20, 30, 44, 0.72);
    border-color: #2A3545;
}

[data-theme="dark"] .payment-row-title,
[data-theme="dark"] .payment-schedule-amount strong,
[data-theme="dark"] .hours-summary-tile strong,
[data-theme="dark"] .hours-card-date,
[data-theme="dark"] .hours-card-hours,
[data-theme="dark"] .profitability-row-compact strong,
[data-theme="dark"] .finance-details summary {
    color: #E6EAF0;
}

[data-theme="dark"] .payments-summary-tile strong,
[data-theme="dark"] .payment-row-amounts strong,
[data-theme="dark"] .payment-row-amounts .amt-pending {
    color: #E6EAF0;
}

[data-theme="dark"] .finance-details .data-table {
    border-top-color: #2A3545;
}
[data-theme="dark"] .payment-schedule-note {
    background: rgba(46, 204, 113, 0.08);
    border-left-color: rgba(46, 204, 113, 0.34);
    color: #B6BEC9;
}
[data-theme="dark"] .hours-card-notes {
    color: #B6BEC9;
}

@media (max-width: 768px) {
    .payments-action-bar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .payments-action-bar .doc-import-btn {
        justify-content: center;
        width: 100%;
    }

    .payments-summary-grid {
        grid-template-columns: 1fr;
    }

    .payment-row-card {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .payment-schedule-card {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .payment-schedule-amount {
        text-align: left;
        border-top: 1px solid var(--gray-1);
        padding-top: 10px;
    }

    .payment-row-amounts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        text-align: left;
        border-top: 1px solid var(--gray-1);
        padding-top: 10px;
    }

    .payment-subtitle,
    .finance-subtitle {
        align-items: flex-start;
        flex-direction: column;
    }

    .finance-action-chips {
        width: 100%;
        justify-content: flex-start;
    }

    .profitability-row-compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .finance-card-stack thead {
        display: none;
    }

    .finance-card-stack,
    .finance-card-stack tbody,
    .finance-card-stack tr,
    .finance-card-stack td {
        display: block;
        width: 100%;
    }

    .finance-card-stack tr {
        border: 1px solid var(--gray-1);
        border-radius: 12px;
        background: var(--white);
        margin-bottom: 10px;
        padding: 10px 12px;
    }

    .finance-card-stack td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        min-height: 0;
        height: auto;
        border: 0 !important;
        padding: 5px 0 !important;
        text-align: right;
    }

    .finance-card-stack td::before {
        content: attr(data-label);
        color: var(--gray-3);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.6px;
        text-transform: uppercase;
        text-align: left;
    }

    .finance-card-stack td[data-primary] {
        display: block;
        text-align: left;
        padding-bottom: 8px !important;
    }

    .finance-card-stack td[data-primary]::before {
        display: none;
    }

    [data-theme="dark"] .payment-row-amounts {
        border-top-color: #2A3545;
    }

    [data-theme="dark"] .payment-schedule-amount {
        border-top-color: #2A3545;
    }

    [data-theme="dark"] .finance-card-stack tr {
        background: rgba(20, 30, 44, 0.72);
        border-color: #2A3545;
    }
}

/* ── Permit Checklist ────────────────────────────────────────────────────── */

.checklist-table {
    font-size: 12px;
}
.checklist-table th {
    font-size: 11px;
}
.checklist-desc {
    color: var(--gray-3);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.checklist-date {
    font-size: 11px;
    color: var(--gray-3);
    white-space: nowrap;
}
.checklist-progress {
    font-size: 11px;
    color: var(--gray-3);
    font-weight: 400;
    margin-left: 8px;
}
.checklist-bar-wrap {
    height: 4px;
    background: var(--gray-1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}
.checklist-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}
.checklist-status-badge {
    cursor: pointer;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    user-select: none;
}
.checklist-status-badge:hover { opacity: 0.8; }
.status-pending { background: #FFF3CD; color: #856404; }
.status-submitted { background: #D1ECF1; color: #0C5460; }
.status-issued { background: #D4EDDA; color: #155724; }
.status-rejected { background: #F8D7DA; color: #721C24; }
.status-na { background: var(--gray-1); color: var(--gray-3); }

/* Responsive */
@media (max-width: 600px) {
    #analytics-panel {
        margin: 0 8px 12px;
    }
    .chart-card canvas {
        height: 180px;
        max-height: 180px;
    }
    .gauge-ring {
        width: 110px;
        height: 110px;
    }
    .gauge-inner {
        width: 78px;
        height: 78px;
    }
    .gauge-pct { font-size: 22px; }
}

/* ── ANALYTICS DEDICATED PAGE ── */

.analytics-page-inner {
    padding: 0;
}
.analytics-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.analytics-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
@media (max-width: 640px) {
    .analytics-tiles {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 12px;
    }
    .analytics-tiles .stat-value {
        font-size: 22px;
    }
}

/* ── HOME PAGE ── */

.home-page {
    padding: 0;
}
.home-content {
    padding: 0 16px 24px;
}
.settings-page {
    padding: 0;
}
.settings-content {
    padding: 0 16px 24px;
}
.home-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--navy);
}
/* Desktop: the site-header already carries logo + brand + nav + bell +
   profile, so the home-view's duplicate top bar is both redundant and
   stacks directly over the real nav (same position/z-index/background).
   Hide it on desktop and reset the content offset. */
@media (min-width: 769px) {
    .home-header {
        display: none;
    }
    .home-content {
        padding-top: 0;
    }
}
.home-content {
    padding-top: 56px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Mobile: home and settings panels sit outside .main-wrap, so they don't
   inherit the bottom-tab-bar padding. Add it here so cards stay clear of the
   tab bar (and of the floating clock widget when it's active). */
@media (max-width: 768px) {
    .home-content,
    .settings-content {
        padding-bottom: calc(var(--btab-h) + env(safe-area-inset-bottom) + 30px);
    }
    body.clock-active .home-content,
    body.clock-active .settings-content {
        padding-bottom: calc(var(--btab-h) + env(safe-area-inset-bottom) + 50px + 30px);
    }
}
[data-theme="dark"] .home-header {
    background: #0A1220;
}
.home-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.home-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}
.home-brand {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 17px;
    letter-spacing: 1px;
    color: #fff;
}
.home-location {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
}
.home-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.home-icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    position: relative;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
}
.home-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #E74C3C;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}
.home-welcome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 4px;
    font-family: 'DM Sans', sans-serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}
.home-refresh {
    font-size: 16px;
    color: var(--text);
}
.home-section-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 14px 0 6px;
}
.home-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.home-card-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.home-edit-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-3);
    cursor: pointer;
    padding: 6px 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.home-edit-btn:hover { color: var(--blue); }
.home-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.home-picker-item:hover { background: var(--gray-1); }
.home-picker-selected { background: var(--gray-1); }

/* Reorderable picker (bottom tabs, FAB, pinned, quick) */
.home-picker-section-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--gray-3);
    margin: 8px 2px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.home-picker-counter {
    font-weight: 600;
    color: var(--text-lt);
}
.home-picker-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.home-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--gray-1);
    border: 1px solid transparent;
    -webkit-tap-highlight-color: transparent;
}
.home-picker-row-selected {
    background: var(--white);
    border-color: var(--gray-2);
    transition: background 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.home-picker-row-flash {
    background: rgba(41,104,166,0.12);
    border-color: var(--blue);
    box-shadow: 0 4px 14px rgba(41,104,166,0.25);
}
[data-theme="dark"] .home-picker-row-flash {
    background: rgba(74,144,217,0.18);
}
.home-picker-row-available {
    cursor: pointer;
    border-color: var(--gray-2);
}
.home-picker-row-available:hover {
    background: var(--white);
    border-color: var(--blue);
}
.home-picker-pos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}
.home-picker-label {
    flex: 1;
    font-size: 14px;
    color: var(--text);
}
.home-picker-arrows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.home-picker-arrow {
    width: 38px;
    height: 24px;
    border: 1px solid var(--gray-2);
    border-radius: 6px;
    background: var(--white);
    color: var(--text);
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s, color 0.12s, transform 0.08s;
}
.home-picker-arrow:hover:not(:disabled),
.home-picker-arrow:active:not(:disabled) {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}
.home-picker-arrow:active:not(:disabled) {
    transform: scale(0.94);
}
.home-picker-arrow:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.home-picker-remove {
    width: 28px;
    height: 28px;
    border: 1px solid var(--gray-2);
    border-radius: 6px;
    background: transparent;
    color: var(--gray-3);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    -webkit-tap-highlight-color: transparent;
}
.home-picker-remove:hover {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}
.home-picker-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 18px;
    line-height: 1;
}
.home-picker-empty {
    padding: 14px 10px;
    text-align: center;
    color: var(--gray-3);
    font-size: 12px;
    font-style: italic;
    background: var(--gray-1);
    border-radius: 8px;
}
.home-card-tiles {
    padding: 14px;
}
.home-card-tiles .home-tiles {
    gap: 8px;
}
.home-tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.home-tile {
    background: var(--gray-bg);
    border-radius: 10px;
    padding: 12px 14px;
    position: relative;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
[data-theme="dark"] .home-tile {
    background: var(--gray-1);
}
.home-tile-period {
    font-size: 11px;
    color: var(--gray-3);
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}
.home-tile-icon {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.home-tile-value {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 34px;
    color: var(--text);
    line-height: 1;
    margin-top: 6px;
}
.home-tile-label {
    font-size: 13px;
    color: var(--gray-3);
    font-weight: 500;
    margin-top: 4px;
}
.home-card {
    background: var(--white);
    border-radius: 14px;
    border: 1px solid var(--gray-1);
    padding: 20px;
}
.home-pipeline {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.home-activity {
    display: flex;
    flex-direction: column;
}
.home-activity-row {
    display: grid;
    grid-template-columns: 64px auto auto 1fr;
    gap: 8px;
    align-items: baseline;
    padding: 10px 0;
    border-top: 1px solid var(--gray-1);
    font-size: 13px;
    line-height: 1.4;
}
.home-activity-row:first-child { border-top: none; padding-top: 4px; }
.home-activity-time {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--gray-3);
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.home-activity-who {
    color: var(--navy);
    font-weight: 600;
    white-space: nowrap;
}
.home-activity-verb {
    color: var(--gray-3);
}
.home-activity-ctx {
    justify-self: end;
    min-width: 0;
    color: var(--gray-3);
}
.home-activity-chip {
    display: inline-block;
    padding: 1px 8px;
    background: rgba(41,104,166,0.08);
    color: var(--blue);
    border-radius: 10px;
    font-family: 'DM Mono', monospace;
    font-weight: 500;
    font-size: 12px;
}
.home-activity-detail {
    display: inline-block;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    vertical-align: bottom;
}
.home-activity-empty {
    color: var(--gray-3);
    font-size: 13px;
    padding: 6px 0;
    font-style: italic;
}
[data-theme="dark"] .home-activity-row { border-top-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .home-activity-who { color: #E4ECF5; }
[data-theme="dark"] .home-activity-chip {
    background: rgba(139,184,224,0.14);
    color: #8BB8E0;
}
.home-pipeline-pill {
    flex: 1;
    min-width: 65px;
    background: transparent;
    border: 1.5px solid var(--gray-2);
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.home-pipeline-pill:hover {
    background: var(--gray-1);
}
.home-pipeline-count {
    display: block;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 26px;
    line-height: 1;
}
.home-pipeline-label {
    display: block;
    font-size: 11px;
    color: var(--gray-3);
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 4px;
}
/* .home-action-icon is still used by the bottom-tabs picker rows. */
