/* Original colour scheme (light + dark), with the system sans-serif throughout. */
:root {
  color-scheme: light;
  --paper: #f6f6f4;      /* page background */
  --card: #fcfcfb;       /* cards, fields, popup */
  --line: #e2e1dc;       /* borders and dividers */
  --field: #d3d2cc;      /* field borders */
  --ink: #0b0b0b;
  --muted: #52514e;
  --faint: #72716d;      /* 4.52:1 on page (hint text) */
  --green: #2770c9;      /* accent: selection, links, actual values. 4.57:1 on page, 4.82:1 on cards */
  --rust: #52514e;       /* targets in the detail chart: neutral, not a second hue */
  --target: #939289;     /* muted target line on cards, 3.05:1 */
  --met: #1f7a45;        /* status: meets target, 5.2:1 on cards */
  --miss: #b0451f;       /* status: not meeting target, 5.5:1 on cards */
  /* Goal colours (media/Strategic Plan Goal Colors.xlsx). Used only for the goal strip and the goal-focus
     wash, never for text, charts or status. */
  --goal-1: #B4793A; --goal-2: #316967; --goal-3: #3E3E3E; --goal-4: #AA5732; --goal-5: #3A6A54; --goal-6: #3B81C0;
  --focus-mix: 4%;
  --grid: #ecebe7;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;
  --backdrop: rgb(0 0 0 / .45);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #121211; --card: #1a1a19; --line: #2e2e2c; --field: #3a3a37; --ink: #f0efec; --muted: #c3c2b7;
    --faint: #9a998f; --green: #3987e5; --rust: #c3c2b7; --target: #7a7974; --grid: #262624;
    --warn-bg: #3a2e0c; --warn-ink: #f3d68a; --backdrop: rgb(0 0 0 / .6); --met: #5cc489; --miss: #f08a6a; --goal-3: #8a8a8a; --focus-mix: 7%;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121211; --card: #1a1a19; --line: #2e2e2c; --field: #3a3a37; --ink: #f0efec; --muted: #c3c2b7;
  --faint: #9a998f; --green: #3987e5; --rust: #c3c2b7; --target: #7a7974; --grid: #262624;
  --warn-bg: #3a2e0c; --warn-ink: #f3d68a; --backdrop: rgb(0 0 0 / .6); --met: #5cc489; --miss: #f08a6a; --goal-3: #8a8a8a; --focus-mix: 7%;
}
/* Increased contrast (system setting): darker secondary text, visible edges on cards and fields. */
@media (prefers-contrast: more) {
  :root { --muted: #3d3c3a; --faint: #52514e; --line: #8f8e88; --field: #8f8e88; --target: #6b6a66; --green: #1f5fae; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --muted: #e0dfd6; --faint: #c3c2b7; --line: #6b6a66; --field: #6b6a66; --target: #9a998f; }
}
* { box-sizing: border-box; }
/* --page is the page colour (with the goal wash); the frozen pane paints the same colour so cards scroll under it. */
body { --page: var(--paper); margin: 0; background: var(--page); color: var(--ink); line-height: 1.4; transition: background-color .4s ease; }
/* Goal focus: a single goal is selected; the page takes a faint wash of that goal's colour. */
body.goal-focus { --page: color-mix(in srgb, var(--focus) var(--focus-mix), var(--paper)); }
.top, .goalbar-wrap, .layout { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
main { min-width: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
p { margin: 0 0 14px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-top: 24px; padding-bottom: 4px; }
h1 { margin: 0; font-size: 1.6rem; }
/* Seal before the page title, sized to the title block (title + subtitle). */
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.seal { flex: none; width: 52px; height: 52px; }
.sub { margin: 4px 0 0; color: var(--muted); }
.intro { max-width: 72ch; font-size: .9rem; line-height: 1.4; }
.as-of { font-size: .85rem; }

/* type tabs */
/* Six-colour goal strip under the header (as in media/colorbar.png). In goal focus, the other goals fade. */
.goalbar { display: flex; height: 3px; margin-top: 16px; border-radius: 2px; overflow: hidden; }
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 28px; }
.goalbar span { flex: 1; background: var(--c); transition: opacity .4s ease; }
body.goal-focus .goalbar span:not(.on) { opacity: .25; }
/* One row: type tabs on the left, Results and search on the right, sharing the bottom rule. */
/* Frozen pane: goal heading with Results and search on one line, then the type tabs. Sticks to the top of
   the window; the measures scroll beneath it. */
.pane { position: sticky; top: 0; z-index: 3; background: var(--page); transition: background-color .4s ease;
  border-bottom: 1px solid var(--line); padding-top: 18px; }
.pane-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; }
.goal-title { margin: 0; font-size: 1.15rem; line-height: 1.3; flex: 1 1 320px; min-width: 0; }
.goal-title .goal-code { display: inline-flex; align-items: center; gap: 7px; margin-right: 10px; }
.goal-title .goal-code::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.tabs { display: flex; gap: 25px; overflow-x: auto; margin-top: 8px; }
.tabs button { margin-bottom: -1px; padding: 12px 1px; border: 0; border-bottom: 3px solid transparent; background: none; font: inherit;
  color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { border-color: var(--green); color: var(--green); font-weight: 650; }

/* Goal sidebar: one level, one item selected. Goal colours appear only as a small swatch and, on the
   selected item, a faint tint with a thin leading bar. */
.sidebar { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow: auto; padding: 18px 0 16px; }
.goalnav { display: flex; flex-direction: column; gap: 2px; }
/* Term + definition: quiet reference text, clearly not a control (no fill, no hover, default cursor). */
.term { padding: 0 12px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); cursor: default; user-select: text; }
.term-name { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.term-def { margin: 2px 0 0; font-size: .8rem; line-height: 1.35; color: var(--faint); }
.about-item .term-def { margin: -2px 0 6px; font-style: italic; }
.kind-def { margin: 14px 0 0; font-size: .85rem; color: var(--muted); }
.gnav { position: relative; display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; font: inherit;
  color: var(--ink); background: none; border: 0; border-radius: 8px; padding: 8px 10px 8px 12px; cursor: pointer; }
.gnav:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.gnav[aria-current="true"] { background: color-mix(in srgb, var(--c, var(--ink)) 12%, var(--card)); }
.gnav[aria-current="true"]::before { content: ''; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 2px;
  background: var(--c, var(--ink)); }
.swatch { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-top: 5px; }
.gtext { min-width: 0; }
.gtitle { display: block; font-weight: 600; font-size: .9rem; }
.glabel { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .8rem;
  color: var(--muted); line-height: 1.3; margin-top: 1px; }

/* filters */
.filters { display: flex; align-items: center; gap: 12px; margin-left: auto; }
  border: 1px solid var(--field); border-radius: 3px; padding: 8px 36px 8px 10px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%237a7974' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center/12px 8px; }
/* Search: a quiet magnifying glass field, pushed to the right; it only gains a border on focus. */
.filters .search { display: block; width: 240px; }

/* Cards / Rows switch: a two-segment control; the selected segment is raised. */
/* Funnel filter button and its pane. */
.filter-wrap { position: relative; }
.filter-btn { position: relative; display: grid; place-items: center; width: 36px; height: 34px; border: 1px solid var(--field);
  border-radius: 8px; background: var(--card); color: var(--muted); cursor: pointer; }
.filter-btn:hover, .filter-btn[aria-expanded="true"] { color: var(--ink); border-color: var(--faint); }
.filter-btn.on { color: var(--green); border-color: var(--green); }
.filter-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.filter-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--green); color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }
.filter-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 5; width: 320px; max-height: min(70vh, 560px);
  display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(0 0 0 / .16); }
.fp-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.fp-body { overflow: auto; padding: 4px 16px 8px; }
.fp-group { border: 0; margin: 0; padding: 10px 0 6px; }
.fp-group + .fp-group { border-top: 1px solid var(--line); }
.fp-group legend { padding: 0; margin-bottom: 4px; font-size: .75rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fp-opt { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: .9rem; cursor: pointer; }
.fp-opt input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.fp-foot { display: flex; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--line); }
.link { border: 0; background: none; padding: 4px 0; font: inherit; font-size: .9rem; color: var(--green); cursor: pointer; }
.done { border: 0; border-radius: 8px; padding: 7px 16px; font: inherit; font-weight: 600; background: var(--green); color: #fff; cursor: pointer; }

/* Active filter pills, under the button row; one line only. */
.pills { display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 6px; overflow: hidden; margin: 8px 0 0 auto; }
.pill { flex: none; display: inline-flex; align-items: center; gap: 2px; padding: 3px 3px 3px 10px; border-radius: 999px;
  font-size: .8rem; background: color-mix(in srgb, var(--green) 10%, var(--card)); color: var(--ink); }
.pill button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: none;
  color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer; }
.pill button:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
.pill .pill-open { width: auto; height: auto; border-radius: 0; font-size: .8rem; color: var(--ink); padding: 0 4px 0 0; }
.pill .pill-open:hover { background: none; text-decoration: underline; }

.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: 8px; background: color-mix(in srgb, var(--ink) 7%, transparent); }
.segmented button { display: grid; place-items: center; width: 34px; height: 30px; border: 0; border-radius: 6px; background: none;
  color: var(--muted); cursor: pointer; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.segmented svg { width: 16px; height: 16px; fill: currentColor; }
.search input { width: 100%; font: inherit; font-size: .9rem; color: var(--ink); border: 1px solid transparent;
  border-radius: 3px; padding: 8px 8px 8px 30px; background: transparent
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Ccircle cx='6.5' cy='6.5' r='5' fill='none' stroke='%237a7974' stroke-width='1.6'/%3E%3Cpath d='M10.3 10.3l4.2 4.2' stroke='%237a7974' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 8px center/15px 15px; }
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--field); background-color: var(--card); }

/* goal sections */
.goal-code { color: var(--ink); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }

.card { text-align: left; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: 6px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-height: 170px; }
.card:hover { border-color: var(--green); }
.card-top { display: flex; justify-content: space-between; gap: 8px; }
.kind { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0; }
.badge.review { font-size: .72rem; background: var(--warn-bg); color: var(--warn-ink); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.name { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .value { font-size: 1.7rem; font-weight: 650; margin-top: auto; }
.period { font-size: .85rem; color: var(--muted); }
.no-results { margin-top: auto; color: var(--muted); font-style: italic; padding: 10px 0 2px; }
.spark { width: 100%; height: 40px; display: block; margin-top: 4px; }
.spark-line { fill: none; stroke: var(--green); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: url(#spark-fill); stroke: none; }
.spark-stop-top { stop-color: var(--green); stop-opacity: .18; }
.spark-stop-bottom { stop-color: var(--green); stop-opacity: 0; }
.spark-target { fill: none; stroke: var(--target); stroke-width: 1.5; stroke-dasharray: 4 3; }
.spark-dot { fill: var(--green); stroke: var(--card); stroke-width: 2; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* Rows view: one measure per row, about 76px tall. */
.rows { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 240px 240px 16px; align-items: center; gap: 24px; width: 100%;
  min-height: 76px; text-align: left; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 18px 10px 20px; cursor: pointer; }
.row:hover { border-color: var(--green); }
.row .name { font-weight: 600; font-size: 1.05rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.r-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 3px; }
.r-meta .status { font-size: .8rem; }
.r-val { border-left: 1px solid var(--line); padding-left: 24px; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.r-val .value { font-size: 1.6rem; font-weight: 650; line-height: 1.1; }
.r-val .period { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-val .no-results { margin: 0; padding: 0; font-size: .9rem; }
.r-spark .spark { height: 48px; margin: 0; }
.chev { width: 10px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; justify-self: end; }
.row:hover .chev { stroke: var(--ink); }
.status { font-size: .85rem; font-weight: 600; }
.status.met { color: var(--met); }
.status.miss { color: var(--miss); }
.headline .status { margin-top: 4px; font-size: .9rem; }
footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 17px 0 32px; color: var(--muted); font-size: .8rem; }

/* detail popup */
/* The popup rises slightly into place near the top of the window, covering the top of the page. */
dialog { margin: 24px auto auto; width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 28px 28px; background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgb(0 0 0 / .2); }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
dialog[open] { animation: rise .32s cubic-bezier(.2, .8, .2, 1); }
dialog[open]::backdrop { animation: fade .32s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  dialog[open] { animation: fade .15s ease-out; }
  body, .goalbar span { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  dialog::backdrop { backdrop-filter: none; background: rgb(0 0 0 / .65); }
}
.close-row { display: flex; justify-content: flex-end; margin: 0 -12px -8px 0; }
.close-row button { font: inherit; font-size: 1.1rem; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 10px; }
.close-row button:hover { color: var(--ink); }
#d-body:focus { outline: none; }
#d-body h2 { margin: 4px 0; font-size: 1.35rem; }
.goal-line { margin-bottom: 10px; }
.status.warn { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 12px; border-radius: 4px; font-size: .9rem; font-weight: 400; }
.headline { border-block: 1px solid var(--line); padding: 12px 0; margin: 12px 0 8px; }
.headline .value { font-size: 1.7rem; font-weight: 650; }
.headline .period { font-size: .9rem; }

.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.key.actual { background: var(--green); }
.key.target { border: 2px solid var(--rust); }
.chart { position: relative; }
.trend { width: 100%; height: auto; display: block; }
.trend-line { fill: none; stroke: var(--green); stroke-width: 2; stroke-linejoin: round; }
.trend-dot { fill: var(--green); stroke: var(--card); stroke-width: 2; }
.target-dot { fill: none; stroke: var(--rust); stroke-width: 2; }
.axis text { fill: var(--muted); font-size: 11px; }
.axis .domain, .axis .tick line { stroke: var(--line); }
.grid .tick line { stroke: var(--grid); }
.crosshair { stroke: var(--faint); stroke-dasharray: 3 3; }
.hit { fill: transparent; }
.tooltip { position: absolute; pointer-events: none; background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; font-size: .85rem; box-shadow: 0 4px 14px rgb(0 0 0 / .1); min-width: 140px; }

.comment { border-left: 3px solid var(--green); padding: 0 0 0 14px; margin: 20px 0; }
.comment h3 { font-size: .95rem; margin: 0 0 4px; }
.comment p { color: var(--muted); line-height: 1.5; white-space: pre-line; margin: 0; }

.about { border-top: 1px solid var(--line); margin-top: 20px; }
.about-item h3 { font-size: 1rem; margin: 16px 0 4px; }
.about-item p { color: var(--muted); line-height: 1.5; max-width: 75ch; margin: 0 0 8px; }

details.values { margin: 6px 0 0; }
details.values summary { cursor: pointer; color: var(--green); font-weight: 650; }
.tablewrap { overflow: auto; margin-top: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
tr > *:first-child { text-align: left; padding-left: 0; }

@media (max-width: 860px) {
  /* Narrow screens: the sidebar becomes a row of goal chips above the tabs. */
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { position: static; max-height: none; padding: 12px 0 2px; }
  .goalnav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .gnav { width: auto; flex: none; align-items: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; }
  .gnav[aria-current="true"]::before, .glabel { display: none; }
  .swatch { margin-top: 0; }
}
@media (max-width: 1000px) {
  .row { grid-template-columns: minmax(0, 1fr) 210px 150px 16px; gap: 16px; }
}
@media (max-width: 720px) {
  /* Phones: stack the row. Name (with status) on top, value and period beneath, chevron on the right. */
  .row { grid-template-columns: minmax(0, 1fr) 12px; gap: 6px 12px; padding: 12px 14px 12px 16px; }
  .r-name { grid-column: 1; }
  .r-val { grid-column: 1; grid-row: 2; border-left: 0; padding-left: 0; flex-direction: row; justify-content: flex-start; align-items: baseline; gap: 10px; }
  .r-val .value { font-size: 1.35rem; }
  .r-spark { display: none; }
  .chev { grid-column: 2; grid-row: 1 / span 2; }
  h1 { font-size: 1.3rem; }
  .seal { width: 40px; height: 40px; }
  .filters { width: 100%; margin-left: 0; }
  .filters .search { flex: 1 1 0; width: auto; min-width: 0; }
  .filter-panel { position: fixed; left: 16px; right: 16px; top: auto; width: auto; }
  .pills { justify-content: flex-start; margin-left: 0; max-width: none !important; }
  dialog { padding: 14px 18px 24px; }
}
