/* GH Sales Dashboard - shared styles. Tokens copied from the approved mockup. */
@font-face { font-family: "Cabinet Grotesk"; src: url(/assets/fonts/CabinetGrotesk-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Cabinet Grotesk"; src: url(/assets/fonts/CabinetGrotesk-Medium.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Cabinet Grotesk"; src: url(/assets/fonts/CabinetGrotesk-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Cabinet Grotesk"; src: url(/assets/fonts/CabinetGrotesk-Extrabold.woff2) format("woff2"); font-weight: 800; font-display: swap; }

:root {
    --forest: #1C312C; --teal: #267F70; --teal-ink: #1F6A5D; --cream: #FCF2D7;
    --card: #FFFBEF; --line: #E9D9B4; --line-soft: #EFE2C2; --track: #EFE2C2;
    --alert: #D04E38; --alert-ink: #8C2E1F; --alert-bg: #FBE3DC;
    --amber: #F7CD45; --amber-ink: #8A5A00; --amber-bg: #FCEFD0;
    --hatch-a: #F4E3BD; --hatch-b: #FCF2D7; --hatch-line: #9A6B4F; --hatch-ink: #7A3A26;
    --ink: #1C312C; --muted: #4F564E; --eyebrow: #5A5F55;
    --bar: #267F70; --bar-dark: #1C312C;
    --btn-bg: #267F70; --btn-ink: #FFFFFF; --btn-danger: #B8412D; --btn-hover: #1F6A5D; --btn-danger-hover: #9C3524; --focus: #F7CD45;
    --good-bg: #DDEFEA; --good-ink: #1F6A5D; --target-ink: #4F564E;
    --nav-bg: #1C312C; --nav-ink: #FCF2D7; --nav-muted: #C9D3C8;
    --field-bg: #FFFBEF; --field-line: #C9B58A;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --cream: #13201D; --card: #1B2B27; --line: #33463F; --line-soft: #2A3B35; --track: #2A3B35;
        --alert: #E0664F; --alert-ink: #F4A897; --alert-bg: #3A211C;
        --amber-ink: #F7CD45; --amber-bg: #3A3220;
        --hatch-a: #22322D; --hatch-b: #1A2824; --hatch-line: #B8896B; --hatch-ink: #E8B89A;
        --ink: #F3EBD3; --muted: #B9C2B7; --eyebrow: #AEB6AA;
        --bar: #3FA792; --bar-dark: #F3EBD3; --teal-ink: #6FCBB6;
        --btn-bg: #23796A; --btn-hover: #1B6254; --good-bg: #1D3B35; --good-ink: #6FCBB6; --target-ink: #B9C2B7; --nav-bg: #0D1714; --field-bg: #1B2B27; --field-line: #4A5E56;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --cream: #13201D; --card: #1B2B27; --line: #33463F; --line-soft: #2A3B35; --track: #2A3B35;
    --alert: #E0664F; --alert-ink: #F4A897; --alert-bg: #3A211C;
    --amber-ink: #F7CD45; --amber-bg: #3A3220;
    --hatch-a: #22322D; --hatch-b: #1A2824; --hatch-line: #B8896B; --hatch-ink: #E8B89A;
    --ink: #F3EBD3; --muted: #B9C2B7; --eyebrow: #AEB6AA;
    --bar: #3FA792; --bar-dark: #F3EBD3; --teal-ink: #6FCBB6;
    --btn-bg: #23796A; --btn-hover: #1B6254; --good-bg: #1D3B35; --good-ink: #6FCBB6; --target-ink: #B9C2B7; --nav-bg: #0D1714; --field-bg: #1B2B27; --field-line: #4A5E56;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--cream); color: var(--ink);
    font-family: "Cabinet Grotesk", "Segoe UI", system-ui, sans-serif; font-size: 16px; line-height: 1.45;
    font-variant-numeric: tabular-nums;
}
a { color: var(--teal-ink); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Top bar */
.topbar { background: var(--nav-bg); color: var(--nav-ink); padding: 14px 16px; }
.topbar-inner { max-width: 1320px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.topbar img { width: 150px; height: auto; display: block; }
.topbar .who { display: flex; align-items: center; gap: 14px; font-size: 15px; flex-wrap: wrap; }
.topbar .who strong { font-weight: 700; }
.topbar .who .role { color: var(--nav-muted); }
.topbar a, .topbar button.link { color: var(--nav-ink); }
.topnav { max-width: 1320px; margin: 10px auto 0; }
.topnav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.topnav a { display: inline-block; padding: 8px 12px; border-radius: 8px; font-size: 15px; font-weight: 600; text-decoration: none;
    color: var(--nav-muted); border: 1px solid transparent; }
.topnav a:hover { color: var(--nav-ink); border-color: var(--nav-muted); }
.topnav a[aria-current="page"] { color: var(--nav-bg); background: var(--nav-ink); }
.topnav a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (max-width: 600px) {
    /* One compact line for logo, name and Sign out, then one scrollable nav row: about 110 px in all. */
    .topbar { padding: 8px 16px; }
    .topbar-inner { flex-wrap: nowrap; gap: 10px; }
    .topbar img { width: 96px; flex: none; }
    .topbar .who { flex-wrap: nowrap; gap: 10px; font-size: 14px; min-width: 0; }
    .topbar .who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
    .topbar .who .role { display: none; }
    .topbar .who button.link { flex: none; white-space: nowrap; }
    .topnav { margin-top: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 4px 4px; margin-left: -4px; margin-right: -4px; }
    .topnav::-webkit-scrollbar { display: none; }
    .topnav ul { flex-wrap: nowrap; gap: 4px; width: max-content; }
    .topnav a { padding: 7px 10px; font-size: 14px; white-space: nowrap; }
}

/* Page */
main { max-width: 1320px; margin: 0 auto; padding: 24px 16px 64px; display: flex; flex-direction: column; gap: 28px; }
.page-head { display: flex; flex-direction: column; gap: 4px; }
.page-head h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 800; letter-spacing: -0.01em; }
section.block { display: flex; flex-direction: column; gap: 16px; }
section.block > h2 { font-size: 24px; font-weight: 800; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; align-items: start; }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
/* Head of Sales sections: a heading with its one-line caption, and smaller subheadings inside a section. */
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.section-head h2 { font-size: 24px; font-weight: 800; }
.section-head .caption { margin: 0; }
h3.subsection { font-size: 18px; font-weight: 800; margin-top: 8px; }
/* A card of a few figures or a short table reads better at a scannable width than spread over 1,300 px. */
.card.narrow { max-width: 760px; width: 100%; }
/* One column of a .grid holding several cards, so a tall card is paired with two shorter ones instead of a hole. */
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card [data-body] .chip { vertical-align: middle; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card.accent { border-top: 6px solid var(--teal); }
.card.accent-alert { border-top: 6px solid var(--alert); }
.card.accent-amber { border-top: 6px solid var(--amber); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.asof { font-size: 13px; color: var(--muted); }
.asof.warn { color: var(--alert-ink); font-weight: 700; }
.eyebrow { font-size: 14px; font-weight: 700; letter-spacing: .06em; font-variant-caps: all-small-caps; color: var(--eyebrow); }
.big { font-size: 52px; font-weight: 800; line-height: 1; white-space: nowrap; }
.caption { font-size: 14px; color: var(--muted); }
.target-label { font-weight: 700; color: var(--alert-ink); margin: 0; }
.count { background: var(--forest); color: var(--cream); border-radius: 99px; padding: 2px 12px; font-weight: 800; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .count { background: var(--cream); color: var(--ink); border: 1px solid var(--line); } }

.gap { background: repeating-linear-gradient(135deg, var(--hatch-a) 0 10px, var(--hatch-b) 10px 20px); border: 1.5px dashed var(--hatch-line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.gap .eyebrow { color: var(--hatch-ink); }
.gap h3 { font-size: 24px; font-weight: 800; color: var(--muted); }
.gap .fill, .gap .partly { font-size: 15px; }
.gap .fill { border-top: 1px dashed var(--hatch-line); padding-top: 10px; }
.gap .partly { color: var(--muted); }


.unavailable { background: repeating-linear-gradient(135deg, var(--hatch-a) 0 10px, var(--hatch-b) 10px 20px); border: 1.5px dashed var(--hatch-line); border-radius: 12px; padding: 14px 16px; color: var(--hatch-ink); font-weight: 700; }
.note { background: var(--amber-bg); border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.note.alert { background: var(--alert-bg); color: var(--alert-ink); }

.stale { background: var(--amber-bg); border: 1.5px solid var(--amber); color: var(--ink); border-radius: 12px; padding: 12px 16px; font-weight: 700; }
.stale[hidden] { display: none; }

/* Bars */
.track { height: 14px; background: var(--track); border-radius: 7px; overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--bar); border-radius: 7px; }
.track.target > span { background: var(--amber); }
.bars { display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr) 3.2em; gap: 10px; align-items: center; }
.bars.money .bar-row { grid-template-columns: minmax(0, 7em) minmax(0, 1fr) auto; }
.bar-row > span:first-child { overflow-wrap: anywhere; }
.bar-row .b { height: 14px; background: var(--bar); border-radius: 4px; min-width: 2px; }
.bar-row .b.dark { background: var(--bar-dark); }
.bar-row strong { text-align: right; }
.subhead { font-weight: 700; font-size: 15px; margin-top: 4px; }

/* Rows / lists */
.rows { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.row:last-child { border-bottom: 0; }
.row .main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 14em; }
.row .main .title { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.row .main .sub { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.row.stuck { background: var(--alert-bg); border-left: 5px solid var(--alert); padding-left: 12px; padding-right: 8px; border-radius: 8px; margin: 4px 0; }
.stuck-label { color: var(--alert-ink); font-weight: 800; font-size: 14px; }
.left { font-weight: 800; color: var(--amber-ink); white-space: nowrap; }
.empty { color: var(--muted); }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border-radius: 10px; font: 700 15px "Cabinet Grotesk", system-ui, sans-serif; text-decoration: none; border: 0; cursor: pointer; background: var(--btn-bg); color: var(--btn-ink); }
.btn:hover { color: var(--btn-ink); background: var(--btn-hover); }
.btn.ghost:hover { background: transparent; }
.btn.danger:hover { background: var(--btn-danger-hover); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn.ghost:hover { color: var(--ink); }
.btn.danger { background: var(--btn-danger); color: #fff; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; min-height: 32px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
form.inline { display: flex; flex-direction: column; gap: 10px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 700; }
input, select, textarea { min-height: 48px; border-radius: 10px; border: 1px solid var(--field-line); background: var(--field-bg); color: var(--ink); padding: 0 12px; font: 500 16px "Cabinet Grotesk", system-ui, sans-serif; max-width: 100%; }
textarea { padding: 10px 12px; min-height: 80px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 700; min-height: 48px; }
label.check input { min-height: 0; width: 22px; height: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 10px; }
.msg { font-size: 14px; }
.msg.err { color: var(--alert-ink); font-weight: 700; }
.msg.ok { color: var(--teal-ink); font-weight: 700; }
.msg:empty { display: none; }

/* Stock */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7em, 1fr)); gap: 12px; }
.stats .n { font-size: clamp(24px, 7vw, 36px); font-weight: 800; line-height: 1; }
.stats .l { color: var(--muted); }
table.plain { width: 100%; border-collapse: collapse; font-size: 15px; }
table.plain th, table.plain td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line-soft); }
table.plain th { font-size: 14px; color: var(--eyebrow); font-variant-caps: all-small-caps; letter-spacing: .05em; }
table.plain td.num, table.plain th.num { text-align: right; }
.num, td.num, th.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats .n { white-space: nowrap; }
.scroll-x { overflow-x: auto; max-width: 100%; }

.loading { color: var(--muted); }

/* Expired session: a small fixed banner, so nothing on the page moves or clears. The banner is forest green in both
   themes, so its text is the top bar's ink (--nav-ink); --cream turns dark in the dark theme. */
.reauth { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50; max-width: 640px; margin: 0 auto;
    background: var(--forest); color: var(--nav-ink); border: 2px solid var(--amber); border-radius: 14px; padding: 12px 14px;
    display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.reauth span { flex: 1 1 14em; font-weight: 700; }
.big.money { font-size: clamp(26px, 7vw, 52px); }
.track.spaced { margin: 10px 0 14px; }

/* month picker */
.period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.period label { font-size: 14px; font-weight: 700; letter-spacing: .06em; font-variant-caps: all-small-caps; color: var(--eyebrow); }
.period select { min-height: 44px; max-width: 100%; min-width: 0; flex: 1 1 220px; }
@media (min-width: 640px) { .period select { flex: 0 0 auto; min-width: 260px; } }
.period .caption { flex-basis: 100%; margin: 0; }
.period .caption[hidden] { display: none; }
.current-only { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; margin: 0; }
.card[aria-busy="true"] { opacity: .5; transition: opacity .15s; }
.period .notice { color: var(--ink); font-weight: 700; }

/* Last 12 months: three SVG charts stacked in one card, each drawn at the card's pixel width and 220 px high
   (home.js redraws on resize), so axis text is 14 px like a caption. Colours come from the theme tokens. */
.trend-chart + .trend-chart { margin-top: 18px; }
.trend-h { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
#m-trend, .trend-chart, .trend-plot { min-width: 0; }
.trend-plot svg { display: block; max-width: 100%; height: auto; }
.trend-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.trend-legend span { display: inline-flex; align-items: center; gap: 6px; }
.trend-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; flex: none; }
.trend-legend .sw.bar { background: var(--bar); }
.trend-legend .sw.bar-dark { background: var(--bar-dark); }
.trend-legend .sw.target { width: 18px; height: 0; border-radius: 0; border-top: 2px dashed var(--alert); }

/* Board view: target / actual / variance for the month, quarter to date and year to date. */
.board-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.board-actions .msg { flex: 1 1 14em; }
.board-fallback { width: 100%; min-height: 8em; font: 13px ui-monospace, Menlo, monospace; background: var(--field-bg); color: var(--ink); border: 1px solid var(--field-line); border-radius: 8px; padding: 8px; }
table.board-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
table.board-table th, table.board-table td { padding: 8px 6px; border-bottom: 1px solid var(--line-soft); text-align: right; vertical-align: top; }
table.board-table th { font-size: 14px; color: var(--eyebrow); font-variant-caps: all-small-caps; letter-spacing: .05em; }
table.board-table thead th.group { text-align: center; border-bottom: 2px solid var(--line); color: var(--ink); }
table.board-table th:first-child, table.board-table td:first-child { text-align: left; position: sticky; left: 0; z-index: 1; background: var(--card);
    min-width: 8em; max-width: 12em; white-space: normal; }
table.board-table tbody th[scope="row"] { font-size: 15px; font-weight: 700; font-variant-caps: normal; letter-spacing: 0; color: var(--ink); }
ul.board-key { margin: 6px 0 0; padding-left: 1.6em; font-size: 14px; color: var(--muted); list-style: none; padding-left: 0; display: flex; flex-direction: column; gap: 4px; }
table.board-table td.num, table.board-table tbody th[scope="row"] { vertical-align: middle; }
table.board-table tbody tr { height: 4.3em; }   /* two label lines, so every row is the same height */
table.board-table tbody th[scope="row"] { line-height: 1.4; }
table.board-table td .chip { margin-left: 6px; padding: 1px 8px; font-size: 12px; vertical-align: middle; }
ol.board-notes { margin: 0; padding-left: 1.6em; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
table.board-table td.unread { color: var(--muted); font-style: italic; }
table.board-table td.var-good { color: var(--teal-ink); font-weight: 700; }
table.board-table td.var-bad { color: var(--alert-ink); font-weight: 700; }
table.board-table td.group-start, table.board-table th.group-start { border-left: 1px solid var(--line); }
.board-pipeline-missing { font-size: 14px; color: var(--muted); }
@media print {
    .topbar, .period, .board-actions, .reauth, .stale { display: none !important; }
    body { background: #fff; color: #000; }
    main { max-width: none; padding: 0; gap: 14px; }
    .card { border: 1px solid #999; border-radius: 0; padding: 8px; break-inside: avoid; }
    .scroll-x { overflow: visible; }
    table.board-table { font-size: 10px; white-space: normal; }
    table.board-table th:first-child, table.board-table td:first-child { position: static; background: #fff; }
    table.board-table td.var-good, table.board-table td.var-bad { color: #000; }
    table.board-table td.unread { color: #000; }
    table.board-table td.num { white-space: normal; }
    table.board-table tbody th[scope="row"] a, table.board-table tbody th[scope="row"] br { display: none !important; }
}

table.plain td.indent { padding-left: 1.5em; color: var(--muted); }

/* One chip. Meaning is fixed: red = breach, amber = waiting, teal = good, outline = a target value. Right-align in a row with margin-left:auto or put it last in a flex row. */
.chip { display: inline-flex; align-items: center; border-radius: 99px; padding: 3px 10px; font-size: 13px; font-weight: 800; line-height: 1.3; white-space: nowrap; border: 1px solid transparent; flex: none; }
.chip.chip-breach { background: var(--alert-bg); color: var(--alert-ink); border-color: var(--alert); }
.chip.chip-wait { background: var(--amber-bg); color: var(--amber-ink); border-color: var(--amber); }
.chip.chip-good { background: var(--good-bg); color: var(--good-ink); border-color: var(--teal); }
.chip.chip-target { background: transparent; color: var(--target-ink); border-color: var(--line); font-weight: 700; }
.row > .chip, .row .chip-slot { margin-left: auto; }

/* "How this is counted": a method block folded at the foot of a card. */
details.method { border-top: 1px solid var(--line-soft); padding-top: 10px; font-size: 14px; color: var(--muted); }
details.method summary { cursor: pointer; font-weight: 700; color: var(--teal-ink); min-height: 32px; display: flex; align-items: center; }
details.method[open] summary { margin-bottom: 6px; }
details.method p + p { margin-top: 6px; }

/* Head of Sales card contents (formatting task 4). */
.headline { display: flex; align-items: baseline; gap: 8px 12px; flex-wrap: wrap; }
.headline .chip { align-self: center; }
p.chips, .chip-slot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip-slot { justify-content: flex-end; }
.row.stuck { margin-right: -8px; }   /* the highlight's own 8 px inner padding, so its Review button lines up with the rows above and below */
.funnel-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 18px 24px; }
.funnel-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.funnel-list .subhead { margin-top: 0; }
.sale-row { display: flex; flex-direction: column; gap: 6px; }
.sale-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
details.detail { border-top: 1px solid var(--line-soft); padding-top: 10px; font-size: 15px; }
details.detail summary { cursor: pointer; font-weight: 700; color: var(--teal-ink); min-height: 32px; display: flex; align-items: center; }
details.detail[open] summary { margin-bottom: 6px; }
details.detail .caption { margin-top: 6px; }
/* Money tiles ("KES 410,581") need a wider column than counts, or the unbroken figure runs past its tile. */
#m-website .stats { grid-template-columns: repeat(auto-fit, minmax(12em, 1fr)); }
#m-website .stats .n { font-size: clamp(22px, 6vw, 30px); }

/* Advisor offer rows: the status chip always sits at the right edge; any action buttons drop to their own line beneath it. */
.row[data-offer] > .actions { flex-basis: 100%; }
