/* Tokens follow themes/default.css (fincore's design tokens), plus a few the site needs. */
:root {
  color-scheme: light;
  --bg: #f6f5f2; --surface: #fcfcfb; --surface-2: #f1f0eb; --border: #e2e0da; --border-strong: #c9c7c0;
  --text: #0b0b0b; --text-2: #52514e; --muted: #6f6d68; --detail: #333333; --pc: #9b9994; --detail-pc: #999999;
  --accent: #0B98EF; --accent-soft: #e1f2fd; --link: #1c5cab;
  --bad: #c03535; --bad-soft: #fbe9e9; --bad-text: #a12b2b;
  --warn-soft: #fdf1d6; --warn-text: #7a5200;
  --good-soft: #e7f5e7; --good-text: #1f6b1f;
  --goal: #d4d2cc; --red: #F76565; --exp-bg: #F76565; --exp-fg: #ffffff; --exp-pc: #ffffff; --margin: #78B053; --s1: #0B98EF; --s2: #F59C64; --s3: #78B053; --s4: #82CCFB; --s5: #F76565; --s6: #7a5cc4; --s7: #8d8c85;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #22221f; --border: #2e2e2b; --border-strong: #4a4945;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #9a9890; --detail: #cccccc; --pc: #74736d; --detail-pc: #777777;
    --accent: #0B98EF; --accent-soft: #12324a; --link: #7fb2f0;
    --bad: #ef6b6b; --bad-soft: #3a1c1c; --bad-text: #f3a0a0;
    --warn-soft: #3a2f14; --warn-text: #f2c96b;
    --good-soft: #17301a; --good-text: #7fd17f;
    --goal: #5a5955; --red: #F76565; --exp-bg: #F76565; --exp-fg: #ffffff; --exp-pc: #ffffff; --margin: #78B053; --s1: #0B98EF; --s2: #F59C64; --s3: #78B053; --s4: #82CCFB; --s5: #F76565; --s6: #7a5cc4; --s7: #8d8c85;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #22221f; --border: #2e2e2b; --border-strong: #4a4945;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #9a9890; --detail: #cccccc; --pc: #74736d; --detail-pc: #777777;
  --accent: #0B98EF; --accent-soft: #12324a; --link: #7fb2f0;
  --bad: #ef6b6b; --bad-soft: #3a1c1c; --bad-text: #f3a0a0;
  --warn-soft: #3a2f14; --warn-text: #f2c96b;
  --good-soft: #17301a; --good-text: #7fd17f;
  --goal: #5a5955; --red: #F76565; --exp-bg: #F76565; --exp-fg: #ffffff; --exp-pc: #ffffff; --margin: #78B053; --s1: #0B98EF; --s2: #F59C64; --s3: #78B053; --s4: #82CCFB; --s5: #F76565; --s6: #7a5cc4; --s7: #8d8c85;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); text-align: center; }

/* Sign-in */
.signin { max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 28px; display: grid; gap: 14px; text-align: left; }
.signin h1 { margin: 0; font-size: 22px; }
.signin p { margin: 0; color: var(--text-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--surface); border-color: var(--text); }

/* Shell */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); background: var(--surface); border-bottom: 1px solid var(--border); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.menu-btn { display: none; width: 44px; height: 44px; border: 0; background: none; align-items: center; justify-content: center; margin-left: -10px; }
.period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.seg.dark button[aria-pressed="true"] { background: var(--text); color: var(--surface); }
select { min-height: 32px; padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-size: 13px; }
.badge { font-size: 12px; color: var(--text-2); background: var(--surface-2); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.user { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--link); text-decoration: underline; font-size: 13px; }

.layout { display: flex; align-items: flex-start; }
nav.side { flex: none; width: 236px; position: sticky; top: 60px; min-height: calc(100vh - 60px); max-height: calc(100vh - 60px); overflow: auto; padding: 18px 12px 24px; border-right: 1px solid var(--border); background: var(--surface); align-self: stretch; }
.navgroup { display: grid; gap: 1px; margin-bottom: 16px; }
.navgroup h3 { margin: 0 0 4px; padding: 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.navgroup a { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 13.5px; }
.navgroup a:hover { background: var(--surface-2); }
.navgroup a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }
.navgroup a.planned { color: var(--muted); }
.navgroup a small { color: var(--muted); font-size: 11px; }
.scrim { display: none; }

main { flex: 1 1 auto; min-width: 0; padding: 26px max(16px, env(safe-area-inset-right, 0px)) 48px 32px; display: grid; gap: 20px; max-width: 1240px; }
.pagehead { display: grid; gap: 4px; }
.crumb { font-size: 12px; color: var(--muted); }
.titlerow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px; }
h1.pt { margin: 0; font-size: 26px; letter-spacing: -.01em; text-wrap: balance; }
.lede { margin: 0; color: var(--text-2); max-width: 70ch; }
.pnote { margin: 0; font-size: 12px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; min-width: 0; }
.kpi .k { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--text-2); }
.neg { color: var(--bad); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card.flush { padding: 14px 0 6px; }
.cardhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-bottom: 12px; }
.card.flush .cardhead { padding: 0 16px; margin-bottom: 8px; }
.cardhead h2 { margin: 0; font-size: 14px; }
.cardhead .hint { font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.chart { display: flex; gap: 8px; align-items: flex-start; overflow-x: auto; padding-bottom: 2px; }
.chart .col { flex: 1 1 0; min-width: 34px; display: grid; gap: 4px; }
.chart .plot { position: relative; height: 180px; }
.chart .plot.base { border-bottom: 1px solid var(--muted); }
.chart .zero { position: absolute; left: -4px; right: -4px; height: 1px; background: var(--muted); }
.chart .seg { position: absolute; left: 16%; right: 16%; border-radius: 1px; }
.chart .lbl { text-align: center; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart .val { text-align: center; font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.tablewrap { overflow-x: auto; }
table.fin { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.fin th, table.fin td { padding: 6px 10px; white-space: nowrap; text-align: right; }
table.fin thead th { font-size: 12px; color: var(--text-2); font-weight: 600; border-bottom: 1px solid var(--border-strong); }
table.fin th[scope="row"], table.fin thead th:first-child { text-align: left; padding-left: 16px; position: sticky; left: 0; background: var(--surface); min-width: 220px; white-space: normal; z-index: 1; font-weight: 400; }
table.fin thead th:first-child { font-weight: 600; }
table.fin td:last-child, table.fin th:last-child { padding-right: 16px; }
table.fin .tot { border-left: 1px solid var(--border); font-weight: 600; }
tr.sec th[scope="row"] { font-weight: 700; padding-top: 14px; }
tr.cat th[scope="row"] { padding-left: 28px; }
tr.sub th, tr.sub td { font-weight: 600; border-top: 1px solid var(--border); }
tr.key th, tr.key td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
tr.net th, tr.net td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--text); }
tr.ratio th, tr.ratio td { color: var(--muted); font-style: italic; font-size: 12px; }
td.z { color: var(--muted); }
table.fin .pc { font-size: 10px; color: var(--pc); padding-left: 2px; text-align: right; min-width: 46px; }
table.fin thead th.pc { font-size: 10px; font-weight: 500; }
table.fin td.pc.neg { color: var(--bad); }
tr.grp th, tr.grp td { font-weight: 600; }
tr.grp th[scope="row"] { padding-left: 28px; }
/* Detail rows: 2px smaller, 80% grey, tight to each other and to their summary row */
tr.line th, tr.line td { font-size: 11px; line-height: 1.25; color: var(--detail); padding-top: 1px; padding-bottom: 1px; }
tr.line th[scope="row"] { padding-left: 46px; }
tr.line td.pc { font-size: 8px; color: var(--detail-pc); }
tr.line td.z { color: var(--muted); }
tr.grp th, tr.grp td { padding-top: 3px; padding-bottom: 1px; }  /* summary rows: half the usual padding */

.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split > .card { flex: 3 1 420px; }
.split > .card + .card { flex: 2 1 300px; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--border); }
.item:first-of-type { border-top: 0; }
.item p { margin: 0 0 2px; }
.chip { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.chip.bad { background: var(--bad-soft); color: var(--bad-text); }
.chip.warn { background: var(--warn-soft); color: var(--warn-text); }
.chip.good { background: var(--good-soft); color: var(--good-text); }
a.go { color: var(--link); font-size: 13px; }
.note { font-size: 12px; color: var(--muted); max-width: 90ch; margin: 0; }
.planned-box { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 32px 28px; display: grid; gap: 10px; max-width: 640px; justify-items: start; }
.planned-box h2 { margin: 0; font-size: 18px; }
.error { border: 1px solid var(--bad); background: var(--bad-soft); border-radius: var(--radius); padding: 14px 16px; }

@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .menu-btn { display: inline-flex; }
  .top { position: static; }
  nav.side { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: 290px; min-height: 0; max-height: none; padding-top: calc(16px + env(safe-area-inset-top, 0px)); padding-left: max(12px, env(safe-area-inset-left, 0px)); transform: translateX(-105%); transition: transform .18s ease; border-right: 1px solid var(--border-strong); }
  body.menu-open nav.side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.4); border: 0; }
  main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-top: 18px; }
  .navgroup a { min-height: 44px; align-items: center; }
  .user .email { display: none; }
  h1.pt { font-size: 22px; }
  .kpi .v { font-size: 19px; }
  table.fin th[scope="row"], table.fin thead th:first-child { min-width: 150px; }
}
@media (prefers-reduced-motion: reduce) { nav.side { transition: none; } }

/* Collapsible summary rows: a right-pointing triangle that turns down when open */
button.tog { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
button.tog:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.tri { width: 0; height: 0; border-left: 6px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .2s ease; flex: none; }
button.tog[aria-expanded="true"] .tri { transform: rotate(90deg); }
.tri-sp { display: inline-block; width: 14px; }
tr[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .tri { transition: none; } }

/* Column rules: light between quarters (same as before Total), heavy black before Average */
table.fin .sep { border-left: 1px solid var(--border); }
table.fin .sep-strong { border-left: 2px solid var(--text); }

/* Direct / Indirect section rows: black band, white text, % cells on blue (as in Shannon's sheet) */
table.fin tr.section th, table.fin tr.section td { background: #000; color: #fff; font-weight: 700; border-top: 1px solid #000; }
table.fin tr.section td.pc { background: var(--s1); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
table.fin tr.section td.neg { color: #ff9b9b; }

/* Factors chart: bars of 100% revenue with labelled boxes and thin goal lines */
.fchart .col { min-width: 90px; }
.fchart .fplot { margin: 0 6%; }
.fbx { position: absolute; left: 0; right: 0; }
.fbx.over { box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.flbl { position: absolute; left: 0; right: 0; z-index: 4; display: flex; align-items: center; justify-content: center; gap: 5px; color: #fff; white-space: nowrap; pointer-events: none; overflow: hidden; font-variant-numeric: tabular-nums; }
.flbl span { font-size: 13px; font-weight: 700; }
.flbl small { font-size: 12px; font-weight: 400; }
.goal { position: absolute; left: -4%; right: -4%; height: 0; border-top: 1px dashed var(--goal); z-index: 3; }
.goal em { position: absolute; right: calc(3.7% + 3px); font-style: normal; font-size: 8.5px; font-weight: 400; color: var(--goal); line-height: 1; }  /* 30% smaller, inside the bar's edge (the line runs 4% past it) */
.goal.d em { top: 2px; }        /* direct goal: label just below its line */
.goal.i em { bottom: 2px; }     /* indirect goal: label just above its line */
.legend i.dash { width: 16px; height: 0; border-top: 1px dashed var(--goal); border-radius: 0; vertical-align: 3px; }

/* Total Expenses row: soft red band, readable in light and dark */
table.fin tr.totexp th, table.fin tr.totexp td { background: var(--exp-bg); color: var(--exp-fg); font-weight: 700; border-top: 1px solid var(--border-strong); }
table.fin tr.totexp td.pc { color: var(--exp-pc); }

/* ---------- BGSTR brand: salmon wordmark on near-black, asterisk accents ---------- */
:root { --brand: #E8877B; --brand-ink: #18181B; --brand-line: #2E2E33; --brand-text: #EDEDED; --brand-muted: #A1A1A6; }
.wordmark { position: relative; display: inline-flex; align-items: flex-start; font-family: "Inter Tight", "Inter", system-ui, sans-serif; font-weight: 800; letter-spacing: -0.02em; color: var(--brand); font-size: 22px; line-height: 1; }
.wordmark .star { width: .5em; height: .5em; color: var(--brand); margin-left: .12em; margin-top: -.18em; }
.product { font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-muted); padding-left: 10px; border-left: 1px solid var(--brand-line); }

/* Top bar in the brand's near-black, in light and dark mode alike */
.top { background: var(--brand-ink); border-bottom-color: var(--brand-line); color: var(--brand-text); }
body::before { background: var(--brand-ink); }
.top .menu-btn { color: var(--brand-text); }
.top .seg { border-color: var(--brand-line); }
.top .seg button { background: transparent; color: var(--brand-text); }
.top .seg button + button { border-left-color: var(--brand-line); }
.top .seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.top select { background: #232327; color: var(--brand-text); border-color: var(--brand-line); color-scheme: dark; }
.top label { color: var(--brand-muted); }
.top .badge { background: #232327; color: var(--brand-muted); }
.top .user { color: var(--brand-muted); }
.top .linkbtn { color: var(--brand); }

/* Menu: the asterisk marks the page you're on */
.navgroup a[aria-current="page"] { background: transparent; font-weight: 700; }
.navlabel { display: inline-flex; align-items: center; gap: 6px; }
.navgroup a .star { width: 11px; height: 11px; color: var(--brand); flex: none; margin-left: -17px; }
.navgroup a { padding-left: 24px; }
.navgroup h3 { padding-left: 24px; }

/* Sign-in screen */
.center.brandbg { background: var(--brand-ink); }
.signin-mark .wordmark { font-size: 40px; }

/* Admin pages */
.adminbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); font-size: 13px; color: var(--text-2); }
.adminbar .btn { min-height: 34px; }
.adminbar .btn:first-of-type { margin-left: auto; }
.adminbar .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* A column hidden by default (Notes): its header keeps a "+" to open it */
/* A closed column keeps a narrow empty slot (so other columns stay aligned) with just its "+" in the header */
table.fin td.tcol.off { font-size: 0; color: transparent; padding-left: 0; padding-right: 0; width: 30px; min-width: 0; max-width: 30px; }
table.fin th.tcol-h.off { width: 30px; min-width: 0; max-width: 30px; padding-left: 6px; padding-right: 6px; }
table.fin th.tcol-h { text-align: left; width: 1%; }
.tcol-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 600; }
.tcol-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.tcol-sign { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 13px; line-height: 1; }
table.fin th.tcol-h.off .tcol-name { display: none; }
table.fin td.tcol-11 { white-space: normal; min-width: 260px; text-align: left; color: var(--text-2); font-size: 12px; }

/* Text columns in admin tables: left-aligned; long ones wrap */
table.fin th.txt, table.fin td.txt { text-align: left; }
table.fin td.wrap, table.fin th.wrap { white-space: normal; max-width: 150px; min-width: 110px; font-size: 12px; line-height: 1.3; }
table.fin.narrow-first th[scope="row"], table.fin.narrow-first thead th:first-child { min-width: 140px; }

/* Project bonus: one square per project, by delivery quarter */
.qgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.qcol { border: 1px solid var(--border); border-radius: 8px; padding: 12px; min-width: 0; }
.qcol h3 { margin: 0; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.qcol .qsub { font-size: 12px; opacity: .75; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 4px; }
.tile { display: block; aspect-ratio: 1; border-radius: 4px; border: 1px solid transparent;
        animation: tilepop .45s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 25ms); }
.tile.proj { border: 1.5px dashed var(--border-strong); }
.tile:hover { outline: 2px solid var(--s1); outline-offset: 1px; }
@keyframes tilepop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tile { animation: none; } }
.scale { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .8; margin-top: 12px; flex-wrap: wrap; }
.scale i { width: 18px; height: 12px; border-radius: 2px; display: inline-block; }
