: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); }

/* Sidebar layout (add-portal-layout-choice; Components/Layout/MainLayout.razor): a client site set to Sidebar on the
   admin Clients page. The sidebar stays in view while the page scrolls; below 760px it sits above the page. */
.shell-sidebar { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: .3rem;
           padding: 1rem .8rem; background: var(--brand); color: var(--brand-ink); font-size: .92rem; }
.sidebar a, .sidebar .linklike { color: var(--brand-ink); }
.sb-brand { font-weight: 600; font-size: 1.05rem; text-decoration: none; margin-bottom: .6rem; }
.sb-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; opacity: .7; margin-top: .7rem; }
.sb-client, .sb-switcher summary { background: rgba(255,255,255,.12); border-radius: 5px; padding: .3rem .55rem; }
.sb-switcher summary { cursor: pointer; }
.sb-switcher ul { list-style: none; margin: .3rem 0 0; padding: .3rem 0; background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
                  box-shadow: 0 4px 12px rgba(0,0,0,.12); max-height: 50vh; overflow-y: auto; }
.sb-switcher li a { display: block; padding: .35rem .7rem; color: var(--ink); text-decoration: none; }
.sb-switcher li a:hover { background: var(--bg); }
.sb-reports { display: flex; flex-direction: column; gap: .15rem; }
.sb-reports a { padding: .3rem .55rem; border-radius: 5px; text-decoration: none; }
.sb-reports a:hover { background: rgba(255,255,255,.12); }
.sb-reports a.current { background: var(--brand-ink); color: var(--brand); font-weight: 600; }
.sb-account { margin-top: auto; padding-top: .7rem; border-top: 1px solid rgba(255,255,255,.25); display: flex; flex-direction: column;
              align-items: flex-start; gap: .3rem; font-size: .85rem; }
.sb-account a, .sb-account .linklike { text-decoration: none; opacity: .9; }
.sb-account a:hover, .sb-account .linklike:hover { text-decoration: underline; opacity: 1; }
.sb-account .who { opacity: .7; font-size: .8rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-main { min-width: 0; display: flex; flex-direction: column; }
.sb-main .page { width: 100%; }
@media (max-width: 760px) {
    .shell-sidebar { display: block; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; padding: .6rem 1rem; }
    .sb-brand { margin: 0; }
    .sb-label { display: none; }
    .sb-reports { flex-direction: row; flex-wrap: wrap; }
    .sb-account { margin: 0; padding: 0; border: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; }
    .sb-switcher ul { position: absolute; z-index: 5; min-width: 14rem; }
    .sb-switcher { position: relative; }
}
@media print {
    .sidebar { display: none; }
    .shell-sidebar { display: block; }
}

.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, .period-picker, .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. */
/* Title tabs (a client with several titles, e.g. the demo's three): one title at a time on each report page. */
.title-tabs { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 1.25rem; border-bottom: 2px solid var(--brand); }
.title-tabs a { padding: .5rem 1.1rem; margin-bottom: -2px; border: 2px solid transparent; border-radius: 6px 6px 0 0; color: var(--ink); text-decoration: none; font-weight: 600; }
.title-tabs a:hover { background: var(--panel); }
.title-tabs a.current { border-color: var(--brand); border-bottom-color: var(--bg, #fff); background: var(--bg, #fff); color: var(--brand); }
.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); }
.period-picker { align-items: center; margin: .25rem 0 .5rem; }
.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; }

/* Public landing page (Components/Pages/Landing.razor): the central site's front page for someone not signed in. */
.landing-hero { max-width: 46rem; margin: 2.5rem auto 2rem; text-align: center; }
.landing-hero h1 { font-size: 2.1rem; line-height: 1.2; margin-bottom: .75rem; }
.landing-hero .lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 1.5rem; }
.landing-actions { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; justify-content: center; align-items: center; }
.landing-actions .button { padding: .65rem 1.6rem; font-size: 1rem; }
.landing-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin: 1rem 0 2rem; }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1.1rem 1.2rem; }
.feature h2 { font-size: 1.02rem; margin: 0 0 .35rem; color: var(--brand); }
.feature p { margin: 0; color: var(--ink); font-size: .92rem; }
.landing-note { text-align: center; max-width: 40rem; margin: 0 auto .5rem; }
@media (max-width: 640px) { .landing-hero { margin-top: 1.5rem; } .landing-hero h1 { font-size: 1.6rem; } }
/* Automation map diagram (Components/Admin/AutomationMapPage.razor): boxes are automations, arrows point at what each
   one can set off. Laid out on the server; the only interaction is the link on each box, plus hover. Identity is never
   colour alone - every box carries its ID and name, and the status dot is repeated in words in the list below. */
.map-svg { display: block; margin: .5rem 0 .25rem; max-width: none; }
.map-svg a { cursor: pointer; }

.map-edge { fill: none; stroke: #b9c1cb; stroke-width: 1.5; }
.map-edge.back { stroke-dasharray: 5 4; }
.map-edge.mutual { stroke: #9c6500; }
.map-edge.lit { stroke: var(--brand); stroke-width: 2.5; }
.map-head { fill: #b9c1cb; }
.map-head.lit { fill: var(--brand); }

.map-edge-labels text { fill: var(--muted); font-size: 11px; paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round; }

.map-node rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
.map-node .map-key { fill: var(--ink); font-size: 12px; font-weight: 600; }
.map-node .map-name { fill: var(--muted); font-size: 11px; }
.map-node.off rect { fill: #f3f5f8; stroke-dasharray: 4 3; }
.map-node.current rect { stroke: var(--brand); stroke-width: 2.5; }
.map-node.current .map-key { fill: var(--brand); }
.map-svg a:hover .map-node rect, .map-svg a:focus .map-node rect { stroke: var(--brand); stroke-width: 2.5; }
.map-svg a:focus { outline: none; }
.map-svg a:focus-visible .map-node rect { stroke: var(--brand); stroke-width: 3; }

.map-node.folded rect { fill: var(--section); stroke: var(--line); stroke-dasharray: 4 3; }
.map-node.folded .map-key { fill: var(--muted); }
.map-edge.many { stroke-width: 3; }

/* Trigger type. Three hues only: a fourth categorical colour cannot be told apart reliably when any box can sit beside
   any other (validated all-pairs on the white panel), so every other trigger type carries no bar and is named in words.
   The status colours above are not reused here - a green dot beside the aqua bar would read as a fourth category. */
.map-bar { fill: none; }
.map-bar.field { fill: #2a78d6; }
.map-bar.tagadd { fill: #eb6834; }
.map-bar.submit { fill: #1baf7a; }

.map-legend { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; margin: .5rem 0 0; padding: 0; font-size: .82rem; color: var(--muted); }
.map-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.map-swatch { width: 5px; height: 1rem; border-radius: 2px; background: var(--line); }
.map-swatch.field { background: #2a78d6; }
.map-swatch.tagadd { background: #eb6834; }
.map-swatch.submit { background: #1baf7a; }
.map-swatch.other { background: transparent; border: 1px solid var(--line); width: 1rem; }
.map-swatch.paused { background: transparent; border: 1px dashed var(--muted); width: 1rem; }

/* The focused chain is what a node link navigates to, so leave it a little room below the viewport edge. */
#chain { scroll-margin-top: 1rem; }

@media print {
    .map-svg { page-break-inside: avoid; }
}
