/* ==========================================================================
   Office Finance — design system

   Restrained on purpose: neutral greys, one accent, borders and spacing doing
   the work instead of gradients and shadows. Numbers are the content here, so
   they get tabular figures and right alignment everywhere.
   ========================================================================== */

:root {
    --bg:            #ffffff;
    --bg-subtle:     #f7f8f9;
    --bg-sunken:     #f1f3f5;
    --surface:       #ffffff;
    --border:        #e3e6ea;
    --border-strong: #cfd4da;

    --text:          #16191d;
    --text-muted:    #616a75;
    --text-faint:    #8b939d;

    --accent:        #1f5f8b;
    --accent-soft:   #e8f0f6;
    --accent-text:   #1a5074;

    --positive:      #1a7f4b;
    --positive-soft: #e6f4ec;
    --negative:      #b3261e;
    --negative-soft: #fce8e6;
    --warning:       #8a5a00;
    --warning-soft:  #fdf3e0;

    --radius:        6px;
    --radius-sm:     4px;

    /* Numbers use the UI face with tabular figures rather than a code font.
       Monospace was making amounts look like terminal output; proportional-width
       digits are what finance software actually uses, and tabular-nums keeps
       columns aligned without the typewriter look. */
    --num: "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, sans-serif;
    --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, sans-serif;

    --sidebar-width: 212px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            #14171a;
        --bg-subtle:     #191d21;
        --bg-sunken:     #1e2328;
        --surface:       #1a1e22;
        --border:        #2b3138;
        --border-strong: #3a424b;

        --text:          #e8eaed;
        --text-muted:    #9aa4af;
        --text-faint:    #6e7883;

        --accent:        #6fb3dd;
        --accent-soft:   #1b2c38;
        --accent-text:   #8ec5e8;

        --positive:      #5cc98d;
        --positive-soft: #162a1f;
        --negative:      #f2857c;
        --negative-soft: #2e1a19;
        --warning:       #e0b063;
        --warning-soft:  #2b2317;
    }
}

:root[data-theme="dark"] {
    --bg:            #14171a;
    --bg-subtle:     #191d21;
    --bg-sunken:     #1e2328;
    --surface:       #1a1e22;
    --border:        #2b3138;
    --border-strong: #3a424b;
    --text:          #e8eaed;
    --text-muted:    #9aa4af;
    --text-faint:    #6e7883;
    --accent:        #6fb3dd;
    --accent-soft:   #1b2c38;
    --accent-text:   #8ec5e8;
    --positive:      #5cc98d;
    --positive-soft: #162a1f;
    --negative:      #f2857c;
    --negative-soft: #2e1a19;
    --warning:       #e0b063;
    --warning-soft:  #2b2317;
}

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

body {
    margin: 0;
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-subtle);
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }

/* --- Layout ------------------------------------------------------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 14px 12px 12px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.sidebar-brand .brand-text { flex: 1; min-width: 0; }
.sidebar-brand span.sub { color: var(--text-faint); font-weight: 400; display: block;
    font-size: 0.72rem; letter-spacing: 0.02em; text-transform: uppercase; margin-top: 2px; }

/* --- Sidebar collapse ----------------------------------------------------
   Collapsing hides the rail entirely rather than shrinking it to icons: this is
   a data-dense app, and the width is better spent on table columns. */
.sidebar-toggle {
    flex: 0 0 auto;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}
.sidebar-toggle:hover { background: var(--bg-sunken); color: var(--text); }

body.sidebar-hidden .sidebar { display: none; }

.sidebar-show {
    display: none;
    flex: 0 0 auto;
    width: 30px; height: 30px;
    align-items: center; justify-content: center;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 15px;
    margin-right: 4px;
}
.sidebar-show:hover { background: var(--bg-sunken); color: var(--text); }
body.sidebar-hidden .sidebar-show { display: flex; }

.nav { padding: 8px; flex: 1; overflow-y: auto; }
.nav-item {
    display: block;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.855rem;
    margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 500; }
.nav-section {
    padding: 14px 10px 5px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    font-weight: 600;
}

.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.topbar h1 { flex: 1; min-width: 200px; }
.topbar-sub { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; }

.content { padding: 20px 24px 60px; max-width: 1400px; width: 100%; }

/* --- Cards -------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.card-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.card-head h2, .card-head h3 { flex: 1; min-width: 140px; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

.hint { color: var(--text-muted); font-size: 0.82rem; margin: 0 0 12px; }
.hint:last-child { margin-bottom: 0; }

/* --- Stat tiles --------------------------------------------------------- */
.stats { display: grid; gap: 12px; margin-bottom: 16px; }
.stats-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stats-3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stats-4 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.stats-5 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 15px;
}
.stat-label {
    font-size: 0.735rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    font-weight: 600;
}
.stat-value {
    font-family: var(--num);
    font-size: 1.38rem;
    font-weight: 650;
    margin-top: 5px;
    font-variant-numeric: tabular-nums lining-nums;
    font-feature-settings: "tnum" 1, "lnum" 1;
    letter-spacing: -0.022em;
}
.stat-note { font-size: 0.775rem; color: var(--text-muted); margin-top: 3px; }
.stat.is-positive .stat-value { color: var(--positive); }
.stat.is-negative .stat-value { color: var(--negative); }
.stat.is-warning .stat-value { color: var(--warning); }
.stat.is-accent  .stat-value { color: var(--accent-text); }

/* --- Tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.855rem;
}
table.data th {
    text-align: left;
    padding: 9px 12px;
    font-size: 0.715rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--bg-subtle);
}
table.data td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-subtle); }
table.data tfoot td {
    padding: 10px 12px;
    font-weight: 600;
    border-top: 2px solid var(--border-strong);
    background: var(--bg-subtle);
}

.num {
    text-align: right;
    white-space: nowrap;
    font-family: var(--num);
    font-variant-numeric: tabular-nums lining-nums;
    font-feature-settings: "tnum" 1, "lnum" 1;
    font-size: 0.875rem;
    letter-spacing: -0.005em;
}
.num-strong { font-weight: 600; }
.pos { color: var(--positive); }
.neg { color: var(--negative); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 0.8rem; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Badges ------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 0.735rem;
    font-weight: 500;
    background: var(--bg-sunken);
    color: var(--text-muted);
    white-space: nowrap;
}
.badge-paid    { background: var(--positive-soft); color: var(--positive); }
.badge-open    { background: var(--warning-soft);  color: var(--warning); }
.badge-partial { background: var(--accent-soft);   color: var(--accent-text); }
.badge-void,
.badge-draft   { background: var(--bg-sunken);     color: var(--text-faint); }
.badge-overdue { background: var(--negative-soft); color: var(--negative); }
.badge-matched { background: var(--positive-soft); color: var(--positive); }
.badge-discrepancy { background: var(--negative-soft); color: var(--negative); }

/* Timing and kind read as annotations, not alerts — they sit beside a name and
   must never out-shout the amount in the next column. */
.badge-timing, .badge-kind {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    font-weight: 400;
}
.badge-kind-recurring { border-color: var(--accent); color: var(--accent-text); }

/* --- Staff category tags -------------------------------------------------
   Light fills, readable text, distinct hue per group so a glance down a column
   tells you who is who. Muted enough not to fight the numbers for attention. */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.735rem;
    font-weight: 550;
    white-space: nowrap;
    border: 1px solid transparent;
}
/* --- Dashboard month banner and hero ------------------------------------- */
.month-banner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface);
    margin-bottom: 14px;
    font-size: 0.865rem;
}

/* The one number worth reading from across the room. */
.hero {
    padding: 22px 24px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.hero-label {
    font-size: 0.735rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--accent-text); font-weight: 600;
}
.hero-value {
    font-family: var(--num); font-variant-numeric: tabular-nums lining-nums;
    font-size: 2.4rem; font-weight: 600; line-height: 1.15; margin: 4px 0;
    color: var(--text);
}
.hero-note { font-size: 0.8rem; color: var(--text-muted); }

.stats-6 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.stat.is-highlight { border-width: 2px; }

/* Invoice-status cards carry the same colour as the tag they summarise. */
.status-stat { border-top: 3px solid var(--border-strong); }
.pay-border-settled { border-top-color: var(--positive); }
.pay-border-part    { border-top-color: var(--warning); }
.pay-border-pending { border-top-color: var(--border-strong); }
.pay-border-overdue { border-top-color: var(--negative); }

/* --- Collapsible sections ------------------------------------------------ */
.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.section > summary {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 11px 15px;
    cursor: pointer;
    background: var(--bg-subtle);
    font-size: 0.875rem;
    list-style: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::before { content: "▸"; color: var(--text-faint); font-size: 0.7rem; }
.section[open] > summary::before { content: "▾"; }
.section > summary:hover { background: var(--bg-sunken); }
.section .table-wrap { border-top: 1px solid var(--border); }

/* --- Pill filters and card grids ---------------------------------------- */
.pill-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pill {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.845rem;
    background: var(--bg-sunken);
    color: var(--text-muted);
    white-space: nowrap;
}
.pill:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.pill.active { background: var(--accent); color: #fff; font-weight: 500; }
.pill .count { opacity: 0.75; margin-left: 4px; font-size: 0.78rem; }

.group-head {
    display: flex; align-items: baseline; gap: 10px;
    margin: 22px 0 10px;
}
.group-head h2 { font-size: 1rem; margin: 0; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 8px;
}

.client-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.client-card.is-archived { opacity: 0.62; }
.client-head h3 { margin: 0; font-size: 0.95rem; }
.client-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.agency-tag { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.client-meta { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

.client-figures { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.client-figures > div { display: flex; justify-content: space-between; align-items: baseline; }
.client-figures dt { color: var(--text-muted); font-size: 0.82rem; }
.client-figures dd {
    margin: 0; font-family: var(--num); font-variant-numeric: tabular-nums lining-nums;
    font-size: 0.875rem; font-weight: 500;
}
.client-foot { font-size: 0.76rem; }
.client-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; }
.client-actions .btn { font-size: 0.76rem; padding: 4px 9px; }

/* Past a target the bar changes colour rather than overflowing its track. */
.bar-fill.bar-over { background: var(--positive); }

/* The P&L reads top to bottom, so the rules and indents do the explaining. */
.pnl td { padding: 7px 14px; }
.pnl .indent { padding-left: 32px; color: var(--text-muted); }
.pnl .pnl-rule td { border-top: 1px solid var(--border-strong); }
.pnl .pnl-final td { border-bottom: 2px solid var(--border-strong); }
.pnl .pnl-aside td { padding-top: 12px; color: var(--text-muted); }
.pnl .pnl-section td { font-weight: 500; }
tr.row-current td { background: var(--accent-soft); }

/* Collapsible payroll breakdown: the arithmetic behind one person's pay. */
.btn-expand .chev { display: inline-block; width: 10px; font-size: 0.7rem; }
.breakdown { padding: 12px 4px 4px; max-width: 620px; }
.breakdown h4 { margin: 0 0 8px; font-size: 0.9rem; }
.breakdown-table td { border: 0; padding: 5px 10px; }
.breakdown-table tr.breakdown-total td { border-top: 1px solid var(--border-strong); }

/* Back sits before the heading, quiet enough to ignore when not needed. */
.btn-back {
    padding: 5px 10px;
    color: var(--text-muted);
    align-self: flex-start;
    white-space: nowrap;
}
.btn-back:hover { color: var(--text); }

/* The one-click settle control. Quiet until hovered — it writes to the ledger,
   so it should not look like the most inviting thing on the row. */
.settle-form { gap: 4px; align-items: center; }
.btn-settle { white-space: nowrap; }
.btn-settle:hover {
    background: var(--positive-soft);
    color: var(--positive);
    border-color: currentColor;
}
.settle-account {
    width: auto; min-width: 96px; padding: 3px 6px;
    font-size: 0.78rem; height: auto;
}

/* What a line on a bank statement was. Money in green, money out red, moving
   your own money neutral — because it is neither. */
.act-received     { background: #e6f5ec; color: #1b6b3f; border-color: #c9e7d6; }
.act-paid         { background: #fbeaea; color: #a02525; border-color: #f2cccc; }
.act-payroll      { background: #fdf2e3; color: #8a5a00; border-color: #f6e3c2; }
.act-transfer_in,
.act-transfer_out { background: #eef1f5; color: #4b5768; border-color: #dde3ea; }
.act-manual       { background: #f1f3f6; color: #8a929e; border-color: #e3e7ec; }

/* The paid-on date is read on the list and changed on the payment form, so it
   is a link rather than a field. */
.paid-on-col { min-width: 112px; }
.inline-controls { display: inline-flex; gap: 6px; align-items: center; }

/* A voided row stays visible — that is the point of voiding rather than
   deleting — but must not read as live money. */
tr.is-voided td { opacity: 0.55; text-decoration: line-through; }
tr.is-voided td:first-child, tr.is-voided td:last-child { text-decoration: none; }

/* Payment state: green settled, amber part-way, neutral waiting, red late. */
.pay-settled  { background: #e6f5ec; color: #1b6b3f; border-color: #c9e7d6; }
.pay-part     { background: #fdf2e3; color: #8a5a00; border-color: #f6e3c2; }
.pay-pending  { background: #eef1f5; color: #4b5768; border-color: #dde3ea; }
.pay-overdue  { background: #fbeaea; color: #a02525; border-color: #f2cccc; }
.pay-draft,
.pay-void     { background: #f1f3f6; color: #8a929e; border-color: #e3e7ec; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .pay-settled { background: #16301f; color: #6fc98f; border-color: #21472e; }
    :root:not([data-theme="light"]) .pay-part    { background: #33291a; color: #e0b063; border-color: #4a3a22; }
    :root:not([data-theme="light"]) .pay-pending { background: #21262e; color: #99a3b1; border-color: #303844; }
    :root:not([data-theme="light"]) .pay-overdue { background: #351a1a; color: #e58b8b; border-color: #4d2626; }
    :root:not([data-theme="light"]) .pay-draft,
    :root:not([data-theme="light"]) .pay-void    { background: #21262e; color: #7b838f; border-color: #303844; }
}
:root[data-theme="dark"] .pay-settled { background: #16301f; color: #6fc98f; border-color: #21472e; }
:root[data-theme="dark"] .pay-part    { background: #33291a; color: #e0b063; border-color: #4a3a22; }
:root[data-theme="dark"] .pay-pending { background: #21262e; color: #99a3b1; border-color: #303844; }
:root[data-theme="dark"] .pay-overdue { background: #351a1a; color: #e58b8b; border-color: #4d2626; }
:root[data-theme="dark"] .pay-draft,
:root[data-theme="dark"] .pay-void    { background: #21262e; color: #7b838f; border-color: #303844; }

.tag-executive  { background: #f1ebfb; color: #6b3fa0; border-color: #e0d2f5; }
.tag-full-time  { background: #e6f0fa; color: #1f5f8b; border-color: #cfe2f3; }
.tag-part-time  { background: #fdf2e3; color: #8a5a00; border-color: #f6e3c2; }
.tag-contractor { background: #e3f4f1; color: #12695c; border-color: #c8e8e2; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .tag-executive  { background: #2a2038; color: #c4a8ea; border-color: #3d2f52; }
    :root:not([data-theme="light"]) .tag-full-time  { background: #17293a; color: #8ec5e8; border-color: #24405a; }
    :root:not([data-theme="light"]) .tag-part-time  { background: #33291a; color: #e0b063; border-color: #4a3a22; }
    :root:not([data-theme="light"]) .tag-contractor { background: #14302c; color: #6cc9ba; border-color: #1f4841; }
}
:root[data-theme="dark"] .tag-executive  { background: #2a2038; color: #c4a8ea; border-color: #3d2f52; }
:root[data-theme="dark"] .tag-full-time  { background: #17293a; color: #8ec5e8; border-color: #24405a; }
:root[data-theme="dark"] .tag-part-time  { background: #33291a; color: #e0b063; border-color: #4a3a22; }
:root[data-theme="dark"] .tag-contractor { background: #14302c; color: #6cc9ba; border-color: #1f4841; }

/* Left accent on a card, matching the category tag */
.card-executive  { border-left: 3px solid #9b7fd4; }
.card-full-time  { border-left: 3px solid #5b9bd0; }
.card-part-time  { border-left: 3px solid #d9a441; }
.card-contractor { border-left: 3px solid #4bab9c; }

/* --- View tabs ----------------------------------------------------------- */
.tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    padding-bottom: 0;
}
.tab {
    padding: 8px 14px;
    font-size: 0.865rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; background: var(--bg-subtle); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 8px;
    background: var(--bg-sunken);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}
.tab.active .count { background: var(--accent-soft); color: var(--accent-text); }

/* --- Forms -------------------------------------------------------------- */
.field { margin-bottom: 13px; }
.field label {
    display: block;
    font-size: 0.79rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-muted);
}
.field .help { font-size: 0.755rem; color: var(--text-faint); margin-top: 3px; }

input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], select, textarea {
    width: 100%;
    padding: 7px 10px;
    font-size: 0.865rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=number], .input-money {
    font-family: var(--num);
    font-variant-numeric: tabular-nums lining-nums;
    text-align: right;
}
textarea { min-height: 64px; resize: vertical; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; align-items: center; }

/* --- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    font-size: 0.845rem;
    font-family: inherit;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-sunken); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { color: var(--negative); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--negative-soft); }
.btn-sm { padding: 4px 9px; font-size: 0.79rem; }
.btn-link { border: none; background: none; color: var(--accent-text); padding: 2px 4px; }
.btn-link:hover { background: none; text-decoration: underline; }

/* --- Toolbar & filters -------------------------------------------------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input { width: auto; min-width: 130px; }
.spacer { flex: 1; }

.month-switch {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}
.month-switch a, .month-switch span { padding: 6px 10px; font-size: 0.845rem; color: var(--text); }
.month-switch a:hover { background: var(--bg-sunken); text-decoration: none; }
.month-switch .label { min-width: 110px; text-align: center; font-weight: 500;
    border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
/* The picker sits inside the switch so stepping and jumping are one control. */
.month-switch .month-jump {
    width: 34px; min-width: 34px; border: 0; border-left: 1px solid var(--border);
    border-radius: 0; background: transparent; padding: 6px 4px; color: transparent;
    cursor: pointer; font-size: 0.845rem;
}
.month-switch .month-jump:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.month-switch .month-jump::-webkit-calendar-picker-indicator {
    opacity: 0.55; cursor: pointer; margin: 0;
}
.month-switch .month-jump:hover::-webkit-calendar-picker-indicator { opacity: 1; }

/* --- Messages ----------------------------------------------------------- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px;
         font-size: 0.865rem; border: 1px solid transparent; }
.flash-success { background: var(--positive-soft); color: var(--positive); border-color: currentColor; }
.flash-error   { background: var(--negative-soft); color: var(--negative); border-color: currentColor; }
.flash-warning { background: var(--warning-soft);  color: var(--warning);  border-color: currentColor; }
.flash-info    { background: var(--accent-soft);   color: var(--accent-text); border-color: currentColor; }

.empty { padding: 34px 20px; text-align: center; color: var(--text-faint); font-size: 0.875rem; }

.callout {
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    padding: 11px 14px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
    margin-bottom: 14px;
}
.callout-warning { border-left-color: var(--warning); background: var(--warning-soft); }
.callout-success { border-left-color: var(--positive); background: var(--positive-soft); }
.callout-danger  { border-left-color: var(--negative); background: var(--negative-soft); }

/* --- Check list --------------------------------------------------------- */
.check { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border);
         align-items: flex-start; }
.check:last-child { border-bottom: none; }
.check-mark { width: 17px; height: 17px; border-radius: 50%; flex: 0 0 17px; margin-top: 2px;
              display: flex; align-items: center; justify-content: center; font-size: 11px;
              font-weight: 700; color: #fff; }
.check-ok   { background: var(--positive); }
.check-todo { background: var(--warning); }

/* --- Bars --------------------------------------------------------------- */
.bar-track { height: 6px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--accent); border-radius: 3px; }
.bar-fill.over { background: var(--negative); }

/* --- Misc --------------------------------------------------------------- */
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.stack > * + * { margin-top: 14px; }
.inline-form { display: inline; }
.right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }

@media (max-width: 820px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex: none;
               border-right: none; border-bottom: 1px solid var(--border); }
    .nav { display: flex; flex-wrap: wrap; gap: 2px; }
    .nav-section { display: none; }
    .content { padding: 16px 14px 40px; }
}

@media print {
    .sidebar, .toolbar, .btn, .form-actions { display: none !important; }
    body { background: #fff; }
    .card { border-color: #ccc; break-inside: avoid; }
}
