:root {
    --color-primary: #2f6fed;
    --color-primary-hover: #2559c4;
    --color-nav: #0063c1;
    --color-nav-active: #002d79;
    --color-text: #1a2b44;
    --color-text-muted: #576981;
    --color-bg: #f6f8fb;
    --color-surface: #ffffff;
    --color-border: #dfe3ea;
    --color-border-strong: #c9d1dc;
    --color-card-hover: #9bb5e8;
    --color-success: #166534;
    --color-success-bg: #dcfce7;
    --color-warning: #92400e;
    --color-warning-bg: #fef3c7;
    --color-danger: #991b1b;
    --color-danger-bg: #fee2e2;
    --color-info: #1e40af;
    --color-info-bg: #dbeafe;
    --color-neutral: #374151;
    --color-neutral-bg: #e5e7eb;
    --font-sm: .875rem;
    --font-base: 1rem;
    --font-lg: 1.25rem;
    --font-xl: 1.625rem;
    --font-2xl: 2rem;
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --radius-control: 6px;
    --radius-card: 8px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.10);
    --shadow-card-hover: 0 4px 12px rgba(16, 24, 40, 0.12);
    --shadow-menu: 0 4px 12px rgba(0, 0, 0, 0.12);
}
/* All primary actions, including legacy btn-green, use the same blue. */
tr[data-href] { cursor: pointer; }
tr[data-href]:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
/* IBM Plex Sans, self-hosted from /style/fonts (SIL OFL 1.1, see OFL.txt there).
   Bold (700) resolves to the 600 face, so no faux-bold is synthesized. */
@font-face {
    font-family: "IBM Plex Sans";
    src: url("/style/fonts/ibm-plex-sans-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Sans";
    src: url("/style/fonts/ibm-plex-sans-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Sans";
    src: url("/style/fonts/ibm-plex-sans-600.woff2") format("woff2");
    font-weight: 600 700;
    font-style: normal;
    font-display: swap;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-surface);
    color: var(--color-text);
}

button,
input,
select,
textarea {
    font-family: inherit;
}

a {
    color: var(--color-primary);
}

a:not(.btn):not(.btn-outline):hover {
    text-decoration: underline;
}

.app-shell {
    display: flex;
    align-items: flex-start;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #0075dd;
    color: #fff;
    min-height: 100vh;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-divider {
    height: 1px;
    margin: 0.75rem 0.5rem;
    background: rgba(255, 255, 255, 0.35);
}

.sidebar-header {
    padding: 0 1.1rem 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-company {
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.sidebar-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    text-transform: capitalize;
    margin-top: 0.2rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

/* FreshBooks-style nav: rounded rows, the current page as a dark-navy pill. */
.sidebar-nav > a,
.nav-group > summary {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 1px 0.5rem;
    padding: 0.55rem 0.7rem;
    border-radius: 6px;
    color: #fff;
    text-decoration: none;
    font-size: 0.93rem;
    font-weight: 500;
    cursor: pointer;
    list-style: none;
}

.nav-group > summary::-webkit-details-marker {
    display: none;
}

.nav-chevron {
    width: 16px;
    height: 16px;
    margin-left: auto;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.15s ease;
}

.nav-group[open] > summary .nav-chevron {
    transform: rotate(180deg);
}

.nav-sub {
    display: flex;
    flex-direction: column;
    margin: 0.1rem 0 0.3rem;
}

.nav-sub a {
    margin: 1px 0.5rem 1px 2.6rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.85rem;
}

.sidebar-secondary {
    display: flex;
    flex-direction: column;
    padding-bottom: 1rem;
}

.sidebar-secondary a {
    margin: 0 0.5rem;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    color: #fff;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-nav > a:hover,
.nav-group > summary:hover,
.nav-sub a:hover,
.sidebar-secondary a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    text-decoration: none !important;
}

.sidebar-nav > a.active,
.nav-sub a.active,
.sidebar-secondary a.active {
    background: var(--color-nav-active);
    color: #fff;
    font-weight: 600;
}

/* A collapsed group that holds the current page still reads as "you are here". */
.nav-group:not([open]) > summary.has-active {
    background: var(--color-nav-active);
    font-weight: 600;
}

.main-area {
    flex: 1;
    min-width: 0;
    /* Full-bleed strips (.status-banner) paint past the content column; clip them
       at the edge of the main area so they never cover the sidebar. clip (unlike
       hidden) does not create a scroll container, so position:sticky still works. */
    overflow-x: clip;
}

.container {
    max-width: 1040px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 2rem;
}

.container > h1:first-child {
    font-size: 1.6rem;
    font-weight: 600;
    margin: 0 0 1.25rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.create-menu {
    margin-left: auto;
}

/* Doubled-up selector: .btn and .dropdown > summary are declared later in this file
   and would otherwise repaint this button blue-on-blue. */
.create-menu > summary.btn-create {
    display: inline-flex;
    color: #fff;
    align-items: center;
    gap: 0.4rem;
    background: var(--color-primary);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.55rem 1rem;
    list-style: none;
}

.create-menu > summary.btn-create:hover {
    background: var(--color-primary-hover);
}

.create-menu-panel {
    width: 200px;
    padding: 0.4rem;
}

.create-menu-panel a {
    display: block;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.92rem;
}

.create-menu-panel a:hover {
    background: #eef3fd;
    color: #1d4ed8;
    text-decoration: none !important;
}

.sidebar-toggle,
.sidebar-close,
.sidebar-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .app-shell {
        display: block;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        border: none;
        background: #0075dd;
        color: #fff;
        cursor: pointer;
    }

    .sidebar-toggle svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
    }

    .topbar {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .container {
        padding: 1rem 1rem 1.5rem;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 82vw;
        min-height: 100vh;
        height: auto;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 50;
        overflow-y: auto;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 0.6rem;
        right: 0.6rem;
        width: 32px;
        height: 32px;
        border-radius: 6px;
        border: none;
        background: rgba(255, 255, 255, 0.15);
        color: #fff;
        cursor: pointer;
    }

    .sidebar-close svg {
        width: 18px;
        height: 18px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
    }

    .sidebar-backdrop.open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 45;
    }
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: #1d4ed8;
    width: 17px;
    height: 17px;
    cursor: pointer;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

/* One hover for every clickable card: a soft blue edge and a slightly deeper shadow
   (instead of each card type using its own bright blue border). */
a.card:hover, .report-card:hover, .est-card:hover, .attention-card:hover {
    border-color: var(--color-card-hover);
    box-shadow: var(--shadow-card-hover);
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ccd1d9;
    border-radius: var(--radius-control);
    font-size: 1rem;
    color: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.2);
}

:is(.btn, .btn-green, .btn-outline, .btn-danger, .btn-text) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 40px;
    max-width: 100%;
    font-weight: 600;
    line-height: 1.25;
    background: var(--color-primary);
    color: #fff;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    padding: 0.55rem 1.1rem;
    font-size: var(--font-base);
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    background: var(--color-primary-hover);
}

.btn-outline {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-outline:hover {
    background: #f3f4f6;
    color: #1d4ed8;
    border-color: #c7d2fe;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: #fde8e8;
    color: #9b1c1c;
}

.alert-success {
    background: #e6f4ea;
    color: #1e7e34;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.kpi {
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 1rem 1.1rem;
}

.muted {
    color: var(--color-text-muted);
}

/* "Recently added" expense cards - a colored accent bar + dot (both driven by the
   --accent custom property, set inline per-card from a hash of the category name so
   the same category always lands on the same color) plus the existing torn-ticket-stub
   notch effect at the seam between the info block and the amount footer. */
.expense-cards {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.expense-card {
    flex: 0 0 auto;
    width: 150px;
    display: block;
    text-decoration: none;
    color: inherit;
}

.expense-card-top {
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: var(--color-surface);
    overflow: hidden;
}

.expense-card-accent {
    height: 4px;
    background: var(--accent, #9ca3af);
}

.expense-card-content {
    padding: 0.6rem 0.7rem;
}

.expense-card-category {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-card-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent, #9ca3af);
    flex-shrink: 0;
}

.expense-card-vendor {
    font-weight: 600;
    margin: 0.3rem 0 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-card-date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.expense-card-amount {
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 0.5rem 0.7rem;
    text-align: right;
    font-weight: 700;
    background: #f9fafb;
    /* Solid body plus a 6px strip of notches along the bottom edge. A lone
       repeat-x notch layer only covered the top 12px and hid the amount. */
    -webkit-mask:
        linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat,
        radial-gradient(circle at 6px 100%, transparent 5px, #000 5.5px) bottom left / 12px 6px repeat-x;
    mask:
        linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat,
        radial-gradient(circle at 6px 100%, transparent 5px, #000 5.5px) bottom left / 12px 6px repeat-x;
    padding-bottom: calc(0.5rem + 6px);
}

/* A page's primary actions (e.g. a "More Actions" menu + a main CTA), stacked full
   width on a phone and set side by side once there's room. */
.header-actions-stack {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 280px;
    margin: 1rem 0;
}

.header-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    text-align: center;
}

/* Gives a <details class="row-menu"><summary class="header-action-btn"> the same
   bordered-button look as .btn-outline. Scoped past .row-menu > summary's own
   rules (specificity, not source order, is what makes this win). */
.row-menu > summary.header-action-btn {
    padding: 0.65rem 1.2rem;
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    list-style: none;
}

.row-menu > summary.header-action-btn::-webkit-details-marker {
    display: none;
}

.row-menu > summary.header-action-btn:hover {
    background: #f3f4f6;
}

@media (min-width: 641px) {
    .header-actions-stack {
        flex-direction: row;
        max-width: none;
    }

    .header-action-btn {
        width: auto;
    }
}

/* Page toolbar: a caption/description on the left, action buttons on the right. */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.toolbar .toolbar-note {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin: 0;
    flex: 1;
    min-width: 220px;
}

.toolbar .toolbar-actions,
.toolbar-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* A form wrapping a single action button shouldn't force a line break. */
.toolbar-actions form {
    margin: 0;
    display: inline-flex;
}

/* Primary section navigation, rendered as underline tabs. */
.section-tabs {
    display: flex;
    gap: 0.15rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}

.section-tabs a {
    padding: 0.6rem 0.9rem;
    color: #4b5563;
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}

.section-tabs a:hover {
    color: #1d4ed8;
    background: var(--color-bg);
}

.section-tabs a.is-active {
    color: #1d4ed8;
    font-weight: 600;
    border-bottom-color: #1d4ed8;
}

/* On a phone the tabs wrap as pills instead of an underline row: a sideways-
   scrolling strip slid around under the finger while scrolling the page, and an
   underline would sit mid-row once the tabs wrap. */
@media (max-width: 640px) {
    .section-tabs {
        gap: 0.35rem;
        border-bottom: none;
    }

    .section-tabs a {
        padding: 0.4rem 0.8rem;
        border: 1px solid var(--color-border);
        border-radius: 999px;
        margin-bottom: 0;
    }

    .section-tabs a.is-active {
        background: #eef6fc;
        border-color: #bcd6f5;
    }
}

/* Tab bar and page actions sharing one row, both sitting on the tab baseline. */
.section-tabs-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.75rem 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.section-tabs-row .section-tabs {
    margin-bottom: 0;
    flex: 1 1 auto;
}

.section-tabs-row .toolbar-actions {
    padding-bottom: 0.35rem;
}

/* Lightweight pill row for a secondary filter (status, type, ...). */
.subtabs {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.subtabs a {
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    color: #4b5563;
    text-decoration: none;
}

.subtabs a:hover {
    background: #f3f4f6;
}

.subtabs a.is-active {
    background: #e0e7ff;
    color: #1d4ed8;
    font-weight: 600;
}

/* Right-aligned running totals under a table. */
.totals {
    margin-left: auto;
    max-width: 300px;
    margin-top: 0.75rem;
}

.totals .totals-row {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.2rem 0;
    font-size: 0.9rem;
}

.totals .totals-row.is-negative {
    color: var(--color-danger);
}

.totals .totals-row.is-grand {
    border-top: 1px solid var(--color-border);
    margin-top: 0.25rem;
    padding-top: 0.45rem;
    font-weight: 700;
    font-size: 1rem;
}

/* Horizontal progress stepper (job stages, etc). Each step is a real <button> so it
   still submits the enclosing form - only the look changes. Desktop connects the
   dots with a line spanning between each pair; on narrow screens it switches to a
   vertical list (long labels wrapping mid-row is what this replaces). */
.stepper {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.stepper li {
    flex: 1;
    position: relative;
    text-align: center;
}

.stepper button {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0;
    font: inherit;
    position: relative;
    z-index: 1;
}

.stepper .step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: #9ca3af;
    flex-shrink: 0;
}

.stepper .step-label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.stepper li.is-done .step-dot {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
}

.stepper li.is-done .step-label {
    color: #1d4ed8;
}

.stepper li.is-current .step-dot {
    background: #111827;
    border-color: #111827;
    color: #fff;
}

.stepper li.is-current .step-label {
    color: #111827;
    font-weight: 600;
}

.stepper button:hover .step-dot {
    border-color: #1d4ed8;
}

@media (min-width: 641px) {
    .stepper li:not(:first-child)::before {
        content: '';
        position: absolute;
        top: 14px;
        left: -50%;
        width: 100%;
        height: 2px;
        background: #d5d9e0;
        z-index: 0;
    }

    .stepper li.is-done::before,
    .stepper li.is-current::before {
        background: #1d4ed8;
    }

    .stepper .step-label {
        max-width: 100px;
    }
}

@media (max-width: 640px) {
    .stepper {
        display: block;
    }

    .stepper li {
        text-align: left;
        padding-bottom: 1.1rem;
    }

    .stepper li:not(:last-child) {
        position: relative;
    }

    .stepper li:not(:last-child)::before {
        content: '';
        position: absolute;
        left: 13px;
        top: 28px;
        bottom: 0;
        width: 2px;
        background: #d5d9e0;
    }

    .stepper li.is-done:not(:last-child)::before {
        background: #1d4ed8;
    }

    .stepper button {
        flex-direction: row;
        justify-content: flex-start;
        gap: 0.75rem;
    }
}

/* Combined search + advanced-search pill. */
.search-bar {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    max-width: 480px;
    margin-bottom: 1rem;
}

.search-bar-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.4rem 0 1rem;
    min-width: 0;
}

.search-bar-main input[type="text"] {
    border: none;
    outline: none;
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0;
    font-size: 0.9rem;
    background: transparent;
}

.search-bar-main button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0.4rem;
    cursor: pointer;
    color: #9ca3af;
    flex-shrink: 0;
}

.search-bar-main button svg,
.search-bar-main > svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.search-bar-divider {
    width: 1px;
    background: var(--color-neutral-bg);
    margin: 0.5rem 0;
}

.search-bar-advanced {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    height: auto;
    padding: 0 1rem;
    border: none;
    background: none;
    color: #1d4ed8;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.search-bar-advanced svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Wraps .search-bar + its popover so the popover can anchor to it. */
.search-area {
    position: relative;
    margin-bottom: 1rem;
}

.search-bar-advanced-panel {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    width: min(620px, 100%);
    z-index: 30;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.14);
}

/* The little pointer connecting the popover back to the "Advanced Search" trigger. */
.search-bar-advanced-panel::before {
    content: '';
    position: absolute;
    top: -7px;
    right: 28px;
    width: 14px;
    height: 14px;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    border-top: 1px solid var(--color-border);
    transform: rotate(45deg);
}

.adv-search-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.adv-search-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #eef0f3;
}

@media (max-width: 640px) {
    .search-bar-advanced-panel {
        position: static;
        width: auto;
        box-shadow: none;
        margin-top: 0.75rem;
    }

    .search-bar-advanced-panel::before {
        display: none;
    }

    .adv-search-grid {
        grid-template-columns: 1fr;
    }

    .adv-search-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .adv-search-actions > div {
        display: flex;
        gap: 0.5rem;
    }

    .adv-search-actions > div > .btn {
        flex: 1;
    }
}

/* Notebook-style tabs: the active tab's box merges with the white content below it. */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}

.tabs a {
    padding: 0.6rem 1.1rem;
    margin-bottom: -1px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    color: #1d4ed8;
    text-decoration: none;
    font-size: 0.9rem;
}

.tabs a.active {
    border-color: var(--color-border);
    background: var(--color-surface);
    color: #111827;
    font-weight: 600;
}

.kpi .label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.kpi .value {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.report-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.report-card {
    display: block;
    background: var(--color-surface);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--shadow-card);
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--color-border-strong);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}



.report-card-title {
    font-weight: 600;
    color: #1d4ed8;
    margin-bottom: 0.35rem;
}

.report-card-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.report-card-disabled {
    opacity: 0.55;
    cursor: default;
}

.report-card-disabled .report-card-title {
    color: var(--color-text);
}

/* Login/signup/reset screens: brand-tinted backdrop with two soft diagonal bands,
   card centered on top. --brand is set inline per company (falls back to blue). */
.auth-wrapper {
    --brand: #1d4ed8;
    position: relative;
    overflow: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #0b1a3a 0%, var(--brand) 100%);
}

.auth-wrapper::before,
.auth-wrapper::after {
    content: "";
    position: absolute;
    width: 140vmax;
    height: 40vmax;
    background: rgba(255, 255, 255, 0.06);
    transform: rotate(-35deg);
    pointer-events: none;
}

.auth-wrapper::before {
    top: -10vmax;
    left: -50vmax;
}

.auth-wrapper::after {
    bottom: -15vmax;
    right: -55vmax;
    background: rgba(0, 0, 0, 0.12);
}

.portal-topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
}

.portal-topbar-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.portal-brand img {
    max-height: 40px;
    max-width: 160px;
    display: block;
}

.portal-brand strong {
    font-size: 1.1rem;
    color: #111827;
}

.portal-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.portal-nav a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.3rem 0;
    border-bottom: 2px solid transparent;
}

.portal-nav a.active {
    color: #1d4ed8;
    font-weight: 600;
    border-bottom-color: #1d4ed8;
}

.portal-welcome {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin: -0.75rem 0 1rem;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    margin-bottom: 0;
    padding: 2.5rem 2.5rem 2rem;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.auth-logo {
    display: block;
    max-width: 220px;
    max-height: 80px;
    margin: 0 auto 1.5rem;
}

.auth-card h1 {
    text-align: center;
    font-size: 1.6rem;
    margin: 0 0 1.5rem;
    text-wrap: balance;
}

.auth-card h1 + p {
    text-align: center;
    color: var(--color-text-muted);
}

/* "Signed in as" chip on the password step: initial, email, and a Change link. */
.auth-account {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.9rem 0.55rem 0.55rem;
    margin: -0.5rem 0 1.5rem;
    background: #f4f6fa;
    border: 1px solid #e2e6ec;
    border-radius: 999px;
}

.auth-account-avatar {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
}

.auth-account-email {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.auth-account-change {
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.auth-card .form-group input {
    padding: 0.8rem 0.9rem;
    border-radius: 8px;
}

.auth-card form .btn {
    display: block;
    width: 100%;
    padding: 0.85rem 1.2rem;
    margin-top: 1.5rem;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
}

.auth-card form + p,
.auth-card > p:last-child {
    text-align: center;
    margin: 1.5rem 0 0;
    font-size: 0.95rem;
}

.auth-secure {
    position: relative;
    z-index: 1;
    margin-top: 1.5rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
}

@media (max-width: 480px) {
    .auth-card {
        padding: 2rem 1.25rem 1.5rem;
    }
}

/* Wraps any password <input> with a Show/Hide toggle - the JS (in footer.ejs and
   auth-footer.ejs) is one delegated click listener shared by every password field
   in the app, so adding the toggle anywhere is just this markup, no extra script. */
.password-field {
    position: relative;
}

.password-field input {
    padding-right: 3.4rem;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem 0.3rem;
}

.password-toggle:hover {
    text-decoration: underline;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}

th,
td {
    padding: 0.7rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid #eef0f3;
    font-size: 0.9rem;
    white-space: nowrap;
}

th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--color-text-muted);
    background: #f9fafb;
    border-bottom: 1px solid var(--color-border);
}

/* A sortable column header: looks like plain header text, not a hyperlink, until
   hovered - the whole label is the click target, same underline/color-change cue
   as any other link in the app so it still reads as interactive. */
.sortable-th {
    color: inherit;
    text-decoration: none;
}

.sortable-th:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

tbody tr:hover {
    background: #f9fafb;
}

tbody tr:has(.row-check:checked) {
    background: #eff6ff;
}

tfoot td {
    border-bottom: none;
    border-top: 2px solid var(--color-border);
}

/* Hover-reveal modifier for .row-menu: hidden until the row is hovered or its
   checkbox is selected, so the table reads clean at rest. Always visible on
   touch/narrow screens, where hover doesn't apply. Opt-in via an extra class
   so existing always-visible .row-menu usage (Invoices, Estimates) is unaffected. */
.row-menu.hover-reveal {
    opacity: 0;
    transition: opacity 0.15s ease;
}

tbody tr:hover .row-menu.hover-reveal,
tbody tr:has(.row-check:checked) .row-menu.hover-reveal {
    opacity: 1;
}

@media (max-width: 640px) {
    .row-menu.hover-reveal {
        opacity: 1;
    }
}

/* Card view for tables on narrow screens - each row becomes a stacked card
   using the data-label attribute already present on every <td> in the templates. */
@media (max-width: 640px) {
    .table-wrap table {
        min-width: 0;
    }

    .table-wrap thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .table-wrap table,
    .table-wrap tbody,
    .table-wrap tfoot,
    .table-wrap tr,
    .table-wrap td {
        display: block;
        width: 100%;
    }

    .table-wrap tbody tr,
    .table-wrap tfoot tr {
        border: 1px solid #eef0f3;
        border-radius: 8px;
        margin-bottom: 0.75rem;
        padding: 0.25rem 0.75rem;
    }

    .table-wrap tbody tr:hover {
        background: none;
    }

    .table-wrap td {
        border-bottom: 1px solid #f4f5f7;
        white-space: normal;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        text-align: right;
    }

    .table-wrap tr td:last-child {
        border-bottom: none;
    }

    .table-wrap td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        color: var(--color-text-muted);
        text-align: left;
        margin-right: auto;
    }

    .table-wrap td:not([data-label]),
    .table-wrap td[data-label=""] {
        justify-content: flex-end;
    }

    /* Opt-in: drop a column entirely on narrow screens instead of stacking it into
       the card - for a field that's secondary enough to skip on a phone (e.g. a
       free-text internal note) rather than add another row to every card. */
    .table-wrap .hide-mobile {
        display: none !important;
    }
}

/* Inverse of .hide-mobile: content that only makes sense as a mobile-only fallback
   (e.g. folding a column that got hidden into a note under the one next to it). */
@media (min-width: 641px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Bank transactions table: descriptions from Plaid (long Zelle memos, etc.) would
   otherwise force the whole table wider than the viewport because of the global
   `white-space: nowrap`. Let text wrap here and pin sensible column widths so the
   table always fits its card on desktop. The 640px card-view rules above still win
   on narrow screens (higher specificity via .table-wrap). */
@media (min-width: 641px) {
    .txn-table {
        table-layout: fixed;
        min-width: 0;
    }

    .txn-table th,
    .txn-table td {
        white-space: normal;
        overflow-wrap: anywhere;
        vertical-align: top;
    }

    /* Widths keyed to explicit column classes rather than nth-child position - the
       checkbox column only renders on the Unmatched tab, which would otherwise shift
       every nth-child width onto the wrong column (this broke once already: Account
       forced into the old Amount column's nowrap width, overlapping its neighbors). */
    .txn-table .col-check { width: 2rem; }
    .txn-table .col-date { width: 6.5rem; }
    .txn-table .col-account { width: 9rem; }
    .txn-table .col-amount { width: 6rem; white-space: nowrap; }
    .txn-table .col-actions { width: 7.5rem; }
    /* Action links ("Restore to Unmatched") break between words, never mid-word. */
    .txn-table td.col-actions { overflow-wrap: normal; }
    /* .col-desc is intentionally left without a fixed width - table-layout:fixed
       gives it whatever space the other, explicitly-sized columns don't use. */
}

/* Clients list: fixed column widths so "Internal Note" doesn't drift away from the
   name column when there's little content to naturally size against (table-layout:
   auto would stretch whichever column has the least content to fill leftover
   space). Desktop only - the 640px card-view rules above own mobile. */
@media (min-width: 641px) {
    .clients-table {
        table-layout: fixed;
    }

    /* All percentages, summing to exactly 100% - mixing rem and % here (as an
       earlier version did) made the columns add up to slightly over 100% of the
       table's own width, which is what actually forced .table-wrap's horizontal
       scrollbar to appear, not any single column being genuinely too wide. */
    .clients-table .col-check { width: 5%; }
    .clients-table .col-name { width: 43%; }
    .clients-table .col-note { width: 27%; }
    .clients-table .col-amount { width: 15%; }
    .clients-table .col-actions { width: 10%; }
}

/* Clients list on a phone: a compact single-line row (checkbox, name + contact,
   amount) instead of the generic stacked label:value card every other table gets -
   there are only 2-3 fields left once Internal Note/Actions are hidden, so stacking
   them across several lines would waste space the reference layout doesn't. The
   name/amount cells use data-label="" precisely so the generic ::before label
   prefix (which only fires for a non-empty data-label) never renders here. */
@media (max-width: 640px) {
    /* !important throughout: this is fighting .table-wrap's own card-view rules
       (also !important-free but numerous), and a real phone showed the base rules
       still winning despite this block appearing later in the file with what should
       be higher specificity - forcing every property removes any doubt. */
    .clients-table tbody tr {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 0.75rem !important;
        justify-content: flex-start !important;
    }

    .clients-table tbody td {
        display: block !important;
        border-top: none !important;
        border-bottom: none !important;
        padding: 0 !important;
        width: auto !important;
        white-space: normal !important;
        justify-content: flex-start !important;
        text-align: left !important;
    }

    .clients-table .col-check {
        flex: 0 0 auto !important;
    }

    .clients-table .col-name {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        text-align: left !important;
    }

    .clients-table .col-amount {
        flex: 0 0 auto !important;
        text-align: right !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
    }
}

/* Generic "let this table wrap" opt-in: undoes the global `white-space: nowrap`
   so long cell content (Stripe reference ids, payer names, payout methods) wraps
   instead of pushing the table past its card. No fixed column widths - the browser
   sizes columns to content. The 640px card-view rules still apply via .table-wrap. */
@media (min-width: 641px) {
    .wrap-table th,
    .wrap-table td {
        white-space: normal;
        vertical-align: top;
    }

    /* Category names, vendor names, rule text etc. wrap at their own natural spaces/
       slashes like normal text - never arbitrarily mid-word. Forcing overflow-wrap:
       anywhere on every cell (the previous default here) broke short words that had
       nowhere sensible to wrap ("RECEIPT" -> "RECEIP"/"T", "Shipping" -> "Shippi"/"ng")
       whenever a column got squeezed a little narrow. Genuinely unbreakable long
       tokens (a Stripe reference id with no spaces at all) opt in with .wrap-anywhere
       instead of forcing this on every table that shares this class. */
    .wrap-table .col-date,
    .wrap-table .col-amount {
        white-space: nowrap;
    }
}

.wrap-anywhere {
    overflow-wrap: anywhere;
}

.link-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    padding: 0;
    margin-left: 0.75rem;
    font-size: 0.9rem;
    text-decoration: underline;
}

.row-menu {
    position: relative;
    display: inline-block;
}

.row-menu > summary {
    list-style: none;
    cursor: pointer;
    color: var(--color-primary);
    padding: 0.15rem 0.4rem;
}

.row-menu > summary::-webkit-details-marker {
    display: none;
}

.row-menu .menu-panel {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: var(--shadow-menu);
    min-width: 170px;
    max-height: min(440px, 80vh);
    overflow-y: auto;
    z-index: 60;
    padding: 0.25rem 0;
}

/* Once JS repositions an open panel with position:fixed (see footer script), it
   escapes any scrolling ancestor (e.g. .table-wrap) that would otherwise clip it. */
.row-menu .menu-panel.js-positioned {
    position: fixed;
    top: auto;
    right: auto;
}

.row-menu .menu-panel a,
.row-menu .menu-panel button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    color: #111827;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
}

.row-menu .menu-panel svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: #6b7280;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.row-menu .menu-panel .danger svg {
    stroke: #b91c1c;
}

.row-menu .menu-panel a:hover,
.row-menu .menu-panel button:hover {
    background: #f3f4f6;
}

.row-menu .menu-panel .danger {
    color: #b91c1c;
}

/* Generalized floating dropdown - same positioning/border/shadow treatment as
   .row-menu/.menu-panel, but without that pattern's forced full-width single-line
   link/button rows, so it can hold richer content: grouped sections, headings, a
   small inline form. Shares the footer script's outside-click-close and
   viewport-edge repositioning (both listen for '.dropdown' alongside '.row-menu'). */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown > summary {
    list-style: none;
    cursor: pointer;
    color: var(--color-primary);
    padding: 0.15rem 0.4rem;
}

.dropdown > summary::-webkit-details-marker {
    display: none;
}

.dropdown-panel {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: var(--shadow-menu);
    width: 300px;
    max-width: min(300px, calc(100vw - 2rem));
    max-height: min(420px, 80vh);
    overflow-y: auto;
    z-index: 60;
    padding: 0.85rem;
}

.dropdown-panel.js-positioned {
    position: fixed;
    top: auto;
    right: auto;
    margin-top: 0;
}

.dropdown-panel .dropdown-section + .dropdown-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f0f1f3;
}

.dropdown-panel .dropdown-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 0 0 0.4rem;
}

.dropdown-panel .dropdown-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.dropdown-panel .dropdown-form-row {
    display: flex;
    gap: 0.4rem;
}

.dropdown-panel .dropdown-form-row input {
    min-width: 0;
}

.dropdown-panel .dropdown-form-row input[name="vendor"],
.dropdown-panel .dropdown-form-row input[name="source"] {
    flex: 1;
}

.dropdown-panel .link-row {
    display: block;
    font-size: 0.85rem;
    padding: 0.3rem 0;
}

/* Split-transaction form (bank-connections/split.ejs): one category+amount+remove
   row per line, stacking on narrow screens like the rest of the app's forms. */
.split-line {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.split-line input[name="category_name"] {
    flex: 1;
    min-width: 0;
}

.split-line input.split-amount {
    width: 110px;
}

@media (max-width: 640px) {
    .split-line {
        flex-wrap: wrap;
    }

    .split-line input[name="category_name"] {
        flex-basis: 100%;
    }

    .split-line input.split-amount {
        flex: 1;
    }
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    background: var(--color-neutral-bg);
    color: var(--color-text);
}

.badge-draft {
    background: var(--color-neutral-bg);
    color: var(--color-text);
}

.badge-sent {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-partial {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.badge-paid {
    background: #d1fae5;
    color: #065f46;
}

.badge-overdue {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-void {
    background: var(--color-neutral-bg);
    color: var(--color-text-muted);
}

.badge-unpaid {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

/* "Recently Updated" card strip on list pages (Invoices). */
.recent-strip {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.recent-card {
    flex: 0 0 160px;
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    padding: 0.85rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recent-card-number {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.recent-card-client {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-card-date {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.recent-card-amount {
    font-weight: 700;
    font-size: 1rem;
    text-align: right;
    border-top: 1px solid #f4f5f7;
    padding-top: 0.5rem;
}

.recent-card-status {
    text-align: center;
    border-radius: 6px;
    padding: 0.3rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
}

/* Live document preview pane, shown beside the Invoice/Estimate form. */
.form-with-preview {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.form-with-preview > .form-col {
    flex: 1 1 420px;
    min-width: 320px;
}

.form-with-preview > .preview-col {
    flex: 1 1 360px;
    min-width: 300px;
    position: sticky;
    top: 1rem;
}

.doc-preview {
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    font-size: 0.8rem;
}

.doc-preview-header {
    border-top: 5px solid #1d4ed8;
    padding: 1rem 1rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.doc-preview-header img {
    max-width: 100px;
    max-height: 50px;
}

.doc-preview-company {
    text-align: right;
    color: var(--color-text);
    line-height: 1.4;
    font-size: 0.75rem;
    min-width: 0;
    overflow-wrap: break-word;
}

.doc-preview-title {
    padding: 0 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.doc-preview-meta {
    padding: 0.75rem 1rem 1rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--color-text-muted);
}

.doc-preview-meta strong {
    display: block;
    color: #111827;
    font-weight: 600;
    overflow-wrap: break-word;
}

.doc-preview-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    margin: 0;
    table-layout: fixed;
}

.doc-preview-table col.col-desc { width: 44%; }
.doc-preview-table col.col-qty { width: 16%; }
.doc-preview-table col.col-rate { width: 20%; }
.doc-preview-table col.col-total { width: 20%; }

.doc-preview-table th {
    text-align: left;
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 0.5rem 0.4rem;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    background: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-preview-table th:first-child,
.doc-preview-table td:first-child {
    padding-left: 1rem;
}

.doc-preview-table th:last-child,
.doc-preview-table td:last-child {
    padding-right: 1rem;
}

.doc-preview-table th.num,
.doc-preview-table td.num {
    text-align: right;
}

.doc-preview-table td {
    padding: 0.5rem 0.4rem;
    border-bottom: 1px solid #f4f5f7;
    font-size: 0.75rem;
    overflow-wrap: break-word;
}

.doc-preview-detail {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.68rem;
}

.doc-preview-empty {
    color: #9ca3af;
    text-align: center;
    padding: 1rem;
}

.doc-preview-totals {
    padding: 0.75rem 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.doc-preview-totals-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    max-width: 220px;
    font-size: 0.8rem;
}

.doc-preview-totals-row.total {
    font-weight: 700;
    font-size: 0.85rem;
    border-top: 1px solid var(--color-border);
    padding-top: 0.35rem;
    margin-top: 0.15rem;
}

.doc-preview-notes {
    padding: 0 1rem 1.25rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    white-space: pre-line;
}

@media (max-width: 900px) {
    .form-with-preview > .preview-col {
        position: static;
    }
}

@media print {
    .sidebar,
    .btn,
    form {
        display: none !important;
    }

    .app-shell {
        display: block;
    }
}

/* Phones: Create New collapses to just its + icon so search keeps the room. */
@media (max-width: 480px) {
    .btn-create-label {
        display: none;
    }

    .create-menu > summary.btn-create {
        padding: 0.55rem 0.7rem;
    }
}

/* ---- Dashboard ----
   FreshBooks-style: section title + link sit above each card, big colored totals
   on the right, everything stacks to one column on phones. */
.page-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 0.9rem;
    margin-bottom: 1.25rem;
}

.page-head h1 {
    font-size: var(--font-xl);
    font-weight: 600;
    margin: 0;
}

.dash-kpis {
    margin-bottom: 1rem;
}

.notice-warning {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid #f5e3a3;
    border-left: 4px solid #f1b308;
    border-radius: 8px;
    background: #fffbea;
    color: #6b4e05;
    font-size: 0.92rem;
}

.dash-section {
    margin-bottom: 1.75rem;
}

.dash-section .card {
    margin-bottom: 0;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-bottom: 0.6rem;
}

.section-head h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: #001b40;
}

.section-head > a {
    font-size: 0.85rem;
    text-decoration: none;
}

.section-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.2rem 0.75rem;
}

.section-period {
    font-size: 0.8rem;
    color: #7f8c9f;
}

.section-period a {
    text-decoration: none;
    padding: 0 0.2rem;
    font-weight: 600;
}

.dash-empty {
    margin: 0.25rem 0;
}

.dash-totals {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    margin-bottom: 0.75rem;
}

.dash-total {
    text-align: right;
}

.dash-total-value {
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.15;
    color: #0063c1;
}

.dash-total-label {
    font-size: 0.78rem;
    color: #7f8c9f;
}

.dash-hint {
    font-size: 0.82rem;
    max-width: 240px;
    margin: 0.3rem 0 0;
}

/* Invoice aging: stacked overdue/outstanding bar + bucket list. */
.aging {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem 2rem;
}

.aging-main {
    flex: 1;
    min-width: 240px;
}

.dash-total-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.aging-bar {
    flex: 1;
    display: flex;
    height: 16px;
    border-radius: 8px;
    overflow: hidden;
    background: #eef0f3;
}

.legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.6rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.legend i,
.pie-legend i {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 0.4rem;
}

.aging-buckets {
    min-width: 200px;
    margin: 0;
    padding-left: 1.5rem;
    border-left: 1px solid #eef0f3;
    font-size: 0.85rem;
}

.aging-buckets div {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.3rem 0;
}

.aging-buckets dt {
    color: var(--color-text-muted);
}

.aging-buckets dd {
    margin: 0;
    font-weight: 600;
}

/* P&L chart scrolls sideways on phones rather than shrinking its labels to nothing. */
.chart-scroll {
    overflow-x: auto;
}

.pl-chart {
    display: block;
    width: 100%;
    min-width: 520px;
    height: auto;
}

.pl-chart .axis-label {
    font-size: 9.5px;
    fill: #7f8c9f;
    font-family: inherit;
}

/* Pie widgets (Revenue by Client / Spending): pie | legend | total, full width. */
.pie-widget {
    display: grid;
    grid-template-columns: 190px 1fr auto;
    grid-template-areas: "pie legend total";
    align-items: center;
    gap: 1rem 2rem;
}

.pie {
    grid-area: pie;
    align-self: start;
    width: 190px;
    height: 190px;
}

.pie-legend-wrap {
    grid-area: legend;
    min-width: 0;
}

.pie-total {
    grid-area: total;
    align-self: start;
}

.pie-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.95rem;
}

.pie-legend li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    min-width: 0;
}

.pie-legend li i {
    flex-shrink: 0;
    margin-right: 0.15rem;
}

.pie-legend li a {
    color: var(--color-nav);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pie-amount {
    color: var(--color-text-muted);
    white-space: nowrap;
}

.pie-more > summary {
    display: inline-block;
    margin: 0.3rem 0 0 1.1rem;
    color: var(--color-nav);
    font-size: 0.92rem;
    cursor: pointer;
    list-style: none;
}

.pie-more > summary::-webkit-details-marker {
    display: none;
}

.pie-more > summary:hover {
    text-decoration: underline;
}

.pie-more .when-open,
.pie-more[open] .when-closed {
    display: none;
}

.pie-more[open] .when-open {
    display: inline;
}

/* Open list sits above the toggle so "Show Less" ends up at the bottom. */
.pie-more[open] {
    display: flex;
    flex-direction: column-reverse;
}

.pie-more[open] > summary {
    align-self: flex-start;
}

@media (max-width: 640px) {
    /* Keep each section's link on the title row; the period drops below the title. */
    .section-head {
        flex-wrap: nowrap;
        align-items: flex-start;
    }

    .section-title {
        flex-direction: column;
        gap: 0.1rem;
    }

    .section-head > a {
        flex-shrink: 0;
        padding-top: 0.15rem;
    }

    .aging-buckets {
        padding-left: 0;
        border-left: none;
        width: 100%;
    }

    .dash-total-value {
        font-size: 1.35rem;
    }

    .pl-chart .axis-label {
        font-size: 13px;
    }

    .pie-widget {
        grid-template-columns: 1fr;
        grid-template-areas: "total" "pie" "legend";
        justify-items: center;
    }

    .pie-widget .pie-total {
        justify-self: end;
    }

    .pie-legend-wrap {
        width: 100%;
    }

    .pie {
        width: 170px;
        height: 170px;
    }
}

/* ---- List pages (Items & Services; reusable) ----
   Title + action buttons row, a centered Items/Services switch, search, an
   All/Archived filter, a selection bar for bulk actions, and a pager. */
.page-head-actions {
    justify-content: space-between;
    align-items: center;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-actions .row-menu > summary.header-action-btn {
    padding: 0.55rem 1rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: #001b40;
    border-color: #001b40;
}

.create-menu.create-menu-inline {
    margin-left: 0;
}

.menu-rich {
    width: 280px;
}

.menu-rich a strong {
    display: block;
    font-weight: 600;
}

.menu-rich a span {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.35;
    margin-top: 0.1rem;
}

.menu-rich a + a {
    border-top: 1px solid #eef0f3;
}

.btn-danger {
    background: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
}

.segmented-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.25rem 0 1.25rem;
}

.segmented-wrap::before,
.segmented-wrap::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e6e9ee;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border: 1px solid #b3bbc6;
    border-radius: 999px;
    background: var(--color-surface);
}

.segmented a {
    padding: 0.4rem 1.1rem;
    border-radius: 999px;
    color: #001b40;
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
}

.segmented a.active {
    background: #0075dd;
    color: #fff;
}

.segmented a:not(.active):hover {
    background: #eef6fc;
    text-decoration: none !important;
}

.list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.list-title {
    font-weight: 600;
    color: #001b40;
}

.list-title a {
    text-decoration: none;
}

.list-search {
    position: relative;
    width: 100%;
    max-width: 320px;
}

.list-search .nav-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: #7f8c9f;
    pointer-events: none;
}

.list-search input {
    width: 100%;
    padding: 0.55rem 0.75rem 0.55rem 2.3rem;
    border: 1px solid #b3bbc6;
    border-radius: 6px;
    font-size: 0.92rem;
}

.list-search input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.2);
}

.filter-bar {
    display: flex;
    gap: 0.25rem;
    padding: 0.35rem;
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.filter-bar a {
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    color: var(--color-text);
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none;
}

.filter-bar a.active {
    background: #eef6fc;
    color: var(--color-nav);
}

.list-note {
    font-size: 0.88rem;
    margin: -0.25rem 0 0.75rem;
}

.empty-state {
    text-align: center;
    padding: 2rem 1.25rem;
}

.empty-state .btn {
    margin: 0.25rem;
}

/* Selection bar: "N Selected  Edit  Archive  Delete  Duplicate  More" as icon links. */
.bulk-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem 1.1rem;
    padding: 0.5rem 0.9rem;
    margin-bottom: 0.75rem;
    border-radius: 6px;
    background: #eef6fc;
    font-size: 0.9rem;
}

.bulk-bar[hidden] {
    display: none;
}

.bulk-count {
    color: #001b40;
    margin-right: 0.25rem;
}

.bulk-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.1rem;
    border: none;
    background: none;
    color: var(--color-nav);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.bulk-link::-webkit-details-marker {
    display: none;
}

.bulk-link svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bulk-link:hover {
    color: #001b40;
}

/* .dropdown > summary is declared later with its own color/padding. */
.bulk-more > summary.bulk-link {
    color: var(--color-nav);
    padding: 0.3rem 0.1rem;
}

.bulk-more-panel {
    width: 260px;
    padding: 0.4rem;
}

.bulk-more-section {
    padding: 0.4rem;
}

.bulk-more-section + .bulk-more-section {
    border-top: 1px solid #eef0f3;
}

.bulk-more-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
    margin-bottom: 0.3rem;
}

.bulk-more-section > button {
    display: block;
    width: 100%;
    padding: 0.45rem 0.5rem;
    border: none;
    border-radius: 6px;
    background: none;
    text-align: left;
    font: inherit;
    color: var(--color-text);
    cursor: pointer;
}

.bulk-more-section > button:hover {
    background: #eef6fc;
    color: var(--color-nav);
}

.bulk-more-row {
    display: flex;
    gap: 0.4rem;
}

.bulk-more-row select {
    flex: 1;
    min-width: 0;
    padding: 0.35rem;
    border: 1px solid #ccd1d9;
    border-radius: 6px;
    font: inherit;
    font-size: 0.85rem;
}

.bulk-edit-table input,
.bulk-edit-table select {
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 1px solid #ccd1d9;
    border-radius: 6px;
    font: inherit;
    font-size: 0.9rem;
    color: inherit;
}

.bulk-edit-table input:focus,
.bulk-edit-table select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.2);
}

.bulk-edit-table td {
    white-space: normal;
}

.bulk-edit-table .be-name { width: 32%; }
.bulk-edit-table .be-desc { width: 32%; }
.bulk-edit-table .be-rate { width: 14%; }
.bulk-edit-table .be-tax { width: 22%; }

@media (max-width: 640px) {
    .table-wrap .bulk-edit-table tbody tr {
        display: block;
    }

    .table-wrap .bulk-edit-table td {
        display: block;
        text-align: left;
        border-top: none !important;
        padding: 0.35rem 0;
    }

    .table-wrap .bulk-edit-table td[data-label]:not([data-label=""])::before {
        display: block;
        margin-bottom: 0.2rem;
    }
}

.items-table {
    table-layout: fixed;
}

.items-table th {
    background: none;
    border-bottom: 2px solid var(--color-text-muted);
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text);
}

.items-table .col-check {
    width: 2.5rem;
}

.items-table .col-amount {
    text-align: right;
}

.items-table td.col-name,
.items-table td.col-desc {
    overflow: hidden;
    text-overflow: ellipsis;
}

.items-table .col-name a {
    color: var(--color-text);
    text-decoration: none;
}

.items-table .col-name a:hover {
    color: var(--color-nav);
}

.sort-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.sort-link:hover {
    color: var(--color-nav);
}

.sort-arrow {
    font-size: 0.65rem;
    color: #b3bbc6;
}

.sort-link.is-active {
    font-weight: 600;
}

.sort-link.is-active .sort-arrow {
    color: var(--color-text);
}

.list-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.pager {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pager a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 6px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 1.05rem;
}

.pager a:hover {
    background: #eef6fc;
    text-decoration: none !important;
}

.pager a.is-disabled {
    color: #ccd1d9;
    pointer-events: none;
}

.pager-range {
    padding: 0 0.5rem;
    font-size: 0.88rem;
    color: var(--color-text-muted);
}

.pager-range strong {
    color: var(--color-text);
}

/* Forms that sit in a single card (item/service, import). */
.form-card {
    max-width: 560px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.check-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500 !important;
}

.form-group .check-label input[type="checkbox"] {
    width: 17px;
    padding: 0;
    flex-shrink: 0;
}

.field-hint {
    font-size: 0.82rem;
    margin: 0.35rem 0 0;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.form-danger-zone {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #eef0f3;
}

.danger-link {
    color: #dc2626 !important;
}

.import-columns {
    padding-left: 1.2rem;
    font-size: 0.9rem;
    line-height: 1.7;
}

.import-errors {
    font-size: 0.85rem;
    color: var(--color-warning);
}

@media (max-width: 640px) {
    .page-actions {
        width: 100%;
    }

    .page-actions > details {
        flex: 1;
    }

    .page-actions .row-menu > summary.header-action-btn,
    .page-actions .create-menu > summary.btn-create {
        width: 100%;
        justify-content: center;
    }

    .list-search {
        max-width: none;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    /* Item cards: checkbox + name share the top line, details stack underneath. */
    .table-wrap .items-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }

    .table-wrap .items-table td.col-check {
        width: auto;
        border-bottom: none;
        padding-right: 0;
    }

    .table-wrap .items-table td.col-name {
        flex: 1;
        width: auto;
        min-width: 0;
        justify-content: flex-start;
        border-bottom: none;
        font-weight: 600;
    }

    .table-wrap .items-table td.col-name a {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-wrap .items-table td:not(.col-check):not(.col-name) {
        border-top: 1px solid #f4f5f7;
        border-bottom: none;
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }

    .list-footer {
        justify-content: center;
    }
}

/* Phones: the label shrinks away in the topbar Create New, but on a page's own
   action row there's room, so keep it. */
@media (max-width: 480px) {
    .page-actions .create-menu .btn-create-label {
        display: inline;
    }
}

/* ---- Clients list (FreshBooks style) ---- */
.page-head-ruled {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.btn-green {
    background: var(--color-primary);
    font-weight: 600;
}

.btn-green:hover {
    background: var(--color-primary-hover);
}

/* Big centered figures without cards (overdue / outstanding / draft). */
.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1.75rem 0 2rem;
    text-align: center;
}

.stat-value {
    font-size: 2.1rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--color-nav);
}

.stat-label {
    margin-top: 0.3rem;
    color: var(--color-text-muted);
    font-size: 0.92rem;
}

.list-toolbar-tight {
    margin: 0.75rem 0;
}

.list-heading {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #001b40;
}

.list-toolbar .search-bar {
    margin-bottom: 0;
    flex: 1;
    max-width: 440px;
}

.clients-table .col-actions {
    text-align: right;
}

.th-sub {
    font-weight: 400;
    color: var(--color-text-muted);
}

.name-stack {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.name-stack a {
    color: var(--color-text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
}

.name-stack a:hover {
    color: var(--color-nav);
}

.name-stack .muted {
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.currency-code {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.table-total {
    padding: 1rem 0.6rem;
    background: #f1f3f6;
    border-bottom: 1px solid var(--color-border);
    text-align: right;
    font-size: 0.95rem;
}

.table-total strong {
    margin-left: 0.4rem;
}

.list-footer-3 {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
}

.footer-center {
    text-align: center;
}

.footer-sub {
    margin-top: 0.3rem;
    font-size: 0.82rem;
}

.per-page {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    font-size: 0.88rem;
}

.per-page select {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--color-text-muted);
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
}

@media (max-width: 640px) {
    .stat-row {
        grid-template-columns: 1fr;
        gap: 1.1rem;
        margin: 1.25rem 0 1.5rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .list-toolbar .search-bar {
        max-width: none;
        width: 100%;
    }

    .list-footer-3 {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 1rem;
    }

    .per-page {
        justify-content: center;
    }

    .table-total {
        border-radius: 8px;
    }
}

/* ---- Time Tracking (FreshBooks style: Day / Week / Month / All) ---- */
.segmented-tight {
    margin: -0.25rem 0 1rem;
}

.segmented-tight .segmented a {
    min-width: 5.5rem;
    text-align: center;
}

.te-timer-running {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid #b7e3c4;
    border-radius: 8px;
    background: #effaf2;
    color: #14532d;
}

.te-timer-running form {
    margin: 0;
}

.te-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: te-pulse 1.4s ease-in-out infinite;
}

@keyframes te-pulse {
    50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
    .te-pulse { animation: none; }
}

.te-clock {
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
}

.te-nav-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.te-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.te-nav > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 6px;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    line-height: 1;
    text-decoration: none;
}

.te-nav > a:hover {
    background: #eef6fc;
    text-decoration: none !important;
}

.te-nav-label {
    font-size: 1.1rem;
    color: #001b40;
    margin: 0 0.25rem;
}

/* Calendar icon with the real date input stretched invisibly over it. */
.te-cal {
    position: relative;
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    color: var(--color-text-muted);
}

.te-cal:hover {
    background: #eef6fc;
}

.te-cal svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
}

.te-cal input {
    position: absolute;
    inset: 0;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

.te-cal input::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.te-user {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 230px;
}

.te-user label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.te-user select {
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--color-text-muted);
    border-radius: 6px;
    font: inherit;
    font-size: 0.92rem;
}

.te-today {
    display: inline-block;
    min-width: 1.5rem;
    padding: 0 0.3rem;
    border-radius: 4px;
    background: #0075dd;
    color: #fff;
    font-weight: 600;
    text-align: center;
}

/* Day view: week strip */
.te-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr) 1.3fr;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #f1f3f6;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.te-strip-day {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.55rem 0.75rem;
    border-right: 1px solid var(--color-border);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.92rem;
}

.te-strip-day:hover {
    background: #e6ebf2;
    text-decoration: none !important;
}

.te-strip-day.is-selected {
    background: #ccd3dd;
}

.te-strip-total {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 1rem;
    color: var(--color-text);
}

/* Entry list (Day, the Month view's selected day, All) */
.te-head,
.te-link {
    display: grid;
    grid-template-columns: minmax(150px, 28%) 1fr auto;
    gap: 1rem;
    align-items: center;
}

.te-head {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #ccd1d9;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.te-head > span:last-child {
    text-align: right;
}

.te-head-check {
    grid-template-columns: 2rem minmax(150px, 28%) 1fr auto;
}

.te-add-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.te-new {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem;
    border: 2px dashed #ccd1d9;
    border-radius: 6px;
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;
}

.te-new:hover {
    border-color: #0075dd;
    color: var(--color-nav);
    text-decoration: none !important;
}

.te-new svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
}

.te-timer-btn svg {
    width: 14px;
    height: 14px;
    fill: #576981;
}

.te-timer-form {
    margin: 0;
}

.te-timer-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    height: 100%;
    padding: 0.55rem 1.4rem;
    border: 2px solid #ccd1d9;
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.te-timer-btn:hover {
    border-color: #0075dd;
}

.te-row {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
    border-left: 3px solid #b3bbc6;
}

.te-row:has(.te-check) {
    grid-template-columns: 2rem 1fr;
}

.te-row:hover {
    background: #f7f9fb;
}

.te-check {
    display: flex;
    justify-content: center;
    padding-left: 0.5rem;
}

.te-link {
    padding: 0.7rem 0.75rem;
    color: var(--color-text);
    text-decoration: none;
}

.te-link:hover {
    text-decoration: none !important;
}

.te-who,
.te-what,
.te-time {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-size: 0.9rem;
}

.te-who .muted,
.te-what .muted {
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.te-time {
    align-items: flex-end;
    gap: 0.2rem;
}

.te-badge {
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    background: var(--color-border);
    color: #334966;
    font-size: 0.72rem;
    font-weight: 600;
}

.te-badge.is-billable {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.te-badge.is-invoiced {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.te-total-bar {
    padding: 1rem 0.75rem;
    margin-bottom: 1.5rem;
    background: #f1f3f6;
    border-bottom: 1px solid var(--color-border);
    text-align: right;
}

.te-empty {
    padding: 1rem 0.75rem;
    margin: 0;
}

/* Week view grid: scrolls sideways on phones instead of becoming cards. */
.te-week-scroll {
    overflow-x: auto;
    margin-bottom: 0.25rem;
}

.te-week {
    table-layout: fixed;
    min-width: 620px;
}

.te-week th {
    background: #f1f3f6;
    text-align: center;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.88rem;
    color: var(--color-text);
}

.te-week th a {
    color: inherit;
    text-decoration: none;
}

.te-week td {
    text-align: center;
}

.te-week .te-week-label {
    width: 28%;
    text-align: left;
    white-space: normal;
}

.te-week tfoot td {
    background: #f1f3f6;
}

/* Month view calendar */
.te-month {
    border: 1px solid #ccd1d9;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.te-month-head,
.te-month-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr) 1.2fr;
}

.te-month-head span {
    padding: 0.55rem 0.5rem;
    background: #f1f3f6;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
    border-bottom: 1px solid #ccd1d9;
}

.te-month-head .te-month-total-col {
    text-align: right;
}

.te-month-day {
    position: relative;
    min-height: 84px;
    border-right: 1px solid #ccd1d9;
    border-bottom: 1px solid #ccd1d9;
}

.te-month-day.is-out {
    background: #f1f3f6;
}

.te-month-hit {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    min-height: 84px;
    padding: 0.35rem 0.4rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.85rem;
}

.te-month-hit:hover {
    background: #f7f9fb;
    text-decoration: none !important;
}

.te-month-day.is-selected {
    outline: 2px solid #0075dd;
    outline-offset: -2px;
}

.te-month-hours {
    align-self: flex-end;
    font-weight: 600;
}

.te-month-num {
    align-self: flex-start;
}

.te-month-add {
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    display: none;
    width: 1.6rem;
    height: 1.6rem;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccd1d9;
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;
}

.te-month-day:hover .te-month-add,
.te-month-day.is-selected .te-month-add {
    display: flex;
}

.te-month-weektotal {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    background: #f1f3f6;
    border-bottom: 1px solid #ccd1d9;
    font-size: 0.85rem;
}

.te-month .te-total-bar {
    margin: 0;
    border-bottom: none;
}

.te-day-title {
    font-size: 1.05rem;
    font-weight: 500;
    color: #001b40;
    margin: 0 0 0.5rem;
}

/* All view: team members + time per client */
.te-summary {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 320px;
    border: 1px solid #ccd1d9;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.75rem;
}

.te-members {
    border-right: 1px solid #ccd1d9;
    padding: 0.5rem 0;
}

.te-member {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.88rem;
}

.te-member > span:last-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.te-member .muted {
    font-size: 0.78rem;
}

.te-member-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.te-member:hover {
    background: #f7f9fb;
    text-decoration: none !important;
}

.te-member.is-active {
    background: #e2f0fb;
}

.te-avatar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    background: #ccd1d9;
    color: #fff;
}

.te-avatar svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
}

.te-avatar-letter {
    background: #0075dd;
    font-weight: 600;
}

.te-avatar-add {
    background: var(--color-surface);
    border: 1px dashed var(--color-text-muted);
    color: var(--color-text-muted);
    font-size: 1.2rem;
}

.te-chart {
    padding: 0.75rem 1.25rem 1.25rem;
}

.te-chart-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding-bottom: 0.6rem;
    margin: 0 -1.25rem 1rem;
    border-bottom: 1px solid #e6e9ee;
}

.te-chart-nav a {
    font-size: 1.4rem;
    color: #576981;
    text-decoration: none;
}

.te-chart-who {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.te-chart-who .muted {
    font-size: 0.85rem;
}

.te-chart-empty {
    margin: 2rem 0;
}

.te-bars {
    list-style: none;
    margin: 0;
    padding: 0;
}

.te-bars li {
    margin-bottom: 0.85rem;
}

.te-bar-label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.te-bar {
    display: block;
    height: 18px;
    border-radius: 9px;
}

@media (max-width: 760px) {
    .te-summary {
        grid-template-columns: 1fr;
    }

    .te-members {
        display: flex;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid #ccd1d9;
        padding: 0.25rem;
    }

    .te-member {
        flex-shrink: 0;
        border-radius: 8px;
    }
}

@media (max-width: 640px) {
    .segmented-tight .segmented a {
        min-width: 0;
        padding: 0.4rem 0.85rem;
    }

    .segmented-tight::before,
    .segmented-tight::after {
        display: none;
    }

    .segmented-tight {
        justify-content: center;
    }

    .te-nav-row {
        flex-direction: column;
        align-items: stretch;
    }

    .te-user {
        min-width: 0;
    }

    /* Week strip: seven compact days, total on its own line. */
    .te-strip {
        grid-template-columns: repeat(7, 1fr);
    }

    .te-strip-total {
        grid-column: 1 / -1;
        justify-content: center;
        padding: 0.5rem;
        border-top: 1px solid var(--color-border);
    }

    .te-strip-day {
        padding: 0.4rem 0.25rem;
        font-size: 0.72rem;
        align-items: center;
        text-align: center;
    }

    .te-head {
        display: none;
    }

    .te-link {
        grid-template-columns: 1fr auto;
        grid-template-areas: "what time" "who time";
        gap: 0.2rem 0.75rem;
    }

    .te-what { grid-area: what; }
    .te-who { grid-area: who; flex-direction: row; gap: 0.5rem; }
    .te-time { grid-area: time; }

    .te-add-row {
        flex-direction: column;
    }

    .te-timer-btn {
        width: 100%;
        justify-content: center;
    }

    /* Month calendar: compact cells, weekly totals drop to their own row. */
    .te-month-head,
    .te-month-week {
        grid-template-columns: repeat(7, 1fr);
    }

    .te-month-head .te-month-total-col {
        display: none;
    }

    .te-month-head span {
        padding: 0.4rem 0.2rem;
        text-align: center;
        font-size: 0.75rem;
    }

    .te-month-day,
    .te-month-hit {
        min-height: 54px;
    }

    .te-month-hit {
        padding: 0.25rem;
        font-size: 0.75rem;
    }

    .te-month-hours {
        font-size: 0.68rem;
    }

    .te-month-add {
        display: none !important;
    }

    .te-month-weektotal {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: space-between;
        padding: 0.3rem 0.6rem;
    }
}

/* ---- Top bar icons: search, notifications, help, account (FreshBooks style) ---- */
.topbar-icons {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}

.topbar .create-menu {
    margin-left: 0.5rem;
}

.topbar-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border: none;
    border-radius: 999px;
    background: none;
    color: #334966;
    cursor: pointer;
    list-style: none;
}

.topbar-icon::-webkit-details-marker {
    display: none;
}

.topbar-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topbar-icon:hover,
.topbar-menu[open] > .topbar-icon,
.topbar-icon.active {
    background: #eef6fc;
    color: #0063c1;
}

/* .dropdown > summary is declared later with its own color/padding. */
.topbar-menu > summary.topbar-icon {
    padding: 0;
    color: #334966;
}

.topbar-menu[open] > summary.topbar-icon {
    color: #0063c1;
}

.topbar-badge {
    position: absolute;
    top: 0.15rem;
    right: 0.1rem;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.25rem;
    border: 2px solid var(--color-surface);
    border-radius: 999px;
    background: #df2f4a;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 0.85rem;
    text-align: center;
}

.topbar-badge[hidden] {
    display: none;
}

.topbar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    margin-left: 0.2rem;
    border-radius: 999px;
    background: var(--color-nav-active);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    list-style: none;
}

.topbar-menu > summary.topbar-avatar {
    padding: 0;
    color: #fff;
}

.topbar-avatar::-webkit-details-marker {
    display: none;
}

.topbar-menu[open] > .topbar-avatar {
    box-shadow: 0 0 0 3px #b8d8f6;
}

.topbar-avatar-lg {
    width: 2.4rem;
    height: 2.4rem;
    margin: 0;
    cursor: default;
}

/* Notifications panel */
.notif-panel {
    width: 360px;
    max-width: calc(100vw - 1.5rem);
    max-height: min(480px, 75vh);
    padding: 0;
}

.notif-empty {
    margin: 0;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.notif-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.notif-item.is-unread {
    background: #eef6fc;
}

.notif-avatar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    border: 2px solid #9fd8cf;
    border-radius: 50%;
    background: var(--color-surface);
    color: #001b40;
    font-size: 0.8rem;
    font-weight: 600;
}

.notif-payment .notif-avatar { border-color: #ff94a4; }
.notif-estimate .notif-avatar { border-color: #ae8ee0; }
.notif-bill_due .notif-avatar,
.notif-bill_overdue .notif-avatar { border-color: #f9c78e; }

.notif-body {
    min-width: 0;
}

.notif-text {
    margin: 0 0 0.3rem;
    font-size: 0.86rem;
    line-height: 1.35;
    color: var(--color-text);
}

.notif-meta {
    margin: 0;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.notif-meta a {
    text-decoration: none;
}

/* Account panel */
.account-panel {
    width: 260px;
    padding: 0.4rem;
}

.account-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.5rem 0.75rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid var(--color-border);
}

.account-head > span:last-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.account-head strong {
    font-size: 0.9rem;
    text-transform: uppercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-head .muted {
    font-size: 0.78rem;
    text-transform: capitalize;
}

.account-panel > a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.6rem;
    border-radius: 6px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.92rem;
}

.account-panel > a:hover {
    background: #eef6fc;
    color: var(--color-nav);
    text-decoration: none !important;
}

.account-panel > a svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.account-panel .account-logout {
    margin-top: 0.3rem;
    border-top: 1px solid var(--color-border);
    border-radius: 0 0 6px 6px;
}

/* Search dialog */
.search-dialog {
    width: min(580px, calc(100vw - 1.5rem));
    max-height: min(560px, 80vh);
    margin: 10vh auto auto;
    padding: 0;
    border: 1px solid #ccd1d9;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 27, 64, 0.25);
    color: inherit;
}

.search-dialog::backdrop {
    background: rgba(0, 27, 64, 0.45);
}

.search-dialog-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem;
    border-bottom: 1px solid #ccd1d9;
}

.search-dialog-bar svg {
    position: absolute;
    left: 1.3rem;
    width: 20px;
    height: 20px;
    stroke: #576981;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    pointer-events: none;
}

.search-dialog-bar input {
    flex: 1;
    min-width: 0;
    padding: 0.7rem 0.75rem 0.7rem 2.6rem;
    border: none;
    border-radius: 6px;
    background: #eef0f3;
    font: inherit;
    font-size: 1rem;
}

.search-dialog-bar input:focus {
    outline: 2px solid #0075dd;
    background: #fff;
}

.search-dialog-cancel {
    padding: 0.5rem 0.6rem;
    border: none;
    background: none;
    color: #334966;
    font: inherit;
    cursor: pointer;
}

.search-dialog-body {
    max-height: calc(min(560px, 80vh) - 4.5rem);
    overflow-y: auto;
    padding-bottom: 0.5rem;
}

.search-dialog-all {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-bottom: 1px solid #e6e9ee;
    background: #eef6fc;
    color: #0063c1;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.search-dialog-all[hidden] {
    display: none;
}

.search-dialog-label {
    padding: 0.75rem 1rem 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #576981;
}

.search-dialog-pages a {
    display: block;
    padding: 0.6rem 1rem;
    color: #1a2b44;
    text-decoration: none;
}

.search-dialog-pages a:hover,
.search-dialog-pages a:focus {
    background: #eef6fc;
    color: #0063c1;
    outline: none;
    text-decoration: none !important;
}

.search-dialog-pages a[hidden] {
    display: none;
}

.search-dialog-none {
    padding: 0.5rem 1rem;
    margin: 0;
    color: #576981;
}

/* Support page */
.support-hero {
    position: relative;
    overflow: hidden;
    margin: 1.25rem 0 2rem;
    padding: 2.5rem 1.5rem;
    border-radius: 8px;
    background: #fff8e6;
    text-align: center;
}

.support-hero-body {
    position: relative;
    z-index: 1;
    max-width: 440px;
    margin: 0 auto;
}

.support-hero h2 {
    margin: 0 0 0.6rem;
    font-size: 1.9rem;
    color: #001b40;
}

.support-hero p {
    margin: 0 0 1.25rem;
    color: #334966;
}

.support-shape {
    position: absolute;
    pointer-events: none;
}

.support-shape-a {
    left: 0;
    bottom: 0;
    width: 180px;
    height: 120px;
    border-top-right-radius: 120px;
    background: var(--color-nav-active);
}

.support-shape-b {
    right: 0;
    top: 0;
    width: 180px;
    height: 160px;
    border-bottom-left-radius: 160px;
    background: #ffc414;
}

.support-shape-c {
    right: 0;
    bottom: 0;
    width: 180px;
    height: 70px;
    background: #0075dd;
}

.support-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.support-intro p {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #001b40;
}

.support-bubble {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border: 2px solid #001b40;
    border-radius: 50% 50% 50% 8px;
    background: #ffc414;
    color: #001b40;
    font-size: 1.4rem;
    font-weight: 700;
}

.support-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.support-card {
    padding: 1.25rem 1rem;
    border: 1px solid #ccd1d9;
    border-radius: 8px;
    box-shadow: 3px 3px 0 rgba(0, 27, 64, 0.08);
    text-align: center;
}

.support-card h3 {
    margin: 0 0 0.6rem;
    font-size: 1.02rem;
}

.support-card h3 a {
    color: var(--color-nav);
    text-decoration: none;
}

.support-card p {
    margin: 0 0 0.75rem;
    font-size: 0.88rem;
    color: #334966;
}

.support-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

@media (max-width: 640px) {
    .topbar-icons {
        gap: 0;
    }

    .topbar-icon {
        width: 2.2rem;
        height: 2.2rem;
    }

    .search-dialog {
        margin-top: 0.75rem;
    }

    /* Bell / account menus span the screen instead of hanging off its left edge. */
    .topbar-menu .dropdown-panel,
    .topbar-menu .dropdown-panel.js-positioned {
        left: 0.75rem !important;
        right: 0.75rem !important;
        width: auto;
        max-width: none;
    }

    .support-shape {
        opacity: 0.35;
    }

    .support-hero h2 {
        font-size: 1.5rem;
    }
}

/* ---- Estimates and Proposals list ---- */
.split-btn {
    display: inline-flex;
    align-items: stretch;
}

.split-btn-main {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    font-size: 1rem;
    padding: 0.6rem 1.1rem;
}

.split-btn-more > summary.btn {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 0.75rem;
    border-left: 1px solid rgba(255, 255, 255, 0.45);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    color: #fff;
    list-style: none;
}

.split-btn-more > summary::-webkit-details-marker {
    display: none;
}

.create-estimate-panel {
    width: 320px;
}

.create-from-recent {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.7rem 0.3rem;
    border-top: 1px solid #eef0f3;
    font-size: 0.85rem;
}

.create-from-recent form {
    margin: 0;
}

.create-from-recent button {
    width: 100%;
    padding: 0.35rem 0;
    border: none;
    background: none;
    color: var(--color-nav);
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.create-from-recent button:hover {
    text-decoration: underline;
}

.section-title-lg {
    margin: 1.5rem 0 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #001b40;
}

.est-recent {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.est-card {
    display: flex;
    flex-direction: column;
    min-height: 210px;
    border: 1px solid #ccd1d9;
    border-radius: 6px;
    box-shadow: 0 0 0 3px #eef0f3;
    overflow: hidden;
    color: var(--color-text);
    text-decoration: none;
}

.est-card:hover {
    text-decoration: none !important;
}

.est-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.9rem 0.9rem 0;
    font-size: 0.85rem;
    min-width: 0;
}

.est-card-body strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.est-card-amount {
    margin: 0 0.9rem;
    padding: 0.45rem 0;
    border-top: 1px solid var(--color-border);
    text-align: right;
    font-size: 1rem;
}

.est-card-status {
    padding: 0.5rem;
    text-align: center;
    font-weight: 500;
    background: #eef0f3;
}

.est-card-status.is-sent,
.est-card-status.is-viewed,
.est-badge.is-sent,
.est-badge.is-viewed {
    background: #fdecb5;
    color: #5c4300;
}

.est-card-status.is-accepted,
.est-badge.is-accepted {
    background: #b9e4c2;
    color: #14532d;
}

.est-card-status.is-declined,
.est-badge.is-declined {
    background: #fbd0d6;
    color: #7f1d1d;
}

.est-card-status.is-invoiced,
.est-badge.is-invoiced {
    background: #ccd1d9;
    color: var(--color-text);
}

.est-badge {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.05rem 0.45rem;
    border-radius: 4px;
    background: #eef0f3;
    color: #334966;
    font-size: 0.8rem;
    font-weight: 600;
}

.amount-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.est-table .est-col-client { width: 30%; }
.est-table .est-col-desc { width: 30%; overflow: hidden; text-overflow: ellipsis; }
.est-table .est-col-date { width: 16%; }

/* Advanced Search panel (FreshBooks: grey box under the search bar) */
.adv-panel {
    margin: 0 0 1rem;
    padding: 1rem 1rem 0.75rem;
    border: 1px solid #ccd1d9;
    border-radius: 6px;
    background: #f1f3f6;
}

.adv-panel[hidden] {
    display: none;
}

.adv-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 1rem;
}

.adv-grid .form-group label {
    font-weight: 500;
    font-size: 0.85rem;
}

.adv-range,
.adv-keyword {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.adv-range input {
    min-width: 0;
}

.adv-keyword input {
    flex: 1.4;
    min-width: 0;
}

.adv-keyword select {
    flex: 1;
    min-width: 0;
}

.adv-custom-dates {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.adv-custom-dates[hidden] {
    display: none;
}

.adv-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.25rem;
}

.adv-actions > div {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 1100px) {
    .est-recent {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .est-recent {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding: 3px;
    }

    .est-card {
        flex: 0 0 150px;
        min-height: 170px;
        scroll-snap-align: start;
    }

    .adv-grid {
        grid-template-columns: 1fr;
    }

    .split-btn {
        width: 100%;
    }

    .split-btn-main {
        flex: 1;
        text-align: center;
    }

    .table-wrap .items-table td.col-name {
        text-align: left;
    }

    .table-wrap .est-table td.col-amount {
        width: 100%;
    }
}

/* ---- Estimate / Proposal editor: the document is the form ---- */
.doc-editor-head .page-actions {
    align-items: center;
}

.doc-cancel {
    margin-right: 0.5rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-decoration: none;
}

.doc-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 1.5rem;
    align-items: start;
}

.doc-page {
    --doc-color: #1a5fb4;
    padding: 3rem 3rem 2.5rem;
    border: 1px solid #ccd1d9;
    border-radius: 10px;
    background: var(--color-surface);
    box-shadow: 0 2px 10px rgba(0, 27, 64, 0.06);
    color: var(--color-text);
}

.doc-page.font-modern { font-family: "IBM Plex Sans", "Segoe UI", Arial, sans-serif; }
.doc-page.font-classic { font-family: Georgia, "Times New Roman", serif; }
.doc-page.font-friendly { font-family: "Trebuchet MS", "Segoe UI", sans-serif; }

.doc-page input,
.doc-page select,
.doc-page textarea {
    font: inherit;
    color: inherit;
}

.doc-top {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 2.75rem;
}

.doc-logo img {
    max-width: 220px;
    max-height: 120px;
    display: block;
}

.doc-logo-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 180px;
    height: 90px;
    border: 2px dashed #ccd1d9;
    border-radius: 6px;
    color: var(--color-text-muted);
    text-decoration: none;
}

.doc-company {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-style: normal;
    font-size: 0.88rem;
    line-height: 1.45;
    text-align: right;
}

.doc-company strong {
    font-weight: 500;
    text-transform: uppercase;
}

.doc-meta {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 1.25rem 1.5rem;
    margin-bottom: 2.5rem;
}

.doc-field label {
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.85rem;
    color: var(--doc-color);
}

.doc-field-client {
    grid-row: span 2;
}

/* Inline inputs read as document text until hovered/focused. */
.doc-page .doc-field input,
.doc-page .doc-field select,
.doc-line input,
.doc-line select,
.doc-totals select,
.doc-totals input {
    width: 100%;
    padding: 0.3rem 0.35rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: var(--color-bg);
    font-size: 0.92rem;
}

.doc-page .doc-field input:hover,
.doc-page .doc-field select:hover,
.doc-line input:hover,
.doc-line select:hover {
    border-color: #ccd1d9;
}

.doc-page input:focus,
.doc-page select:focus,
.doc-page textarea:focus {
    outline: none;
    border-color: var(--doc-color);
    background: var(--color-surface);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--doc-color) 20%, transparent);
}

.doc-static {
    display: block;
    padding: 0.3rem 0.35rem;
    font-size: 0.92rem;
}

.doc-client-address {
    display: block;
    margin-top: 0.35rem;
    padding: 0 0.35rem;
    font-size: 0.85rem;
    white-space: pre-line;
    color: #334966;
}

.doc-pricing h2 {
    margin: 0;
    padding-bottom: 0.35rem;
    border-bottom: 3px solid var(--doc-color);
    color: var(--doc-color);
    font-size: 1.15rem;
    font-weight: 500;
}

.doc-lines-head,
.doc-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 6rem 4rem 6rem 1.6rem;
    gap: 0.5rem;
    align-items: start;
}

.doc-lines-head {
    padding: 0.55rem 0 0.4rem;
    color: var(--doc-color);
    font-size: 0.85rem;
}

.doc-lines-head .num,
.doc-line .num {
    text-align: right;
}

.doc-line {
    padding: 0.45rem 0;
    border-bottom: 1px solid #eef0f3;
}

.doc-line-desc {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.doc-line-sub {
    display: flex;
    gap: 0.35rem;
}

.doc-line .doc-detail {
    flex: 1;
    min-width: 0;
    font-size: 0.82rem !important;
    color: var(--color-text-muted) !important;
}

.doc-line .doc-tax {
    width: auto !important;
    max-width: 45%;
    font-size: 0.82rem !important;
    color: var(--color-text-muted) !important;
}

.doc-line-total {
    padding-top: 0.35rem;
    font-size: 0.92rem;
}

.doc-remove {
    margin-top: 0.15rem;
    border: none;
    background: none;
    color: #b3bbc6;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.doc-remove:hover {
    color: #dc2626;
}

.doc-add-line {
    margin: 0.6rem 0 0;
    padding: 0.45rem 0.75rem;
    border: 1px dashed #ccd1d9;
    border-radius: 6px;
    background: none;
    color: var(--doc-color);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.doc-totals {
    width: min(360px, 100%);
    margin: 1.75rem 0 0 auto;
    font-size: 0.92rem;
}

.doc-totals > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.55rem 0;
}

.doc-discount > span:first-child {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.doc-totals select {
    width: auto !important;
}

.doc-totals input {
    width: 5rem !important;
}

.doc-grand {
    margin-top: 0.25rem;
    border-top: 3px double #ccd1d9;
    color: var(--doc-color);
}

.doc-grand strong {
    color: var(--color-text);
    font-size: 1.05rem;
}

.doc-notes {
    margin-top: 2rem;
}

.doc-notes label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--doc-color);
    font-size: 0.9rem;
}

.doc-notes textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    resize: vertical;
}

.doc-signature {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    width: 260px;
    margin-top: 3.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.doc-signature[hidden] {
    display: none;
}

.doc-signature-line {
    height: 1px;
    margin-bottom: 0.3rem;
    background: #b3bbc6;
}

.doc-attachments h2 {
    margin: 1.5rem 0 0.6rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #001b40;
}

.doc-attach-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: #e6e9ee;
}

.doc-attach-tile,
.doc-attach-add {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    width: 170px;
    min-height: 110px;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.82rem;
    text-align: center;
}

.doc-attach-tile {
    background: var(--color-surface);
    border: 1px solid #ccd1d9;
}

.doc-attach-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.doc-attach-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    color: #b91c1c;
    cursor: pointer;
}

.doc-attach-add {
    position: relative;
    border: 2px dashed #b3bbc6;
    color: #334966;
    font-weight: 600;
    cursor: pointer;
}

.doc-attach-add[hidden] {
    display: none;
}

.doc-attach-add .muted {
    font-weight: 400;
    font-size: 0.72rem;
}

.doc-attach-add input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.doc-attach-new {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
    font-size: 0.85rem;
}

/* Right-hand panels */
.doc-editor-side {
    position: sticky;
    top: 4.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.doc-side-panel {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.doc-side-panel h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #001b40;
}

.doc-side-group {
    margin-bottom: 1rem;
}

.doc-side-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: #334966;
}

.doc-side-group select {
    width: 100%;
    padding: 0.55rem;
    border: 1px solid var(--color-text-muted);
    border-radius: 6px;
    font: inherit;
}

.doc-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.doc-swatch {
    position: relative;
    cursor: pointer;
}

.doc-swatch input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.doc-swatch > span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 6px;
    background: var(--swatch);
    color: #fff;
    font-weight: 700;
}

.doc-swatch input:checked + span {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #001b40;
}

.doc-swatch input:checked + span::after {
    content: "✓";
}

.doc-swatch input:focus-visible + span {
    outline: 2px solid #0075dd;
    outline-offset: 3px;
}

.doc-swatch-custom > span {
    background: conic-gradient(#f43f5e, #f59e0b, #22c55e, #06b6d4, #6366f1, #d946ef, #f43f5e);
}

.doc-swatch-custom input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.doc-side-note {
    margin: 0;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.doc-side-check {
    align-items: flex-start !important;
    font-size: 0.88rem;
    line-height: 1.4;
}

.doc-side-check input {
    margin-top: 0.2rem;
}

@media (max-width: 980px) {
    .doc-editor {
        grid-template-columns: 1fr;
    }

    .doc-editor-side {
        position: static;
        order: -1;
    }
}

@media (max-width: 640px) {
    .doc-page {
        padding: 1.25rem 1rem 1.5rem;
    }

    .doc-top {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .doc-company {
        align-items: flex-start;
        text-align: left;
    }

    .doc-meta {
        grid-template-columns: 1fr 1fr;
    }

    .doc-field-client {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .doc-lines-head {
        display: none;
    }

    /* Each line becomes a small stacked block: description, then rate/qty/tax/total. */
    .doc-line {
        grid-template-columns: 1fr 4rem 5rem 1.6rem;
        grid-template-areas:
            "desc desc desc remove"
            "rate qty total .";
    }

    .doc-line-desc { grid-area: desc; }
    .doc-line [name="unit_price[]"] { grid-area: rate; }
    .doc-line [name="quantity[]"] { grid-area: qty; }
    .doc-line .doc-line-total { grid-area: total; }
    .doc-line .doc-remove { grid-area: remove; }

    .doc-line-sub {
        flex-direction: column;
    }

    .doc-line .doc-tax {
        max-width: none;
    }

    .doc-editor-head .page-actions {
        flex-wrap: wrap;
    }
}

/* ---- Client-facing estimate / proposal page ---- */
.public-doc-body {
    background: #f1f3f6;
}

.public-doc {
    max-width: 880px;
    padding-top: 1.25rem;
}

.public-doc-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.doc-lines-ro {
    grid-template-columns: minmax(0, 1fr) 7rem 4.5rem 7.5rem;
}

.doc-ro-detail {
    font-size: 0.82rem;
}

.doc-ro-text {
    margin: 0;
    white-space: pre-line;
    font-size: 0.92rem;
}

.doc-signed-name {
    font-family: "Brush Script MT", "Segoe Script", cursive;
    font-size: 1.6rem;
    color: var(--color-text);
}

.public-doc .doc-attach-tile {
    color: var(--color-text);
    text-decoration: none;
}

.public-doc .doc-attach-tile:hover {
    border-color: #0075dd;
}

.public-accept {
    margin-top: 1.5rem;
}

.public-accept h2 {
    margin-top: 0;
}

.signature-input {
    font-family: "Brush Script MT", "Segoe Script", cursive !important;
    font-size: 1.4rem !important;
}

.fine-print {
    font-size: 0.82rem;
}

.public-accept-btn {
    background: var(--doc-color);
    font-weight: 600;
}

.public-accept-btn:hover {
    background: var(--doc-color);
    filter: brightness(0.9);
}

.public-decline {
    margin-top: 1.25rem;
}

.public-decline summary {
    cursor: pointer;
    color: var(--color-text-muted);
}

.public-status {
    margin-top: 1.5rem;
}

.public-status.is-accepted {
    background: var(--color-success-bg);
    color: #14532d;
}

.public-status.is-declined {
    background: var(--color-danger-bg);
    color: #7f1d1d;
}

.public-doc-foot {
    margin: 1.5rem 0;
    text-align: center;
}

@media (max-width: 640px) {
    .doc-lines-ro {
        grid-template-columns: 1fr 1fr;
        grid-template-areas: none;
    }

    .doc-lines-ro .doc-line-desc {
        grid-column: 1 / -1;
    }

    .doc-lines-ro .num[data-label]::before {
        content: attr(data-label) ": ";
        color: var(--color-text-muted);
        font-size: 0.8rem;
    }
}

@media print {
    .public-doc-body {
        background: var(--color-surface);
    }

    .public-doc-actions,
    .public-accept,
    .public-doc-foot {
        display: none;
    }

    .doc-page {
        border: none;
        box-shadow: none;
        padding: 0;
    }
}

/* ---- Online Payments (FreshBooks style) ----
   Title + Export CSV, a Payout Overview card, then the status pill bar with a
   Filter toggle that opens date/keyword fields, and a plain ruled table. */
.btn-strong {
    font-weight: 600;
    color: #001b40;
    border-color: #001b40;
}

.payout-overview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 1.75rem;
    padding: 1.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    text-align: center;
}

.payout-stat + .payout-stat {
    border-left: 1px solid var(--color-border);
}

.payout-label {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.92rem;
}

.payout-value {
    margin: 0.35rem 0;
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.1;
    color: #001b40;
}

.payout-note {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

a.payout-note {
    color: var(--color-nav);
    text-decoration: none;
}

a.payout-note:hover {
    text-decoration: underline;
}

.list-subheading {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #001b40;
}

.status-filter {
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

/* Only the status links and the Filter label react to clicks - a stray click on
   the bar's empty space shouldn't open the filter panel. */
.status-filter > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem;
    list-style: none;
    pointer-events: none;
}

.status-filter > summary::-webkit-details-marker {
    display: none;
}

.status-filter > summary a,
.status-filter .filter-toggle {
    pointer-events: auto;
}

.filter-bar-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.filter-bar-links a {
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    color: var(--color-text);
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none;
}

.filter-bar-links a:hover {
    background: #f3f4f6;
}

.filter-bar-links a.active {
    background: #eef6fc;
    color: var(--color-nav);
}

.filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    color: var(--color-text);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
}

.filter-toggle:hover,
.status-filter[open] .filter-toggle {
    background: #eef6fc;
    color: var(--color-nav);
}

.filter-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.status-filter-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid #eef0f3;
}

.status-filter-panel .form-group {
    margin-bottom: 0;
}

.status-filter-panel .form-group-grow {
    flex: 1;
    min-width: 180px;
}

.status-filter-actions {
    display: flex;
    gap: 0.5rem;
}

.payments-table td {
    vertical-align: middle;
}

.payments-table .col-amount .currency-code {
    margin-left: 0.15rem;
}

.refund-note {
    font-size: 0.78rem;
    color: var(--color-danger);
}

.no-results {
    padding: 2.5rem 1rem;
}

.no-results-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #f1f3f6;
}

.no-results-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #576981;
    stroke-width: 2;
    stroke-linecap: round;
}

.no-results-title {
    margin: 0.75rem 0 0.25rem;
    font-weight: 600;
    color: #001b40;
}

.no-results .muted {
    margin: 0;
}

@media (min-width: 641px) {
    .payments-table .col-date { width: 17%; }
    .payments-table .col-name { width: 22%; }
    .payments-table .col-status { width: 15%; }
    .payments-table .col-fee { width: 13%; }
    .payments-table .col-amount { width: 17%; }
}

/* Phone: each payment is a compact two-line row - client (+ source) and amount on
   top, date and status underneath - instead of the generic label:value card. */
@media (max-width: 640px) {
    .payout-overview {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        padding: 1.25rem 1rem;
    }

    .payout-stat + .payout-stat {
        border-left: none;
        border-top: 1px solid var(--color-border);
        padding-top: 1.25rem;
    }

    .payout-value {
        font-size: 1.7rem;
    }

    .status-filter-panel .form-group,
    .status-filter-actions {
        flex: 1 1 100%;
    }

    .status-filter-actions .btn {
        flex: 1;
        text-align: center;
    }

    .payments-table tbody tr {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "name amount" "date status";
        gap: 0.3rem 0.75rem;
        padding: 0.75rem !important;
    }

    .payments-table tbody td {
        display: block !important;
        padding: 0 !important;
        border: none !important;
        width: auto !important;
        text-align: left !important;
    }

    .payments-table .col-name { grid-area: name; font-weight: 600; }
    .payments-table .col-amount { grid-area: amount; text-align: right !important; font-weight: 600; white-space: nowrap; }
    .payments-table .col-date { grid-area: date; color: var(--color-text-muted); font-size: 0.85rem; }
    .payments-table .col-status { grid-area: status; text-align: right !important; }

    .payments-table .name-stack a {
        font-weight: 400;
    }
}

.list-toolbar > a {
    color: var(--color-nav);
    text-decoration: none;
}

.list-toolbar > a:hover {
    text-decoration: underline;
}

/* ---- Page-level "More Actions" menu (FreshBooks style) ----
   Bigger rows with a 20px icon, an arrow pointing up at the button, and
   .menu-sep lines between groups of actions. Only page header menus - the small
   per-row ••• menus keep the compact look. */
.page-actions .row-menu .menu-panel {
    margin-top: 10px;
    min-width: 230px;
    max-height: none;
    overflow: visible;
    padding: 0.35rem 0;
    border-color: #c5ccd6;
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(0, 27, 64, 0.14);
}

.page-actions .row-menu .menu-panel::before,
.page-actions .row-menu .menu-panel::after {
    content: "";
    position: absolute;
    right: 3.5rem;
    border: 9px solid transparent;
    border-top: none;
}

.page-actions .row-menu .menu-panel::before {
    top: -9px;
    border-bottom-color: #c5ccd6;
}

.page-actions .row-menu .menu-panel::after {
    top: -8px;
    border-bottom-color: #fff;
}

.page-actions .row-menu .menu-panel a,
.page-actions .row-menu .menu-panel button {
    gap: 0.85rem;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    color: var(--color-text);
    white-space: nowrap;
}

.page-actions .row-menu .menu-panel svg {
    width: 20px;
    height: 20px;
    stroke: #1a2b44;
    stroke-width: 1.6;
}

.page-actions .row-menu .menu-panel a:hover,
.page-actions .row-menu .menu-panel button:hover {
    background: #eef6fc;
}

.page-actions .row-menu .menu-panel form {
    margin: 0;
}

.menu-sep {
    height: 0;
    margin: 0.3rem 0;
    border: none;
    border-top: 1px solid var(--color-border);
}

/* ---- Expenses list (FreshBooks style) ---- */
.section-heading {
    margin: 0.5rem 0 0.75rem;
}

.expenses-table .name-stack > * {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.merchant-stack {
    padding-left: 0.6rem;
    border-left: 3px solid var(--accent, #9ca3af);
}

.merchant-stack .expense-card-dot {
    display: inline-block;
    margin-right: 0.35rem;
    vertical-align: middle;
}

.expenses-table .name-stack a.muted {
    color: var(--color-text-muted);
}

.expenses-table .name-stack a.muted:hover {
    color: var(--color-nav);
}

.amount-status {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.amount-status.is-paid {
    color: #12873a;
}

.expenses-table tr.notice-row td {
    padding: 0.7rem 1rem;
    text-align: center;
    background: #fdf3d1;
    color: var(--color-text);
    white-space: normal;
}

.expenses-table tr.notice-row:hover,
.expenses-table tr.add-row:hover {
    background: none;
}

.expenses-table tr.add-row td {
    padding: 0.6rem 0;
    white-space: normal;
}

.quick-add > summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem;
    border: 1.5px dashed #c5ccd6;
    border-radius: 6px;
    color: var(--color-text);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.quick-add > summary::-webkit-details-marker {
    display: none;
}

.quick-add > summary:hover {
    border-color: var(--color-nav);
    color: var(--color-nav);
}

.quick-add > summary svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.quick-add[open] > summary {
    border-style: solid;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.quick-add-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 1rem;
    border: 1.5px solid #c5ccd6;
    border-top: none;
    border-radius: 0 0 6px 6px;
}

.quick-add-form .form-group {
    flex: 1 1 140px;
    margin-bottom: 0;
}

.quick-add-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

@media (min-width: 641px) {
    .expenses-table .col-check { width: 2.5rem; }
    .expenses-table .col-name { width: 24%; }
    .expenses-table .col-date { width: 16%; }
    .expenses-table .col-amount { width: 17%; }
    .expenses-table .col-actions { width: 3.5rem; text-align: right; }
}

/* Phone: checkbox, merchant + category, amount on one line; date underneath. */
@media (max-width: 640px) {
    .expenses-table tbody tr:not(.notice-row):not(.add-row) {
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: "check name amount" "check date date";
        gap: 0.3rem 0.75rem;
        align-items: center;
        padding: 0.75rem !important;
    }

    .expenses-table tbody td {
        display: block !important;
        padding: 0 !important;
        border: none !important;
        width: auto !important;
        text-align: left !important;
    }

    .expenses-table .col-check { grid-area: check; }
    .expenses-table .col-name { grid-area: name; }
    .expenses-table .col-date { grid-area: date; font-size: 0.85rem; }
    .expenses-table .col-date .name-stack { flex-direction: row; gap: 0.75rem; }
    .expenses-table .col-amount { grid-area: amount; text-align: right !important; font-weight: 600; white-space: nowrap; }

    .expenses-table tr.notice-row,
    .expenses-table tr.add-row {
        border: none !important;
        padding: 0 !important;
    }

    .expenses-table tr.notice-row td {
        padding: 0.7rem !important;
        border-radius: 6px;
        text-align: center !important;
    }

    .quick-add-actions {
        flex: 1 1 100%;
        justify-content: space-between;
    }
}

@media (max-width: 640px) {
    .expenses-table tr.notice-row td,
    .expenses-table tr.add-row td {
        width: 100% !important;
    }

    .tabs a {
        padding: 0.55rem 0.7rem;
        white-space: nowrap;
    }
}

/* ---- Settings hub (FreshBooks style) ----
   A narrow centered column of grouped cards, each opening one section page. */
.settings-hub {
    max-width: 640px;
    margin: 0 auto;
}

.settings-hub h1 {
    font-size: 1.6rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: #001b40;
}

.settings-group-title {
    margin: 1.75rem 0 0.75rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #001b40;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid #c5ccd6;
    border-radius: 4px;
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0, 27, 64, 0.06);
}

.settings-item:hover {
    border-color: var(--color-nav);
    box-shadow: 0 2px 6px rgba(0, 27, 64, 0.12);
}

.settings-item-title {
    display: block;
    font-size: 0.95rem;
}

.settings-item-desc {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.settings-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: #576981;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Policy forms at the end of Settings: same frame as the cards above. */
.settings-panel {
    margin-bottom: 0.6rem;
    padding: 1rem;
    border: 1px solid #c5ccd6;
    border-radius: 4px;
    background: var(--color-surface);
    box-shadow: 0 1px 2px rgba(0, 27, 64, 0.06);
}

.settings-panel h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.settings-panel form > label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.settings-panel form > label input {
    margin-top: 0.2rem;
}

.settings-panel textarea,
.settings-panel input[type="date"] {
    width: 100%;
    box-sizing: border-box;
}

.settings-hub .back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    color: var(--color-nav);
    text-decoration: none;
    font-size: 0.92rem;
}

.settings-hub .back-link svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.settings-panel {
    margin-bottom: 1rem;
    padding: 1.25rem;
    border: 1px solid #c5ccd6;
    border-radius: 4px;
    background: var(--color-surface);
}

.settings-panel h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #001b40;
}

.settings-panel .form-group + h2 {
    margin-top: 1.25rem;
}

.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.settings-row-address {
    grid-template-columns: 2fr 1fr 1fr 1fr;
}

.settings-narrow {
    max-width: 220px;
}

.settings-hint {
    margin: 0.3rem 0 0;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.settings-logo {
    display: block;
    max-width: 220px;
    max-height: 120px;
    margin-bottom: 0.75rem;
}

.settings-inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.settings-color {
    width: 48px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.settings-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

@media (max-width: 640px) {
    .settings-row,
    .settings-row-address {
        grid-template-columns: 1fr;
    }

    .settings-actions .btn {
        flex: 1;
        text-align: center;
    }

    .settings-form {
        max-width: none;
    }
}

/* ---- Invoice detail (FreshBooks style) ----
   A sticky header (back link, title, More Actions, Edit) with a full-width status
   banner under it, the invoice as a paper sheet, then its payments. */
.inv-sticky {
    position: sticky;
    top: 58px;
    z-index: 20;
    margin: -1.5rem 0 1.25rem;
    padding-top: 1rem;
    background: var(--color-surface);
}

.inv-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    color: var(--color-nav);
    text-decoration: none;
    font-size: 0.92rem;
}

.inv-head-title .back-link svg,
.btn-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.inv-head-title h1 {
    margin: 0.15rem 0 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: #001b40;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.page-actions .row-menu .menu-panel .is-disabled {
    color: #9aa4b2;
    pointer-events: none;
}

.page-actions .row-menu .menu-panel .is-disabled svg {
    stroke: #9aa4b2;
}

/* Full-bleed colored strip: the shadow paints the color past the content column
   and clip-path keeps it from bleeding vertically. */
.status-banner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    padding: 0.55rem 0;
    font-size: 0.95rem;
    color: var(--color-text);
    background: var(--banner);
    box-shadow: 0 0 0 100vmax var(--banner);
    clip-path: inset(0 -100vmax);
}

.status-banner a {
    color: var(--color-nav);
}

.status-banner.is-overdue { --banner: #fdd5dc; }
.status-banner.is-paid { --banner: #d7f2df; }
.status-banner.is-partial { --banner: #fdf3d1; }
.status-banner.is-sent { --banner: #e3effb; }
.status-banner.is-draft,
.status-banner.is-void { --banner: #eceff3; }

.inv-client-note {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 1rem;
    font-size: 0.92rem;
    color: var(--color-text);
}

.inv-client-note svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: #576981;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.inv-client-note a {
    color: var(--color-nav);
}

.inv-sheet {
    max-width: 780px;
    margin: 0 auto 2.5rem;
    padding: 3rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 27, 64, 0.08);
    font-size: 0.9rem;
    color: var(--color-text);
}

.inv-sheet-top {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.inv-sheet-logo img {
    max-width: 200px;
    max-height: 110px;
}

.inv-sheet-from {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.inv-sheet-meta {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr 1.3fr;
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.inv-label {
    color: var(--accent);
    font-size: 0.85rem;
}

.inv-label-gap {
    margin-top: 0.9rem;
}

.inv-amount-due {
    text-align: right;
}

.inv-amount-due-value {
    margin-top: 0.4rem;
    font-size: 2rem;
    font-weight: 600;
    color: #001b40;
}

.inv-lines {
    min-width: 0;
    border-top: 3px solid var(--accent);
}

.inv-lines th {
    background: none;
    color: var(--accent);
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.85rem;
    font-weight: 400;
    border-bottom: none;
    padding: 0.75rem 0;
}

.inv-lines td {
    padding: 0.75rem 0;
    white-space: normal;
    vertical-align: top;
    border-bottom: 1px solid var(--color-border);
}

.inv-lines .num {
    text-align: right;
    white-space: nowrap;
    padding-left: 1rem;
}

.inv-lines tbody tr:hover {
    background: none;
}

.inv-line-detail {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.inv-totals {
    width: min(100%, 320px);
    margin: 1.25rem 0 2rem auto;
}

.inv-totals > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.2rem 0;
}

.inv-totals-rule {
    margin-top: 0.4rem;
    padding-top: 0.6rem !important;
    border-top: 1px solid var(--color-border);
}

.inv-totals-due {
    color: var(--accent);
    font-weight: 600;
}

.inv-text {
    margin: 0.2rem 0 1.25rem;
    white-space: pre-line;
    font-size: 0.85rem;
}

.inv-payments {
    max-width: 780px;
    margin: 0 auto 2rem;
    scroll-margin-top: 180px;
}

.inv-payments-add > summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    list-style: none;
}

.inv-payments-add > summary::-webkit-details-marker {
    display: none;
}

.inv-payments-add h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: #001b40;
}

.plus-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    background: var(--color-primary);
    cursor: pointer;
}

.plus-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #fff;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.inv-payments-add[open] .plus-btn {
    background: var(--color-primary-hover);
}

.inv-payment-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: #f8fafc;
}

.inv-payment-form .form-group {
    margin-bottom: 0;
}

.inv-payment-form .form-group-grow {
    flex: 1;
    min-width: 160px;
}

.inv-payment-actions {
    display: flex;
    gap: 0.5rem;
}

.inv-payments-empty {
    margin: 0;
    padding: 0.75rem;
    text-align: center;
    font-style: italic;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

@media (max-width: 640px) {
    .inv-sticky {
        top: 56px;
        margin-top: -1rem;
    }

    .inv-head-title h1 {
        font-size: 1.35rem;
    }

    .inv-head .page-actions {
        width: 100%;
    }

    .inv-head .page-actions > * {
        flex: 1;
    }

    .inv-head .page-actions .btn-icon {
        justify-content: center;
    }

    .inv-head .row-menu > summary.header-action-btn {
        width: 100%;
    }

    .status-banner {
        font-size: 0.88rem;
    }

    .inv-sheet {
        padding: 1.25rem;
    }

    .inv-sheet-top {
        flex-direction: column;
        margin-bottom: 1.5rem;
    }

    .inv-sheet-from {
        text-align: left;
    }

    .inv-sheet-meta {
        grid-template-columns: 1fr 1fr;
        margin-bottom: 1.5rem;
    }

    .inv-amount-due {
        text-align: left;
    }

    .inv-amount-due-value {
        font-size: 1.5rem;
    }

    .inv-payment-form .form-group,
    .inv-payment-actions {
        flex: 1 1 100%;
    }

    .inv-payment-actions .btn {
        flex: 1;
    }
}

@media print {
    .inv-sticky,
    .inv-client-note,
    .inv-payments,
    .topbar {
        display: none !important;
    }

    .inv-sheet {
        border: none;
        box-shadow: none;
        padding: 0;
    }
}

/* Section forms sit on the page (no card), one narrow column like FreshBooks. */
.settings-form {
    max-width: 450px;
}

.settings-form .form-group {
    margin-bottom: 1rem;
}

.settings-form label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text);
}

.settings-form input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
.settings-form select,
.settings-form textarea {
    width: 100%;
}

.settings-form input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
.settings-form select {
    padding: 0.45rem 0.65rem;
    font-size: 0.92rem;
}

/* ---- Invoices list (FreshBooks style) ----
   Shares the Estimates list's cards (.est-card) and badges (.est-badge); these
   are the invoice-only statuses. */
.est-card-status.is-paid,
.est-badge.is-paid {
    background: #b9e4c2;
    color: #14532d;
}

.est-card-status.is-overdue,
.est-badge.is-overdue {
    background: #fbd0d6;
    color: #7f1d1d;
}

.est-card-status.is-partial,
.est-badge.is-partial {
    background: #cfe3fb;
    color: #0b3a75;
}

.est-card-status.is-void,
.est-badge.is-void {
    background: #ccd1d9;
    color: var(--color-text);
}

.list-heading-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

a.plus-btn:hover {
    background: var(--color-primary-hover);
}

@media (min-width: 641px) {
    .invoices-table .col-check { width: 2.5rem; }
    .invoices-table .col-name { width: 26%; }
    .invoices-table .col-desc { width: 30%; overflow: hidden; text-overflow: ellipsis; }
    .invoices-table .col-date { width: 18%; }
    .invoices-table .col-amount { width: 16%; }
    .invoices-table .col-actions { width: 3.5rem; text-align: right; }
}

/* Phone: checkbox, client + number, amount + status on one compact row. */
@media (max-width: 640px) {
    .invoices-table tbody tr {
        display: flex !important;
        align-items: center !important;
        gap: 0.75rem !important;
    }

    .invoices-table tbody td {
        display: block !important;
        padding: 0 !important;
        border: none !important;
        width: auto !important;
        text-align: left !important;
    }

    .invoices-table .col-name {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    .invoices-table .col-amount {
        flex: 0 0 auto !important;
        font-weight: 600;
        white-space: nowrap;
    }
}

/* Checkbox with a title and hint beside it (e.g. vendor "1099 contractor"). */
.settings-form label.check-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 1rem;
    font-size: 0.92rem;
    font-weight: 400;
    cursor: pointer;
}

.check-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0.1rem 0 0;
    flex-shrink: 0;
    accent-color: var(--color-nav);
}

.check-row-title {
    display: block;
    color: var(--color-text);
}

.check-row .settings-hint {
    display: block;
    margin-top: 0.1rem;
}

.settings-form .settings-group-title:first-of-type {
    margin-top: 0.5rem;
}

/* ---- Form page (FreshBooks Bill Pay "New Vendor" style) ----
   "Vendors > New Vendor" breadcrumb title with Cancel + Save at the top right,
   then one white rounded card. Labels mark optional fields in grey. */
.form-page {
    max-width: 1030px;
    margin: 0 auto;
}

.form-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin-bottom: 1.25rem;
}

.crumb-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0;
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--color-text);
}

.crumb-title a {
    color: #6b7686;
    font-weight: 400;
    text-decoration: none;
}

.crumb-title a:hover {
    color: var(--color-nav);
}

.crumb-title svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #6b7686;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.form-page-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.form-page-actions .btn {
    padding: 0.7rem 1.4rem;
    font-weight: 600;
}

.btn-text {
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;
}

.btn-text:hover {
    color: var(--color-nav);
}

.fp-card {
    max-width: 800px;
    margin: 0 auto 2rem;
    padding: 2rem;
    background: var(--color-surface);
    border: 1px solid #e3e6ea;
    border-radius: 10px;
}

.fp-card-title {
    margin: 0.5rem 0 1.75rem;
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--color-text);
}

.fp-card-title-gap {
    margin-top: 2.25rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eceef1;
}

.fp-card .form-group {
    margin-bottom: 1.5rem;
}

.fp-card label {
    margin-bottom: 0.5rem;
    font-size: 0.88rem;
    font-weight: 400;
    color: var(--color-text);
}

.fp-card .optional {
    margin-left: 0.15rem;
    color: #6b7686;
}

.fp-card input:not([type="checkbox"]):not([type="radio"]),
.fp-card select,
.fp-card textarea {
    width: 100%;
    padding: 0.75rem 0.85rem;
    font-size: 0.92rem;
    border: 2px solid #d9dce1;
    border-radius: 6px;
}

.fp-card input::placeholder,
.fp-card textarea::placeholder {
    color: #a3a9b3;
}

.fp-card input:focus,
.fp-card select:focus,
.fp-card textarea:focus {
    outline: none;
    border-color: var(--color-nav);
    box-shadow: none;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
}

.form-hint {
    display: block;
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    color: #6b7686;
}

.fp-card label.check-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    font-size: 0.92rem;
    cursor: pointer;
}

/* The top-right buttons already cover desktop; on phones they scroll out of view. */
.fp-card-foot {
    display: none;
}

@media (max-width: 640px) {
    .crumb-title {
        font-size: 1.4rem;
    }

    .form-page-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .fp-card {
        padding: 1.25rem 1rem;
        border-radius: 8px;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .fp-card-foot {
        display: flex;
        gap: 0.75rem;
        margin-top: 0.5rem;
    }

    .fp-card-foot .btn {
        flex: 1;
        text-align: center;
    }
}

/* ---- Vendors list (same layout as Clients / Invoices) ---- */
.list-toolbar-spaced {
    margin-top: 1.5rem;
}

@media (min-width: 641px) {
    .vendors-table .col-name { width: 32%; }
    .vendors-table .col-email { width: 32%; overflow: hidden; text-overflow: ellipsis; }
    .vendors-table .col-phone { width: 18%; }
    .vendors-table .col-tag { width: 9%; }
    .vendors-table .col-actions { width: 9%; text-align: right; }
}

/* Phone: name (+ location, email) on the left, phone on the right, one row. */
@media (max-width: 640px) {
    .vendors-table tbody tr {
        display: flex !important;
        align-items: center !important;
        gap: 0.75rem !important;
    }

    .vendors-table tbody td {
        display: block !important;
        padding: 0 !important;
        border: none !important;
        width: auto !important;
        text-align: left !important;
    }

    .vendors-table .col-name {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    .vendors-table .col-phone {
        flex: 0 0 auto !important;
        white-space: nowrap;
        font-size: 0.85rem;
    }
}

.vendors-table .col-row-actions {
    text-align: right;
    white-space: nowrap;
}

.vendors-table .col-row-actions .link-btn + .link-btn {
    margin-left: 0.75rem;
}

.link-btn.link-danger {
    color: #b91c1c;
}

.page-head .crumb-title {
    font-size: 1.6rem;
}

@media (max-width: 640px) {
    .vendors-table .col-row-actions {
        flex: 0 0 auto !important;
    }
}

/* ---- Expenses list: sticky header, selection heading, inline edit ---- */

/* Page title bar stays under the top bar while scrolling (FreshBooks). */
.sticky-head {
    position: sticky;
    top: 58px;
    z-index: 20;
    margin-top: -1.5rem;
    padding-top: 1rem;
    background: var(--color-surface);
}

@media (max-width: 640px) {
    .sticky-head {
        position: static;
        margin-top: 0;
        padding-top: 0;
    }
}

.list-heading-group[hidden] {
    display: none;
}

.crumb-heading {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.crumb-heading svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #1a2b44;
    stroke-width: 2;
    stroke-linecap: round;
}

.crumb-link {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: var(--color-nav);
    cursor: pointer;
}

.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    margin-left: 0.25rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: #e6e9ee;
    font-size: 0.85rem;
    font-weight: 600;
}

.bulk-menu {
    position: relative;
}

.bulk-menu > summary.header-action-btn {
    padding: 0.45rem 0.9rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: #001b40;
    border-color: #a8b0bc;
}

.bulk-menu .menu-panel {
    left: 0;
    right: auto;
    min-width: 240px;
}

.menu-note {
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    border-bottom: 1px solid #eef0f3;
}

.expenses-table tr.notice-row td {
    position: relative;
    padding-right: 2.5rem;
}

.expenses-table tr.notice-row[hidden] {
    display: none !important;
}

.notice-icon {
    width: 17px;
    height: 17px;
    margin-right: 0.3rem;
    vertical-align: -3px;
    fill: none;
    stroke: #c58a00;
    stroke-width: 2;
    stroke-linecap: round;
}

.notice-close {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    padding: 0.2rem;
    border: none;
    background: none;
    cursor: pointer;
}

.notice-close svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: #1a2b44;
    stroke-width: 2.4;
    stroke-linecap: round;
}

.expenses-table tr.expense-row {
    cursor: pointer;
}

.expenses-table tr.expense-row[hidden] {
    display: none !important;
}

/* While a row is being edited the others fade back, like FreshBooks. */
.expenses-table tbody.is-editing tr.expense-row {
    opacity: 0.45;
}

.expenses-table tr.inline-edit-row:hover {
    background: none;
}

.expenses-table tr.inline-edit-row td {
    padding: 0.9rem 0 0.9rem 0;
    white-space: normal;
}

.inline-edit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "fields actions" "foot actions";
    gap: 0.5rem 1rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--accent, #9ca3af);
}

.inline-edit-fields {
    grid-area: fields;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem 0.75rem;
}

.inline-edit-fields .form-group {
    margin: 0;
}

.inline-edit-fields label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.inline-edit-fields input,
.inline-edit-fields select,
.inline-edit-fields textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    font-size: 0.92rem;
    border: 1.5px solid #a8b0bc;
    border-radius: 4px;
}

.inline-edit-fields textarea {
    resize: vertical;
    min-height: 2.35rem;
}

.inline-edit-foot {
    grid-area: foot;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    font-size: 0.88rem;
}

.inline-edit-source:empty {
    display: none;
}

.attach-link,
.advanced-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--color-nav);
    text-decoration: none;
    cursor: pointer;
}

.attach-link input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.advanced-link {
    margin-left: auto;
}

.attach-link svg,
.advanced-link svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.inline-edit-actions {
    grid-area: actions;
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
}

.inline-save {
    width: 40px;
    border: none;
    border-radius: 4px;
    background: var(--color-primary);
    cursor: pointer;
}

.inline-save:hover {
    background: var(--color-primary-hover);
}

.inline-save svg,
.inline-cancel svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.inline-save svg {
    stroke: #fff;
}

.inline-cancel {
    align-self: center;
    padding: 0.2rem;
    border: none;
    background: none;
    cursor: pointer;
}

.inline-cancel svg {
    stroke: #576981;
}

/* ---- Edit Expense (FreshBooks receipt look) ----
   Left: the expense as a paper receipt with a pinned receipt photo and a torn
   bottom edge. Right: "Expense Settings" rows. One column on phones. */
.expense-layout {
    display: grid;
    grid-template-columns: minmax(0, 500px) minmax(0, 300px);
    justify-content: center;
    gap: 2.5rem;
    align-items: start;
}

.receipt-paper {
    position: relative;
    padding: 1.5rem 2.25rem 2.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: 5px solid #6fae7c;
    border-radius: 4px 4px 0 0;
    box-shadow: 0 2px 6px rgba(0, 27, 64, 0.08);
    /* Torn bottom edge. */
    -webkit-mask:
        linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat,
        conic-gradient(from 135deg at top, #000 90deg, #0000 0) bottom left / 20px 10px repeat-x;
    mask:
        linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat,
        conic-gradient(from 135deg at top, #000 90deg, #0000 0) bottom left / 20px 10px repeat-x;
}

.receipt-top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.receipt-fields {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
    padding-top: 0.5rem;
}

.receipt-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-weight: 400;
}

.receipt-inline svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: #4a9a5c;
    stroke-width: 1.8;
    stroke-linejoin: round;
}

/* Fields sit on the paper like printed text and only show a border on hover/focus. */
.receipt-paper input,
.receipt-paper textarea {
    width: 100%;
    padding: 0.3rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--color-text);
    font-size: 0.95rem;
}

.receipt-paper input:hover,
.receipt-paper textarea:hover {
    border-color: var(--color-border);
}

.receipt-paper input:focus,
.receipt-paper textarea:focus {
    outline: none;
    border-color: var(--color-nav);
    background: var(--color-surface);
}

.receipt-merchant {
    margin-bottom: 0.4rem;
    font-size: 1.75rem !important;
}

.receipt-notes {
    min-height: 7rem;
    resize: vertical;
}

.receipt-drop {
    position: relative;
    flex: 0 0 165px;
    height: 165px;
    margin: -0.25rem -1rem 0 0;
    padding: 0.6rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: 2px 3px 8px rgba(0, 27, 64, 0.12);
    transform: rotate(4deg);
    cursor: pointer;
}

.receipt-drop::before {
    content: "";
    position: absolute;
    inset: 0.6rem;
    border: 2px dashed #c5ccd6;
    border-radius: 3px;
    pointer-events: none;
}

.receipt-drop.has-file::before {
    display: none;
}

.receipt-drop.is-over::before {
    border-color: var(--color-nav);
}

.receipt-drop img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.receipt-drop-text {
    position: absolute;
    inset: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: #6b7686;
    overflow-wrap: anywhere;
}

.receipt-drop-text .link {
    color: var(--color-nav);
}

.receipt-clip {
    position: absolute;
    top: -22px;
    left: 50%;
    width: 22px;
    height: 40px;
    fill: none;
    stroke: #8b95a3;
    stroke-width: 2;
    stroke-linecap: round;
    z-index: 1;
}

/* The file input covers the whole photo, so clicks and native drops both land on it. */
.receipt-drop input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.receipt-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.receipt-total label {
    margin: 0;
    font-weight: 400;
    font-size: 0.92rem;
}

.receipt-total-input {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 1.8rem;
    color: var(--color-text);
}

.receipt-total-input input {
    width: 9rem;
    text-align: right;
    font-size: 1.8rem;
}

.expense-settings h2 {
    margin: 0 0 0.25rem;
    padding-bottom: 0.6rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #001b40;
    border-bottom: 1px solid #c5ccd6;
}

.setting-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.setting-row > svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: #576981;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.setting-row > div,
.setting-row > span {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    flex: 1;
}

.setting-row label,
.setting-title {
    margin: 0;
    font-weight: 500;
    color: var(--color-text);
}

.setting-row select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    font-size: 0.88rem;
}

.setting-row .muted {
    font-size: 0.82rem;
}

.setting-check {
    cursor: pointer;
}

.setting-check input {
    width: 18px;
    height: 18px;
    margin-top: 0.15rem;
    accent-color: var(--color-nav);
}

.setting-receipt a {
    overflow-wrap: anywhere;
}

.setting-receipt .link-btn {
    align-self: flex-start;
    padding: 0;
}

.expense-page .fp-card-foot {
    grid-column: 1 / -1;
}

@media (max-width: 640px) {
    .expense-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.5rem;
    }

    .receipt-paper {
        padding: 1.25rem 1rem 2.25rem;
    }

    .receipt-top {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .receipt-drop {
        flex-basis: auto;
        height: 150px;
        margin: 0.5rem 0 0;
        transform: none;
    }

    .receipt-merchant {
        font-size: 1.4rem !important;
    }

    .receipt-total-input,
    .receipt-total-input input {
        font-size: 1.4rem;
    }

    .receipt-total-input input {
        width: 7rem;
    }
}

/* Row icon toolbar (edit / receipt / full page / delete), shown on row hover. */
.expenses-table .col-actions {
    width: 9.5rem;
}

.row-tools {
    display: inline-flex;
    border: 1px solid #c5ccd6;
    border-radius: 999px;
    background: var(--color-surface);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.12s;
}

.expenses-table tr.expense-row:hover .row-tools,
.expenses-table tr.expense-row:focus-within .row-tools {
    opacity: 1;
}

@media (hover: none) {
    .row-tools {
        opacity: 1;
    }
}

.row-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    padding: 0;
    border: none;
    background: none;
    color: var(--color-text);
    cursor: pointer;
}

.row-tool + .row-tool {
    border-left: 1px solid var(--color-border);
}

.row-tool:hover {
    background: #eef6fc;
    color: var(--color-nav);
}

.row-tool svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.row-tool[data-confirm]:hover {
    color: #b91c1c;
    background: #fdecee;
}

/* Inline editor: row 2 fields carry an icon instead of a label. */
.inline-edit-fields .label-spacer {
    color: transparent;
    user-select: none;
}

.inline-edit-fields .icon-input {
    position: relative;
}

.inline-edit-fields .icon-input svg {
    position: absolute;
    top: 50%;
    left: 0.65rem;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--accent, #576981);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.inline-edit-fields .icon-input input,
.inline-edit-fields .icon-input textarea {
    padding-left: 2.1rem;
}

.money-input {
    position: relative;
    display: block;
}

.money-input > span {
    position: absolute;
    top: 50%;
    left: 0.65rem;
    transform: translateY(-50%);
    color: var(--color-text);
    pointer-events: none;
}

.money-input input {
    padding-left: 1.4rem !important;
}

.inline-edit-fields input,
.inline-edit-fields select,
.inline-edit-fields textarea {
    height: 2.6rem;
}

.inline-edit-fields textarea {
    resize: none;
    overflow: hidden;
    line-height: 1.5;
}

.inline-edit-fields textarea:focus {
    height: 5rem;
    overflow: auto;
    position: relative;
    z-index: 2;
}

.inline-save {
    width: 44px;
}

/* Account language controls stay usable in the mobile account menu. */
.account-language { padding: 0.75rem; display: grid; gap: 0.5rem; }
.account-language select, .account-language button { min-height: 44px; width: 100%; }
@media (max-width: 640px) {
    .page-actions { flex-wrap: wrap; }
    .page-actions > * { max-width: 100%; }
}

.doc-preview-totals-row[hidden] {
    display: none;
}

/* Expenses > Categories: add / rename / merge */
.cat-add { margin-bottom: 1rem; }
.cat-add label, .cat-edit-panel label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.35rem; }
.cat-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.cat-row input[type="text"] { flex: 1 1 14rem; min-width: 0; }
.cat-row select { flex: 0 1 auto; min-width: 0; max-width: 100%; }
.cat-account select { flex: 1 1 12rem; }
/* Phone card view: the ledger account (long names like "5010 - Government & Filing Fees
   Paid for Clients") goes under its label at full width instead of pushing the card wide. */
@media (max-width: 640px) {
    .table-wrap td.cat-account-cell { flex-direction: column; align-items: stretch; text-align: left; }
    .table-wrap td.cat-account-cell::before { margin-right: 0; }
    .cat-account select { width: 100%; }
}
.cat-edit > summary { cursor: pointer; color: var(--color-nav); font-weight: 600; list-style: none; white-space: nowrap; }
.cat-edit > summary::-webkit-details-marker { display: none; }
.cat-edit-panel { display: grid; gap: 0.75rem; margin-top: 0.5rem; min-width: 16rem; text-align: left; }
@media (max-width: 640px) {
    .cat-row > * { flex: 1 1 100%; }
    .cat-edit { width: 100%; }
    .cat-edit-panel { min-width: 0; }
}

/* External bulk controls wrap without widening the transaction list. */
#bulk-bar > * { max-width: 100%; min-width: 0; }
#bulk-bar [hidden] { display: none; }
#bulk-category { flex: 0 1 14rem; padding: 0.5rem; }
@media (max-width: 640px) {
    #bulk-bar > * { flex: 1 1 100%; }
    #bulk-bar .btn, #bulk-category { min-height: 44px; white-space: normal; }
}

.txn-table .col-actions .dropdown > summary { white-space: nowrap; }
@media (min-width: 641px) {
    .txn-table .col-actions { min-width: 6.5rem; width: 6.5rem; }
}

/* Bank Transactions pager: page numbers next to ‹ › (same look as the shared .pager). */
.pager { flex-wrap: wrap; }
.pager .pager-num { width: auto; min-width: 2rem; padding: 0 0.35rem; font-size: 0.9rem; }
.pager span.pager-num { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 2rem; border-radius: 6px; font-size: 0.9rem; }
.pager .pager-num.is-current { background: var(--color-nav); color: #fff; font-weight: 600; }
.pager-gap { color: #8a96a8; padding: 0 0.15rem; }
.txn-pager-top { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
@media (max-width: 640px) { .txn-pager-top { justify-content: flex-start; } }

/* Client overview and invoice CSV period picker. */
.nav-group > summary > .nav-group-link { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.nav-group-link:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
.invoice-export-dialog { width: min(560px, calc(100vw - 24px)); max-width: calc(100vw - 24px); box-sizing: border-box; border: 0; border-radius: 10px; padding: 24px; }
.invoice-export-dialog::backdrop { background: #10253a80; }
.invoice-export-dialog select { width: 100%; margin: 12px 0 20px; }
.invoice-export-dialog h2 { margin: 0; }
.invoice-export-dialog .page-head { gap: 12px; }
.invoice-export-dates:not([hidden]) { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.invoice-export-dates label { flex: 1; min-width: 0; }
.invoice-export-dates input { width: 100%; min-width: 0; box-sizing: border-box; }
.client-detail-head h1 { overflow-wrap: anywhere; min-width: 0; }
.client-detail-cards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 20px; margin: 20px 0; }
.client-contact { display: flex; align-items: flex-start; gap: 16px; overflow-wrap: anywhere; }
.client-contact > div:last-child { min-width: 0; }
.client-contact h2, .client-revenue h2 { margin-top: 0; }
.client-avatar { flex-shrink: 0; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: #e6f1fb; color: #24659b; font-size: 20px; }
.client-revenue-total { font-size: 2rem; }
.client-revenue-bar { height: 12px; background: #dbeaf4; border-radius: 6px; overflow: hidden; margin-top: 16px; }
.client-revenue-bar span { display: block; height: 100%; background: #e96a88; }
.client-revenue-stats { display: flex; flex-wrap: wrap; gap: 20px; border-top: 1px solid #e1e6ea; padding-top: 16px; }
.client-revenue-stats > div { flex: 1; min-width: 105px; }
.client-revenue-stats span, .client-revenue-stats small { display: block; color: #64748b; }
.client-tabs-wrap { display: flex; min-width: 0; align-items: center; gap: 4px; }
.client-tabs { display: flex; min-width: 0; flex: 1; overflow-x: auto; overscroll-behavior-x: contain; position: relative; }
.client-tabs a { flex-shrink: 0; padding: 14px 16px; border: 1px solid transparent; border-bottom-color: #d6dde3; text-decoration: none; white-space: nowrap; }
.client-tabs a.active { background: white; border-color: #d6dde3; border-bottom-color: white; border-radius: 6px 6px 0 0; font-weight: 600; }
.client-records { min-width: 0; }
.client-records td { overflow-wrap: anywhere; }
@media (max-width: 640px) {
    .client-detail-cards { grid-template-columns: minmax(0, 1fr); }
    .client-detail-head { align-items: flex-start; flex-wrap: wrap; }
    .client-detail-head .page-actions { flex-wrap: wrap; }
    .client-records .page-head { flex-wrap: wrap; gap: 8px; }
    .invoice-export-dialog { padding: 16px; }
    .invoice-export-dialog h2 { font-size: 1.2rem; }
}

.client-tabs-wrap > button[hidden] { display: none; }
.client-detail-head .row-menu > summary.btn-green { color: #fff; padding: 0.55rem 1.1rem; }
.invoice-export-dialog .page-head { display: flex; justify-content: space-between; align-items: center; }
.invoice-export-dialog select { min-height: 2.6rem; padding: 0.45rem 0.6rem; font-size: 1rem; }
.invoice-import { min-width: 0; overflow-wrap: anywhere; }
.invoice-import input[type=file] { max-width: 100%; }
.invoice-import-scroll { max-height: 28rem; overflow: auto; margin: 1rem 0; }
.invoice-import-scroll table { min-width: 650px; }

/* Accessibility: visible keyboard focus and 44px touch targets on phones. */
.search-bar:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.2);
}

.search-dialog-pages a:focus-visible,
.sidebar a:focus-visible,
.sidebar summary:focus-visible,
.sidebar-toggle:focus-visible,
.sidebar-close:focus-visible,
.topbar-icon:focus-visible,
.topbar-avatar:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.sidebar a:focus-visible,
.sidebar summary:focus-visible,
.sidebar-close:focus-visible {
    outline-color: #fff;
}

.inv-payments-empty p {
    margin: 0;
}

.inv-payments-empty .btn {
    margin-top: 0.6rem;
    font-style: normal;
}

.inv-payments-add[open] ~ .inv-payments-empty .btn {
    display: none;
}

@media (max-width: 768px) {
    .sidebar-toggle,
    .sidebar-close {
        width: 44px;
        height: 44px;
    }

    .sidebar-close {
        top: 0.4rem;
        right: 0.4rem;
    }
}

@media (max-width: 640px) {
    .topbar-icon {
        width: 44px;
        height: 44px;
    }

    summary.topbar-avatar {
        width: 44px;
        height: 44px;
    }
}

/* Shared visual system: actions, state labels and aligned financial figures. */
.btn-text { background: transparent; border-color: transparent; color: var(--color-text); }
.btn-text:hover { background: var(--color-bg); color: var(--color-primary); }
:is(.btn, .btn-green, .btn-outline, .btn-danger, .btn-text):focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
:is(.btn, .btn-green, .btn-outline, .btn-danger, .btn-text):disabled,
:is(.btn, .btn-green, .btn-outline, .btn-danger, .btn-text)[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-sm { min-height: 32px; }
.btn-brand,
.btn-brand:hover { background: var(--button-brand, var(--color-primary)); }
.btn-brand:hover { filter: brightness(0.92); }
.btn-block { width: 100%; }
.back-link { margin-bottom: var(--space-2); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-danger, .alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-info { background: var(--color-info-bg); color: var(--color-info); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); }
:is(.badge, .est-badge, .te-badge, .count-pill, .recent-card-status) { display: inline-flex; align-items: center; justify-content: center; min-height: 24px; padding: 2px 8px; border-radius: var(--radius-control); font-size: .75rem; font-weight: 600; line-height: 20px; }
.badge-paid,
.est-badge.is-paid,
.est-card-status.is-paid,
.badge-accepted,
.est-badge.is-accepted,
.est-card-status.is-accepted,
.badge-invoiced,
.est-badge.is-invoiced,
.est-card-status.is-invoiced { background: var(--color-success-bg); color: var(--color-success); }
.badge-sent,
.est-badge.is-sent,
.est-card-status.is-sent,
.badge-viewed,
.est-badge.is-viewed,
.est-card-status.is-viewed,
.badge-unpaid,
.est-badge.is-unpaid,
.est-card-status.is-unpaid { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-overdue,
.est-badge.is-overdue,
.est-card-status.is-overdue,
.badge-declined,
.est-badge.is-declined,
.est-card-status.is-declined { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-partial,
.est-badge.is-partial,
.est-card-status.is-partial { background: var(--color-info-bg); color: var(--color-info); }
.badge-draft,
.est-badge.is-draft,
.est-card-status.is-draft,
.badge-void,
.est-badge.is-void,
.est-card-status.is-void { background: var(--color-neutral-bg); color: var(--color-neutral); }

.invoice-recent .est-card { min-height: 0; }
.invoice-recent .est-card-body { flex: 0; padding: .65rem .75rem .4rem; }
.invoice-recent .est-card-amount { margin: 0 .75rem; }
.invoice-recent .est-card-status { padding: .3rem .5rem; font-size: .75rem; line-height: 20px; }
.expense-cards { align-items: flex-start; }
.expense-card-content { padding: .5rem .65rem; }
:is(.recent-card-amount, .est-card-amount, .expense-card-amount, .kpi .value, .stat-value, .amount, .total, .col-amount, .num, .totals, .amount-stack), td[style*="text-align:right"], td[style*="text-align: right"], td[data-label*="Amount"], td[data-label*="Balance"], td[data-label*="Total"], tfoot { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
    :is(.btn, .btn-green, .btn-outline, .btn-danger, .btn-text, .btn-sm) { min-height: 44px; }
    .page-head-actions { max-width: 100%; }
}

@media print {
    .back-link { display: none; }
}
/* Invoice form: compact metadata, line grid and responsive preview. */
.inv-form-layout { display:grid; grid-template-columns:minmax(0, 1.65fr) minmax(0, 1fr); }
.inv-form-layout > .form-col, .inv-form-layout > .preview-col { min-width:0; width:100%; }
.inv-form-layout > .preview-col { position:sticky; top:74px; }
.inv-form-actions { display:flex; flex-wrap:wrap; align-items:center; gap:var(--space-2); padding:var(--space-3) 0; }
.inv-form-actions.invoice-actions { position:sticky; top:58px; z-index:20; background:var(--color-surface); }
.inv-form-client { position:relative; }
.inv-form-layout #client-options { max-height:220px; overflow:auto; border:1px solid var(--color-border); background:var(--color-surface); }
.inv-form-layout #client-options [role=option] { padding:var(--space-3); cursor:pointer; overflow-wrap:anywhere; }
.inv-form-layout #client-options [aria-selected=true] { background:var(--color-bg); }
.inv-form-layout #client-settings, .inv-form-layout #client-message, .inv-form-preline { white-space:pre-line; overflow-wrap:anywhere; }
.inv-form-meta, .inv-form-pair { display:grid; gap:var(--space-3); grid-template-columns:repeat(2,minmax(0,1fr)); }
.inv-form-meta { grid-template-columns:repeat(3,minmax(0,1fr)); }
.inv-form-details { border-top:1px solid var(--color-border); padding:var(--space-2) 0; }
.inv-form-details summary { cursor:pointer; color:var(--color-primary); min-height:44px; display:flex; align-items:center; gap:var(--space-2); }
.inv-form-details summary::before { content:'\203a'; }
.inv-form-details[open] summary::before { transform:rotate(90deg); }
/* Desktop: two rows per line - Detail sits under Description, Tax under Qty+Rate. */
.inv-form-line, .inv-form-line-head { display:grid; grid-template-columns:minmax(0,2fr) minmax(0,.6fr) minmax(0,.9fr) minmax(0,1fr) 44px; gap:var(--space-2); }
.inv-form-line { grid-template-areas:"desc qty rate amt rm" "desc tax tax amt rm"; }
.inv-form-line > :nth-child(1) { grid-area:desc; }
.inv-form-line > :nth-child(2) { grid-area:qty; }
.inv-form-line > :nth-child(3) { grid-area:rate; }
.inv-form-line > :nth-child(4) { grid-area:tax; }
.inv-form-line > .inv-form-amount { grid-area:amt; }
.inv-form-line > .inv-form-remove { grid-area:rm; }
.inv-form-line-head { font-size:.8rem; color:var(--color-text-muted); padding-bottom:var(--space-2); }
.inv-form-line { align-items:start; margin-bottom:var(--space-3); }
.inv-form-line .form-group { min-width:0; margin-bottom:0; }
.inv-form-line .form-group > label, .inv-form-mobile-label { display:none; }
.inv-form-line input, .inv-form-line select, .inv-form-meta input { min-width:0; width:100%; }
.inv-form-detail { margin-top:var(--space-1); font-size:.85rem; }
.inv-form-amount { min-width:0; min-height:2.6rem; display:flex; align-items:center; justify-content:flex-end; font-size:.9rem; overflow-wrap:anywhere; font-variant-numeric:tabular-nums; }
.inv-form-line-head > :nth-child(4) { text-align:right; }
.inv-form-line { position:relative; }
.inv-form-remove { width:44px; min-height:44px; padding:0; font-size:1.4rem; }
.inv-form-help { font-size:.8rem; color:var(--color-text-muted); margin:0 0 var(--space-2); }
.inv-form-notes { margin-top:var(--space-4); }
.inv-form-notes-title { color:var(--color-text); }
@media(max-width:1000px) {
    .inv-form-layout { grid-template-columns:minmax(0,1fr); }
    .inv-form-layout > .preview-col { position:static; }
}
@media(max-width:600px) {
    .inv-form-meta { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .inv-form-meta > :first-child { grid-column:1 / -1; }
    .inv-form-pair { grid-template-columns:minmax(0,1fr); }
    .inv-form-line-head { display:none; }
    .inv-form-line { grid-template-columns:repeat(2,minmax(0,1fr)); padding:var(--space-3); border:1px solid var(--color-border); border-radius:var(--radius-card); background:var(--color-bg); }
    .inv-form-description { grid-column:1 / -1; }
    .inv-form-line .form-group > label, .inv-form-mobile-label { display:block; }
    .inv-form-line input, .inv-form-line select, .inv-form-layout summary, .inv-form-layout [role=option] { min-height:44px; }
    .inv-form-amount { min-height:0; display:block; text-align:left; align-self:end; padding-bottom:var(--space-2); }
    .inv-form-remove { position:absolute; top:var(--space-1); right:var(--space-1); }
    .inv-form-line { grid-template-areas:none; }
    .inv-form-line > :nth-child(n) { grid-area:auto; }
    .inv-form-line > .inv-form-description { grid-column:1 / -1; padding-right:40px; }
    .inv-form-actions > :is(a,button) { min-height:44px; padding:.5rem; font-size:.85rem; }
}
.inv-form-layout [hidden] { display:none !important; }
@media(max-width:600px) {
    .inv-form-layout :is(input:not([type=hidden]):not([type=checkbox]), select, textarea) { min-height:44px; }
    .inv-form-layout #time-options label { display:flex; align-items:center; min-height:44px; }
}

/* Dashboard: current work first, compact annual charts. */
.attention-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:var(--space-3, 0.75rem); }
.attention-card { display:flex; flex-direction:column; gap:0.4rem; color:var(--color-text); text-decoration:none; min-width:0; min-height:44px; margin:0; }

.attention-count { font-size:1.8rem; }
.attention-count, .dash-kpis .value, .donut-center strong { font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.dash-year { display:flex; align-items:center; flex-wrap:wrap; gap:0.5rem; margin-block:0.75rem; }
.dash-year .btn { min-width:44px; min-height:44px; display:inline-flex; justify-content:center; align-items:center; }
.pie-widget { grid-template-columns:160px minmax(0,1fr); grid-template-areas:"pie legend"; }
/* The donut centre already shows the total. */
.pie-widget .pie-total { display:none; }
.donut-chart { grid-area:pie; position:relative; width:160px; height:160px; }
.donut-chart .pie { width:160px; height:160px; }
.donut-center { position:absolute; inset:29%; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; pointer-events:none; }
.donut-center strong { font-size:1rem; max-width:100%; }
.donut-center span { font-size:0.65rem; color:var(--color-text-muted); }
.pie-legend li a, .pie-more > summary { min-height:44px; display:inline-flex; align-items:center; }
@media(max-width:640px) {
    .dash-kpis { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .dash-kpis .kpi { min-width:0; }
    .dash-kpis .kpi:last-child { grid-column:1 / -1; display:flex; align-items:center; justify-content:space-between; gap:1rem; }
    .attention-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .attention-card { padding:0.9rem; overflow-wrap:anywhere; }
    .pie-widget { grid-template-columns:minmax(0,1fr); grid-template-areas:"pie" "legend"; gap:0.75rem; }
    .donut-chart { justify-self:center; }
    .dash-section .section-head { flex-wrap:wrap; gap:0.5rem; }
    .dash-section .section-head > a { min-height:44px; display:inline-flex; align-items:center; }
    .pie-legend li { flex-wrap:wrap; gap:0.35rem; }
    .pie-legend li a { white-space:normal; overflow-wrap:anywhere; }
    .pie-amount { white-space:normal; overflow-wrap:anywhere; }
}

/* Books Check */
.books-check-summary { max-width: 28rem; margin: 0; }
.books-check-summary div { display: flex; justify-content: space-between; gap: var(--space-3, .75rem); padding: var(--space-2, .5rem) 0; border-bottom: 1px solid var(--color-border, #e5e7eb); }
.books-check-summary dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.books-check-total { font-weight: 600; }
:is(td, th).num { text-align: right; font-variant-numeric: tabular-nums; }
.books-check-repair { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3, .75rem); justify-content: space-between; }
.books-check-repair p { margin: 0; flex: 1 1 18rem; }

/* Receipt inbox: cards remain within the viewport on phones. */
.receipt-inbox { min-width: 0; max-width: 100%; }
.receipt-tabs, .receipt-search { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 16px 0; }
.receipt-tabs a { padding: 10px; }
.receipt-tabs [aria-current] { font-weight: 700; text-decoration: underline; }
.receipt-inbox-drop { border: 2px dashed var(--border, #cbd5e1); padding: 20px; border-radius: 8px; display: grid; gap: 12px; }
.receipt-inbox-drop.dragging { background: #eff6ff; }
.receipt-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,360px),1fr)); gap: 20px; }
.receipt-card { min-width: 0; border: 1px solid var(--border, #cbd5e1); padding: 16px; border-radius: 8px; overflow-wrap: anywhere; }
.receipt-card h2 { font-size: 18px; }
.receipt-preview { display: flex; align-items: center; justify-content: center; height: 180px; background: #f8fafc; }
.receipt-preview img { max-width: 100%; max-height: 180px; object-fit: contain; }
.receipt-create { display: grid; gap: 12px; margin: 16px 0; }
.receipt-create label { display: grid; gap: 5px; min-width: 0; }
.receipt-inbox input, .receipt-inbox select { max-width: 100%; min-width: 0; box-sizing: border-box; }
.receipt-create input, .receipt-create select { width: 100%; }
.receipt-match { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.receipt-card summary { cursor: pointer; padding: 12px 0; }
.receipt-inbox button { min-height: 44px; white-space: normal; }

/* General Ledger: long memos wrap so Debit/Credit/Balance always stay in view. */
@media (min-width: 641px) {
    .gl-table .col-amount { text-align: right; font-variant-numeric: tabular-nums; width: 1%; }
}
.gl-table .gl-memo > div { min-width: 0; overflow-wrap: anywhere; white-space: normal; }

/* Bank changed or removed a movement someone already recorded (plaidSyncApply.js). */
.bank-change-note { margin-top:0.35rem; padding:0.35rem 0.5rem; border-radius:6px; background:var(--color-warning-bg); color:var(--color-warning); font-size:0.82rem; white-space:normal; overflow-wrap:anywhere; display:flex; flex-wrap:wrap; gap:0.25rem 0.75rem; align-items:center; }
.bank-change-note form { margin:0; }
.bank-change-note .link-btn { margin-left:0; color:var(--color-warning); font-size:0.82rem; }
.bank-changed-banner a { margin-right:0.5rem; font-weight:600; }

/* Bank Connections: opening balance of each account in the books (bankLedger.js). */
.opening-box { margin-top:0.75rem; border-top:1px solid var(--color-border); padding-top:0.75rem; }
.opening-box summary { cursor:pointer; color:var(--color-nav); font-weight:600; }
.opening-form { display:flex; flex-wrap:wrap; gap:0.5rem 0.75rem; align-items:flex-end; }
.opening-form label { display:flex; flex-direction:column; font-size:0.85rem; font-weight:600; gap:0.25rem; }
.opening-form input { min-height:38px; padding:0 0.5rem; border:1px solid var(--color-border-strong); border-radius:var(--radius-control); font:inherit; max-width:100%; }

/* Bank Transactions: owner draw / contribution / transfer choices (bankLedger.js). */
.kind-buttons { display:flex; flex-wrap:wrap; gap:0.35rem; margin-top:0.35rem; }
.kind-cell { display:flex; flex-direction:column; gap:0.3rem; align-items:flex-start; margin-bottom:0.3rem; }
.kind-change { width:100%; }
.kind-change select { font-size:0.8rem; width:100%; max-width:100%; }

/* Bank Transactions: one-account summary card. */
.acct-summary { padding:1rem 1.25rem; }
.acct-summary h2 { font-size:1.05rem; margin:0 0 0.6rem; }
.acct-stats { display:grid; grid-template-columns:repeat(auto-fit, minmax(160px, 1fr)); gap:0.75rem 1.5rem; }
.acct-stats div { display:flex; flex-direction:column; gap:0.15rem; }
.acct-stats strong { font-size:1.15rem; font-variant-numeric:tabular-nums; }

/* Books Check: opening adjustment of Undeposited Funds. */
.cleanup-actions { display:flex; flex-wrap:wrap; gap:0.5rem; }
.cleanup-actions form { margin:0; }

/* Books Check: records still in Undeposited Funds since the books start. */
.open-funds .open-hint { font-size:0.85rem; margin-bottom:0.2rem; }
.open-funds .open-hint-other_income, .open-funds .open-hint-twin { color:var(--color-danger); font-weight:600; }
.open-funds .open-hint-waiting { color:var(--color-warning); }
.open-funds .open-find { font-size:0.85rem; display:block; }
.open-funds td:first-child { white-space:nowrap; }
.open-funds .open-fix { margin:0.35rem 0; }
@media (max-width: 640px) { .open-funds .open-hints { display:flex; flex-direction:column; align-items:flex-end; text-align:right; gap:0.25rem; max-width:65%; } .open-funds .open-fix .btn { white-space:normal; } }
.open-other { margin-top:0.5rem; }
.open-other .open-hints br { display:none; }
.open-other .open-hints .muted { display:block; }
.open-other summary { cursor:pointer; color:var(--color-primary, #1d4ed8); font-size:0.9rem; }
.open-record { display:flex; flex-wrap:wrap; gap:0.35rem; justify-content:flex-end; margin-top:0.35rem; }
.open-record select { max-width:12rem; }
@media (max-width: 640px) { .open-other td:has(.open-record) { flex-direction:column; align-items:flex-end; gap:0.35rem; } .open-other td:has(.open-record)::before { align-self:flex-start; } }
