/* Dogwood Spend Dashboard (Demo) — offline build.
   Design tokens copied from the Grok Bot Page theme (light + dark). */
:root {
  --bg-base: #fcfcfc; --bg-subtle: #f7f7f7;
  --text-primary: #141414; --text-secondary: #14141499; --text-tertiary: #14141466;
  --text-on-primary: #fcfcfc; --text-accent: #0c64c1; --text-accent-deep: #084382;
  --text-success: #009957; --text-danger: #c21d2e; --text-warning: #c27400;
  --fill-primary: #070707; --fill-primary-hover: #2f2f2f;
  --fill-secondary: #77777717; --fill-secondary-hover: #77777726; --fill-hover: #1414140f;
  --fill-accent-subtle: #1084fe17;
  --border-subtle: #1414140d; --border-default: #14141426; --border-focus: #14141466;
  --data-0: #1084FE; --data-1: #FF9800; --data-2: #00BCA6; --data-other: #777777;
  --data-rest: #80BEFE; --data-area: #1084FE29;
  --font: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-base: #070707; --bg-subtle: #111111;
    --text-primary: #fcfcfc; --text-secondary: #fcfcfc99; --text-tertiary: #fcfcfc66;
    --text-on-primary: #141414; --text-accent: #459ffe; --text-accent-deep: #80befe;
    --text-success: #38d591; --text-danger: #ff5667; --text-warning: #ffaf38;
    --fill-primary: #fafafa; --fill-primary-hover: #d5d5d5;
    --fill-secondary: #7777772c; --fill-secondary-hover: #77777747; --fill-hover: #fcfcfc14;
    --fill-accent-subtle: #1084fe2c;
    --border-subtle: #fcfcfc0d; --border-default: #fcfcfc26; --border-focus: #fcfcfc66;
    --data-rest: #084382; --data-area: #1084FE3D;
  }
}
/* Force a theme with <html data-theme="light|dark"> if the host system needs it. */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] {
  color-scheme: dark;
  --bg-base: #070707; --bg-subtle: #111111;
  --text-primary: #fcfcfc; --text-secondary: #fcfcfc99; --text-tertiary: #fcfcfc66;
  --text-on-primary: #141414; --text-accent: #459ffe; --text-accent-deep: #80befe;
  --text-success: #38d591; --text-danger: #ff5667; --text-warning: #ffaf38;
  --fill-primary: #fafafa; --fill-primary-hover: #d5d5d5;
  --fill-secondary: #7777772c; --fill-secondary-hover: #77777747; --fill-hover: #fcfcfc14;
  --fill-accent-subtle: #1084fe2c;
  --border-subtle: #fcfcfc0d; --border-default: #fcfcfc26; --border-focus: #fcfcfc66;
  --data-rest: #084382; --data-area: #1084FE3D;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg-base); }
body { font-family: var(--font); color: var(--text-primary); -webkit-font-smoothing: antialiased; }
#app { padding: 32px 24px 96px; }
.page { max-width: 1280px; margin: 0 auto; overflow-wrap: anywhere; }

/* Type scale */
.t-h1 { font-size: 30px; line-height: 36px; letter-spacing: -0.4px; font-weight: 600; margin: 0; }
.t-h2 { font-size: 24px; line-height: 30px; letter-spacing: -0.25px; font-weight: 600; margin: 0; }
.t-h3 { font-size: 20px; line-height: 26px; letter-spacing: -0.1px; font-weight: 500; margin: 0; }
.t-body1 { font-size: 16px; line-height: 24px; letter-spacing: 0.1px; font-weight: 400; margin: 0; }
.t-subtext { font-size: 14px; line-height: 20px; letter-spacing: 0.1px; margin: 0; }
.t-body2 { font-size: 13px; line-height: 18px; letter-spacing: -0.08px; margin: 0; }
.t-label { font-size: 12px; line-height: 16px; letter-spacing: 0; margin: 0; }
.t-metric { font-size: 24px; line-height: 30px; letter-spacing: -0.25px; font-weight: 500; margin: 0; }
.caption { font-size: 14px; line-height: 20px; letter-spacing: 0.1px; color: var(--text-secondary); margin: 0; }
.num { font-variant-numeric: tabular-nums; overflow-wrap: normal; }

/* Section */
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: 16px; row-gap: 6px; }
.section-actions { display: flex; align-items: center; min-width: 0; max-width: 100%; }
.section-actions .segmented { margin-bottom: 0; }
.subtitle { margin-top: 2px; }
section { scroll-margin-top: 16px; }

/* Segmented control */
.segmented { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 12px; }
.segmented button { appearance: none; background: none; border: none; padding: 0; margin: 0; cursor: pointer; font: inherit;
  font-size: 13px; line-height: 18px; letter-spacing: -0.08px; color: var(--text-tertiary); border-bottom: 1.5px solid transparent; transition: color 140ms ease; }
.segmented button:hover { color: var(--text-secondary); }
.segmented button[aria-pressed="true"] { color: var(--text-primary); font-weight: 500; border-bottom-color: var(--text-primary); }
.segmented button span.inner { display: inline-block; padding: 2px 0; }
.segmented .count { font-size: 12px; line-height: 16px; color: var(--text-tertiary); margin-left: 5px; font-weight: 400; }

/* Metrics */
.metrics { display: grid; column-gap: 28px; row-gap: 16px; }
.metric .label { color: var(--text-primary); margin-top: 8px; }
.metric .detail { color: var(--text-secondary); margin-top: 4px; }

/* Table of contents */
.toc { border: 1px solid var(--border-default); border-radius: 12px; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.toc .toc-title { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-secondary); margin: 0 0 2px; }
.toc a { font-size: 14px; line-height: 20px; letter-spacing: 0.1px; color: var(--text-secondary); text-decoration: none;
  padding: 2px 6px; margin: 0 -6px; border-radius: 4px; align-self: flex-start; transition: background 140ms ease, color 140ms ease; }
.toc a:hover { background: var(--fill-hover); color: var(--text-primary); }
.toc a.active { color: var(--text-primary); font-weight: 500; }

/* Table */
.table-wrap { max-width: 100%; }
.table-wrap.scroll { overflow-x: auto; }
.table { display: grid; border: 0.5px solid var(--border-default); border-radius: 10px; overflow: clip; overflow-wrap: normal; }
.table .cell { padding: 8px 10px; font-size: 15px; line-height: 22px; letter-spacing: 0.1px; min-width: 0; }
.table .cell.c-n { border-inline-start: 0.5px solid var(--border-default); }
.table .cell.r-n { border-top: 0.5px solid var(--border-default); }
.table .cell.head { font-size: 14px; line-height: 20px; font-weight: 500; }
.table .cell.end { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .cell.em { font-weight: 500; }
.table .cell.tone-danger { color: var(--text-danger); font-weight: 500; }
.table .cell.tone-success { color: var(--text-success); font-weight: 500; }

/* Buttons and inputs */
.btn { appearance: none; border: none; cursor: pointer; font: inherit; font-size: 12px; line-height: 16px; font-weight: 500;
  border-radius: 9999px; padding: 4px 10px; height: 24px; color: var(--text-primary); background: var(--fill-secondary); transition: background 140ms ease; }
.btn:hover { background: var(--fill-secondary-hover); }
.btn.primary { background: var(--fill-primary); color: var(--text-on-primary); }
.btn.primary:hover { background: var(--fill-primary-hover); }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .segmented button:focus-visible, .toc a:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; line-height: 16px; color: var(--text-secondary); }
.field input { font: inherit; font-size: 14px; line-height: 20px; letter-spacing: 0.1px; color: var(--text-primary); background: var(--fill-secondary);
  border: none; border-radius: 8px; height: 28px; padding: 4px 8px; width: 100%; outline: none; }
.field input::placeholder { color: var(--text-tertiary); }
.field.select { display: inline-flex; max-width: 100%; }
.select-box { position: relative; display: inline-flex; max-width: 100%; }
.field select { appearance: none; -webkit-appearance: none; font: inherit; font-size: 14px; line-height: 20px; color: var(--text-primary);
  background: var(--fill-secondary); border: none; border-radius: 8px; padding: 4px 28px 4px 8px; max-width: 100%; cursor: pointer; }
.field select option { background: var(--bg-base); color: var(--text-primary); }
.select-box svg { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-secondary); }

/* Properties */
.props { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.props .row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; }
.props dt { font-size: 14px; line-height: 20px; color: var(--text-secondary); margin: 0; }
.props dd { font-size: 14px; line-height: 20px; color: var(--text-primary); margin: 0; }

/* Cards, grid, callout */
.card { background: var(--bg-base); border: 1px solid var(--border-default); border-radius: 16px; padding: 20px; min-width: 0; }
.card > .caption { margin-top: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid > .card { display: flex; flex-direction: column; align-items: stretch; }
.grid > .card > h3 { margin-bottom: 12px; }
.callout { display: flex; align-items: flex-start; gap: 8px; border-radius: 12px; background: var(--fill-accent-subtle); padding: 12px 16px; }
.callout .icon { display: flex; align-items: center; flex-shrink: 0; width: 20px; height: 24px; color: var(--text-accent); }
.callout .lead { font-size: 16px; line-height: 24px; letter-spacing: 0.1px; font-weight: 600; color: var(--text-accent); margin: 0; }
.callout .body { font-size: 16px; line-height: 24px; letter-spacing: 0.1px; color: var(--text-accent-deep); margin: 2px 0 0; }

/* Bars */
.bars { display: grid; grid-template-columns: minmax(80px, max-content) minmax(60px, 1fr) fit-content(40%); column-gap: 12px; row-gap: 10px; align-items: center; width: 100%; }
.bars .b-label { font-size: 13px; line-height: 18px; color: var(--text-secondary); }
.bars .b-label.em { color: var(--text-primary); }
.bars .track { height: 6px; border-radius: 9999px; background: var(--fill-secondary); overflow: hidden; }
.bars .fill { height: 100%; border-radius: 9999px; background: var(--data-rest); }
.bars .fill.em { background: var(--data-0); }
.bars .b-value { font-size: 13px; line-height: 18px; color: var(--text-primary); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bars .b-meta { font-size: 12px; line-height: 16px; color: var(--text-tertiary); }

/* Pie */
.pie { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.pie-legend { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 160px; }
.pie-legend .row { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 18px; color: var(--text-secondary); }
.pie-legend .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pie-legend .v { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.pie-legend .row:first-child .v { font-weight: 500; }
.pie-legend .share { color: var(--text-tertiary); margin-left: auto; font-variant-numeric: tabular-nums; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { font-family: var(--font); font-size: 12px; fill: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--border-default); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 12px; line-height: 16px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--bg-base); border: 1px solid var(--border-default); border-radius: 8px;
  padding: 8px 10px; box-shadow: 0 4px 16px #0000001a; font-size: 12px; line-height: 16px; min-width: 140px; white-space: nowrap; }
.tip .tt { font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
.tip .tr { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tip .tr b { margin-left: auto; padding-left: 12px; font-weight: 500; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tip i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

.load-error { max-width: 700px; margin: 64px auto; padding: 16px; border: 1px solid var(--border-default); border-radius: 12px; font-size: 14px; line-height: 20px; }
.load-error code { background: var(--fill-secondary); padding: 1px 4px; border-radius: 4px; }
@media (max-width: 600px) { #app { padding: 20px 14px 64px; } }
