/* ==========================================================================
   App UI kit — design system for business screens
   --------------------------------------------------------------------------
   Compact 11–12px type, gray-400 hairline borders, tinted section header bars,
   sticky table heads, summary tiles and a bordered pager strip. See
   Pages/Demo/CustomerList.razor (register) and CustomerEntry.razor (entry form)
   for every piece in use. Classes keep the short "qf-" prefix.

   Written as plain CSS (not Tailwind utilities) on purpose: wwwroot/css/output.css
   is a PRE-BUILT Tailwind bundle, so any class it does not already contain renders
   with no style at runtime. Night-mode overrides live in darkmode.css.
   ========================================================================== */

:root {
    --qf-blue: #2563eb;
    --qf-blue-dark: #1d4ed8;
    --qf-blue-ink: #1e40af;
    --qf-blue-soft: #dbeafe;
    --qf-blue-faint: #eff6ff;
    --qf-line: #9ca3af; /* gray-400 — the grid hairline */
    --qf-line-soft: #d1d5db; /* gray-300 — input + divider */
    --qf-bg: #f3f4f6;
    --qf-bg-soft: #f9fafb;
    --qf-ink: #111827;
    --qf-ink-2: #374151;
    --qf-muted: #6b7280;
    --qf-radius: 0.25rem;
}

/* ── Shell ───────────────────────────────────────────────────────────────── */

.qf {
    color: var(--qf-ink-2);
    font-size: 0.75rem;
    line-height: 1.45;
}

/* Full-height working surface under the 70px PageHeader. Below 1024px the lock is
   released so the PAGE scrolls instead of trapping content inside clipped boxes. */
.qf-shell {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 70px);
    background: var(--qf-bg);
    padding: 0.5rem;
    gap: 0.5rem;
    min-width: 0;
}

@media (min-width: 1024px) {
    .qf-shell {
        height: calc(100vh - 70px);
        min-height: 0;
        overflow: hidden;
        padding: 0.6rem;
    }
}

.qf-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--qf-line);
    border-radius: var(--qf-radius);
    padding: 0.6rem;
}

/* Scrollbars. */
.qf-scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
}

    .qf-scroll::-webkit-scrollbar {
        width: 12px;
        height: 12px;
    }

    .qf-scroll::-webkit-scrollbar-track {
        background: #f1f5f9;
    }

    .qf-scroll::-webkit-scrollbar-thumb {
        background: #94a3b8;
        border-radius: 6px;
        border: 2px solid #f1f5f9;
    }

        .qf-scroll::-webkit-scrollbar-thumb:hover {
            background: #64748b;
        }

    .qf-scroll::-webkit-scrollbar-corner {
        background: #f1f5f9;
    }

/* ── Summary tiles ───────────────────────────────────────────────────────── */

.qf-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .qf-tiles {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .qf-tiles {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .qf-tiles-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.qf-tile {
    border: 1px solid var(--qf-line-soft);
    border-radius: var(--qf-radius);
    padding: 0.35rem 0.55rem;
    background: #fff;
    min-width: 0;
}

.qf-tile-label {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--qf-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qf-tile-value {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
}

.qf-tile-sub {
    font-size: 0.625rem;
    color: var(--qf-muted);
}

/* A tile that doubles as a filter (the follow-up buckets). */
.qf-tile-click {
    cursor: pointer;
}

.qf-tile-on {
    outline: 2px solid var(--qf-blue);
}

.qf-t-slate {
    background: #f8fafc;
    border-color: #cbd5e1;
}

    .qf-t-slate .qf-tile-value {
        color: #334155;
    }

.qf-t-blue {
    background: #eff6ff;
    border-color: #93c5fd;
}

    .qf-t-blue .qf-tile-value {
        color: #1d4ed8;
    }

.qf-t-green {
    background: #f0fdf4;
    border-color: #86efac;
}

    .qf-t-green .qf-tile-value {
        color: #15803d;
    }

.qf-t-amber {
    background: #fffbeb;
    border-color: #fcd34d;
}

    .qf-t-amber .qf-tile-value {
        color: #b45309;
    }

.qf-t-red {
    background: #fef2f2;
    border-color: #fca5a5;
}

    .qf-t-red .qf-tile-value {
        color: #b91c1c;
    }

.qf-t-indigo {
    background: #eef2ff;
    border-color: #a5b4fc;
}

    .qf-t-indigo .qf-tile-value {
        color: #4338ca;
    }

.qf-t-purple {
    background: #faf5ff;
    border-color: #d8b4fe;
}

    .qf-t-purple .qf-tile-value {
        color: #7e22ce;
    }

.qf-t-teal {
    background: #f0fdfa;
    border-color: #5eead4;
}

    .qf-t-teal .qf-tile-value {
        color: #0f766e;
    }

/* ── Bordered section (fieldset look from the register) ──────────────────── */

.qf-sec {
    border: 1px solid var(--qf-line);
    border-radius: var(--qf-radius);
    background: #fff;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.qf-sec-head {
    background: var(--qf-blue-soft);
    border-bottom: 1px solid var(--qf-line-soft);
    padding: 0.35rem 0.6rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.qf-sec-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--qf-blue-ink);
    margin: 0;
}

.qf-sec-head-gray {
    background: #f3f4f6;
}

    /* A gray header carries a plain title, not the blue one — set here rather than by an
       inline style on every heading, so night mode can restate it in one place. */
    .qf-sec-head-gray .qf-sec-title {
        color: var(--qf-ink-2);
    }

.qf-sec-body {
    padding: 0.6rem;
    min-height: 0;
    min-width: 0;
}

.qf-fieldset {
    border: 1px solid var(--qf-line);
    border-radius: var(--qf-radius);
    padding: 0.5rem;
    min-width: 0;
}

.qf-legend {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0 0.4rem;
    color: var(--qf-ink-2);
}

/* ── Filter bar ──────────────────────────────────────────────────────────── */

.qf-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.8rem;
    font-size: 0.7rem;
}

.qf-radioset {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--qf-line-soft);
    border-radius: var(--qf-radius);
    padding: 0.1rem 0.4rem;
    background: #fff;
    white-space: nowrap;
}

    .qf-radioset > span:first-child {
        font-weight: 600;
    }

    .qf-radioset label {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        cursor: pointer;
        user-select: none;
    }

.qf-fld {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

    .qf-fld > label {
        font-weight: 600;
        flex-shrink: 0;
    }

/* ── Form controls ───────────────────────────────────────────────────────── */

.qf-input,
.qf-select,
.qf-textarea {
    border: 1px solid var(--qf-line-soft);
    background: #fff;
    padding: 0.22rem 0.45rem;
    font-size: 0.72rem;
    color: var(--qf-ink);
    border-radius: var(--qf-radius);
    outline: none;
    width: 100%;
    min-width: 0;
}

.qf-textarea {
    resize: vertical;
}

    .qf-input:focus,
    .qf-select:focus,
    .qf-textarea:focus {
        border-color: var(--qf-blue);
        box-shadow: 0 0 0 2px rgba(37, 122, 235, 0.18);
    }

    .qf-input[readonly],
    .qf-input:disabled,
    .qf-select:disabled,
    .qf-textarea:disabled {
        background: #f3f4f6;
        color: var(--qf-muted);
        cursor: not-allowed;
    }

/* Key (required) fields carry a yellow tint. */
.qf-input-key {
    background: #fefce8;
}

    .qf-input-key[readonly] {
        background: #fefce8;
        color: var(--qf-ink);
        cursor: default;
    }

.qf-input-auto {
    background: #fefce8;
    font-style: italic;
    color: var(--qf-muted);
}

.qf-w-auto {
    width: auto;
}

/* Entry form: label on the left, control filling the rest — three columns wide. */
.qf-form-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 0.4rem 1.4rem;
}

@media (min-width: 640px) {
    .qf-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1100px) {
    .qf-form-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .qf-form-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.qf-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

    .qf-row > label {
        width: 96px;
        flex-shrink: 0;
        font-weight: 500;
        font-size: 0.7rem;
    }

    .qf-row.qf-row-wide > label {
        width: 120px;
    }

    .qf-row > .qf-input,
    .qf-row > .qf-select,
    .qf-row > .qf-textarea,
    .qf-row > .qf-ctl {
        flex: 1;
        min-width: 0;
    }

.qf-req {
    color: #ef4444;
    margin-left: 0.1rem;
}

/* Input with a trailing action button (the "pick" pattern from the PR screen). */
.qf-pick {
    position: relative;
    flex: 1;
    min-width: 0;
}

    .qf-pick .qf-input {
        padding-right: 1.9rem;
    }

.qf-pick-btn {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 1.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--qf-blue);
    color: #fff;
    border: 1px solid var(--qf-blue);
    border-radius: 0 var(--qf-radius) var(--qf-radius) 0;
    cursor: pointer;
    font-weight: 700;
}

    .qf-pick-btn:hover {
        background: var(--qf-blue-dark);
    }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.qf-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: var(--qf-radius);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.4;
    background: #fff;
    color: var(--qf-ink-2);
    transition: background-color 0.12s ease;
}

    .qf-btn:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

/* An anchor styled as a button has no disabled state of its own — this is how one is shown as
   unavailable, alongside dropping its href so it cannot be followed. */
.qf-btn-off {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.qf-btn-xs {
    padding: 0.1rem 0.4rem;
    font-size: 0.625rem;
}

/* Slim action-bar button: same width and text size as .qf-btn, less height. */
.qf-btn-sm {
    padding: 0.08rem 0.6rem;
    line-height: 1.2;
}

.qf-btn-lg {
    padding: 0.4rem 0.9rem;
    font-size: 0.78rem;
}

.qf-btn-primary {
    background: var(--qf-blue);
    border-color: var(--qf-blue-dark);
    color: #fff;
}

    .qf-btn-primary:hover:not(:disabled) {
        background: var(--qf-blue-dark);
    }

.qf-btn-success {
    background: #16a34a;
    border-color: #15803d;
    color: #fff;
}

    .qf-btn-success:hover:not(:disabled) {
        background: #15803d;
    }

.qf-btn-danger {
    background: #ef4444;
    border-color: #dc2626;
    color: #fff;
}

    .qf-btn-danger:hover:not(:disabled) {
        background: #dc2626;
    }

.qf-btn-warn {
    background: #f59e0b;
    border-color: #d97706;
    color: #fff;
}

    .qf-btn-warn:hover:not(:disabled) {
        background: #d97706;
    }

.qf-btn-neutral {
    background: #6b7280;
    border-color: #4b5563;
    color: #fff;
}

    .qf-btn-neutral:hover:not(:disabled) {
        background: #4b5563;
    }

.qf-btn-purple {
    background: #7c3aed;
    border-color: #6d28d9;
    color: #fff;
}

    .qf-btn-purple:hover:not(:disabled) {
        background: #6d28d9;
    }

.qf-btn-teal {
    background: #0d9488;
    border-color: #0f766e;
    color: #fff;
}

    .qf-btn-teal:hover:not(:disabled) {
        background: #0f766e;
    }

.qf-btn-wa {
    background: #25d366;
    border-color: #1ea952;
    color: #06331a;
    font-weight: 600;
}

    .qf-btn-wa:hover:not(:disabled) {
        background: #1ea952;
        color: #fff;
    }

.qf-btn-ghost {
    background: #fff;
    border-color: var(--qf-line-soft);
    color: var(--qf-ink-2);
}

    .qf-btn-ghost:hover:not(:disabled) {
        background: #f3f4f6;
    }

.qf-btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */

.qf-grid {
    border: 1px solid var(--qf-line);
    border-radius: var(--qf-radius);
    max-width: 100%;
    min-width: 0;
    overflow: auto;
    max-height: 46vh;
    min-height: 140px;
}

@media (min-width: 1024px) {
    .qf-grid {
        max-height: none;
        flex: 1;
        min-height: 150px;
    }
}

.qf-grid-fixed-sm {
    max-height: 30vh;
    min-height: 110px;
    flex: none;
}

.qf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}

    .qf-table thead {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .qf-table thead th {
        background: #e5e7eb;
        border: 1px solid var(--qf-line);
        padding: 0.3rem 0.5rem;
        font-weight: 600;
        text-align: left;
        white-space: nowrap;
        color: var(--qf-ink);
    }

    .qf-table tbody td {
        border: 1px solid var(--qf-line);
        padding: 0.25rem 0.5rem;
        vertical-align: middle;
    }

    .qf-table tbody tr:hover {
        background: var(--qf-blue-faint);
    }

    .qf-table tbody tr.qf-sel,
    .qf-table tbody tr.qf-sel:hover {
        background: var(--qf-blue-soft);
    }

    .qf-table tfoot {
        position: sticky;
        bottom: 0;
        z-index: 10;
    }

        .qf-table tfoot td {
            background: #e5e7eb;
            border: 1px solid var(--qf-line);
            padding: 0.3rem 0.5rem;
            font-weight: 600;
        }

.qf-th-sort {
    cursor: pointer;
    user-select: none;
}

    .qf-th-sort:hover {
        background: #d1d5db;
    }

/* Inline column-search row under the header. */
.qf-searchrow td {
    background: #dbeafe;
    padding: 0.15rem 0.25rem !important;
}

.qf-colsearch {
    width: 100%;
    background: transparent;
    border: 0;
    font-size: 0.68rem;
    outline: none;
    color: var(--qf-ink);
}

    .qf-colsearch::placeholder {
        color: #64748b;
    }

.qf-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.qf-mid {
    text-align: center;
}

.qf-nowrap {
    white-space: nowrap;
}

.qf-strong {
    font-weight: 600;
}

.qf-link {
    color: var(--qf-blue-dark);
    font-weight: 600;
    cursor: pointer;
}

    .qf-link:hover {
        text-decoration: underline;
    }

.qf-empty {
    text-align: center;
    color: #9ca3af;
    padding: 1.6rem 0.5rem;
}

/* Cell-level editors inside a grid row (editable line items). */
.qf-cell-input {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.7rem;
    padding: 0.1rem 0.25rem;
    outline: none;
    color: var(--qf-ink);
    border-radius: 2px;
}

    .qf-cell-input:hover {
        border-color: var(--qf-line-soft);
    }

    .qf-cell-input:focus {
        border-color: var(--qf-blue);
        background: #fff;
    }

    .qf-cell-input.qf-num {
        text-align: right;
    }

/* ── Status chips ────────────────────────────────────────────────────────── */

.qf-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 600;
    white-space: nowrap;
    background: #f3f4f6;
    color: #4b5563;
}

.qf-chip-draft {
    background: #f1f5f9;
    color: #475569;
}

.qf-chip-sent {
    background: #dbeafe;
    color: #1d4ed8;
}

.qf-chip-viewed {
    background: #e0e7ff;
    color: #4338ca;
}

.qf-chip-accepted {
    background: #dcfce7;
    color: #15803d;
}

.qf-chip-rejected {
    background: #fee2e2;
    color: #b91c1c;
}

.qf-chip-changes {
    background: #ffedd5;
    color: #c2410c;
}

.qf-chip-expired {
    background: #f3f4f6;
    color: #6b7280;
}

.qf-chip-converted {
    background: #ccfbf1;
    color: #0f766e;
}

.qf-chip-paid {
    background: #dcfce7;
    color: #15803d;
}

.qf-chip-partial {
    background: #fef9c3;
    color: #a16207;
}

.qf-chip-due {
    background: #fff7ed;
    color: #c2410c;
}

.qf-chip-overdue {
    background: #fee2e2;
    color: #b91c1c;
}

.qf-chip-upcoming {
    background: #e0f2fe;
    color: #0369a1;
}

.qf-chip-done {
    background: #dcfce7;
    color: #15803d;
}

/* Channel pills for follow-ups. */
.qf-ch {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.05rem 0.35rem;
    border-radius: var(--qf-radius);
}

.qf-ch-wa {
    background: #dcfce7;
    color: #15803d;
}

.qf-ch-em {
    background: #dbeafe;
    color: #1d4ed8;
}

.qf-ch-cl {
    background: #ede9fe;
    color: #6d28d9;
}

/* ── Pager strip ─────────────────────────────────────────────────────────── */

.qf-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    row-gap: 0.25rem;
    border: 1px solid var(--qf-line-soft);
    border-radius: var(--qf-radius);
    background: var(--qf-bg-soft);
    font-size: 0.7rem;
    flex-shrink: 0;
}

@media (min-width: 1024px) {
    .qf-pager {
        flex-wrap: nowrap;
        justify-content: space-between;
    }
}

.qf-pager-info {
    color: var(--qf-muted);
    padding: 0.25rem 0.7rem;
    white-space: nowrap;
}

.qf-pager-btns {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem;
    padding: 0.25rem 0.7rem;
    flex: 1;
    justify-content: center;
}

.qf-pg {
    padding: 0.1rem 0.45rem;
    border: 1px solid var(--qf-line-soft);
    border-radius: var(--qf-radius);
    background: #fff;
    cursor: pointer;
}

    .qf-pg:hover:not(:disabled) {
        background: #f3f4f6;
    }

    .qf-pg:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

    .qf-pg.qf-pg-on {
        background: var(--qf-blue);
        border-color: var(--qf-blue);
        color: #fff;
    }

/* ── Two-panel entry screen (left list + right form) ─────────────────────── */

.qf-split {
    display: flex;
    min-height: 0;
    flex: 1;
    gap: 0;
}

.qf-side {
    width: 290px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid var(--qf-line);
    border-radius: var(--qf-radius);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: width 0.2s ease;
    min-height: 0;
}

    .qf-side.qf-side-off {
        width: 2.2rem;
    }

/* Sits just inside the panel's right edge, not hanging off it: .qf-side clips its
   overflow so the collapse animation stays clean, and a hanging button would be cut. */
.qf-side-toggle {
    position: absolute;
    right: 0.25rem;
    top: 0.4rem;
    z-index: 20;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: var(--qf-blue);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    font-size: 0.65rem;
}

    .qf-side-toggle:hover {
        background: var(--qf-blue-dark);
    }

.qf-side-filter {
    /* Right padding leaves room for the collapse button pinned in the corner. */
    padding: 0.6rem 2rem 0.6rem 0.6rem;
    border-bottom: 1px solid var(--qf-line-soft);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.qf-side-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border-bottom: 1px solid var(--qf-line-soft);
}

.qf-side-item {
    padding: 0.35rem 0.55rem;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    font-size: 0.7rem;
}

    .qf-side-item:hover {
        background: #f3f4f6;
    }

    .qf-side-item.qf-sel {
        background: var(--qf-blue);
        color: #fff;
    }

        .qf-side-item.qf-sel .qf-side-item-sub {
            color: #dbeafe;
        }

.qf-side-item-main {
    font-weight: 600;
}

.qf-side-item-sub {
    color: var(--qf-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.3rem;
}

.qf-side-foot {
    padding: 0.35rem 0.5rem;
    background: #f3f4f6;
    font-size: 0.65rem;
    color: var(--qf-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.3rem;
    flex-shrink: 0;
}

.qf-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-left: 0.5rem;
    gap: 0.5rem;
}

@media (max-width: 1023px) {
    .qf-split {
        flex-direction: column;
    }

    .qf-side {
        width: 100%;
        max-height: 45vh;
    }

        .qf-side.qf-side-off {
            width: 100%;
            max-height: 2.6rem;
        }

    .qf-main {
        margin-left: 0;
        margin-top: 0.75rem;
    }
}

/* ── Dashboard bits ──────────────────────────────────────────────────────── */

.qf-cols {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 0.6rem;
    min-height: 0;
}

@media (min-width: 1024px) {
    .qf-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .qf-cols-3 {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .qf-cols-21 {
        grid-template-columns: 2fr 1fr;
    }
}

.qf-quick {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .qf-quick {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.qf-quick-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--qf-line-soft);
    border-radius: var(--qf-radius);
    background: #fff;
    cursor: pointer;
    text-align: left;
    color: var(--qf-ink-2);
    font-size: 0.72rem;
    font-weight: 600;
    transition: border-color 0.12s, background 0.12s;
}

    .qf-quick-btn:hover {
        border-color: var(--qf-blue);
        background: var(--qf-blue-faint);
    }

.qf-quick-ico {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: var(--qf-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.qf-ico-blue {
    background: var(--qf-blue);
}

.qf-ico-green {
    background: #16a34a;
}

.qf-ico-purple {
    background: #7c3aed;
}

.qf-ico-amber {
    background: #f59e0b;
}

.qf-ico-teal {
    background: #0d9488;
}

.qf-ico-red {
    background: #ef4444;
}

/* Simple CSS bar strip — the dashboard "trend" without pulling in a chart lib. */
.qf-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    height: 92px;
    padding: 0.3rem 0.2rem 0;
}

.qf-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-width: 0;
}

.qf-bar {
    width: 100%;
    background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
}

.qf-bar-alt {
    background: linear-gradient(180deg, #6ee7b7 0%, #059669 100%);
}

.qf-bar-lbl {
    font-size: 0.6rem;
    color: var(--qf-muted);
    white-space: nowrap;
}

/* Legend key. Shares .qf-bar so it can never drift from the bars it explains. */
.qf-swatch {
    width: 9px;
    height: 9px;
    min-height: 0;
    border-radius: 2px;
    display: inline-block;
}

/* Progress meter — e.g. paid vs due. */
.qf-meter {
    height: 6px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
    min-width: 60px;
}

.qf-meter-fill {
    height: 100%;
    background: #16a34a;
}

.qf-meter-fill-warn {
    background: #f59e0b;
}

.qf-meter-fill-bad {
    background: #ef4444;
}

/* ── Totals block (document footer) ───────────────────────────── */

.qf-totals {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 260px;
    font-size: 0.72rem;
}

.qf-total-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.15rem 0;
}

    .qf-total-line span:last-child {
        font-variant-numeric: tabular-nums;
        font-weight: 600;
    }

.qf-total-grand {
    border-top: 2px solid var(--qf-line);
    margin-top: 0.2rem;
    padding-top: 0.3rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--qf-blue-ink);
}

/* A typed figure sitting in the totals column — shipping and adjustment. Sized to line up
   with the computed amounts above it, so the column still reads as one stack of numbers. */
.qf-total-input {
    width: 110px;
    flex: none;
    text-align: right;
    font-size: 0.72rem;
    padding: 0.1rem 0.3rem;
    font-variant-numeric: tabular-nums;
}

/* ── Line discount: one figure plus the switch that says how to read it ──── */

.qf-disc-cell {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

    .qf-disc-cell .qf-cell-input {
        flex: 1;
        min-width: 0;
    }

.qf-disc-mode {
    flex: none;
    min-width: 30px;
    border: 1px solid var(--qf-line);
    background: #f1f5f9;
    color: #475569;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.2rem 0.25rem;
    border-radius: 3px;
    cursor: pointer;
}

    .qf-disc-mode:hover:not(:disabled) {
        background: #e2e8f0;
    }

    /* A fixed discount is the unusual one, so it is the one that looks different — a glance
       down the column shows which lines are taking an amount off rather than a percentage. */
    .qf-disc-mode.qf-disc-fixed {
        background: #fef3c7;
        border-color: #fcd34d;
        color: #92400e;
    }

    .qf-disc-mode:disabled {
        cursor: default;
        opacity: 0.55;
    }

/* ── Line type badge ─────────────────────────────────────────────────────── */

.qf-tag {
    display: inline-block;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.12rem 0.3rem;
    border-radius: 2px;
    vertical-align: middle;
}

.qf-tag-prd {
    background: #e0e7ff;
    color: #3730a3;
}

.qf-tag-svc {
    background: #ccfbf1;
    color: #0f766e;
}

.qf-tag-cus {
    background: #fae8ff;
    color: #86198f;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */

.qf-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    border-bottom: 1px solid var(--qf-line-soft);
}

.qf-tab {
    padding: 0.3rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--qf-muted);
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--qf-radius) var(--qf-radius) 0 0;
    cursor: pointer;
    margin-bottom: -1px;
}

    .qf-tab:hover {
        color: var(--qf-ink);
        background: #f3f4f6;
    }

    .qf-tab.qf-tab-on {
        background: #fff;
        color: var(--qf-blue-ink);
        border-color: var(--qf-line-soft);
        border-bottom: 1px solid #fff;
    }

/* ── Modal ───────────────────────────────────────────────────────────────── */

.qf-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
}

.qf-modal {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
    width: min(980px, 96vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.qf-modal-sm {
    width: min(560px, 96vw);
}

.qf-modal-head {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--qf-line-soft);
    background: #f3f4f6;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.qf-modal-title {
    font-size: 0.8rem;
    font-weight: 700;
    margin: 0;
}

.qf-modal-x {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: #ef4444;
    cursor: pointer;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: var(--qf-radius);
}

    .qf-modal-x:hover {
        background: #fef2f2;
    }

.qf-modal-body {
    padding: 0.75rem;
    overflow: auto;
    min-height: 0;
}

.qf-modal-foot {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--qf-line-soft);
    background: var(--qf-bg-soft);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ── Misc helpers ────────────────────────────────────────────────────────── */

.qf-muted {
    color: var(--qf-muted);
}

/* Money semantics. Classes rather than inline styles, because an inline colour is the one
   thing night mode cannot restyle — it always wins over a stylesheet. */
.qf-pos {
    color: #15803d; /* received / settled */
}

.qf-neg {
    color: #b91c1c; /* outstanding / overdue */
}

.qf-warn {
    color: #b45309; /* deductions */
}

.qf-ink-danger {
    color: #ef4444;
}

.qf-mini {
    font-size: 0.65rem;
}

.qf-push {
    margin-left: auto;
}

.qf-hr {
    border: 0;
    border-top: 1px solid var(--qf-line-soft);
    margin: 0.5rem 0;
}

.qf-note {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e40af;
    border-radius: var(--qf-radius);
    padding: 0.4rem 0.6rem;
    font-size: 0.68rem;
}

.qf-note-warn {
    border-color: #fcd34d;
    background: #fffbeb;
    color: #92400e;
}

.qf-flex {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.qf-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.qf-avatar {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 999px;
    background: #c7d2fe;
    color: #3730a3;
    font-size: 0.6rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Wide item grids scroll inside their own box rather than pushing the page. */
.qf-table-wide {
    min-width: 1180px;
}

.qf-table-xwide {
    min-width: 1500px;
}

/* ── Public page shell (no sidebar — sign-up and other anonymous pages) ───── */

.qf-public {
    min-height: 100vh;
    background: #eef2f7;
    padding: 1.5rem 1rem;
}

.qf-paper {
    width: min(900px, 100%);
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--qf-line-soft);
    border-radius: 0.5rem;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.qf-paper-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.2rem 1.4rem;
    border-bottom: 3px solid var(--qf-blue);
}

.qf-paper-body {
    padding: 1.2rem 1.4rem;
}

.qf-paper-foot {
    padding: 1rem 1.4rem;
    background: var(--qf-bg-soft);
    border-top: 1px solid var(--qf-line-soft);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.qf-brand {
    width: 46px;
    height: 46px;
    border-radius: 0.4rem;
    background: var(--qf-blue);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

