/* ─────────────────────────────────────────────────────────────────────────
   Billing Ledger (Hours Review) — recreation of the design handoff.
   Self-contained: declares the warm-neutral token set scoped to .leaf-ledger
   (so it does NOT inherit .leaf-calendar's layout chrome and does NOT pollute
   :root / the Material dashboard). Fonts (Manrope, JetBrains Mono) load in _Layout.
   Quiet by default — color appears only on a real billable variance.
   ───────────────────────────────────────────────────────────────────────── */

.leaf-ledger {
    --bg: #f7f6f3;
    --surface: #ffffff;
    --surface-2: #faf9f6;
    --ink-1: #1b1a17;
    --ink-2: #5b5953;
    --ink-3: #8a8881;
    --ink-4: #c8c5be;
    --line: #e9e6df;
    --line-2: #efece5;
    --accent: #2f7a3a;
    --accent-soft: #e6f0e3;
    --accent-ink: #1f4e2a;
    --c-warn-bg: #fbeed0;
    --c-warn-fg: #7a4a06;
    --c-warn-bd: #efd58a;
    --c-conf-bg: #f9dfde;
    --c-conf-fg: #8a1b1a;
    --c-conf-bd: #ebbab8;
    --rv-deliv: #6f6c65;
    --rv-font-ui: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --rv-font-mono: "JetBrains Mono", ui-monospace, monospace;

    font-family: var(--rv-font-ui);
    color: var(--ink-1);
}

/* Per-status token bundles. dot = flag dot + row left-border; bar = delivered fill;
   ink = number/text; tint/line = washes + borders. (Matches RV_STAT + the bar's own fill.) */
.leaf-ledger .rv-st-ok     { --st-dot: var(--line);      --st-bar: var(--rv-deliv);  --st-ink: var(--ink-2);     --st-tint: var(--surface-2); --st-line: var(--line); }
.leaf-ledger .rv-st-under  { --st-dot: var(--ink-1);     --st-bar: var(--c-warn-fg); --st-ink: var(--c-warn-fg); --st-tint: var(--c-warn-bg); --st-line: var(--c-warn-bd); }
.leaf-ledger .rv-st-missed { --st-dot: var(--c-warn-fg); --st-bar: var(--c-warn-fg); --st-ink: var(--c-warn-fg); --st-tint: var(--c-warn-bg); --st-line: var(--c-warn-bd); }
.leaf-ledger .rv-st-over   { --st-dot: var(--c-conf-fg); --st-bar: var(--c-conf-fg); --st-ink: var(--c-conf-fg); --st-tint: var(--c-conf-bg); --st-line: var(--c-conf-bd); }
.leaf-ledger .rv-st-none   { --st-dot: var(--line);      --st-bar: var(--ink-4);     --st-ink: var(--ink-3);     --st-tint: transparent;      --st-line: var(--line); }

/* desktop ↔ mobile switch: render both, toggle by width (no MudHidden) */
.leaf-ledger .rv-mobile { display: none; }
@media (max-width: 760px) {
    .leaf-ledger .rv-desktop { display: none; }
    .leaf-ledger .rv-mobile  { display: flex; flex-direction: column; }
}

/* ── Desktop surface + header ─────────────────────────────────────────────── */
.leaf-ledger .rv-desktop {
    background: var(--surface);
    box-sizing: border-box;
    max-width: 980px;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--line);
}
.leaf-ledger .rv-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 24px; margin-bottom: 18px; flex-wrap: wrap;
}
.leaf-ledger .rv-eyebrow {
    font-size: 10.5px; font-weight: 700; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px;
}
.leaf-ledger .rv-title { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
/* House-name dropdown (MudMenu built-in activator) styled to read as the title */
.leaf-ledger .rv-house-menu .mud-button-root { padding: 2px 4px 2px 0; min-width: 0; text-transform: none; }
.leaf-ledger .rv-house-menu .mud-button-label { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink-1); }
.leaf-ledger .rv-subtitle { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.leaf-ledger .rv-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.leaf-ledger .rv-weeknav-inline { display: flex; align-items: center; gap: 8px; }
.leaf-ledger .rv-weekbtn {
    border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
    width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--ink-3); padding: 0;
}
.leaf-ledger .rv-weekbtn:hover { background: var(--surface-2); }
.leaf-ledger .rv-export {
    border: 1px solid var(--line); background: var(--surface); border-radius: 7px;
    padding: 5px 11px; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
    cursor: pointer; font-family: var(--rv-font-ui);
}
.leaf-ledger .rv-export:hover { background: var(--surface-2); }

/* ── Impact stat cards ────────────────────────────────────────────────────── */
.leaf-ledger .rv-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.leaf-ledger .rv-stat {
    width: 150px; padding: 10px 12px; border-radius: 9px;
    background: var(--surface-2); border: 1px solid var(--line);
}
.leaf-ledger .rv-stat--flag { background: var(--st-tint); border-color: var(--st-line); }
.leaf-ledger .rv-stat-label {
    font-size: 9.5px; font-weight: 700; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.leaf-ledger .rv-stat-value {
    font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums;
    line-height: 1.15; margin-top: 3px; color: var(--ink-1);
}
.leaf-ledger .rv-stat--flag .rv-stat-value { color: var(--st-ink); }
.leaf-ledger .rv-stat-unit { font-size: 11px; color: var(--ink-3); font-weight: 600; margin-left: 3px; }
.leaf-ledger .rv-stat-sub { font-size: 10px; color: var(--ink-3); margin-top: 1px; }

/* ── Legend ───────────────────────────────────────────────────────────────── */
.leaf-ledger .rv-legend {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    margin-bottom: 14px; margin-top: 14px;
}
.leaf-ledger .rv-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2); }
.leaf-ledger .rv-legend-pill { width: 16px; height: 8px; border-radius: 999px; }
.leaf-ledger .rv-legend-sq { width: 10px; height: 10px; border-radius: 3px; }
.leaf-ledger .rv-legend-div { width: 1px; height: 14px; background: var(--line); }

/* ── Table ────────────────────────────────────────────────────────────────── */
.leaf-ledger .rv-tablewrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.leaf-ledger .rv-tablescroll { overflow-x: auto; }
.leaf-ledger .rv-thead, .leaf-ledger .rv-grow {
    display: grid;
    grid-template-columns: 26px minmax(170px,1.3fr) 220px 56px 56px 60px 78px 132px;
    align-items: center; column-gap: 12px;
    min-width: 900px;
}
.leaf-ledger .rv-thead {
    padding: 9px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line);
    font-size: 10px; font-weight: 700; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.leaf-ledger .rv-grow {
    padding: 11px 16px; border-bottom: 1px solid var(--line-2);
    border-left: 3px solid transparent;
}
.leaf-ledger .rv-grow:last-child { border-bottom: 0; }
.leaf-ledger .rv-grow--flag { border-left-color: var(--st-dot); }
.leaf-ledger .rv-grow:hover { background: var(--surface-2); }
.leaf-ledger .rv-r { text-align: right; }

.leaf-ledger .rv-flagdot-wrap { display: flex; justify-content: center; }
.leaf-ledger .rv-flagdot { width: 8px; height: 8px; border-radius: 999px; background: var(--st-dot); }
.leaf-ledger .rv-client { min-width: 0; }
.leaf-ledger .rv-client-name {
    font-size: 13px; font-weight: 700; letter-spacing: -0.005em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.leaf-ledger .rv-client-meta { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }
.leaf-ledger .rv-client-link { color: inherit; text-decoration: none; }
.leaf-ledger .rv-client-link:hover { text-decoration: underline; }
.leaf-ledger .rv-client-meta b { font-weight: 700; color: var(--ink-2); }

.leaf-ledger .rv-num { font-family: var(--rv-font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; display: block; text-align: right; }
.leaf-ledger .rv-num--auth { color: var(--ink-3); font-weight: 600; }
.leaf-ledger .rv-num--sched { color: var(--ink-2); font-weight: 600; }
.leaf-ledger .rv-num--deliv { color: var(--ink-1); font-weight: 700; }
.leaf-ledger .rv-grow--flag .rv-num--deliv { color: var(--st-ink); }
.leaf-ledger .rv-delta { font-family: var(--rv-font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; text-align: right; }
.leaf-ledger .rv-delta--zero { color: var(--ink-4); }
.leaf-ledger .rv-delta--flag { color: var(--st-ink); font-weight: 700; }

/* ── Chain bar (single line: track, wash, fill, auth tick) ─────────────────── */
.leaf-ledger .rv-bar { position: relative; }
.leaf-ledger .rv-desktop .rv-bar { width: 208px; height: 11px; }
.leaf-ledger .rv-card-bar .rv-bar { width: 100%; height: 10px; }
.leaf-ledger .rv-bar-track { position: absolute; left: 0; top: 0; height: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.leaf-ledger .rv-bar-wash  { position: absolute; top: 0; height: 100%; background: var(--c-warn-bg); border: 1px solid var(--c-warn-bd); border-left: 0; border-radius: 0 999px 999px 0; }
.leaf-ledger .rv-bar-fill  { position: absolute; left: 0; top: 0; height: 100%; background: var(--st-bar); border-radius: 999px; transition: width .3s; }
.leaf-ledger .rv-bar-tick  { position: absolute; top: -2px; bottom: -2px; width: 0; border-left: 1.5px dashed var(--ink-3); }

/* ── Day dots ─────────────────────────────────────────────────────────────── */
.leaf-ledger .rv-dots { display: flex; gap: 3px; justify-content: flex-end; }
.leaf-ledger .rv-dot {
    width: 16px; height: 16px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 8px; font-weight: 700; font-family: var(--rv-font-mono);
    background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-4);
}
.leaf-ledger .rv-dot--active { background: var(--st-tint); border-color: var(--st-line); color: var(--st-ink); }
.leaf-ledger .rv-dot--none { background: transparent; }

.leaf-ledger .rv-foot { margin-top: 12px; font-size: 11px; color: var(--ink-3); display: flex; gap: 16px; flex-wrap: wrap; }
.leaf-ledger .rv-foot .rv-glyph-missed { color: var(--c-warn-fg); font-weight: 700; }
.leaf-ledger .rv-foot .rv-glyph-over { color: var(--c-conf-fg); font-weight: 700; }
.leaf-ledger .rv-empty { padding: 24px; font-size: 13px; color: var(--ink-3); }

/* ── Mobile ───────────────────────────────────────────────────────────────── */
.leaf-ledger .rv-mobile { gap: 0; }
.leaf-ledger .rv-m-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin-top: 2px; }
.leaf-ledger .rv-m-sub { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.leaf-ledger .rv-weeknav {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px;
}
.leaf-ledger .rv-weeknav-label { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.leaf-ledger .rv-m-stats { display: flex; gap: 8px; margin-top: 12px; }
.leaf-ledger .rv-m-stat {
    flex: 1; min-width: 0; padding: 9px 10px; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--line);
}
.leaf-ledger .rv-m-stat--flag { background: var(--st-tint); border-color: var(--st-line); }
.leaf-ledger .rv-m-stat-label { font-size: 9px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.leaf-ledger .rv-m-stat-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; margin-top: 2px; color: var(--ink-1); }
.leaf-ledger .rv-m-stat--flag .rv-m-stat-value { color: var(--st-ink); }
.leaf-ledger .rv-m-stat-sub { font-size: 9px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaf-ledger .rv-m-divider { display: flex; align-items: center; gap: 6px; margin: 14px 2px 8px; }
.leaf-ledger .rv-m-divider-label { font-size: 11px; font-weight: 700; color: var(--ink-2); }
.leaf-ledger .rv-m-divider-line { flex: 1; height: 1px; background: var(--line); }
.leaf-ledger .rv-m-divider-sub { font-size: 10px; color: var(--ink-3); font-weight: 600; }

.leaf-ledger .rv-cards { display: flex; flex-direction: column; gap: 9px; }
.leaf-ledger .rv-card {
    background: var(--surface); border-radius: 12px; padding: 12px 13px;
    border: 1px solid var(--line); border-left: 3px solid var(--line);
}
.leaf-ledger .rv-card--flag { border-color: var(--st-line); border-left-color: var(--st-dot); }
.leaf-ledger .rv-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.leaf-ledger .rv-card-id { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.leaf-ledger .rv-card-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.leaf-ledger .rv-card-service { font-size: 9px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); padding: 1px 6px; border-radius: 999px; flex: 0 0 auto; }
.leaf-ledger .rv-card-ontarget { font-size: 11px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.leaf-ledger .rv-chip {
    display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
    background: var(--st-tint); color: var(--st-ink); border: 1px solid var(--st-line);
    padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.leaf-ledger .rv-card-bar { margin-top: 11px; }
.leaf-ledger .rv-card-foot { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 11px; gap: 12px; }
.leaf-ledger .rv-card-stats { display: flex; gap: 16px; }
.leaf-ledger .rv-card-stat-label { font-size: 8.5px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.leaf-ledger .rv-card-stat-value { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 1px; font-family: var(--rv-font-mono); color: var(--ink-1); }
.leaf-ledger .rv-card-stat-value--auth { color: var(--ink-3); font-weight: 600; }
.leaf-ledger .rv-card-stat-value--sched { color: var(--ink-2); font-weight: 600; }
.leaf-ledger .rv-card--flag .rv-card-stat-value--deliv { color: var(--st-ink); }

/* ── Client drill-down: small secondary link to the full client record ── */
.leaf-ledger .rv-client-record { color: var(--ink-3); font-weight: 600; }
.leaf-ledger .rv-client-record:hover { color: var(--ink-1); }

/* ── Company dashboard: house tag on flat rows, view toggle, house rollup ── */
.leaf-ledger .rv-client-house { font-weight: 700; color: var(--ink-2); }
.leaf-ledger .rv-card-id .rv-client-house {
    font-size: 9px; font-weight: 700; color: var(--ink-2); background: var(--surface-2);
    border: 1px solid var(--line); padding: 1px 6px; border-radius: 999px; flex: 0 0 auto;
    white-space: nowrap;
}

.leaf-ledger .rv-viewtoggle {
    display: inline-flex; gap: 2px; margin: 14px 0 12px; padding: 3px;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.leaf-ledger .rv-viewbtn {
    appearance: none; border: 0; background: transparent; cursor: pointer;
    padding: 5px 14px; border-radius: 7px; font-size: 12.5px; font-weight: 700; color: var(--ink-2);
}
.leaf-ledger .rv-viewbtn:hover { color: var(--ink-1); }
.leaf-ledger .rv-viewbtn--active { background: var(--surface); color: var(--ink-1); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.leaf-ledger .rv-rollup { border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
.leaf-ledger .rv-rollup-head, .leaf-ledger .rv-rollup-row {
    display: grid;
    grid-template-columns: minmax(200px,1.6fr) 90px 90px 96px 88px;
    align-items: center; column-gap: 12px;
    min-width: 620px;
}
.leaf-ledger .rv-rollup-head {
    padding: 9px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line);
    font-size: 10px; font-weight: 700; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.leaf-ledger .rv-rollup-row {
    padding: 12px 16px; border-bottom: 1px solid var(--line-2);
    border-left: 3px solid transparent; color: inherit; text-decoration: none;
}
.leaf-ledger .rv-rollup-row:last-child { border-bottom: 0; }
.leaf-ledger .rv-rollup-row:hover { background: var(--surface-2); }
.leaf-ledger .rv-rollup-row--flag { border-left-color: var(--c-warn-fg); }
.leaf-ledger .rv-rollup-house { min-width: 0; }
.leaf-ledger .rv-rollup-name {
    font-size: 13.5px; font-weight: 700; letter-spacing: -0.005em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.leaf-ledger .rv-rollup-meta {
    font-size: 10.5px; color: var(--ink-3); margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.leaf-ledger .rv-rollup .rv-num.rv-st-under { color: var(--c-warn-fg); font-weight: 700; }
.leaf-ledger .rv-rollup .rv-num.rv-st-over { color: var(--c-conf-fg); font-weight: 700; }
.leaf-ledger .rv-rollup-flag {
    font-family: var(--rv-font-mono); font-variant-numeric: tabular-nums;
    font-size: 12.5px; font-weight: 700; color: var(--ink-2); text-align: right;
}
