/* ============================================================
   Rosinad Invoicing — stylesheet

   Theming: every colour below is a CSS variable. The default
   (Rosinad) palette lives in :root; alternative themes are
   :root[data-theme="..."] override blocks at the end of this
   file. base.html stamps data-theme on <html>, so swapping the
   attribute re-skins the whole app. When adding a colour, reach
   for a variable — hardcoded hex won't follow the theme.

     --red          accent (brand colour; name kept for legacy)
     --on-accent    text/icon on top of the accent (buttons, badges)
     --dark         headings / strong text
     --body         body text
     --muted        secondary text (hints, subtitles)
     --muted-2      faintest text (footer, faint hints)
     --bg           page background + cards + inputs
     --card         panels/inputs that must read as "raised"
     --surface      secondary surface (sidebar, thead, footer)
     --border       hairlines
     --accent-soft  tint of the accent (active nav, drop hover)
     --row-hover / --row-alt   table zebra + hover
   ============================================================ */

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

:root {
    --red:        #2C9200;
    --on-accent:  #ffffff;
    --dark:       #272727;
    --body:       #4a4a4a;
    --muted:      #666666;
    --muted-2:    #999999;
    --bg:         #ffffff;
    --card:       #ffffff;
    --surface:    #f5f5f5;
    --border:     #e0e0e0;
    --accent-soft:#eef7e9;
    --row-hover:  #fafafa;
    --row-alt:    #f9f9f9;
    --shadow: 0 1px 4px rgba(0,0,0,.08);
    /* Semantic status tokens — the SINGLE source for "positive / warning /
       danger" anywhere in the app. Pull these; never hardcode a new hex.
       --ok follows the theme accent so the app shows one green (blue on Ocean,
       etc.); --warn / --danger stay fixed so amber still means caution and red
       still means error on every theme. *-soft are the pale banner fills. */
    --ok:          var(--red);
    --ok-soft:     var(--accent-soft);
    --warn:        #e67e22;
    --warn-soft:   #fff8e1;
    --danger:      #c0392b;
    --danger-soft: #fdecea;
    --radius: 4px;
    --font: BlinkMacSystemFont, -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--body);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--red);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ── Header ─────────────────────────────────────────────── */

.site-header {
    background: var(--bg);
    border-bottom: 2px solid var(--red);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.header-logo img {
    height: 48px;
    width: auto;
    max-width: 260px;      /* keep a wide wordmark from crowding out the nav */
    object-fit: contain;
    display: block;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    list-style: none;
}

/* Hamburger toggle — hidden on desktop, shown on mobile. */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--dark);
    padding: 4px;
    line-height: 0;
}

.header-nav a {
    color: var(--dark);
    font-size: 14px;
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: border-color .15s, color .15s;
    text-decoration: none;
}
.header-nav a:hover,
.header-nav a.active {
    color: var(--red);
    border-bottom-color: var(--red);
}

.header-nav form button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--dark);
    font-size: 14px;
    font-weight: 500;
    padding: 4px 0;
    font-family: var(--font);
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.header-nav form button:hover {
    color: var(--red);
    border-bottom-color: var(--red);
}

/* Mobile: collapse the nav into a hamburger dropdown (top-right). */
@media (max-width: 768px) {
    .nav-toggle { display: inline-flex; }
    .header-nav {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        min-width: 210px;
        background: var(--bg);
        border: 1px solid var(--border);
        border-top: 2px solid var(--red);
        box-shadow: var(--shadow);
        padding: 6px 0;
        z-index: 200;
    }
    .header-nav.open { display: flex; }
    .header-nav li { width: 100%; }
    .header-nav a,
    .header-nav form,
    .header-nav form button {
        display: block;
        width: 100%;
        text-align: left;
    }
    .header-nav a,
    .header-nav form button {
        padding: 11px 18px;
        border-bottom: none;
        font-size: 15px;
    }
    .header-nav a.active {
        color: var(--red);
        background: var(--accent-soft);
        border-bottom: none;
    }
    .header-nav a:hover,
    .header-nav form button:hover { border-bottom: none; }
}

/* ── Demo deployment cues ────────────────────────────────── */

.demo-banner {
    background: #fff3cd;
    color: #7a5b00;
    border-bottom: 1px solid #ffe08a;
    text-align: center;
    font-size: 12.5px;
    font-weight: 500;
    padding: 6px 16px;
}
.demo-banner strong { color: #5c4400; }

.demo-tag {
    display: inline-block;
    vertical-align: middle;
    background: #fff3cd;
    color: #7a5b00;
    border: 1px solid #ffe08a;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 1px 6px;
}
.demo-hint {
    background: #fff8e1;
    color: #7a5b00;
    border: 1px solid #ffe08a;
    border-radius: var(--radius);
    font-size: 12.5px;
    line-height: 1.5;
    text-align: center;
    padding: 10px 14px;
    margin-bottom: 16px;
}
.demo-hint strong { color: #5c4400; }

/* ── Main layout ─────────────────────────────────────────── */

.site-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

.page-with-sidebar {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    max-width: 1500px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
    width: 190px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.sidebar-title {
    background: var(--surface);
    color: var(--red);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 10px 14px;
    border-bottom: 2px solid var(--red);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.sidebar-title-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.filter-reset {
    color: var(--red);
    opacity: .7;
    display: inline-flex;
    flex-shrink: 0;
    transition: opacity .15s;
}
.filter-reset:hover { opacity: 1; }
.filter-collapse {
    color: var(--red);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    opacity: .7;
    display: inline-flex;
    transition: opacity .15s;
}
.filter-collapse:hover { opacity: 1; }

.sidebar-body {
    padding: 14px;
}

.sidebar-body label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 4px;
    margin-top: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.sidebar-body label:first-of-type {
    margin-top: 0;
}

.sidebar-body select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--bg);
    color: var(--body);
    font-family: var(--font);
}
.sidebar-body select[multiple] {
    height: 120px;
}

.filter-summary {
    margin-top: 14px;
    font-size: 11px;
    color: var(--muted);
    text-align: center;
}
.filter-summary .fs-count {
    color: var(--red);
}
.btn-mark-paid {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 8px;
    text-align: center;
    background: transparent;
    color: var(--red);
    border: 1px solid var(--red);
    font-weight: 600;
}
.btn-mark-paid:hover {
    background: var(--red);
    color: var(--on-accent);
    opacity: 1;
}

/* ── Content area ────────────────────────────────────────── */

.content-area {
    flex: 1;
    min-width: 0;
}

/* ── Invoices page layout ────────────────────────────────────
   Grid so the table can break out to full width below the
   filters + drop zone (especially on mobile). On desktop the
   filters span the left column; the head (title + drop zone)
   and the table stack on the right. */
.invoices-layout {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    /* Head sized to its content; the table row absorbs any extra height the
       taller sidebar would otherwise dump as a gap under the drop zone. */
    grid-template-rows: min-content 1fr;
    grid-template-areas:
        "sidebar head"
        "sidebar table";
    align-items: start;
}
.invoices-layout > .sidebar      { grid-area: sidebar; }
.invoices-layout > .content-head { grid-area: head; min-width: 0; }
.invoices-layout > .table-wrap,
.invoices-layout > .empty-state  { grid-area: table; }

/* Collapsed filters — sidebar hidden, table claims the full width */
.filters-show-btn {
    display: none;
    align-items: center;
    gap: 5px;
    width: max-content;
    margin-bottom: 12px;
    padding: 5px 11px;
    background: transparent;
    color: var(--red);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
}
.filters-show-btn:hover { background: var(--red); color: var(--on-accent); }

.invoices-layout.filters-collapsed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "head"
        "table";
}
.invoices-layout.filters-collapsed > .sidebar { display: none; }
.invoices-layout.filters-collapsed .filters-show-btn { display: inline-flex; }

@media (max-width: 768px) {
    /* Filters and the drop zone sit side by side at equal height; the
       invoices table drops below and uses the full screen width. The filter
       card is kept compact so the top row doesn't push the table off-screen. */
    .invoices-layout {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "sidebar head"
            "table   table";
        align-items: stretch;
        gap: 10px;
        padding: 12px 10px;
    }
    .invoices-layout > .sidebar { width: auto; }

    /* Compact filter form */
    .invoices-layout .sidebar-title { padding: 7px 10px; font-size: 12px; }
    .invoices-layout .sidebar-body { padding: 10px; }
    .invoices-layout .sidebar-body label { margin-top: 8px; font-size: 11px; }
    .invoices-layout .sidebar-body input,
    .invoices-layout .sidebar-body select { padding: 5px 7px; font-size: 12px; }
    /* iOS renders <select multiple> tall regardless of CSS height; the size="4"
       attribute on the element plus this cap keep it short. */
    .invoices-layout .sidebar-body select[multiple] {
        height: 84px !important;
        min-height: 0;
        font-size: 12px;
    }
    .invoices-layout .sidebar-body .btn-apply { margin-top: 12px; padding: 8px; }

    .invoices-layout > .content-head {
        display: flex;
        flex-direction: column;
    }
    .invoices-layout > .content-head .page-title { font-size: 18px; margin-bottom: 8px; }
    .invoices-layout > .content-head .btn-primary { margin-bottom: 10px !important; }
    /* Drop zone grows to fill the column so it matches the filters' height. */
    .invoices-layout > .content-head .drop-zone {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        margin-bottom: 0;
        padding: 0.75rem;
    }
    .invoices-layout > .content-head .drop-zone p { margin: 2px 0; font-size: 13px; }
    .invoices-layout > .content-head .drop-zone .drop-hint { font-size: 11px; }
    .invoices-layout > .content-head .drop-zone.drop-zone-prominent { padding: 0.75rem; }

    /* Make the table readable full-width below */
    .invoices-layout > .table-wrap { font-size: 12px; }
}

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

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
}

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

.btn {
    display: inline-block;
    padding: 7px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: var(--font);
    transition: opacity .15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover {
    opacity: .88;
    text-decoration: none;
}

.btn-primary {
    background: var(--red);
    color: var(--on-accent);
}
.btn-secondary {
    background: var(--surface);
    color: var(--dark);
    border: 1px solid var(--border);
}
.btn-warning {
    background: var(--warn);
    color: #fff;
}
/* Per-row "mark as paid" action — red pill, PAY!. */
.btn-pay {
    background: var(--danger);
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.btn-pay:hover { opacity: .9; }
.btn-danger {
    background: var(--danger);
    color: #fff;
    border: 1px solid #a93226;
}
.btn-danger:hover { background: #a93226; }

/* Confirmation dialog (reusable) — themed via the tokens above */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: color-mix(in srgb, var(--dark) 55%, transparent);
}
.confirm-overlay[hidden] { display: none; }
.confirm-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,.25);
    padding: 22px 24px;
    max-width: 420px;
    width: 100%;
}
.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}
.btn-apply {
    width: 100%;
    margin-top: 14px;
    text-align: center;
    background: var(--red);
    color: var(--on-accent);
}

/* ── Table ───────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: var(--surface);
    color: var(--dark);
    font-weight: 700;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.sort-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
.sort-link:hover { color: var(--red); }
.sort-link.sort-active { color: var(--red); }
.sort-arrow { font-size: 11px; }

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
tbody tr:last-child {
    border-bottom: none;
}
tbody tr:hover {
    background: var(--row-hover);
}
tbody tr:nth-child(even) {
    background: var(--row-alt);
}
tbody tr:nth-child(even):hover {
    background: var(--surface);
}

td {
    padding: 8px 10px;
    vertical-align: middle;
}

.paid-badge {
    color: var(--red);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.number-link {
    color: var(--dark);
    font-weight: 700;
    text-decoration: none;
}
.number-link:hover { text-decoration: underline; }

/* ── PDF / file icon ─────────────────────────────────────── */

.file-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--dark);
    font-weight: 700;
}
.file-icon:hover {
    text-decoration: underline;
}

.file-icon svg {
    width: 20px;
    height: 20px;
    fill: #ED1C24;
    flex-shrink: 0;
}

/* File row: icon + size + actions, all vertically centred on one line. */
.file-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.file-size {
    color: var(--muted-2);
    font-size: 12px;
}
.btn-file-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--red);
    background: transparent;
    border: 1px solid var(--red);
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.btn-file-action:hover { background: var(--red); color: var(--on-accent); }
.btn-file-action.is-copied { background: var(--red); color: var(--on-accent); }
.btn-file-icon { padding: 0; width: 26px; }
.btn-file-icon svg { width: 15px; height: 15px; fill: currentColor; }

/* Project label rendered as a click-to-edit badge on the invoice page:
   the same pill as in the list, with a pencil inside. */
.project-tag-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    font-family: inherit;
    cursor: pointer;
    padding: 3px 10px;
}
.project-tag-btn svg { width: 12px; height: 12px; fill: currentColor; opacity: .75; }
.project-tag-btn:hover { filter: brightness(1.12); }
.project-tag-btn:hover svg { opacity: 1; }

/* Paid toggle on the invoice page: green when already paid (click = unpay). */
.btn-pay.is-paid { background: var(--ok); }

/* Invoice view: details on the left, file preview on the right. */
.invoice-detail-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.detail-card-main { flex: 1 1 480px; }
.file-preview {
    flex: 0 0 auto;
    width: 300px;
    max-width: 100%;
}
.file-preview img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.file-preview a:hover img { box-shadow: 0 2px 10px rgba(0,0,0,.16); }

/* Audit diff: old value red, new value green (semantic, not theme-tied). */
.diff-old { color: var(--danger); }
.diff-new { color: var(--ok); font-weight: 600; }
.diff-arrow { color: var(--muted-2); }

/* ── Forms ───────────────────────────────────────────────── */

.form-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 560px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--body);
    font-family: var(--font);
    background: var(--bg);
    transition: border-color .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--red);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--red);
    cursor: pointer;
}
.form-check label {
    font-size: 14px;
    cursor: pointer;
    margin: 0;
}

.form-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.current-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
}

/* ── Alert / error ───────────────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 13px;
    border: 1px solid transparent;
}
.alert-error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}
.alert-success {
    background: var(--ok-soft);
    border-color: color-mix(in srgb, var(--ok) 40%, transparent);
    color: var(--ok);
}

/* ── Login page ──────────────────────────────────────────── */

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 24px;
}

.login-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo img {
    /* Height-driven, but a wide logo (e.g. a 7:1 wordmark) must scale down to
       the card instead of overflowing it — hence the max-width cap. */
    height: 52px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: inline-block;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
    text-align: center;
    margin-bottom: 24px;
}

/* ── Account page ────────────────────────────────────────── */

.account-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    max-width: 480px;
}

.account-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    gap: 12px;
}
.account-row:last-child {
    border-bottom: none;
}
.account-label {
    font-weight: 600;
    color: var(--dark);
    width: 140px;
    flex-shrink: 0;
}
.account-value {
    color: var(--body);
}

.role-badge {
    display: inline-block;
    background: var(--red);
    color: var(--on-accent);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    margin-right: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ── Invoice view detail ─────────────────────────────────── */

.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    max-width: 640px;
    margin-bottom: 24px;
}

.detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    gap: 12px;
}
.detail-row:last-child {
    border-bottom: none;
}
.detail-label {
    font-weight: 600;
    color: var(--dark);
    width: 140px;
    flex-shrink: 0;
}
/* Let value cells shrink and wrap so long unbroken strings (e.g. the public
   status URL) don't overflow the card on narrow screens. */
.detail-row > :not(.detail-label) {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ── Status badge ────────────────────────────────────────── */

.status-active   { color: var(--ok); font-weight: 600; }
.status-inactive { color: #e74c3c; font-weight: 600; }

/* ── Footer ──────────────────────────────────────────────── */

.site-footer {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--muted-2);
    background: var(--surface);
}

/* ── Utilities ───────────────────────────────────────────── */

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }

/* ── Drop zone ───────────────────────────────────────────── */

.drop-zone {
    border: 2px dashed var(--red);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 1rem;
}
.drop-zone:hover,
.drop-zone.drag-over {
    background: var(--accent-soft);
}
.drop-zone-prominent {
    padding: 3rem 2rem;
}
.drop-zone-inner .drop-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}
.drop-hint {
    color: var(--muted-2);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* ── Quick panel ─────────────────────────────────────────── */

.quick-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.quick-panel h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1rem;
}
.extract-status {
    margin-bottom: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
    min-height: 1.2em;
}
.extract-status.success { color: var(--ok); }
.extract-status.error   { color: #c62828; }

/* Public upload page */
.upload-page {
    max-width: 600px;
    margin: 60px auto;
    padding: 0 24px;
}
.upload-page h1 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--dark);
}
.upload-subtitle {
    color: var(--muted);
    margin-bottom: 32px;
    line-height: 1.5;
}
.upload-field {
    margin-bottom: 14px;
}
.upload-field label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--dark);
}

/* Public invoice status page */
.status-page {
    max-width: 480px;
    margin: 60px auto;
    padding: 0 24px;
    text-align: center;
}
.status-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    margin: 40px auto 48px;
}
.status-circle-paid    { background: #22c55e; box-shadow: 0 0 60px 10px rgba(34,197,94,.45); }
.status-circle-pending { background: #f9a825; box-shadow: 0 0 60px 10px rgba(249,168,37,.45); }
.status-circle-missing { background: #ef4444; box-shadow: 0 0 60px 10px rgba(239,68,68,.45); }
.status-circle-rejected { background: #ef4444; box-shadow: 0 0 60px 10px rgba(239,68,68,.45); }
.status-title {
    font-size: 28px;
    margin: 0 0 8px;
    color: var(--dark);
}
.status-subtitle {
    color: var(--muted);
    margin-bottom: 32px;
}
.status-details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-align: left;
}
.status-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.status-detail-row:last-child { border-bottom: none; }
.status-detail-row span { color: var(--muted); }
.rejected-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}
tr.row-rejected { opacity: 0.55; }
tr.row-rejected td { text-decoration: line-through; }
tr.row-rejected td:first-child, tr.row-rejected td:last-child { text-decoration: none; }

/* ============================================================
   THEMES — override the variables defined in :root above.
   The default (Rosinad) palette IS :root, so data-theme="rosinad"
   needs no block. Light themes only restyle the accent; dark
   themes restyle the full neutral ramp. Keep this list in sync
   with THEMES in app/web/routes.py.
   ============================================================ */

/* ── Light ─────────────────────────────────────────────────── */

:root[data-theme="testonica"] {
    --red:         #003da6;   /* Testonica brand blue (site template) */
    --accent-soft: #e6edf8;
    --warn:        #f5a800;   /* their amber — used as the warning tone */
    --warn-soft:   #fdf3e0;
}
:root[data-theme="ocean"] {
    --red:         #0a6fb5;
    --accent-soft: #e6f2fb;
}
:root[data-theme="forest"] {
    --red:         #0f7a52;
    --accent-soft: #e4f4ee;
}
:root[data-theme="sunset"] {
    --red:         #e2580f;
    --accent-soft: #fdeee3;
}
:root[data-theme="royal"] {
    --red:         #6d28d9;
    --accent-soft: #f0e9fc;
}
:root[data-theme="graphite"] {
    --red:         #3f4756;
    --accent-soft: #eceef1;
}

/* ── Dark ──────────────────────────────────────────────────── */

:root[data-theme="midnight"] {
    --red:         #3b82f6;
    --on-accent:   #ffffff;
    --dark:        #e8eaed;
    --body:        #c2c7d0;
    --muted:       #98a0ad;
    --muted-2:     #6b7480;
    --bg:          #11151c;
    --card:        #1a1f29;
    --surface:     #1a1f29;
    --border:      #2b323d;
    --accent-soft: #1d2a44;
    --row-hover:   #1e2530;
    --row-alt:     #161b23;
    --shadow: 0 1px 4px rgba(0,0,0,.5);
}
:root[data-theme="carbon"] {
    --red:         #f5a623;
    --on-accent:   #1a1300;
    --dark:        #f0f0f0;
    --body:        #c9c9c9;
    --muted:       #9a9a9a;
    --muted-2:     #6a6a6a;
    --bg:          #141414;
    --card:        #1e1e1e;
    --surface:     #1e1e1e;
    --border:      #2f2f2f;
    --accent-soft: #2b2410;
    --row-hover:   #232323;
    --row-alt:     #181818;
    --shadow: 0 1px 4px rgba(0,0,0,.6);
}

/* ── Bulk selection + action bar (desktop only) ─────────────────────────── */
.bulk-col { width: 34px; text-align: center; padding-left: 8px; padding-right: 0; }
.bulk-col input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }

.bulk-bar {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 6px 24px rgba(0,0,0,.20);
    white-space: nowrap;
}
/* Class selector beats the [hidden] UA rule, so spell the hidden state out. */
.bulk-bar[hidden] { display: none; }
.bulk-bar .bulk-count { font-size: 14px; color: var(--muted-2); }
.bulk-bar .bulk-count strong { color: var(--dark); font-size: 15px; }
.bulk-actions { display: flex; align-items: center; gap: 10px; margin: 0; }
.bulk-move { display: inline-flex; align-items: center; gap: 6px; }
/* Uniform height so the count, buttons and input line up on one baseline. */
.bulk-bar .btn,
.bulk-bar .form-control {
    height: 36px;
    display: inline-flex;
    align-items: center;
    margin: 0;
    box-sizing: border-box;
}
.bulk-move .form-control { width: 160px; padding: 4px 12px; }
/* Mark Paid as a solid button (the .btn-mark-paid base is the outline,
   full-width sidebar variant — override it inside the bar). */
.bulk-bar .btn-mark-paid {
    width: auto;
    margin-top: 0;
    background: var(--red);
    color: var(--on-accent);
    border-color: var(--red);
}
.bulk-bar .btn-mark-paid:hover { opacity: .9; }

@media (max-width: 768px) {
    /* Bulk selection is a desktop-only convenience. */
    .bulk-col, .bulk-bar { display: none !important; }
}

/* ── Projects (registry + colour management) ────────────────────────────── */
/* Project label = a pill with a dark background + light text. */
.project-tag {
    display: inline-block;
    padding: 1px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12px;
    line-height: 1.6;
    white-space: nowrap;
}
a.project-tag { text-decoration: none; }
a.project-tag:hover { filter: brightness(1.12); }

.proj-new { margin-bottom: 18px; }
.proj-new > summary { display: inline-flex; list-style: none; cursor: pointer; }
.proj-new > summary::-webkit-details-marker { display: none; }
.proj-new[open] > summary { margin-bottom: 14px; }
.proj-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.proj-form label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .03em; }

.proj-preview-row { display: flex; align-items: center; gap: 12px; margin: 2px 0 16px; }
.proj-preview-cap { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.proj-preview { font-size: 14px; padding: 4px 16px; }

.swatch-grid { display: grid; grid-template-columns: repeat(16, 1fr); gap: 6px; max-width: 560px; }
.swatch-grid-64 { grid-template-columns: repeat(16, 1fr); gap: 4px; max-width: 620px; }
.swatch { position: relative; aspect-ratio: 1; border-radius: 4px; cursor: pointer; border: 1px solid rgba(0,0,0,.12); }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch:has(input:checked) { outline: 2px solid var(--dark); outline-offset: 2px; z-index: 1; }

.proj-list { display: flex; flex-direction: column; gap: 10px; }
.proj-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 12px 16px; }
.proj-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.proj-name { font-size: 14px; padding: 3px 14px; }
.proj-meta { color: var(--muted-2); font-size: 12px; }
a.proj-count { color: inherit; }
a.proj-count:hover { color: var(--red); text-decoration: underline; }
.proj-card-actions { margin-left: auto; display: flex; gap: 14px; }
.proj-toggle { font-size: 13px; font-weight: 600; cursor: pointer; }
.proj-clients { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border); color: var(--body); }
a.chip:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.proj-edit, .proj-del { margin-top: 12px; }

/* ── Audit feed ─────────────────────────────────────────────────────────── */
.audit-filter { display: flex; gap: 6px; }
.audit-pill { font-size: 13px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border);
    color: var(--body); background: var(--card); }
.audit-pill:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.audit-pill.active { background: var(--red); border-color: var(--red); color: var(--on-accent); }
.audit-table td { vertical-align: top; }
.audit-src { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); }
.audit-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.audit-dot-info { background: var(--muted-2); }
.audit-dot-warning { background: var(--warn); }
.audit-dot-error { background: var(--danger); }
.audit-row.audit-warning td { background: color-mix(in srgb, var(--warn) 7%, transparent); }
.audit-row.audit-error td { background: color-mix(in srgb, var(--danger) 7%, transparent); }
.audit-table td form { margin: 0; }

/* ── Dashboard (monthly financial breakdown) ─────────────────────────── */
.dash-period { display:flex; gap:8px; }
.dash-period select {
    padding:7px 10px; border:1px solid var(--border); border-radius:var(--radius);
    background:var(--card); color:var(--dark); font-size:14px; font-weight:600; cursor:pointer;
}
.dash-income  { color:var(--ok); font-weight:700; }
.dash-expense { color:var(--danger); font-weight:700; }
.dash-net     { font-weight:800; }
.is-pos .dash-net { color:var(--ok); }
.is-neg .dash-net { color:var(--danger); }

/* Grand total banner */
.dash-total {
    background:var(--card); border:1px solid var(--border); border-left:5px solid var(--ok);
    border-radius:var(--radius); padding:20px 22px; margin-bottom:22px; box-shadow:var(--shadow);
}
.dash-total.is-neg { border-left-color:var(--danger); }
.dash-total-head { display:flex; align-items:baseline; justify-content:space-between;
    flex-wrap:wrap; gap:8px; margin-bottom:14px; }
.dash-total-label { font-size:13px; font-weight:800; text-transform:uppercase;
    letter-spacing:.06em; color:var(--muted); }
.dash-total-meta { font-size:13px; color:var(--muted-2); }
.dash-total-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:18px; }
.dash-stat-label { font-size:12px; color:var(--muted); margin-bottom:4px; }
.dash-stat { font-size:26px; line-height:1.1; }

/* Per-project cards */
.dash-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:14px; }
.dash-card {
    background:var(--card); border:1px solid var(--border); border-top:3px solid var(--ok);
    border-radius:var(--radius); padding:14px 16px; box-shadow:var(--shadow);
}
.dash-card.is-neg { border-top-color:var(--danger); }
.dash-card-head { display:flex; align-items:center; justify-content:space-between;
    gap:8px; margin-bottom:10px; }
.dash-card-name { font-weight:700; color:var(--dark); overflow-wrap:anywhere; }
.dash-card-count { font-size:11px; font-weight:700; color:var(--muted-2);
    background:var(--surface); border:1px solid var(--border); border-radius:10px;
    padding:1px 8px; flex:none; }
.dash-card-rows { display:flex; flex-direction:column; gap:5px; margin-bottom:10px;
    padding-bottom:10px; border-bottom:1px solid var(--border); }
.dash-row { display:flex; justify-content:space-between; font-size:14px; }
.dash-row-label { color:var(--muted); }
.dash-card-net { font-size:21px; text-align:right; }

@media (max-width: 560px) {
    .dash-total-grid { grid-template-columns:1fr; gap:10px; }
    .dash-stat { font-size:22px; }
}
