:root {
  --bg: #0f1420;
  --panel: #182033;
  --text: #e7ecf3;
  /* 5:1 on the badge background, the darkest place muted text sits on. */
  --muted: #95a1b7;
  --accent: #4f8cff;
  /* Structural colours: a light theme (step D) only has to override these. */
  --surface: #0d1424;      /* inputs, code, the darkest inset */
  --hover: #141c2d;        /* table row / button hover */
  --border: #2a3652;
  --border-soft: #1e2740;
  --grid: #263150;         /* table rules, chart axes */
  --badge-bg: #24314d;
  --link: #9fc3ff;
  --link-hover: #b9d2ff;
  --on-accent: #0b1220;    /* text on an accent fill */

  /* Semantic colours (also used inline by `format::priority_color`). */
  --priority-urgent: #ff6b6b;
  --priority-high: #ffb454;
  --priority-medium: #95a1b7;
  --priority-low: #7cc7ff;
  --warn: #d29922;
  --warn-strong: #f0b429;
  --warn-bg: #2a2011;
  --warn-border: #4d3a17;
  --error: #ff7a7a;
  --success: #3fb950;
  --danger: #b23c3c;
  --on-danger: #ffffff;    /* 5.8:1 on the danger fill */

  /* Admin-chosen colours (types, statuses) are shown as text through
     `.toned`: their lightness is clamped to this range so they stay readable
     (at least 4.8:1, every hue checked) whatever colour was picked. */
  --tone-l-lo: 0.76;
  --tone-l-hi: 1;
}

/* Light theme: the same structure, re-tuned for a white page (the toggle lives
   in the nav, and `theme.rs` remembers the choice). */
[data-theme="light"] {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1b2436;
  --muted: #5b6577;
  --accent: #2f6fdb;
  --surface: #f1f3f9;
  --hover: #eef2fb;
  --border: #d4dae6;
  --border-soft: #e4e9f2;
  --grid: #dde2ec;
  --badge-bg: #e8edf7;
  --link: #1f5fbf;
  --link-hover: #14498f;
  --on-accent: #ffffff;

  --priority-urgent: #b42318;
  --priority-high: #92400e;
  --priority-medium: #475569;
  --priority-low: #0369a1;
  --warn: #8a5a00;
  --warn-strong: #7a4f00;
  --warn-bg: #fdf3d7;
  --warn-border: #e8c87a;
  --error: #b42318;
  --success: #1a7f37;
  --danger: #b42318;
  --on-danger: #ffffff;    /* 6.6:1 on the danger fill */

  --tone-l-lo: 0;
  --tone-l-hi: 0.46;
}


* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

main { max-width: 820px; margin: 0 auto; padding: 1.5rem 1rem; }

/* Boards and the dashboard need the whole width (A3); forms and the ticket
   detail keep the comfortable 820 px reading width. */
main.wide { max-width: none; margin: 0; }

/* A2: readable links everywhere. Components that style their own links
   (`.ticket`, `.tile`, `.board-card a`, the nav) override this with a class. */
a { color: var(--link); text-decoration: none; }

a:visited { color: var(--link); }

a:hover { color: var(--link-hover); text-decoration: underline; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Focused by script only (the main area, a page heading after navigation):
   the screen reader announces it, no ring is needed. */
[tabindex="-1"]:focus { outline: none; }

/* First Tab stop of every page, visible only once focused. */
.skip-link, .skip-link:visited {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  z-index: 30;
  padding: 0.5rem 0.8rem;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.skip-link:focus { top: 0.5rem; text-decoration: none; }

h1 { margin-top: 0; }

.topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--grid);
  flex-wrap: wrap;
}

.topnav .brand { font-weight: 700; margin-right: auto; }

.topnav a, .topnav a:visited { color: var(--text); text-decoration: none; }
.topnav a:hover { color: var(--accent); }

/* A4: the bar collapses behind a toggle on narrow screens instead of pushing
   the layout wider than the viewport. */
.nav-links {
  display: flex;
  align-items: center;
  /* Between a phone and a wide screen the admin links no longer fit on one
     line: they wrap onto a second one rather than widening the page. */
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem 1rem;
  min-width: 0;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 400;
}

@media (max-width: 640px) {
  .nav-toggle { display: inline-block; margin-left: auto; }

  .nav-links {
    display: none;
    flex: 1 0 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    padding-top: 0.6rem;
  }

  .nav-links.open { display: flex; }
}

form {
  display: grid;
  gap: 0.6rem;
  background: var(--panel);
  padding: 1rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
}

input, textarea, select, button {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

button {
  background: var(--accent);
  /* Dark text on the dark theme's light blue, white on the light theme's
     deeper one: 5.8:1 and 4.8:1. */
  color: var(--on-accent);
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.ticket {
  display: block;
  background: var(--panel);
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.6rem;
  color: inherit;
  text-decoration: none;
}

.ticket:hover { outline: 1px solid var(--accent); }

.ticket h3 { margin: 0 0 0.2rem; }

.meta { color: var(--muted); font-size: 0.85rem; }

.meta.error { color: var(--error); }
/* The ticket page's action error stays in view while the page scrolls. */
.action-error {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--error);
  border-radius: 6px;
  background: var(--bg);
}

.meta.warn { color: var(--warn); }

/* Semantic priority colours (A6): warm = urgent/high, neutral = medium,
   cool = low. All ≥ 4.5:1 against the panel background. */
.priority { text-transform: capitalize; }

.priority.urgent { color: var(--priority-urgent); }
.priority.high { color: var(--priority-high); }
.priority.medium { color: var(--priority-medium); }
.priority.low { color: var(--priority-low); }

.board-card .badge { margin-right: 0.25rem; }

.board-card .badge.priority { text-transform: capitalize; }

/* Light theme: badges are plain coloured text. Their colours are already
   theme-safe: the semantic ones come from the light palette, and the ones
   from the project's data (pastels chosen for a dark background) go through
   `.toned`, which clamps their lightness — no filter on top, which would
   darken them twice and that contrast checkers cannot see. */
[data-theme="light"] .badge {
  background: transparent;
  padding-left: 0;
  padding-right: 0;
}

/* Label chips (step D): the admin-chosen colour becomes a tint plus a border,
   legible in both themes. */
.label-chip {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text);
  background: color-mix(in srgb, var(--label, #8b97ad) 24%, transparent);
  border: 1px solid color-mix(in srgb, var(--label, #8b97ad) 55%, transparent);
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.chip-removable { display: inline-flex; align-items: center; gap: 0.15rem; }

.chip-x {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
}

.chip-x:hover { color: var(--error); }

.labels-field {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.labels-field .field-label { color: var(--muted); }

.label-picker { max-width: 100%; }

/* Initials avatars (step D): the same person keeps the same colour. */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
  flex: none;
}

/* The theme toggle sits with the other nav buttons; it keeps its label short
   so the bar does not wrap on a phone. */
.theme-toggle { white-space: nowrap; }

.avatar.compact {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.6rem;
}

.assignee {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

/* Deadlines: a late one is amber-on-dark and bold enough to catch the eye,
   both in the list and on a board card. */
.due.overdue {
  color: var(--warn-strong);
  font-weight: 600;
}

.due { white-space: nowrap; }

.meta.overdue { color: var(--warn-strong); }

.workflow-warnings:empty { display: none; }

.workflow-warnings {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

/* Workflow warnings (R2): a labelled box whose entries link to the status row
   they talk about. */
.warn-box {
  border: 1px solid var(--warn-border);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  background: var(--warn-bg);
  padding: 0.6rem 0.8rem;
}

.warn-box .warn-title { margin: 0; color: var(--warn); font-weight: 600; }

.warn-box .meta { margin: 0.1rem 0 0.35rem; }

.warn-box ul { margin: 0; padding-left: 1.1rem; }

.warn-box li { margin: 0.1rem 0; }

.warn-box a { color: var(--warn-strong); }

/* Clicking a warning points at a status row (`#status-<id>`): the row is
   marked, so the reader finds it. */
.settings-row.flash {
  outline: 2px solid var(--warn);
  outline-offset: 2px;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--badge-bg);
}

/* An admin-chosen colour (`--tone`) as text: same hue, lightness clamped per
   theme (see `--tone-l-lo`/`--tone-l-hi`). Browsers without relative colours
   fall back to the plain text colour. */
.toned { color: var(--text); }
@supports (color: oklch(from red l c h)) {
  .toned {
    color: oklch(from var(--tone) clamp(var(--tone-l-lo), l, var(--tone-l-hi)) min(c, 0.18) h);
  }
}

/* Dashboard: KPI tiles + hand-rolled SVG charts */
/* Twelve tiles (dashboard.rs): never a lone tile on its last line (A5).
   Phones: 2 columns (6 rows). Tablets: 3 columns (4 rows). Wide screens: 6
   columns, two full rows — what is open right now (not done, in progress,
   awaiting decision, unassigned, late, blocked), then the period's figures.
   Should the count become odd again, the first tile — "Not done", the
   headline figure — takes the whole width on phones and two columns on wide
   screens. Adding or removing a tile means checking these counts again;
   `frontend/e2e/check.mjs` (A5) does it at 1440, 1024 and 390 px. */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

@media (max-width: 699px) {
  .tiles > .tile:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
}

@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tiles > .tile:first-child:nth-last-child(odd) { grid-column: span 2; }
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--panel);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  color: inherit;
  text-decoration: none;
}

.tile:hover { outline: 1px solid var(--accent); }

.tile-label { font-size: 0.8rem; color: var(--muted); }
.tile-value { font-size: 1.4rem; }

.charts { display: grid; gap: 1rem; }

/* Use the width on a large screen instead of stacking everything (A3). */
@media (min-width: 1100px) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

figure.chart {
  background: var(--panel);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin: 0;
}

figure.chart figcaption { font-weight: 600; margin-bottom: 0.5rem; }

.bars { list-style: none; margin: 0; padding: 0; }

.bar-row { margin-bottom: 0.35rem; }

/* Shared by linked and plain rows: the alignment grid lives on the wrapper,
   never on the children (a descendant selector would also grid the fill). */
.bar-row .bar-link {
  display: grid;
  grid-template-columns: 8rem 1fr 2.5rem;
  align-items: center;
  gap: 0.5rem;
  /* WCAG 2.5.8: a clickable row is at least 24 px tall. */
  min-height: 24px;
}

a.bar-link { color: inherit; text-decoration: none; }

a.bar-link:hover .bar-label { color: var(--accent); }

/* An address (frequent requesters) has no space to wrap at. */
.bar-label { font-size: 0.85rem; overflow-wrap: anywhere; }

.bar-track { background: var(--badge-bg); border-radius: 999px; height: 0.6rem; overflow: hidden; }

.bar-fill { display: block; height: 100%; border-radius: 999px; }

.bar-value { text-align: right; font-size: 0.85rem; color: var(--muted); }

.line-chart { width: 100%; height: 10rem; }

.line-chart .axis { stroke: var(--grid); stroke-width: 1; }

.line-chart .axis-label { fill: var(--muted); font-size: 11px; }

.line-chart .series { stroke-width: 2; }

.line-chart .series.created { stroke: var(--accent); }

.line-chart .series.resolved { stroke: var(--success); }

.legend {
  display: inline-block;
  width: 0.7rem;
  height: 0.2rem;
  margin-right: 0.15rem;
  vertical-align: middle;
  border-radius: 2px;
}

.legend.created { background: var(--accent); }
.legend.resolved { background: var(--success); }

/* Admin settings (issue types & workflow) */
.settings-list { display: grid; gap: 0.5rem; margin-bottom: 1rem; }

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}

.settings-row input[type="color"] { width: 2.2rem; height: 1.6rem; padding: 0; border: none; }

.settings-form { margin-bottom: 1.5rem; }

/* Mailbox tab: one even rhythm instead of each element's own margins. */
.mailbox-form { display: grid; gap: 0.9rem; }
.mailbox-form h2, .mailbox-form p { margin: 0; }

.filters button { cursor: pointer; }

/* Tabs (settings): the active one is a filled chip with dark text — accent on
   accent was unreadable (A1). Inactive tabs stay discreet. */
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }

.tabs button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent); /* 5.8:1 on the accent fill */
}

/* Settings rows: a pending change is marked, and only the primary action of a
   dirty row keeps the accent colour (U10). */
.settings-row.dirty { border-left: 3px solid var(--warn); }

.settings-row.dirty::after {
  content: "unsaved";
  font-size: 0.7rem;
  color: var(--warn);
  margin-left: auto;
}

.settings-row button:disabled { opacity: 0.45; cursor: default; }

.settings-row button.ghost.icon { padding: 0.15rem 0.45rem; font-size: 0.8rem; }

/* Service targets (§3.1): the four priorities, two numbers each, saved in one
   go — the row carries the "unsaved" marker like every other settings row. */
.sla-targets { align-items: flex-start; }

.sla-table { border-collapse: collapse; }

.sla-table th,
.sla-table td {
  text-align: left;
  padding: 0.2rem 0.6rem;
  font-size: 0.85rem;
}

.sla-table input { width: 6.5rem; }

/* API tokens (§4.5): the secret shown once, in a block a human can copy. */
.token-secret {
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.8rem;
  display: grid;
  gap: 0.3rem;
}

.token-secret p { margin: 0; }

.token-value {
  word-break: break-all;
  font-size: 0.9rem;
}

/* Custom fields (§9.2): the settings rows and the ticket detail's block. */
.custom-new { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.custom-new input { width: 10rem; }
.custom-new .field-options { width: 12rem; }

.custom-values { display: grid; gap: 0.5rem; }

.custom-value { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.85rem; }

.custom-values button { justify-self: start; }

/* Pull requests and commits attached to a ticket (§4.4). */
/* State and identifier on the first line, Detach at its end, the title on
   its own line under them: the side column is narrow. */
.reference-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.4rem;
  margin: 0 0 0.45rem;
  font-size: 0.85rem;
}
.reference-row > span:nth-child(3) { flex-basis: 100%; order: 3; }
.reference-row > span:nth-child(3):empty { display: none; }
.reference-row > button { margin-left: auto; }
/* Theme variables, never fixed colours: both themes stay readable. */
.ref-merged { border-color: var(--success); color: var(--success); }
.ref-open { border-color: var(--link); color: var(--link); }
.ref-closed { border-color: var(--error); color: var(--error); }
.ref-commit { border-color: var(--muted); color: var(--muted); }

/* Settings › Repository: the integration says whether it is on, and keeps
   its distance from the repository form below. */
.repository-events { margin-bottom: 1.5rem; }
.repository-state { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.repository-state code { word-break: break-all; }
.custom-new select { width: 8.5rem; }
.custom-new input[placeholder^="https://github.com"] { width: 15rem; }

/* Time tracking (§9.2): the total and one line per entry. */
.time-total { font-weight: 600; margin: 0 0 0.3rem; }
.time-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
}
.time-row > span:nth-child(3) { flex: 1; }
.time-row > span:first-child { font-variant-numeric: tabular-nums; min-width: 4rem; }
.custom-new input[type="date"] { width: 9.5rem; }
.custom-new input[type="number"] { width: 6rem; }

/* Sub-tasks (§9.2): the progress line, one row per child, and the banner that
   points a child back at its parent. */
.subtask-progress { font-weight: 600; margin: 0 0 0.3rem; }
.subtask-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
}
.subtask-row > span:nth-child(3) { flex: 1; }
.subtask-row .badge { flex-shrink: 0; }
.parent-notice { margin: 0 0 0.5rem; }

/* Markdown in the conversation (§9.2): just enough to make lists, code and
   links readable inside a comment. */
.comment-body p { margin: 0 0 0.5rem; }
.comment-body p:last-child { margin-bottom: 0; }
.comment-body .md-list { margin: 0 0 0.5rem; padding-left: 1.3rem; display: grid; gap: 0.15rem; }
.comment-body .md-code {
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.7rem;
  overflow-x: auto;
  border-radius: 6px;
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}
.comment-body a { color: var(--link, #7c9cff); text-decoration: underline; }

/* Outgoing webhooks (§9.2): the event checkboxes of the new-subscription row,
   a failing row, and the delivery history it opens. */
.webhook-events { display: flex; flex-wrap: wrap; gap: 0.6rem; font-size: 0.85rem; }

.webhook-events .check { display: inline-flex; align-items: baseline; gap: 0.25rem; }

.ticket-table tr.failing td { background: color-mix(in srgb, var(--danger) 8%, transparent); }

.webhook-history { margin-top: 0.8rem; }
.webhook-history h3 { font-size: 0.9rem; margin: 0 0 0.3rem; }
.webhook-history p { margin: 0.1rem 0; }

/* Relations between tickets (§9.2): the links list, the duplicate banner and
   the trace left by a merge. */
.link-list ul { list-style: none; margin: 0 0 0.5rem; padding: 0; display: grid; gap: 0.25rem; }

.link-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.link-target { font-weight: 600; }

.link-title { color: var(--muted); }
.link-title.done { text-decoration: line-through; }

.link-add { display: flex; gap: 0.35rem; }
/* The key field gives way in the narrow side column, so the Link button
   stays inside the panel. */
.link-add input { width: 7rem; flex: 1 1 5rem; min-width: 0; }
.link-add select { min-width: 0; }

.duplicate-banner {
  border: 1px solid var(--warn);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  display: grid;
  gap: 0.4rem;
}

.duplicate-banner p { margin: 0; }

.duplicate-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.merged-notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin-bottom: 1rem;
  background: var(--surface);
  font-size: 0.9rem;
}

/* The satisfaction page (§3.2): a customer without an account lands here, so
   it is one narrow column with nothing else around it. */
.csat-page {
  max-width: 34rem;
  margin: 3rem auto;
  padding: 1.5rem;
  background: var(--panel);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.csat-page h1 { margin: 0 0 0.4rem; font-size: 1.3rem; }

.csat-ticket { margin: 0; font-size: 0.95rem; }

.csat-scale { display: flex; gap: 0.4rem; }

.csat-score {
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.05rem;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.csat-score.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.csat-legend { margin: 0; }

.csat-comment-box { min-height: 5rem; }

.csat-thanks { font-weight: 600; margin: 0.2rem 0; }

/* The rating an agent sees on a closed ticket. */
.csat-line { margin: 0.15rem 0; }

/* The two deadlines in the ticket detail; `.overdue` (below) turns them red. */
.sla-line { margin: 0.15rem 0; }

/* Project actions (poll the mailbox) sit at the top of the Mailbox tab, quiet by default. */
.settings-actions { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }

/* Support keys (doc/SPEC-support-key.md): the mode as a segmented control, the
   keys with their copy button, and the quarantine below. */
.modes { display: flex; gap: 0; }

.modes button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 0;
}

.modes button:first-child { border-radius: 8px 0 0 8px; }

.modes button:last-child { border-radius: 0 8px 8px 0; }

.modes button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.keys { display: grid; gap: 0.35rem; width: 100%; }

.key {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.key code {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  background: var(--surface);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
}

/* Struck through and muted, not faded: an opacity would take the text below
   4.5:1 (W1). */
.key.revoked code { text-decoration: line-through; color: var(--muted); }

.key .key-actions { margin-left: auto; }

.new-key { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

.quarantine { list-style: none; padding: 0; display: grid; gap: 0.5rem; }

.quarantined {
  background: var(--panel);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}

.quarantined-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quarantined-head .actions { margin-left: auto; display: flex; gap: 0.35rem; }

.warn-badge { background: var(--warn-border); color: var(--warn-strong); }

.quarantined-body {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  border-radius: 6px;
  padding: 0.6rem;
  font-size: 0.85rem;
  max-height: 18rem;
  overflow: auto;
}

/* Ticket key, wherever a ticket is shown without opening it. */
.ticket-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.board-card-key { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.board-card-key a { font-weight: 400; color: var(--muted); }

/* Inline editor for the title and the description. */
.text-edit { display: grid; gap: 0.5rem; margin-bottom: 0.5rem; }

.text-edit .edit-title { font-size: 1.4rem; font-weight: 600; }

.text-edit textarea { min-height: 6rem; }

/* The transition matrix can be wider than a phone (A4). */
.matrix-scroll { overflow-x: auto; }

table.matrix { border-collapse: collapse; margin-bottom: 1rem; }

table.matrix th, table.matrix td {
  border: 1px solid var(--grid);
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  text-align: center;
}

table.matrix thead th { color: var(--muted); font-weight: 600; }

/* Kanban board */
.board-index { display: flex; flex-direction: column; }

.board {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  /* Scroll hint (A3): the two `local` layers hide the shadows once the board
     is scrolled to that end, the `scroll` layers paint them while there is
     more to see on either side. */
  background:
    linear-gradient(90deg, var(--bg) 30%, rgba(15, 20, 32, 0)) left / 2.5rem 100% no-repeat local,
    linear-gradient(270deg, var(--bg) 30%, rgba(15, 20, 32, 0)) right / 2.5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0)) left / 0.9rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0)) right / 0.9rem 100% no-repeat scroll;
}

.board .column {
  background: var(--panel);
  border-radius: 10px;
  padding: 0.7rem;
  flex: 0 0 15rem;
  min-width: 15rem;
}

.board .column h2 { margin: 0 0 0.2rem; font-size: 1rem; }

.board .column.unreachable { opacity: 0.4; }

.board-card {
  background: var(--bg);
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.5rem;
  cursor: grab;
}

.board-card p { margin: 0.15rem 0; }

.board-card a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  /* Keep drags starting on the title attached to the card, not the link. */
  -webkit-user-drag: none;
}
.board-card a:hover { color: var(--accent); text-decoration: none; }

/* Compact move menu: it is the fallback, the drag is the primary gesture (A9). */
.board-card select {
  width: auto;
  max-width: 100%;
  margin-top: 0.25rem;
  padding: 0.1rem 0.25rem;
  font-size: 0.75rem;
}

.drop-hint {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  text-align: center;
}

.drop-hint.active { border-color: var(--accent); color: var(--accent); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filters select, .filters input { flex: 1 1 auto; min-width: 8rem; }
/* The "Save view" inline name field: narrow, since it holds a label. */
.filters input.view-name { flex: 0 1 12rem; }

.pager {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1rem 0;
}

/* Ticket table (list): dense rows, sortable headers. The wrapper scrolls on a
   narrow screen so the page itself never overflows. */
.table-scroll { overflow-x: auto; }

/* Bulk selection (§3.3): a checkbox column and the action bar above the table. */
.ticket-table .select-col { width: 2rem; }
.ticket-table tr.selected td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.bulk-bar select { flex: 0 1 auto; min-width: 9rem; }

.ticket-table {
  width: 100%;
  min-width: 40rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ticket-table th {
  text-align: left;
  border-bottom: 1px solid var(--grid);
  padding: 0.35rem 0.5rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.ticket-table th button {
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.ticket-table th.active { color: var(--accent); }

.ticket-table .sort-mark { font-size: 0.7rem; }

.ticket-table td {
  border-bottom: 1px solid var(--border-soft);
  padding: 0.45rem 0.5rem;
  vertical-align: middle;
}

.ticket-table tr:hover td { background: var(--hover); }

.ticket-table .key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.ticket-table .key a { color: var(--muted); }

.ticket-table .title a { color: var(--text); font-weight: 600; }

.ticket-table .numeric { text-align: right; }

.ticket-table .badge { white-space: nowrap; }

/* Filters row (saved views + filters) */
.filters .saved-views { flex: 0 1 12rem; }

.filters button.ghost.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* Modal dialog (ticket creation): the form moved out of the list page. */
/* The native <dialog> (ticket_create.rs): only its frame is reset, the form
   inside keeps the panel look. */
dialog.modal-dialog {
  width: calc(100% - 2rem);
  max-width: 30rem;
  margin: 4rem auto 1rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  overflow: visible;
}

dialog.modal-dialog::backdrop { background: rgba(6, 9, 16, 0.72); }

.modal {
  width: 100%;
  max-width: 30rem;
  margin: 0;
  border: 1px solid var(--border);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 { margin: 0; font-size: 1.1rem; }

.modal-row { display: flex; gap: 0.5rem; }

.modal-row > * { flex: 1 1 auto; }

/* Secondary button (cancel, quiet actions) — the accent stays for the primary
   action of a screen. */
button.ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 400;
}

button.ghost:hover { border-color: var(--accent); }

/* A disabled button must not look like one that works (Prev on the first
   page, Save with nothing to save). */
button:disabled { opacity: 0.45; cursor: not-allowed; }

.login-page {
  display: flex;
  justify-content: center;
  padding-top: 3rem;
}

.login-form { width: 100%; max-width: 320px; }

.login-form label, .project-form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.project-form label.checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
}

/* Two-column detail (plan §14.4 point 6): thread on the left, fields and
   workflow on the right; single column on narrow screens. */
.breadcrumb { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }

.breadcrumb a { color: var(--muted); }

.detail-header { margin-bottom: 0.5rem; }

.detail-header h1 { margin: 0.2rem 0; }

.detail-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(16rem, 1fr);
  gap: 1.2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .detail-columns { grid-template-columns: minmax(0, 1fr); }
}

/* Section shortcuts of the ticket detail: only once the columns stack. */
.detail-jump { display: none; }

@media (max-width: 900px) {
  .detail-jump {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 1rem;
  }

  .detail-jump button { padding: 0.35rem 0.7rem; }

  /* Stacked, the side panel is just the next block, not a sticky one. */
  .detail-side { position: static; }
}

.detail-main { min-width: 0; }

.detail-side {
  background: var(--panel);
  border-radius: 10px;
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.detail-side h2 { margin: 0.8rem 0 0.4rem; font-size: 1rem; }

.detail-side h2:first-child { margin-top: 0; }

.status-line { margin: 0 0 0.5rem; }

.watch-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
}

.watch-line button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.transitions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }

button.transition {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  padding: 0.35rem 0.6rem;
}

button.transition.toned { border-color: var(--tone); }

button.transition:hover { background: var(--hover); }

dl.dates { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.6rem; margin: 0; }

dl.dates dt { color: var(--muted); font-size: 0.8rem; }

dl.dates dd { margin: 0; font-size: 0.85rem; }

.description { white-space: pre-wrap; }

.ticket-detail .fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.8rem;
  margin: 0.5rem 0 0;
}

.ticket-detail .fields label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

button.danger { background: var(--danger); color: var(--on-danger); }

.comment, .attachment-row, .event {
  background: var(--panel);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.comment.agent { border-left: 3px solid var(--accent); }

/* Internal notes (§2.1): team-only, visually distinct from public replies so
   an agent never mistakes one for a customer-facing message. */
.comment.internal {
  border-left: 3px solid var(--warn, #c08a24);
  background: color-mix(in srgb, var(--warn, #c08a24) 12%, var(--panel));
}

/* Comment editing (§9.2): the "Edit" affordance stays discreet, and an edited
   message carries a marker because the emailed copy cannot be recalled. */
.comment-edit { margin-left: 0.5rem; padding: 0 0.3rem; font-size: 0.8rem; }
.edited-tag { font-style: italic; }
.comment textarea { width: 100%; min-height: 4rem; resize: vertical; }
.comment-edit-actions { display: flex; gap: 0.4rem; margin-top: 0.4rem; }

/* `@agent` mentions (§9.2): readable at a glance in a long note. */
.mention {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
  border-radius: 4px;
  padding: 0 0.15rem;
}
.mention-hint { margin: 0.3rem 0 0.5rem; font-size: 0.82rem; }

.internal-tag {
  font-weight: 600;
  color: var(--warn, #c08a24);
  text-transform: uppercase;
  font-size: 0.72em;
  letter-spacing: 0.03em;
}

.attachment-row { display: flex; align-items: center; gap: 0.6rem; }

.attachment-row button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 400;
  text-decoration: underline;
  cursor: pointer;
}

.reply-form { margin-top: 1rem; }

/* Attaching a file from the app (§9.2): the label acts as the button, the
   real input stays hidden (a bare file input is unstyleable). */
.attach-line { margin: 0.5rem 0 1rem; }
.attach-button {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.attach-input { display: none; }

.reply-kind {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.reply-kind label { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }

/* The whole composer shifts to the internal-note accent while that mode is
   selected, a last guard against sending an internal note to the customer. */
.reply-form.internal textarea { border-color: var(--warn, #c08a24); }

/* Canned responses (§9.2): the picker above the composer, and the settings
   rows, whose textarea needs room for a full message. */
.canned-picker { margin-bottom: 0.5rem; width: 100%; }

.canned-new, .canned-row {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.6rem;
  align-items: start;
}
.canned-new textarea, .canned-row textarea { min-height: 4.5rem; resize: vertical; }
.reply-form.internal button[type="submit"] { background: var(--warn, #c08a24); }

.user-list { list-style: none; padding: 0; }
.user-list li {
  background: var(--panel);
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  margin-bottom: 0.4rem;
}

/* Customers and support contracts (doc/SPEC-customer-contracts.md). */

.page-head, .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.page-head h1 { margin-bottom: 0.5rem; }

.section-head { margin: 1.6rem 0 0.6rem; }

.section-head h2 { margin: 0; font-size: 1.15rem; }

/* The state of a contract, or the support right of a ticket. The words carry
   the meaning; the dot and the tint only reinforce them, so the pill reads the
   same for someone who cannot tell the colours apart. Text stays on --text. */
.pill {
  --pill: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text);
  white-space: nowrap;
  background: color-mix(in srgb, var(--pill) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--pill) 55%, transparent);
}

.pill::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--pill);
}

.pill.covered { --pill: var(--success); }
.pill.expiring { --pill: var(--warn-strong); }
.pill.out_of_contract { --pill: var(--error); }
.pill.suspended { --pill: var(--priority-low); }
/* Not a state of the contract but the absence of one: a hollow dot. */
.pill.unknown { border-style: dashed; }
.pill.unknown::before { background: transparent; border: 1px solid var(--pill); }

.customer-toolbar { align-items: center; margin-bottom: 0.75rem; }

.customer-toolbar input[type="search"] { flex: 1 1 14rem; }

.state-filter { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.state-filter button.ghost.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.empty-state {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
  display: grid;
  gap: 0.6rem;
  justify-items: start;
}

.empty-state h2, .empty-state p { margin: 0; }

.customer-table td.title .meta { display: block; margin-top: 0.1rem; }

.project-support-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }

.project-support {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem 0.5rem;
}

.customer-tag { margin-left: 0.4rem; }
/* In its own column the customer name needs no left offset. */
.ticket-table td.customer { white-space: nowrap; }
.ticket-table td.customer .customer-tag { margin-left: 0; }

/* Forms that open in the page (new customer, new contract, edit). */
.panel-form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.panel-form label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-form input[type="checkbox"] { padding: 0; width: auto; }

.panel-form h2 { margin: 0; font-size: 1.1rem; color: var(--text); }

.panel-form.inset { background: var(--surface); margin: 0.75rem 0 0; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.6rem; }

.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }

.customer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.customer-head h1 { margin: 0 0 0.2rem; }

.customer-head p { margin: 0.2rem 0; }

/* Contract cards: the sentence comes first, the dates and the key after. */
.cards { display: grid; gap: 0.9rem; }

.contract {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.contract.fresh { border-color: var(--success); }

.contract-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }

.contract-line { margin: 0.5rem 0 0.1rem; font-size: 1.1rem; font-weight: 600; }

.contract .meta { margin: 0.15rem 0; }

.contract-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.7rem 0 0.2rem; }

.contract-actions button { padding: 0.35rem 0.8rem; }

.contract-actions button:disabled { opacity: 0.45; cursor: default; }

.contract-actions button.ghost.danger,
.danger-zone button.ghost.danger {
  background: transparent;
  border: 1px solid var(--error);
  color: var(--error);
}

.callout {
  display: grid;
  gap: 0.5rem;
  justify-items: start;
  margin-top: 0.8rem;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--success) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 55%, transparent);
}

.key-block {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border-soft);
}

.key-block h3 { margin: 0; font-size: 0.95rem; }

.key-block > .meta { margin: 0.1rem 0 0.5rem; }

.revoked-keys { margin-top: 0.4rem; }

.revoked-keys summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }

.new-key input { flex: 1 1 12rem; min-width: 0; }

.recent-tickets { list-style: none; margin: 0 0 0.5rem; padding: 0; display: grid; gap: 0.4rem; }

.recent-tickets li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  background: var(--panel);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}

.recent-tickets .meta { margin-left: auto; }

.danger-zone {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
}

.danger-zone button:disabled { opacity: 0.45; cursor: default; }

.support-card p { margin: 0.25rem 0; }

@media (max-width: 640px) {
  .customer-head { flex-direction: column; }
  .recent-tickets .meta { margin-left: 0; }
  .contract-actions button { flex: 1 1 auto; }
}

/* In the ticket table the pill and the customer sit after the title: give
   them air, and keep them off the link. */
.ticket-table .pill, .ticket-table .customer-tag { margin-left: 0.45rem; vertical-align: middle; }

.add-key { margin-top: 0.5rem; }

/* A phone cannot read a three-column table that scrolls sideways: each customer
   becomes a small card (name, then where it stands, then its tickets). */
@media (max-width: 640px) {
  .ticket-table.customer-table { min-width: 0; }
  .customer-table thead { display: none; }
  .customer-table, .customer-table tbody, .customer-table tr, .customer-table td { display: block; }
  .customer-table tr {
    background: var(--panel);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.6rem;
  }
  .customer-table td { border: 0; padding: 0.15rem 0; }
  .customer-table td.numeric { text-align: left; }
}

.hidden { display: none; }

/* --- Lot 0: mailbox supervision and account self-service ------------------ */

/* The nav-wide outage banner: a failing mailbox is otherwise invisible. */
.mailbox-alert {
  flex-basis: 100%;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-strong);
  border-radius: 6px;
}

.mailbox-alert a { color: var(--warn-strong); text-decoration: underline; }

.meta.success { color: var(--success); }

/* Mailbox health, colour-coded like the rest of the app's statuses. */
.badge.state-ok { color: var(--success); }
.badge.state-warning { color: var(--warn); }
.badge.state-error { color: var(--error); }
.badge.state-pending { color: var(--muted); }

.mailboxes-table td { vertical-align: top; }
.mailboxes-table .actions { white-space: nowrap; }
.mailboxes-table .actions button { margin-right: 0.3rem; }
.mailboxes-table tr.unhealthy td { border-left: 3px solid var(--error); }
.mailboxes-table .history-row td { background: var(--surface); }

/* In-app notifications (§2.2): the navigation bell, its panel and the page. */
.notif { position: relative; display: inline-flex; }
.notif-bell { position: relative; padding: 0.15rem 0.35rem; }
.notif-badge {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  min-width: 1.05rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  line-height: 1.05rem;
  text-align: center;
  font-weight: 700;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 30;
  width: min(22rem, calc(100vw - 2rem));
  max-height: 22rem;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 0.5rem 0.6rem;
}
.notif-head, .notif-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.notif-foot { padding-top: 0.4rem; }
.notif-row, .notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0.2rem;
  border-bottom: 1px solid var(--border-soft);
}
.notif-row a, .notif-item a, .notif-plain {
  display: flex;
  flex: 1 1 auto;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
}
.notif-check { flex: 0 0 auto; padding: 0 0.3rem; line-height: 1.2; }
.notif-row.unread, .notif-item.unread { border-left: 3px solid var(--accent); }
.notif-kind { flex: 0 0 auto; opacity: 0.75; }

.notif-text { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.88rem; }
.notif-toggle { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; }
.notif-list { list-style: none; padding: 0; margin: 0; }
.notif-list .notif-item { border-radius: 8px; }

/* Audit log (§2.11): read-only, colour-coded by action so a deletion stands
   out from a routine update at a glance. */
.audit-table td { vertical-align: top; }
.audit-table .audit-details { display: table-cell; }
.audit-detail {
  display: inline-block;
  margin: 0 0.5rem 0.2rem 0;
  font-size: 0.82rem;
}
.badge.action-create { color: var(--success); }
.badge.action-update { color: var(--muted); }
.badge.action-delete { color: var(--error); }
.badge.action-revoke { color: var(--warn); }
.badge.action-accept { color: var(--success); }
.badge.action-drop { color: var(--error); }
.badge.action-export { color: var(--warn); }
.badge.action-anonymise { color: var(--error); }
.badge.action-send { color: var(--success); }

.account-page { max-width: 640px; }
.session-list { list-style: none; padding: 0; display: grid; gap: 0.4rem; margin-bottom: 0.75rem; }

/* Licence files (doc/SPEC-licence-files.md): the block under the key on a
   contract card, the offer on its meta line, and the Licences settings tab. */
.licence-block .warn-box { margin: 0.5rem 0; }

.licence-blockers { margin: 0.4rem 0; }

.licence-blockers ul { margin: 0.1rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.9rem; }

.licence-upload { display: grid; gap: 0.5rem; margin-top: 0.4rem; }

.licence-upload textarea { font-family: ui-monospace, monospace; font-size: 0.85rem; }

.licence-upload code { word-break: break-all; }

.contract .offer { font-weight: 600; color: var(--text); }

.pill.evaluation { --pill: var(--warn-strong); }

.evaluation-end { align-self: end; margin: 0 0 0.45rem; }

button.ghost.link {
  border: none;
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.settings-row label.inline { display: flex; align-items: center; gap: 0.35rem; }

.settings-row input.narrow { width: 5rem; }

.settings-row > label:first-child { flex: 1 1 16rem; }

/* A licence: the id and its download on one line, the dates under it, so
   the row does not break at an arbitrary place on a narrow card. */
.licence-row .licence-meta { flex-basis: 100%; order: 3; margin: -0.1rem 0 0; }

.licence-block .revoked-keys .keys { margin-top: 0.4rem; }

/* Offer rows: the label takes the room left, Save stays at the end. */
.offer-row input.offer-label { flex: 1 1 8rem; min-width: 0; }

.offer-row button[type="submit"] { margin-left: auto; }

/* `"Label" <span class="meta">"(optional)"</span>` loses its space in the
   view macro: put it back for every form label at once. */
label > span > span.meta { margin-left: 0.35em; }


/* Business hours (§3.1), under the service targets. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.business-hours { flex-wrap: wrap; align-items: flex-start; gap: 0.8rem; }
.business-hours .hours-mode { border: 0; padding: 0; margin: 0; display: flex; gap: 1rem; }
.business-hours .hours-zone { display: flex; align-items: center; gap: 0.4rem; }
.hours-table tr.closed td:not(:first-child) { opacity: 0.45; }
/* The matrix inputs are 6.5rem wide; a checkbox keeps its own size. */
.hours-table input[type="checkbox"] { width: auto; }

/* Escalation (§3.1), in the side column of the ticket detail. */
.escalated-line .pill.escalated { background: var(--danger); color: #fff; }
.escalate-form { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.4rem 0; }
.escalate-form textarea { width: 100%; }

/* Service levels (§3.1): one card per level, under the targets. */
.sla-level-card {
  border: 1px solid var(--border, rgba(127, 127, 127, 0.25));
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.8rem;
}
.sla-level-card .sla-level-name { display: flex; gap: 0.5rem; align-items: center; }
.sla-level-card .sla-level-name input { flex: 1 1 14rem; max-width: 22rem; font-weight: 600; }
.new-sla-level { display: flex; gap: 0.5rem; align-items: center; }
.new-sla-level input { flex: 1 1 14rem; max-width: 22rem; }

/* Satisfaction follow-up (§3.2). */
.inline-check { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
.filters .inline-check input { width: auto; min-width: 0; flex: 0 0 auto; }
.satisfaction-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) {
  .satisfaction-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.satisfaction-table .score { white-space: nowrap; font-weight: 600; }
.satisfaction-table .survey-comment { max-width: 32rem; white-space: pre-wrap; }
.bar-row button.bar-link {
  width: 100%;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.bar-row button.bar-link:hover .bar-label,
.bar-row button.bar-link:focus-visible .bar-label { color: var(--accent); }

/* A link inside a sentence is underlined: its colour alone would not tell it
   from the text around it (WCAG 1.4.1). */
a.inline-link, a.inline-link:visited { text-decoration: underline; }

/* Personal data (§6.5): the counts of what is held about an address. */
.privacy-search label { display: grid; gap: 0.3rem; flex: 1 1 18rem; }
.privacy-summary { margin-top: 1rem; }
.privacy-summary h2 { overflow-wrap: anywhere; }
.privacy-counts { margin: 0.4rem 0 0.8rem; padding-left: 1.2rem; }
.privacy-counts li { margin: 0.15rem 0; }
/* Stacked here: a heading, the explanation, the option, then the button. */
.privacy-summary .danger-zone {
  flex-direction: column;
  align-items: flex-start;
  margin-top: 1.5rem;
}
.privacy-summary .danger-zone h3, .privacy-summary .danger-zone p { margin: 0; }

/* The account form's username, for password managers only (account.rs). */
.visually-hidden-field { display: none; }

/* Emailing a licence (spec §8): the recipient, then Send / Cancel. */
.licence-email { margin-top: 0.5rem; }
.licence-email label { display: grid; gap: 0.3rem; flex: 1 1 16rem; }
.licence-emailed { margin: 0.25rem 0 0; }

/* Support hours bundles: the meter on a contract card and on a ticket. */
.hours-block { margin-top: 0.8rem; padding-top: 0.6rem; border-top: 1px solid var(--border-soft); }
.hours-block h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.hours-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.7rem; margin: 0.2rem 0 0.5rem; }
.hours-meter { width: 9rem; height: 0.8rem; }
.hours-over { color: var(--warn); }
.hours-details { margin-top: 0.6rem; }
.hours-nav { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }
.ticket-contract { margin-top: 0.8rem; }
.ticket-contract-name { margin: 0.1rem 0; font-weight: 600; }
.ticket-contract-pick { margin-top: 0.4rem; }
.time-not-counted { display: block; color: var(--warn); }
