/* ==========================================================================
   SGiQ Property Management
   Ledger design system. Warm paper, ink, hairline rules.
   Colour appears only where it carries meaning.
   ========================================================================== */

@font-face {
    font-family: 'Plex Sans';
    src: url('fonts/plex-sans-var.woff2') format('woff2-variations');
    font-weight: 100 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Plex Mono';
    src: url('fonts/plex-mono-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Plex Mono';
    src: url('fonts/plex-mono-500.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Surfaces */
    --paper: #F4F1EA;
    --surface: #FFFDFA;
    --surface-sunk: #EDE9E0;

    /* Ink */
    --ink: #1C1917;
    --ink-2: #6B655C;
    --ink-3: #9A9288;
    --ink-invert: #FFFDFA;

    /* Client brand - taken from the Earl P Ward mark */
    --brand: #1B3A5C;
    --brand-deep: #142C46;
    --brand-gold: #C9A46B;
    --brand-on: #C3D2E0;      /* nav text on navy */
    --brand-on-strong: #FFFFFF;

    /* Rules - borders carry structure, not shadows */
    --rule: #E0DACE;
    --rule-strong: #C9C1B1;

    /* Semantic. Four meanings, no more. */
    --danger: #A32D22;
    --danger-bg: #F7EBE8;
    --good: #2E6B4F;
    --good-bg: #E9F0EA;
    --warn: #8A6519;
    --warn-bg: #F7F0DF;
    --info: #2B4C6F;
    --info-bg: #E8EEF4;

    /* Type */
    --font-ui: 'Plex Sans', system-ui, -apple-system, sans-serif;
    --font-data: 'Plex Mono', ui-monospace, 'SF Mono', Consolas, monospace;

    /* Geometry */
    --radius: 2px;
    --radius-lg: 4px;
    --gutter: 16px;
    --pad: 24px;
    --sidebar-w: 224px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   SHELL
   ========================================================================== */
.navbar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--brand);
    border-right: 1px solid var(--brand-deep);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

/* The client's mark sits on a light plate - on a ledger, a letterhead block.
   Their logo is navy and gold; on the dark rail it would read as mud. */
.nav-brand {
    background: var(--paper);
    border-bottom: 1px solid var(--rule-strong);
    padding: 16px var(--gutter);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 96px;
}

#brand-logo {
    display: block;
    max-width: 100%;
    max-height: 112px;
    width: auto;
    height: auto;
}

/* Shown only if the logo file is missing */
.nav-brand h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    text-align: center;
}

.nav-brand .brand-sub {
    font-family: var(--font-data);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-2);
    margin-top: 3px;
    text-align: center;
}

/* Attribution. Quiet on purpose - this is Earl's tool, not ours. */
.nav-colophon {
    padding: 10px var(--gutter) 14px;
    font-family: var(--font-data);
    font-size: 9.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #94A8BB;   /* 4.75:1 on navy - quiet, but still legible */
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.nav-colophon strong { color: var(--brand-gold); font-weight: 500; }

.nav-user {
    margin-top: auto;
    padding: 14px var(--gutter);
    border-top: 1px solid rgba(255, 255, 255, 0.10);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-user #user-email {
    font-size: 12px;
    color: var(--brand-on);
    word-break: break-all;
}

.role-badge {
    font-family: var(--font-data);
    font-size: 9.5px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--brand-gold);
    align-self: flex-start;
}

.nav-user .btn-small {
    width: 100%;
    background: transparent;
    color: var(--brand-on);
    border: 1px solid rgba(255, 255, 255, 0.20);
}
.nav-user .btn-small:hover {
    background: rgba(255, 255, 255, 0.09);
    color: var(--brand-on-strong);
}

.container {
    margin-left: var(--sidebar-w);
    padding: var(--pad);
    max-width: 1600px;
}

/* ==========================================================================
   NAV (was horizontal tabs, now sidebar)
   ========================================================================== */
.tabs {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    flex: 1;
    overflow-y: auto;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px var(--gutter);
    background: none;
    border: none;
    border-left: 3px solid transparent;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    color: var(--brand-on);
    text-align: left;
    cursor: pointer;
    transition: color 0.12s, background 0.12s;
}

.tab-btn:hover {
    color: var(--brand-on-strong);
    background: rgba(255, 255, 255, 0.06);
}

.tab-btn.active {
    color: var(--brand-on-strong);
    background: rgba(255, 255, 255, 0.09);
    border-left-color: var(--brand-gold);
    font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.tab-grid {
    display: grid;
    /* minmax(0, 1fr) not 1fr - an auto minimum refuses to shrink below its
       content, which lets wide tables push the whole page sideways. */
    grid-template-columns: minmax(0, 1fr);
    gap: var(--gutter);
}

.tab-grid > * { min-width: 0; }

@media (min-width: 1200px) {
    .tab-grid { grid-template-columns: 400px minmax(0, 1fr); }
}

/* ==========================================================================
   CARDS
   ========================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: var(--pad);
}

/* The form only stays pinned while it sits beside the list (two columns).
   Stacked above the list, a pinned form slides over the records below it. */
.form-card { height: fit-content; }
@media (min-width: 1200px) {
    .form-card {
        position: sticky;
        top: var(--pad);
        max-height: calc(100vh - 48px);
        overflow-y: auto;
    }
}

.card h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
    margin-bottom: 18px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: calc(var(--pad) * -1) calc(var(--pad) * -1) var(--pad);
    padding: 12px var(--pad);
    border-bottom: 1px solid var(--rule);
}

.card-header h2 { margin: 0; }

/* Stat tiles */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gutter);
    margin-bottom: 22px;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: 14px var(--gutter) 16px;
}

.stat-tile.flag { border-left: 3px solid var(--danger); }

.stat-label {
    font-family: var(--font-data);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--ink-2);
}
.stat-tile.flag .stat-label { color: var(--danger); }

.stat-value {
    font-size: clamp(22px, 2.4vw, 32px);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.15;
    margin: 8px 0 3px;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.stat-tile.flag .stat-value { color: var(--danger); }

.stat-note { font-size: 12px; color: var(--ink-2); }
.stat-note b {
    font-family: var(--font-data);
    font-weight: 500;
    color: var(--ink);
}

/* ==========================================================================
   FORMS
   ========================================================================== */
.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-family: var(--font-data);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-2);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--ink);
    background: var(--paper);
    transition: border-color 0.12s, background 0.12s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: 2px solid var(--brand);
    outline-offset: -1px;
    background: var(--surface);
}

/* VIN, money, dates read as data */
.form-group input[type="number"],
.form-group input[type="date"],
#car-vin {
    font-family: var(--font-data);
    font-size: 13px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn, .btn-small, .btn-sm {
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid var(--brand);
    border-radius: var(--radius);
    background: var(--brand);
    color: var(--brand-on-strong);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.btn { padding: 9px 18px; font-size: 12px; }
.btn-small { padding: 5px 11px; font-size: 11px; }
.btn-sm { padding: 4px 9px; font-size: 10.5px; }

.btn:hover, .btn-small:hover, .btn-sm:hover {
    background: var(--brand-deep);
    border-color: var(--brand-deep);
}

.btn-primary { flex: 1; }

.btn-secondary {
    background: transparent;
    color: var(--ink);
    border-color: var(--rule-strong);
}
.btn-secondary:hover { background: var(--surface-sunk); }

.btn-edit {
    background: transparent;
    color: var(--ink);
    border-color: var(--rule-strong);
}
.btn-edit:hover { background: var(--surface-sunk); }

.btn-delete {
    background: transparent;
    color: var(--danger);
    border-color: var(--rule-strong);
}
.btn-delete:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--ink-3);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
}
.btn-close:hover { color: var(--ink); }

/* ==========================================================================
   TABLES - the ledger
   ========================================================================== */
.data-table, .users-table, .simple-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th,
.users-table th,
.simple-table th {
    font-family: var(--font-data);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-2);
    text-align: left;
    padding: 9px var(--gutter);
    background: var(--surface-sunk);
    border-bottom: 1px solid var(--rule-strong);
    white-space: nowrap;
}

.data-table tbody td,
.users-table td,
.simple-table td {
    padding: 10px var(--gutter);
    border-bottom: 1px solid var(--rule);
    font-size: 13px;
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table tbody tr:hover,
.users-table tr:hover,
.simple-table tr:hover { background: var(--paper); }

/* Monospaced, tabular columns - digits align down the page */
.data-table td.data, .data-table th.data {
    font-family: var(--font-data);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.data-table td.num, .data-table th.num { text-align: right; }
.data-table td.strong { font-weight: 600; }

.table-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* A wide table scrolls inside its own card. The page never scrolls sideways. */
.table-wrap {
    overflow-x: auto;
    max-width: 100%;
}
.table-wrap .data-table { min-width: 680px; }

/* ==========================================================================
   ENTITY CARDS (screens not yet converted to tables)
   ========================================================================== */
.property-card, .tenant-card, .payment-card,
.walkthrough-card, .maintenance-card {
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: var(--gutter);
    margin-bottom: 10px;
    background: var(--surface);
    transition: border-color 0.12s;
}

.property-card:hover, .tenant-card:hover, .payment-card:hover,
.walkthrough-card:hover, .maintenance-card:hover {
    border-color: var(--rule-strong);
}

.property-header, .tenant-header, .payment-header, .walkthrough-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.property-address { font-size: 15px; font-weight: 600; margin-bottom: 3px; }

.property-price, .payment-amount {
    font-family: var(--font-data);
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.property-details, .tenant-info, .payment-details,
.walkthrough-details, .tenant-details {
    margin: 10px 0;
    color: var(--ink-2);
    font-size: 13px;
}

.property-details { display: flex; flex-wrap: wrap; gap: 16px; }

.tenant-info p, .payment-details p, .walkthrough-details p { margin: 5px 0; }

.property-description { color: var(--ink-2); margin-bottom: 12px; font-size: 13px; }

.tenant-card h3, .walkthrough-card h4 { font-size: 14px; margin-bottom: 3px; }

.features { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.feature-tag {
    background: var(--surface-sunk);
    border: 1px solid var(--rule);
    padding: 2px 7px;
    border-radius: var(--radius);
    font-size: 11.5px;
    color: var(--ink-2);
}

.card-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

.detail-section { margin-bottom: 16px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section h4 {
    font-family: var(--font-data);
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-2);
    margin-bottom: 5px;
}
.detail-section p { font-size: 13px; }

.late-payments-card { border-left: 3px solid var(--danger); }
.late-payments-card h3 { font-size: 14px; color: var(--danger); margin-bottom: 12px; }

.late-payment-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
    font-size: 13px;
}
.late-payment-item:last-child { border-bottom: 0; }
.late-payment-item strong { font-weight: 600; }

/* ==========================================================================
   BADGES - eight states mapped onto four meanings
   ========================================================================== */
.badge {
    display: inline-block;
    font-family: var(--font-data);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: var(--radius);
    white-space: nowrap;
    background: var(--surface-sunk);
    color: var(--ink-2);
}

.badge-available,
.badge-active,
.badge-completed { background: var(--good-bg); color: var(--good); }

.badge-occupied,
.badge-scheduled { background: var(--info-bg); color: var(--info); }

.badge-maintenance { background: var(--warn-bg); color: var(--warn); }

.badge-inactive,
.badge-cancelled { background: var(--danger-bg); color: var(--danger); }

.badge-plain { background: var(--surface-sunk); color: var(--ink-2); }

/* ==========================================================================
   CALL TRANSCRIPT
   ========================================================================== */
.call-transcript {
    max-height: 42vh;
    overflow-y: auto;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 4px 0;
}
.call-turn {
    display: grid;
    grid-template-columns: 78px 1fr;
    gap: 12px;
    padding: 8px var(--gutter);
    border-bottom: 1px solid var(--rule);
    font-size: 13px;
}
.call-turn:last-child { border-bottom: 0; }
.call-turn-bot { background: var(--surface); }
.call-turn-caller { background: var(--paper); }
.call-turn-who {
    font-family: var(--font-data);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-2);
}
.call-turn-bot .call-turn-who { color: var(--brand); }
.call-turn-text { color: var(--ink); }

.call-transcript-raw {
    max-height: 42vh;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 12px var(--gutter);
}

/* ==========================================================================
   UPCOMING THIS WEEK
   ========================================================================== */
.upcoming-row {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
}
.upcoming-row:last-child { border-bottom: 0; }
.upcoming-row:hover { background: var(--paper); }

.upcoming-when { display: flex; flex-direction: column; }
.upcoming-days {
    font-family: var(--font-data);
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
}
.upcoming-time {
    font-family: var(--font-data);
    font-size: 10.5px;
    color: var(--ink-2);
}
.upcoming-what { display: flex; flex-direction: column; min-width: 0; }
.upcoming-what strong { font-size: 13px; font-weight: 600; }
.upcoming-what span {
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Totals row */
.data-table tfoot td {
    padding: 10px var(--gutter);
    border-top: 1px solid var(--rule-strong);
    background: var(--surface-sunk);
    font-size: 13px;
}
.data-table tfoot .strong { font-weight: 600; }

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--gutter);
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-lg);
    padding: var(--pad);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-content h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

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

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* ==========================================================================
   UTILITIES
   ========================================================================== */
.text-muted { color: var(--ink-2); }
.text-success { color: var(--good); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }

.empty-state {
    padding: 36px var(--gutter);
    text-align: center;
    color: var(--ink-3);
}
.empty-state p { font-size: 13px; }

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--rule-strong);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    max-width: 380px;
    white-space: pre-line;
    z-index: 2000;
    animation: slideIn 0.2s ease-out;
}

.toast-success { border-left: 3px solid var(--good); }
.toast-error { border-left: 3px solid var(--danger); }

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

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
    .navbar {
        position: static;
        width: 100%;
        flex-direction: column;
    }
    .nav-brand { min-height: 0; padding: 10px var(--gutter); }
    #brand-logo { max-height: 44px; }
    .nav-user {
        margin-top: 0;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .nav-colophon { display: none; }
    .nav-user .btn-small { width: auto; }
    .tabs {
        flex-direction: row;
        overflow-x: auto;
        border-top: 1px solid rgba(255, 255, 255, 0.10);
    }
    .tab-btn {
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
    }
    .tab-btn.active { border-left: none; border-bottom-color: var(--paper); }

    .container { margin-left: 0; padding: var(--gutter); }
    .form-card { position: static; max-height: none; }

    /* Tables become records. Never horizontal scroll. */
    .data-table, .data-table thead, .data-table tbody, .data-table tfoot,
    .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table thead { display: none; }
    .data-table tfoot td[colspan]:empty { display: none; }
    .data-table tbody tr {
        border: 1px solid var(--rule);
        border-radius: var(--radius-lg);
        margin-bottom: 10px;
        padding: 4px 0;
        background: var(--surface);
    }
    .data-table tbody td {
        border-bottom: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        padding: 5px var(--gutter);
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-family: var(--font-data);
        font-size: 10px;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--ink-2);
        flex: none;
    }
    .data-table td.num { text-align: right; }
    .table-actions { justify-content: flex-start; }
}

@media (max-width: 560px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Buy Here Pay Here (Financing)
   ========================================================================== */
.quote-box {
    background: var(--surface-sunk, #f6f7f9);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin: 4px 0 16px;
    font-size: 13px;
    line-height: 1.7;
}
.quote-box .quote-headline {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.quote-box .quote-detail { color: var(--ink-2); }

.loan-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.loan-detail-grid .stat-tile { padding: 10px 12px 12px; }

.schedule-table { max-height: 320px; overflow-y: auto; }

.badge-late { background: var(--danger, #d33); color: #fff; }
.badge-default { background: #7a1020; color: #fff; }
.badge-paid_off { background: #1c7d4a; color: #fff; }


/* ==========================================================================
   Notifications
   ========================================================================== */
.notif-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 9px;
    background: var(--danger, #d33);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    vertical-align: middle;
    pointer-events: none;   /* clicks fall through to the tab button, not the badge */
}

.notif-list { display: flex; flex-direction: column; }
.notif-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 4px;
    border-bottom: 1px solid var(--rule);
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--surface-sunk, #f6f7f9); }
.notif-item.unread .notif-title::before {
    content: "";
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--brand, #2563eb);
    margin-right: 8px;
    vertical-align: middle;
}
.notif-icon {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-sunk, #eef1f5);
    font-size: 17px;
}
.notif-main { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: 14px; }
.notif-body { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.notif-time { color: var(--ink-2); font-size: 12px; white-space: nowrap; padding-top: 2px; }
.notif-item .btn-small { align-self: center; }

/* ==========================================================================
   Vehicle cost & profit
   ========================================================================== */
.form-section-head {
    font-family: var(--font-data);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-2);
    border-top: 1px solid var(--rule);
    margin: 20px 0 14px;
    padding-top: 14px;
}
.form-section-head .text-muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

.pnl-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}
.pnl-line {
    display: flex;
    justify-content: space-between;
    padding: 7px 0;
    border-bottom: 1px solid var(--rule);
    font-variant-numeric: tabular-nums;
}
.pnl-line:last-child { border-bottom: none; }
.pnl-line .lbl { color: var(--ink-2); }
.pnl-line.total { font-weight: 600; border-top: 2px solid var(--rule-strong); margin-top: 4px; }
.profit-pos { color: var(--good); font-weight: 600; }
.profit-neg { color: var(--danger); font-weight: 600; }

/* ---- Deal paperwork (loan modal) ---- */
.field-hint { font-size: 12px; color: var(--ink-2); margin-top: 4px; line-height: 1.35; }
.pw-notice {
    background: var(--warn-bg); color: var(--warn); border: 1px solid var(--rule);
    border-radius: var(--radius, 6px); padding: 8px 12px; font-size: 13px; margin-bottom: 12px;
}
.pw-notice a { color: inherit; text-decoration: underline; }
.pw-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 8px; }
.pw-warranty { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin: 0; }
.pw-warranty select { width: auto; }
.pw-list { border-top: 1px solid var(--rule); }
.pw-row { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.pw-info { flex: 1; min-width: 0; }
.pw-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pw-hint { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.pw-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.pw-upload { position: relative; overflow: hidden; cursor: pointer; margin: 0; }
.pw-upload input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.pw-upload.busy { opacity: 0.5; pointer-events: none; }
.pw-file { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.pw-file-meta { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.pw-file-meta a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-file-meta .text-muted { font-size: 11px; }
.pw-thumb {
    width: 64px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--rule-strong);
    background: var(--surface-sunk); cursor: zoom-in; flex-shrink: 0;
}
.pw-pdf {
    width: 64px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    border-radius: 4px; border: 1px solid var(--rule-strong); background: var(--danger-bg); color: var(--danger);
    font-size: 11px; font-weight: 700;
}
@media (max-width: 560px) {
    .pw-row { flex-direction: column; }
    .pw-actions { justify-content: flex-start; }
}

/* Loan money: each payment's split, and rows that no longer count (voided, returned, waived). */
.pay-split { font-size: 11.5px; color: var(--ink-2); font-weight: 400; margin-top: 2px; white-space: normal; }
.data.num .pay-split { text-align: right; }
.pay-not-counted td.data { opacity: 0.6; }

/* Staff logins: owner-only controls are hidden (the server refuses them too). */
body.is-staff .owner-only,
body.is-staff .btn-delete { display: none !important; }

/* History log */
.history-row { display: flex; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.history-when { flex: 0 0 150px; color: var(--ink-2); font-size: 12.5px; }
.history-what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .history-row { flex-direction: column; gap: 2px; } .history-when { flex: none; } }

/* Books */
.books-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.books-controls label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.books-pnl td.num, .books-pnl th.num { text-align: right; white-space: nowrap; }
.books-pnl tr.books-total td { font-weight: 700; border-top: 2px solid var(--rule); }
.books-neg { color: var(--danger, #b42318); }

/* Leads */
.lead-filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.lead-filters button { border: 1px solid var(--rule); background: transparent; padding: 5px 10px; font-size: 13px; cursor: pointer; }
.lead-filters button.active { background: var(--brand); color: var(--brand-on-strong); border-color: transparent; }
.lead-row { cursor: pointer; }
.lead-row:hover td { background: rgba(0,0,0,.025); }
.lead-due { color: var(--danger); font-weight: 600; }
.lead-activity { border-left: 2px solid var(--rule); padding: 6px 0 6px 12px; margin-bottom: 6px; }
.lead-activity .when { font-size: 12px; color: var(--ink-3); }
.badge-lead-new { background: var(--danger-bg); color: var(--danger); }

/* Appointments */
.appt-day { margin: 14px 0 6px; font-weight: 700; }
.appt-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.appt-row.appt-closed { opacity: .55; }
.appt-row.appt-block { color: var(--ink-2); font-style: italic; }
.appt-time { font-weight: 600; }
.hours-row { display: grid; grid-template-columns: 110px 90px 1fr 1fr; gap: 10px; align-items: center; margin-bottom: 6px; }
@media (max-width: 640px) { .appt-row { grid-template-columns: 70px 1fr; } .appt-row .table-actions { grid-column: 1 / -1; } .hours-row { grid-template-columns: 1fr 1fr; } }

/* A checkbox with its words beside it, inside a form group */
.form-group label.check { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-family: var(--font-ui); font-size: 14px; letter-spacing: 0; text-transform: none; color: var(--ink); }
.form-group label.check input { width: auto; margin: 0; }

/* Photos for a car or rental */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo-grid .empty-state { grid-column: 1 / -1; }
.photo-tile { border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-sunk); display: flex; flex-direction: column; }
.photo-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.photo-tile .photo-actions { display: flex; gap: 6px; padding: 6px; align-items: center; background: var(--surface); }
.photo-tile .photo-actions .btn-small { flex: 1; }
.photo-cover { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; flex: 1; text-align: center; }
.photo-strip { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.photo-strip img { width: 72px; height: 54px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--rule); }
