/* B2BOWN-1: the MIS B2B targets board (app/static/js/b2b_period.js). Ported rule for rule from the
   journey mockup docs/design/2026-10-03-b2b-handler-journey.html (commit 1a4211f9, blob
   b37d86ce), scoped under #rev-b2b-board. Estate palette tokens, approved 2026-10-02: every
   colour lives here and nowhere else. Two departures, both for live data: the board fills the
   screen below its own top edge, and the detail pane scrolls when a long list outgrows it. */
#rev-b2b-board {
  --forest: #2A5D3C; --navy: #1D3C5A; --green: #4E8B57; --mint: #5EBB8C; --pale-mint: #C4E4D7;
  --bg: #F1F5F2; --surface: #FFFFFF; --surface-2: #EEF3F0; --row-sel: #E7F3EE; --line: #D8E2DD; --line-soft: #E8EEEA;
  --ink: #18211D; --ink-soft: #55615B; --on-accent: #FFFFFF; --risk: #B42318; --risk-soft: #FCEBE8;
  --radius: 8px; --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column; gap: 8px; color: var(--ink); font: 13px/1.4 var(--font);
  -webkit-font-smoothing: antialiased; font-variant-numeric: lining-nums tabular-nums;
}
#rev-b2b-board[hidden], #rev-b2b-board [hidden] { display: none !important; }
#rev-b2b-board b, #rev-b2b-board strong, #rev-b2b-board th, #rev-b2b-board h2, #rev-b2b-board h3 { font-weight: 600; }
#rev-b2b-board button, #rev-b2b-board input { font: inherit; color: inherit; }
#rev-b2b-board button { cursor: pointer; }
#rev-b2b-board button:focus-visible, #rev-b2b-board input:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
#rev-b2b-board .num { text-align: right; font-variant-numeric: tabular-nums; }
#rev-b2b-board .soft { color: var(--ink-soft); }

/* Admin-only B2B revenue schedule chart */
#rev-b2b-board .chart-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
#rev-b2b-board .chart-panel h2 { margin: 0; font-size: var(--text-sm); color: var(--navy); }
#rev-b2b-board .chart-panel p { margin: 0 0 4px; font-size: var(--text-2xs); color: var(--ink-soft); }
#rev-b2b-board .chart-panel svg { display: block; width: 100%; height: 60px; }

/* Workbook tabs bar + period control (4 grains + step arrows) */
#rev-b2b-board .workbook { height: max(520px, calc(100vh - var(--b2bp-top, 240px) - 12px)); min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
#rev-b2b-board .tabs-bar { display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
#rev-b2b-board .tabs { display: flex; gap: 2px; }
#rev-b2b-board .tab { border: 1px solid transparent; border-radius: 6px; background: none; padding: 4px 12px; color: var(--ink-soft); font-weight: 500; }
#rev-b2b-board .tab[aria-selected="true"] { background: var(--pale-mint); border-color: var(--mint); color: var(--forest); font-weight: 600; }
#rev-b2b-board .period { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#rev-b2b-board .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#rev-b2b-board .seg button { border: 0; border-left: 1px solid var(--line); background: var(--surface); padding: 4px 10px; font-weight: 500; }
#rev-b2b-board .seg button:first-child { border-left: 0; }
#rev-b2b-board .seg button[aria-pressed="true"] { background: var(--pale-mint); color: var(--forest); font-weight: 600; }
#rev-b2b-board .stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; }
#rev-b2b-board .stepper button { width: 28px; height: 28px; border: 0; background: none; color: var(--forest); font-size: var(--text-base); }
#rev-b2b-board .stepper button:disabled { color: var(--line); cursor: default; }
#rev-b2b-board .stepper strong { min-width: 112px; text-align: center; color: var(--navy); font-size: var(--text-xs); }

/* Two-pane */
#rev-b2b-board [data-slot="pane"] { flex: 1; min-height: 0; display: flex; }
#rev-b2b-board .twopane-p { flex: 1; min-height: 0; display: grid; grid-template-columns: 268px minmax(0,1fr); }
#rev-b2b-board .master { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
#rev-b2b-board .master-head { padding: 8px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
#rev-b2b-board .view-toggle { display: inline-flex; gap: 2px; }
#rev-b2b-board .view-toggle button { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 2px 10px; font-size: var(--text-2xs); }
#rev-b2b-board .view-toggle button.active { background: var(--pale-mint); border-color: var(--mint); color: var(--forest); font-weight: 600; }
#rev-b2b-board .filter { height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; width: 100%; color: var(--ink-soft); background: var(--surface); }
#rev-b2b-board .list-count { font-size: var(--text-2xs); color: var(--ink-soft); }
#rev-b2b-board .party-list { overflow: auto; min-height: 0; }
#rev-b2b-board .party-row { width: 100%; min-height: 38px; display: grid; grid-template-columns: minmax(0,1fr) 70px; align-items: center; gap: 6px; padding: 4px 10px 4px 12px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; }
#rev-b2b-board .party-row:hover { background: var(--surface-2); }
#rev-b2b-board .party-row.is-selected { background: var(--row-sel); box-shadow: inset 3px 0 var(--green); }
#rev-b2b-board .party-row.is-total { min-height: 44px; background: var(--surface-2); }
#rev-b2b-board .party-row.is-total.is-selected { background: var(--row-sel); }
#rev-b2b-board .group-row { background: var(--surface-2); }
#rev-b2b-board .party-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; font-size: var(--text-xs); }
#rev-b2b-board .party-name .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rev-b2b-board .party-name .chip { flex: none; }
#rev-b2b-board .party-meta { display: block; color: var(--ink-soft); font-size: var(--text-2xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rev-b2b-board .party-total { color: var(--navy); font-weight: 600; font-size: var(--text-2xs); text-align: right; }
#rev-b2b-board .member { padding-left: 24px; }

#rev-b2b-board .detail { min-width: 0; min-height: 0; overflow: auto; background: var(--bg); padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
#rev-b2b-board .detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
#rev-b2b-board .detail-head h2 { margin: 0; font-size: var(--text-lg); line-height: 1.2; color: var(--navy); display: flex; align-items: center; gap: 8px; }
#rev-b2b-board .detail-head p { margin: 2px 0 0; color: var(--ink-soft); }
#rev-b2b-board .tiles { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)) minmax(0,1.35fr); gap: 8px; }
#rev-b2b-board .tile { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--mint); border-radius: var(--radius); padding: 6px 10px; display: grid; gap: 1px; }
#rev-b2b-board .tile-l { font-size: var(--text-2xs); color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
#rev-b2b-board .tile-v { font-size: var(--text-lg); font-weight: 600; color: var(--navy); line-height: 1.25; }
#rev-b2b-board .tile-s { font-size: var(--text-2xs); color: var(--ink-soft); }
#rev-b2b-board .tile.stages { border-top-color: var(--line); display: grid; grid-template-columns: repeat(2, max-content); gap: 4px 6px; align-content: center; }

#rev-b2b-board .chip { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0; text-transform: none; vertical-align: baseline; padding: 1px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
#rev-b2b-board .chip b { font-weight: 700; }
#rev-b2b-board .chip.ahead { background: var(--pale-mint); color: var(--forest); }
#rev-b2b-board .chip.on_target { background: var(--surface-2); border-color: var(--mint); color: var(--forest); }
#rev-b2b-board .chip.behind { background: var(--risk-soft); color: var(--risk); }
#rev-b2b-board .chip.no_target { background: var(--surface); border-color: var(--line); color: var(--ink-soft); }

#rev-b2b-board table.cmp { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
#rev-b2b-board .cmp th, #rev-b2b-board .cmp td { height: 28px; padding: 0 8px; border-top: 1px solid var(--line-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
#rev-b2b-board .cmp thead th { height: 26px; border-top: 0; font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }
#rev-b2b-board .cmp .num { text-align: right; }
#rev-b2b-board .cmp td.party { font-weight: 600; }
#rev-b2b-board .cmp .pct { color: var(--ink-soft); font-size: var(--text-2xs); margin-left: 6px; display: inline-block; min-width: 34px; text-align: right; }
#rev-b2b-board .cmp tr.sel td { background: var(--row-sel); }
#rev-b2b-board .cmp .fig { color: var(--navy); font-weight: 600; }
#rev-b2b-board col.c-party { width: auto; } #rev-b2b-board col.c-t { width: 100px; } #rev-b2b-board col.c-g { width: 112px; } #rev-b2b-board col.c-n { width: 112px; } #rev-b2b-board col.c-s { width: 92px; }

#rev-b2b-board .months { display: grid; gap: 6px; }
#rev-b2b-board .month { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; display: grid; gap: 1px; min-width: 0; }
#rev-b2b-board .month.future { background: var(--surface-2); }
#rev-b2b-board .month.away { border-style: dashed; background: var(--surface-2); }
#rev-b2b-board .month-label { font-size: var(--text-2xs); color: var(--ink-soft); font-weight: 600; }
#rev-b2b-board .month-net { font-size: var(--text-base); font-weight: 600; color: var(--navy); }
#rev-b2b-board .month-sub { font-size: var(--text-2xs); color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Set target */
#rev-b2b-board .set-target { flex: none; min-height: 32px; padding: 0 12px; border: 1px solid var(--green); border-radius: 6px; background: var(--surface); color: var(--forest); font-weight: 600; }
#rev-b2b-board .tpanel { background: var(--surface); border: 1px solid var(--mint); border-radius: var(--radius); padding: 8px 12px; display: grid; gap: 8px; }
#rev-b2b-board .tp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
#rev-b2b-board .tp-head h3 { margin: 0; font-size: var(--text-sm); color: var(--navy); }
#rev-b2b-board .mfields { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 6px 8px; }
#rev-b2b-board .mf { display: grid; gap: 2px; font-size: var(--text-2xs); color: var(--ink-soft); font-weight: 600; }
#rev-b2b-board .mf input { width: 100%; min-width: 0; height: 28px; border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; text-align: right; background: var(--surface); font-weight: 400; color: var(--ink); }
#rev-b2b-board .mf input.changed { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
#rev-b2b-board .mf .ro { height: 28px; display: flex; align-items: center; justify-content: flex-end; padding: 0 6px; border: 1px solid var(--line-soft); border-radius: 4px; background: var(--surface-2); color: var(--ink-soft); font-weight: 400; }
#rev-b2b-board .tp-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#rev-b2b-board .tp-foot .ok { color: var(--forest); font-weight: 600; font-size: var(--text-2xs); }
#rev-b2b-board .apply-label { font-size: var(--text-2xs); color: var(--ink-soft); font-weight: 600; }
#rev-b2b-board .btn { min-height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; }
#rev-b2b-board .btn.primary { background: var(--forest); border-color: var(--forest); color: var(--on-accent); }
#rev-b2b-board .btn:disabled { opacity: .55; cursor: default; }
#rev-b2b-board .error { margin: 0; color: var(--risk); font-weight: 600; font-size: var(--text-2xs); }

/* Skeleton for loading */
#rev-b2b-board .sk { display: block; height: 10px; border-radius: 4px; background: var(--surface-2); }

#rev-b2b-board .workbook.is-tabs-only { height: auto; }
/* A6 rule 18: beneath an admin's unchanged B2B tab the board takes one screen of its own. */
#rev-b2b-view + #rev-b2b-board { margin-top: 18px; }
#rev-b2b-view + #rev-b2b-board .workbook { height: max(520px, calc(100vh - 24px)); }

/* The shell's global button, input and table-head rules (styles.css) are not the mockup's: reset them here. */
#rev-b2b-board :where(button, input) { padding: 0; border: 0; border-radius: 0; background: none; min-height: 0; }
#rev-b2b-board .filter { min-height: 0; }
#rev-b2b-board .cmp th, #rev-b2b-board .cmp td { border-bottom: 0; }
#rev-b2b-board .cmp thead th { position: static; background: none; cursor: default; font-weight: 600; }
#rev-b2b-board .cmp thead th::after { content: none; }

/* #995: the summary Set target grid, from docs/design/2026-10-04-handler-set-target-mockup.html. Same
   tokens, same field look as the salon panel's .mf fields; the not-hers cell carries the salon
   panel's not-available mark, aligned as .mf .ro aligns it. */
#rev-b2b-board .tpanel.all { gap: 6px; }
#rev-b2b-board .tgrid-wrap { max-height: 268px; overflow: auto; border: 1px solid var(--line-soft); border-radius: 4px; }
#rev-b2b-board table.tgrid { width: 100%; border-collapse: collapse; table-layout: fixed; }
/* Month columns hold a 56px input (plus the cell's 3px side padding) so "2,10,000" never clips;
   the Party column takes what is left and ellipses, its cell carrying the full name as a title. */
#rev-b2b-board .tgrid col.c-party { width: auto; }
#rev-b2b-board .tgrid col:not(.c-party) { width: 62px; }
#rev-b2b-board .tgrid th { position: sticky; top: 0; z-index: 1; height: 24px; padding: 0 4px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: var(--text-2xs); color: var(--ink-soft); font-weight: 600; text-align: right; }
#rev-b2b-board .tgrid th:first-child { text-align: left; padding-left: 8px; }
#rev-b2b-board .tgrid td { height: 32px; padding: 2px 3px; border-top: 1px solid var(--line-soft); }
#rev-b2b-board .tgrid tr:first-child td { border-top: 0; }
#rev-b2b-board .tgrid td.party { padding-left: 8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rev-b2b-board .tgrid input { width: 100%; min-width: 0; height: 28px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; text-align: right; background: var(--surface); color: var(--ink); font-size: var(--text-2xs); }
#rev-b2b-board .tgrid input.changed { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
#rev-b2b-board .tgrid .ro { height: 28px; display: flex; align-items: center; justify-content: flex-end; padding: 0 6px; border: 1px dashed var(--line); border-radius: 4px; background: var(--surface-2); color: var(--ink-soft); font-size: var(--text-2xs); }
#rev-b2b-board .tgrid td { border-bottom: 0; }
#rev-b2b-board .tgrid thead th { cursor: default; text-transform: none; letter-spacing: 0; }
#rev-b2b-board .tgrid thead th::after { content: none; }
