:root {
    --ink: #1d2733;
    --muted: #5f6b7a;
    --line: #d9dee5;
    --bg: #f5f7fa;
    --panel: #ffffff;
    --brand: #1f4e79;
    --brand-ink: #ffffff;
    --section: #e8eef5;
    --ok-bg: #c6efce; --ok: #006100;
    --watch-bg: #ffeb9c; --watch: #9c6500;
    --risk-bg: #ffc7ce; --risk: #9c0006;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }

.topbar { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between; padding: .6rem 1rem; background: var(--brand); color: var(--brand-ink); }
.topbar a, .topbar .linklike { color: var(--brand-ink); }
.brand a { font-weight: 600; text-decoration: none; font-size: 1.05rem; }
.site-name { margin-left: .75rem; padding-left: .75rem; border-left: 1px solid rgba(255,255,255,.4); }
.usernav { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; font-size: .9rem; }
.usernav .who { opacity: .8; }
.reportnav { display: inline-flex; gap: .25rem; margin-left: 1rem; vertical-align: middle; }
.reportnav a { padding: .2rem .6rem; border-radius: 4px; text-decoration: none; font-size: .9rem; }
.reportnav a:hover { background: rgba(255,255,255,.12); }
.reportnav a.current { background: rgba(255,255,255,.22); font-weight: 600; }
.switcher { position: relative; }
.switcher summary { cursor: pointer; }
.switcher ul { position: absolute; right: 0; z-index: 5; list-style: none; margin: .3rem 0 0; padding: .3rem 0; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; min-width: 14rem; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.switcher li a { display: block; padding: .35rem .8rem; color: var(--ink); text-decoration: none; }
.switcher li a:hover { background: var(--bg); }

.page { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

form.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
button, .button { display: inline-block; background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 4px; padding: .5rem 1rem; font: inherit; cursor: pointer; text-decoration: none; }
button.small { padding: .25rem .6rem; font-size: .82rem; }
button.danger { background: #a4262c; }
input[type=email], input[type=password], input[type=text] { display: block; width: 100%; max-width: 26rem; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 4px; font: inherit; margin-top: .2rem; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.check { display: inline-flex; gap: .35rem; align-items: center; margin-right: .8rem; }
fieldset { border: 1px solid var(--line); border-radius: 4px; padding: .5rem .8rem; }
.field-error, .validation-message { color: var(--risk); font-size: .85rem; }

.account { max-width: 30rem; margin: 2rem auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1.5rem; }
.notice { padding: .6rem .8rem; border-radius: 4px; margin: .5rem 0 1rem; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-error { background: var(--risk-bg); color: var(--risk); }

.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: .8rem; }
.card { display: flex; flex-direction: column; gap: .2rem; padding: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--ink); }
.card span { color: var(--muted); font-size: .85rem; }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1.25rem; margin-bottom: 1.5rem; }
.kpi-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.subtitle { margin: 0; color: var(--muted); }
.asof { background: #fff8e1; border: 1px solid #f0d58c; border-radius: 4px; padding: .5rem .75rem; margin: 1rem 0; font-size: .9rem; }

table { border-collapse: collapse; width: 100%; }
.dashboard, .grid { background: var(--panel); margin-top: .75rem; }
.dashboard th, .dashboard td, .grid th, .grid td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.dashboard thead th, .grid thead th { background: var(--brand); color: var(--brand-ink); font-weight: 600; font-size: .88rem; }
.dashboard .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dashboard tr.section td { background: var(--section); font-weight: 600; font-size: .82rem; letter-spacing: .03em; }
/* "Where does this number come from": a small marker after a KPI label; hover, tap or focus shows the note. */
.src { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 1.05rem; height: 1.05rem; margin-left: .3rem;
       border: 1px solid var(--muted); border-radius: 50%; color: var(--muted); font: italic 600 .7rem/1 Georgia, serif; cursor: help; vertical-align: .1rem; }
.src:hover, .src:focus { border-color: var(--brand); color: var(--brand); outline: none; }
.src-pop { display: none; position: absolute; z-index: 10; left: -.5rem; top: 1.45rem; width: max-content; max-width: min(26rem, 80vw);
           padding: .5rem .65rem; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 4px;
           box-shadow: 0 4px 12px rgba(0,0,0,.14); font: normal 400 .82rem/1.4 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; text-align: left; cursor: auto; }
.src:hover .src-pop, .src:focus .src-pop, .src:focus-within .src-pop { display: block; }
.src-pop span { display: block; }
.src-pop .src-system { font-weight: 600; }
.src-pop .src-note { color: var(--muted); margin-top: .25rem; }
.src-static { cursor: default; }
@media print { .src { display: none; } }
.grid tr.flag td { background: #fff4f4; }
.grid td.actions { white-space: nowrap; }
.grid td.actions form { display: inline-block; margin: 0 .25rem .25rem 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: .2rem .4rem; align-items: center; }

.status { display: inline-block; min-width: 3.5rem; text-align: center; padding: .1rem .5rem; border-radius: 3px; font-size: .85rem; font-weight: 600; }
.status-ok { background: var(--ok-bg); color: var(--ok); }
.status-watch { background: var(--watch-bg); color: var(--watch); }
.status-risk { background: var(--risk-bg); color: var(--risk); }
.status-none { color: var(--muted); font-weight: 400; }
.tag { display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 3px; background: var(--section); color: var(--brand); margin-top: .2rem; }
.tag-on { background: var(--ok-bg); color: var(--ok); }
.tag-off { background: #eceff3; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .75rem 1rem; margin: 1rem 0; }
.panel summary { cursor: pointer; font-weight: 600; }

@media (max-width: 640px) {
    .dashboard th:nth-child(5), .dashboard td:nth-child(5) { display: none; }
    .grid { display: block; overflow-x: auto; }
}

@media print {
    .topbar, .foot, .button, .asof + table + p { display: none; }
    body { background: #fff; }
    .kpi { border: 0; padding: 0; }
}

/* Qualification expiry (Components/Shared/QualificationExpiry.razor) */
.expiry { margin-top: 1.75rem; }
.expiry h2 { font-size: 1.1rem; margin: 0 0 .2rem; }
.table-scroll { overflow-x: auto; }
.expiry-table { border-collapse: collapse; width: 100%; max-width: 760px; margin-top: .5rem; font-size: .9rem; }
.expiry-table th, .expiry-table td { padding: .35rem .5rem; border-bottom: 1px solid var(--line); text-align: left; }
.expiry-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.expiry-table tr.edge td { color: var(--muted); }
.expiry-table .bar-col { width: 32%; min-width: 80px; }
.expiry-table .bar { display: block; height: .7rem; border-radius: 2px; background: #2f6fa8; }
.expiry-table tr.edge .bar { background: #b9c1cb; }

/* Requestor trend (Components/Shared/TrendChart.razor) */
.trend { margin-top: 1.75rem; }
.trend h2 { font-size: 1.1rem; margin: 0 0 .2rem; }
.trend-svg { width: 100%; max-width: 760px; height: auto; display: block; margin-top: .5rem; }
.trend-svg .grid { stroke: #e3e7ec; stroke-width: 1; }
.trend-svg .grid.base { stroke: #b9c1cb; }
.trend-svg .axis { fill: var(--muted); font-size: 11px; }
.trend-svg .axis.note { font-size: 10px; font-style: italic; }
.trend-svg .value { fill: var(--ink); font-size: 12px; font-weight: 600; }
.trend-svg .goal { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 4; }
.trend-svg .goal-label { fill: var(--ink); font-size: 12px; font-weight: 600; }
.trend-svg .bar:hover path { filter: brightness(1.12); }
.trend-table { margin-top: .5rem; font-size: .9rem; }
.trend-table summary { cursor: pointer; color: var(--brand); }
.trend-table table { max-width: 32rem; }
.trend-foot { margin: .25rem 0 0; }
.downloads { display: flex; gap: .5rem; flex-wrap: wrap; }
.button.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }

/* Audience Report (Components/Pages/AudienceReportPage.razor): tab picker and the generic tab table. */
.report-tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin: 1rem 0 .5rem; }
.report-tabs a { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink); text-decoration: none; font-size: .85rem; }
.report-tabs a.current { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.report-title { font-size: 1.1rem; margin: .75rem 0 .25rem; }
.na-note { color: #9c3d00; margin: .25rem 0; }
/* Wide report tables: the page may use more of a wide screen, and labels and headings wrap so most tabs fit
   without sideways scrolling (only numbers stay on one line). */
.page:has(table.report) { max-width: 1440px; }
table.report { font-size: .82rem; }
table.report th, table.report td { padding: .28rem .4rem; }
table.report td.num { white-space: nowrap; }
table.report tbody td:first-child { min-width: 12rem; }
table.report thead th { text-align: center; line-height: 1.2; vertical-align: bottom; }
table.report thead th.band { border-bottom: 1px solid rgba(255,255,255,.35); }
table.report thead th.sub { font-weight: 400; font-size: .78rem; }
table.report td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.report td.indent-1 { padding-left: 1.4rem; }
table.report td.indent-2 { padding-left: 2.4rem; }
table.report tr.k-section td { background: var(--section); font-weight: 600; }
table.report tr.k-heading td, table.report tr.k-subtotal td { font-weight: 600; }
table.report tr.k-total td { font-weight: 700; background: #f2f2f2; border-top: 1px solid var(--muted); }
table.report tr.k-percent td, table.report tr.k-legend td { font-style: italic; color: var(--muted); }

/* Admin Mappings page: filter by kind. */
.filters { display: flex; flex-wrap: wrap; gap: .25rem; margin: .5rem 0; }
.filters a { padding: .2rem .55rem; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink); text-decoration: none; font-size: .85rem; }
.filters a.current { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.grid select { max-width: 22rem; }
