/* Layout and components. Colours come only from brand.css variables
   (docs/INVARIANTS.md); tests/test_no_colour_outside_brand_css.py checks it.
   Verdicts always carry a text label as well as a colour (DECISIONS.md item 6).
   Tints are made with color-mix() from the brand variables, never new colours. */
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper);
       font-size: 15px; line-height: 1.5; }
a { color: var(--brand-primary); }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 24px 0 8px; }
h3 { font-size: 16px; margin: 16px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
                   overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus { left: 8px; top: 8px; z-index: 10; background: var(--paper); padding: 8px 12px;
                   border: 2px solid var(--brand-primary); border-radius: var(--radius-control); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-card);
        padding: 32px; }

/* Sign-in */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--line);
             border-radius: var(--radius-card); padding: 40px 32px; }
.auth-logo { display: block; max-width: 100%; height: auto; margin: 0 auto 24px; }
.auth-card h1 { text-align: center; margin-bottom: 20px; }
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line);
        border-radius: var(--radius-control); background: var(--paper); color: var(--ink);
        max-width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand-blue); outline-offset: 1px; }
.form-error { border-left: 4px solid var(--status-noncompliant); padding: 8px 12px;
              background: var(--paper); margin: 0 0 16px; }

/* Buttons */
button { font: inherit; cursor: pointer; border-radius: var(--radius-control); }
.btn, .btn-primary, .btn-quiet, .btn-danger { display: inline-block; text-decoration: none;
       border-radius: var(--radius-control); font-weight: 600; line-height: 1.2; }
.btn-primary { background: var(--brand-primary); color: var(--paper); border: 0; padding: 11px 16px; }
.btn-primary:hover { background: var(--brand-blue); }
.btn { background: var(--paper); color: var(--brand-primary); border: 1px solid var(--brand-primary);
       padding: 9px 14px; }
.btn:hover { background: var(--brand-soft); }
.btn-quiet { background: none; border: 1px solid var(--line); color: var(--ink); padding: 6px 12px;
             font-weight: 400; }
/* Ink on a tint, the colour in a heavy border: paper text on the status red is
   only 4.15:1, below WCAG AA for button-size text. */
.btn-danger { background: color-mix(in srgb, var(--status-noncompliant) 10%, var(--paper));
              color: var(--ink); border: 2px solid var(--status-noncompliant); padding: 9px 14px; }
.btn-danger:hover { background: color-mix(in srgb, var(--status-noncompliant) 20%, var(--paper)); }

/* App shell: top bar, navigation, banners, footer */
body.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; padding: 10px 24px;
          border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar .brand { display: flex; align-items: center; gap: 10px; color: var(--ink);
                 text-decoration: none; }
.topbar .brand img { height: 28px; width: auto; }
.topbar .product { font-weight: 600; white-space: nowrap; }
.topbar form { margin: 0; }
.global-search { display: flex; gap: 8px; flex: 1 1 320px; max-width: 560px; margin-left: auto; }
.global-search input { flex: 1; min-width: 0; padding: 8px 12px; }
.global-search .btn { padding: 8px 14px; }
.user-menu { position: relative; }
.user-menu summary { cursor: pointer; list-style: none; padding: 6px 10px; border: 1px solid var(--line);
                     border-radius: var(--radius-control); max-width: 240px; overflow: hidden;
                     text-overflow: ellipsis; white-space: nowrap; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; min-width: 200px;
                   display: grid; gap: 2px; padding: 8px; background: var(--paper);
                   border: 1px solid var(--line); border-radius: var(--radius-control); }
.user-menu .menu a, .user-menu .menu button { display: block; width: 100%; text-align: left;
                   padding: 6px 10px; text-decoration: none; color: var(--ink); border: 0;
                   background: none; border-radius: var(--radius-control); }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--brand-soft); }
.mainnav { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--line);
           overflow-x: auto; background: var(--paper); }
.mainnav a { padding: 10px 12px; color: var(--ink); text-decoration: none; white-space: nowrap;
             border-bottom: 3px solid transparent; }
.mainnav a:hover { color: var(--brand-primary); }
.mainnav a.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary);
                    font-weight: 600; }
.banner { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 24px;
          border-bottom: 1px solid var(--line); }
.banner-draft { background: color-mix(in srgb, var(--status-warning) 14%, var(--paper));
                border-left: 6px solid var(--status-warning); }
.page { max-width: 1200px; width: 100%; margin: 0 auto; padding: 24px; flex: 1; }
.page.wide { max-width: none; }
.footer { display: flex; flex-wrap: wrap; gap: 4px 24px; padding: 16px 24px; font-size: 13px;
          color: var(--muted); border-top: 1px solid var(--line); }

/* Messages and notices */
.flash, .notice { padding: 10px 14px; margin: 0 0 16px; border: 1px solid var(--line);
                  border-left-width: 6px; border-radius: var(--radius-control); background: var(--paper); }
.flash-info { border-left-color: var(--brand-primary); }
.flash-success, .notice-compliant { border-left-color: var(--status-compliant); }
.flash-warning, .notice-warning { border-left-color: var(--status-warning); }
.flash-error, .notice-non_compliant { border-left-color: var(--status-noncompliant); }
.notice-unknown { border-left-color: var(--muted); }
.message-card { max-width: 640px; }

/* Verdict labels: text plus colour, never colour alone. The label text is ink
   (the status colours on their own tint are 2.9:1 to 4.5:1, below WCAG AA for
   13px text); the colour is carried by the border and a leading dot. */
.verdict { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px;
           border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
           color: var(--ink); border: 1px solid var(--verdict-colour, var(--muted));
           background: color-mix(in srgb, var(--verdict-colour, var(--muted)) 10%, var(--paper)); }
.verdict::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%;
                   background: var(--verdict-colour, var(--muted)); }
.verdict-compliant { --verdict-colour: var(--status-compliant); }
.verdict-non_compliant { --verdict-colour: var(--status-noncompliant); }
.verdict-unknown { --verdict-colour: var(--muted); }

/* Badges and chips */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
         background: var(--brand-soft); color: var(--ink); white-space: nowrap; }
.badge-success { background: color-mix(in srgb, var(--status-compliant) 18%, var(--paper)); }
.badge-warning { background: color-mix(in srgb, var(--status-warning) 22%, var(--paper)); }
.badge-danger { background: color-mix(in srgb, var(--status-noncompliant) 18%, var(--paper)); }
.badge-muted { background: var(--line); }

/* Home tiles */
.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
         margin-top: 16px; }
.tile { display: grid; align-content: start; gap: 4px; padding: 20px 22px; color: var(--ink);
        text-decoration: none; background: var(--paper); border: 1px solid var(--line);
        border-top: 6px solid var(--brand-primary); border-radius: var(--radius-card); }
.tile:hover { border-color: var(--brand-primary); }
.tile-title { font-weight: 600; color: var(--muted); }
.tile-value { font-size: 32px; font-weight: 700; line-height: 1.1; }
.tile-sub { font-size: 14px; }
.tile-details { display: grid; gap: 2px; margin-top: 6px; font-size: 13px; }
.tile-non_compliant { border-top-color: var(--status-noncompliant); }
.tile-warning { border-top-color: var(--status-warning); }
.tile-compliant { border-top-color: var(--status-compliant); }
.tile-unknown { border-top-color: var(--muted); }
.tile-unknown .tile-value { font-size: 22px; color: var(--muted); }

/* Tables: dense, sortable, clickable rows */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-control); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data caption { text-align: left; padding: 8px; font-weight: 600; }
table.data th, table.data td { padding: 5px 8px; border-bottom: 1px solid var(--line);
                               text-align: left; vertical-align: top; }
table.data th { position: sticky; top: 0; background: var(--paper); white-space: nowrap;
                font-weight: 600; }
table.data th a.sort { color: var(--ink); text-decoration: none; }
table.data th a.sort:hover { color: var(--brand-primary); text-decoration: underline; }
table.data th a.sorted-asc::after { content: " ▲"; font-size: 10px; }
table.data th a.sorted-desc::after { content: " ▼"; font-size: 10px; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.clickable { cursor: pointer; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--brand-soft) 35%, var(--paper)); }
table.data tr.selected { background: var(--brand-soft); }
table.data td.empty { color: var(--muted); text-align: center; padding: 16px; }
.pagination { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
              padding: 8px 0; font-size: 14px; }
.pagination .pages { display: flex; flex-wrap: wrap; gap: 4px; }
.pagination .pages a, .pagination .pages span { padding: 2px 8px; border-radius: var(--radius-control); }
.pagination .current { background: var(--brand-primary); color: var(--paper); }
.export-links { margin: 8px 0; font-size: 14px; }

/* Forms */
form.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0;
               padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-control); }
form.filters .field { min-width: 160px; flex: 1 1 160px; }
.filter-actions { display: flex; align-items: center; gap: 12px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field-label { font-weight: 600; font-size: 14px; }
.field-help { font-weight: 400; font-size: 13px; }
/* Ink text with a red bar: the status red on paper is 4.15:1 (below AA at 13px). */
.field-error { font-weight: 600; font-size: 13px; color: var(--ink);
               border-left: 3px solid var(--status-noncompliant); padding-left: 6px; }
.field.has-error input, .field.has-error select, .field.has-error textarea {
  border-color: var(--status-noncompliant); }
.field-check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 12px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; }

/* Section tabs (catalogue, admin) */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--ink);
          border-bottom: 3px solid transparent; }
.tabs a.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); font-weight: 600; }

/* Definition lists for record pages (asset, store) */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* Floor plans: the image with an SVG overlay; markers coloured by verdict class */
.floorplan { position: relative; max-width: 100%; overflow: auto; border: 1px solid var(--line);
             border-radius: var(--radius-control); background: var(--paper); }
.floorplan img, .floorplan svg { display: block; max-width: 100%; height: auto; }
.floorplan svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.floorplan .marker { stroke: var(--paper); stroke-width: 2; }
.floorplan .cone { opacity: 0.25; }
.floorplan .verdict-compliant { fill: var(--status-compliant); }
.floorplan .verdict-non_compliant { fill: var(--status-noncompliant); }
.floorplan .verdict-unknown { fill: var(--muted); }
.floorplan .highlight { stroke: var(--ink); stroke-width: 3; }
/* Marker numbers sit beside the circle, over the plan image: ink with a paper
   halo (stroke painted first) reads on any drawing behind it. */
.floorplan .marker-label { fill: var(--ink); stroke: var(--paper); stroke-width: 0.2em;
                           paint-order: stroke; stroke-linejoin: round; font-weight: 700;
                           pointer-events: none; }
.floorplan-legend { margin-top: 8px; }

/* Programme progress: the native bar in the brand colour, not the browser's own. */
progress { accent-color: var(--brand-primary); width: 160px; max-width: 100%; height: 12px;
           vertical-align: middle; }
.progress-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }

/* Phones: everything stacks; nothing needs sideways scrolling but tables */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .product { display: none; }
  .global-search { order: 3; flex: 1 1 100%; max-width: none; margin-left: 0; }
  .user-menu { margin-left: auto; }
  .user-menu summary { max-width: 160px; }
  .mainnav { padding: 0 8px; }
  .banner { padding: 8px 12px; }
  .page { padding: 16px 12px; }
  .card { padding: 20px; }
  .tiles { grid-template-columns: 1fr; }
  .footer { padding: 12px; }
  form.filters .field { flex: 1 1 100%; }
}

/* Phone width (375 px): nothing may force the page wider than the screen. */
.field, .stack > * { min-width: 0; }
select { max-width: 100%; }
fieldset { min-inline-size: 0; }
dl.facts dd { min-width: 0; overflow-wrap: anywhere; }
code.secret { word-break: break-all; }
h1, h2 { overflow-wrap: anywhere; }

/* --- Changes trend chart (/changes; DESIGN-UI section 8) ---------------------------
   A diverging bar per period: devices added or back above the zero line in
   --brand-primary, devices removed or gone missing below it in --brand-cyan.
   Direction carries the meaning; colour only repeats it. The palette check
   (the dataviz validator, run 2 Oct 2026; its full output is recorded beside
   chart_geometry in assets_app/web/reports.py, since hex codes may not appear
   here) passes CVD and normal-vision separation for the pair, but cyan sits
   above the lightness band and below 3:1 against --paper.
   Cyan is too light to hold its own edge on paper, so the relief is: a 1 px
   --brand-primary outline on every removal bar (4.9:1 against --paper), each bar's
   total written in ink at its end, the legend, and the data table under the
   chart. The two series are never told apart by colour alone: they sit on
   opposite sides of the line. No status colours here; nothing in this chart
   is a verdict. */
.chart { margin: 0 0 16px; }
.chart-svg { display: block; max-width: 100%; height: auto; }
.chart-additions { fill: var(--brand-primary); }
.chart-removals { fill: var(--brand-cyan); stroke: var(--brand-primary); stroke-width: 1px;
                  vector-effect: non-scaling-stroke; }
/* Labels and values wear text tokens, never a series colour. */
.chart-text { fill: var(--ink); }
.chart-tick { fill: var(--muted); font-variant-numeric: tabular-nums; }
/* Recessive hairlines: the extents in the table-rule grey, the zero line a step darker. */
.chart-gridline { stroke: var(--line); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.chart-zero { stroke: var(--muted); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.chart-bar a:hover .chart-mark { opacity: 0.8; }
.chart-bar a:focus-visible .chart-mark { stroke: var(--ink); stroke-width: 2px; }
.chart-bar a:focus-visible { outline: none; }
