/* Canopy base styles. Deliberately minimal — a design-system decision is
   still open (see docs/adr/0010-styling.md). Hand-written CSS on custom
   properties; no framework, no build step. */

:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-raised: #fafbfa;
  --text: #1d2b23;
  --muted: #64726a;
  --faint: #8b968f;
  --accent: #1e6f50;
  --accent-dark: #15533b;
  --accent-soft: #e8f4ee;
  --border: #dde3df;
  --border-strong: #c8d1cb;
  --warning-bg: #fff6e5;
  --warning-text: #8a5a00;
  --danger: #b3372f;
  --danger-dark: #922c25;
  --danger-bg: #faedec;
  --info-bg: #eef2ff;
  --info-text: #3b4d9c;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(29, 43, 35, 0.04), 0 1px 3px rgba(29, 43, 35, 0.06);
  --shadow-pop: 0 4px 6px rgba(29, 43, 35, 0.08), 0 12px 28px rgba(29, 43, 35, 0.14);
  --focus-ring: 0 0 0 3px rgba(30, 111, 80, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 0.9375rem;
}

h1 {
  font-size: 1.375rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}

h2 {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.005em;
  margin: 0;
}

h3 {
  font-size: 0.9375rem;
  font-weight: 650;
  margin: 0;
}

a {
  color: var(--accent);
}

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

.hint {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0;
}

.field-value {
  font-weight: 550;
  margin: 0.375rem 0 0;
}

/* ---------- Layout ---------- */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.container-narrow {
  max-width: 40rem;
}

.container-wide {
  max-width: 1140px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  padding: 0 1.5rem;
  height: 3.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  display: block;
  height: 26px;
  width: auto;
}

/* A frame's logo, with the environment's name under it off production (ADR 0044 part 7). The name adds height,
   never width: it is as wide as the logo and truncates, with the full name as its tooltip. */
.topbar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
}

.environment-marker {
  box-sizing: border-box;
  width: 0;
  min-width: 100%;
  padding: 0 0.25rem;
  border-radius: 3px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 0.875rem;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The Rep Console's environment menu (Mail routing, Outbox): the name is its toggle, as narrow as the logo. */
.environment-menu {
  position: relative;
  width: 0;
  min-width: 100%;
}

.environment-menu > .environment-marker {
  display: block;
  width: 100%;
  min-width: 0;
  list-style: none;
  cursor: pointer;
}

.environment-menu > .environment-marker::-webkit-details-marker {
  display: none;
}

.environment-menu > .environment-marker::after {
  content: " \25BE";
}

.environment-menu > .environment-marker:hover,
.environment-menu[open] > .environment-marker {
  background: var(--warning-text);
  color: #fff;
}

.environment-menu-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 0.375rem);
  z-index: 30;
  min-width: 13rem;
  display: flex;
  flex-direction: column;
  padding: 0.375rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}

.environment-menu-note {
  margin: 0;
  padding: 0.375rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
}

.environment-menu-panel a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text);
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
}

.environment-menu-panel a:hover,
.environment-menu-panel a[aria-current="page"] {
  background: var(--accent-soft);
}

/* Off production a frame's topbar carries a warning-coloured rule along its top as well. */
.topbar:has(.environment-marker) {
  box-shadow: inset 0 3px 0 var(--warning-text);
}

/* A page outside every frame (sign-in, entry, consent) names the environment in a strip across its top. */
.environment-strip {
  padding: 0.25rem 1rem;
  background: var(--warning-bg);
  color: var(--warning-text);
  border-bottom: 1px solid rgba(138, 90, 0, 0.2);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.brand-logo-large {
  height: 44px;
  margin: 0 auto;
}

.brand-heading {
  margin: 0;
}

.topbar > * {
  flex-shrink: 0;
}

/* The buyer frame's name: one line, truncated, with the full name as its tooltip (title). */
.topbar-context {
  flex: 0 1 auto;
  min-width: 4rem;
  max-width: 20rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-nav {
  display: flex;
  align-self: stretch;
  gap: 0.25rem;
}

.topbar-nav a {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  border-top: 2px solid transparent;
  white-space: nowrap;
}

.topbar-nav a:hover {
  color: var(--text);
}

.topbar-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* A nav item with a count beside it (the Rep Queue tab, ADR 0030 part 13; the buyer frame's Creatives): the badge
   links to its own page. */
.nav-item-badged {
  display: flex;
  align-items: center;
}

.topbar-nav .nav-badge {
  align-self: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  margin-left: -0.375rem;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.topbar-nav .nav-badge:hover {
  color: #fff;
  background: var(--accent-dark);
}

/* A view switch (Active / Archived / Deleted): the current view reads like the topbar's. */
.button[aria-current="page"],
.button[aria-current="page"]:hover {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* A row of view links keeps the standard gap above the list it switches. */
.form-inline:has(> .button[aria-current]) {
  margin-bottom: 1rem;
}

/* Takes the topbar's free space. The controls keep their size; the identity has no width of its
   own and fills only what is left, so it gives way first and the buyer name truncates after it. */
.topbar-end {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.topbar-end > * {
  flex-shrink: 0;
  white-space: nowrap;
}

.topbar-identity {
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-end > .topbar-identity {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  text-align: right;
}

/* A buyer frame offering every section (Advertisers, Client requests, Proposals, Mockups, IOs, Campaigns, Creatives,
   Members, Service accounts, Settings) fits from 1024 wide up: below 1520px, where the items at full spacing no
   longer fit, the topbar's gaps, padding and the nav items' padding and type tighten, and the buyer's name gives way
   first. */
@media (max-width: 1520px) {
  .topbar {
    gap: 0.75rem;
    padding: 0 1rem;
  }

  .topbar-context {
    min-width: 2.5rem;
  }

  .topbar-nav a {
    font-size: 0.8125rem;
  }

  .topbar-nav {
    gap: 0.125rem;
  }

  /* 0.1875rem, not 0.25rem: the Rep Console's "Client Requests" (CAN-24) still fits just above 1180px. */
  .topbar-nav a {
    padding: 0 0.1875rem;
  }

  /* The badge's negative margin offsets the desktop padding; at this padding it would touch the label. */
  .topbar-nav .nav-badge {
    margin-left: 0;
  }

  .nav-separator {
    margin: 0 0.25rem;
  }

  .topbar-end {
    gap: 0.375rem;
  }
}

/* With a ninth buyer section (Creatives, CANA-111) and its badge, and a tenth (Mockups, CANA-145), the frame no longer
   fits below 1180px at that spacing: the logo, the gaps, the nav items' gap, padding and type, and the account
   controls' padding tighten once more. */
@media (max-width: 1180px) {
  .topbar {
    gap: 0.5rem;
    padding: 0 0.75rem;
  }

  .topbar .brand-logo {
    height: 20px;
  }

  .topbar-nav {
    gap: 0;
  }

  .topbar-nav a {
    padding: 0 0.125rem;
    font-size: 0.75rem;
  }

  .topbar-end {
    gap: 0.25rem;
  }

  .topbar-end .button-small {
    padding-inline: 0.375rem;
  }

  .nav-separator {
    margin: 0 0.1875rem;
  }

  .account-menu-toggle {
    padding-inline: 0.375rem;
    font-size: 0.75rem;
  }
}

/* The buyer frame's "Client requests" (CAN-26, ADR 0031 part 6) is the longest entry of a frame offering every section:
   its items pad 0.625rem, not 0.75rem, above 1520px, their type steps down just above the 1180px tightening (to 1240px)
   and once more below 1100px, so the frame still fits one line from 1024 wide up. The Rep Console wraps instead,
   below. */
@media (min-width: 1521px) {
  .topbar:not(.topbar-rep) .topbar-nav a {
    padding: 0 0.625rem;
  }
}

@media (min-width: 1181px) and (max-width: 1240px) {
  .topbar:not(.topbar-rep) .topbar-nav a {
    font-size: 0.75rem;
  }
}

@media (max-width: 1100px) {
  .topbar:not(.topbar-rep) .topbar-nav a {
    font-size: 0.6875rem;
  }
}

/* The Rep Console's fourteenth entry, Assignments (CAN-27, ADR 0047 part 6), takes the room the buyer frame's longest
   entry took: its items pad 0.375rem, not 0.75rem, above 1520px, their type and padding step down just above the
   1180px tightening (to 1280px) and once more below 1100px, so the nav still fits one line from 1024 wide up. */
@media (min-width: 1521px) {
  .topbar-rep .topbar-nav a {
    padding: 0 0.375rem;
  }
}

@media (min-width: 1181px) and (max-width: 1280px) {
  .topbar-rep .topbar-nav a {
    padding: 0 0.125rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 1100px) {
  .topbar-rep .topbar-nav a {
    padding: 0 0.0625rem;
    font-size: 0.6875rem;
  }
}

/* Below 1024 wide the Rep Console's fourteen entries no longer fit one line: the topbar wraps, the logo and the
   account control on the first line and the navigation, wrapping, under them, so nothing overflows the topbar
   or the page (ADR 0039 part 1). */
@media (max-width: 1023px) {
  .topbar.topbar-rep {
    flex-wrap: wrap;
    height: auto;
    min-height: 3.5rem;
    padding-block: 0.5rem;
    row-gap: 0.375rem;
  }

  .topbar-rep .topbar-nav {
    order: 3;
    flex: 1 1 100%;
    flex-wrap: wrap;
    align-self: auto;
    row-gap: 0.125rem;
  }

  .topbar-rep .topbar-nav a {
    padding: 0.25rem 0.375rem;
    font-size: 0.8125rem;
  }

  .topbar-rep .nav-item-badged,
  .topbar-rep .nav-separator {
    align-self: center;
  }
}

/* The Rep Console's nav groups (Queue · work lists · account lists · platform list; ADR 0039 part 1): a thin rule
   between groups. */
.nav-separator {
  align-self: center;
  flex: none;
  width: 1px;
  height: 1.25rem;
  margin: 0 0.375rem;
  background: var(--border);
}

/* The Rep Console's account control (ADR 0039 part 2): the Rep's name, truncated with the full name as its
   tooltip, opening a menu of Profile, Tokens and connections and Sign out. It takes the topbar's free space, so
   the name gives way before any nav item. */
.topbar-end > .account-menu {
  flex: 1 1 0;
  width: 0;
  min-width: 2.5rem;
  display: flex;
  justify-content: flex-end;
}

.account-menu {
  position: relative;
}

.account-menu-toggle {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  min-width: 0;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
}

.account-menu-toggle::-webkit-details-marker {
  display: none;
}

/* A caret, so the name reads as a menu. */
.account-menu-toggle::after {
  content: "";
  flex: none;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
}

.account-menu-toggle:hover,
.account-menu[open] > .account-menu-toggle {
  background: var(--accent-soft);
}

.account-menu-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.375rem);
  z-index: 30;
  min-width: 13rem;
  display: flex;
  flex-direction: column;
  padding: 0.375rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}

.account-menu-panel a,
.account-menu-signout {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.account-menu-panel a:hover,
.account-menu-signout:hover {
  background: var(--accent-soft);
}

.account-menu-panel form {
  margin: 0;
  border-top: 1px solid var(--border);
}

/* The identity frame's way back to the buyer it was opened from (Planes; CANA-103 3.8), in a slim
   strip under the topbar: one line, the name truncated, with the full name as its tooltip (title). */
.return-bar {
  padding: 0.5rem 1.5rem;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.return-bar a {
  display: block;
  max-width: 100%;
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.return-bar a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.5rem;
}

.card + .card {
  margin-top: 1.25rem;
}

.card > h2 {
  margin-bottom: 0.25rem;
}

/* Flush cards hold tables edge-to-edge. Overflow stays visible so row
   popovers can escape; the corner radius is carried by the cells instead. */
.card-flush {
  padding: 0;
}

.card-flush .data-table thead th:first-child {
  border-top-left-radius: var(--radius);
}

.card-flush .data-table thead th:last-child {
  border-top-right-radius: var(--radius);
}

.card-flush .data-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius);
}

.card-flush .data-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius);
}

/* A card's closing note below its content: small, with the standard gap above. */
.card-note {
  font-size: 0.875rem;
  margin: 0.75rem 0 0;
}

/* A card inside a wrapper (an edit group's anchor) keeps the stacked-card gap to the cards beside it. */
div:has(> .card:last-child) + .card,
.card + div:has(> .card:first-child) {
  margin-top: 1.25rem;
}

.card-section + .card-section {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

/* A card's own secondary action below its text: one standard top spacing, in a form or not. */
.card-action {
  margin-top: 1rem;
}

.form-stack > .card-action {
  margin-top: 0.375rem;
}

.auth-card {
  max-width: 380px;
  margin: 14vh auto 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  padding: 2.25rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

/* A block of an auth card: a heading with its lines (the IdP no-access page, the passkey
   interstitial's offer and success states). */
.auth-card-section {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.auth-card-section[hidden] {
  display: none;
}

.auth-card-section > h2,
.auth-card-section > p {
  margin: 0;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  background: var(--surface-raised);
  border-color: var(--faint);
}

.button:focus-visible,
input:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
}

.button-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.button-quiet {
  border-color: transparent;
  background: none;
  color: var(--muted);
}

.button-quiet:hover {
  border-color: transparent;
  background: rgba(29, 43, 35, 0.06);
  color: var(--text);
}

.button-danger-quiet {
  border-color: transparent;
  background: none;
  color: var(--danger);
}

.button-danger-quiet:hover {
  border-color: transparent;
  background: var(--danger-bg);
  color: var(--danger-dark);
}

.button-small {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
}

/* ---------- Forms ---------- */

input:not([type]),
input[type="text"],
input[type="email"],
input[type="search"],
input[type="url"],
input[type="date"],
textarea,
select {
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  min-width: 0;
}

input:not([type]):focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* A select drawn like the text inputs, with its own chevron in place of the browser's. */
select {
  appearance: none;
  padding-right: 2rem;
  /* A file, not a data: URL: the creative pages' policy allows images from Canopy itself only (ADR 0037). */
  background-image: url("/assets/select-chevron.svg");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 0.75rem;
  cursor: pointer;
}

input::placeholder {
  color: var(--faint);
}

/* A free-text statement (an IO's cancel reason): drawn like the inputs, growing downwards only. */
textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.4;
}

/* The date picker's calendar control in the site's muted tone, never the browser's default glyph colour. */
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.6;
  cursor: pointer;
}

/* An amount input with its currency prefix (ADR 0034): one bordered control, the prefix inside it. */
.input-prefix {
  display: flex;
  align-items: stretch;
  max-width: 16rem;
}

.input-prefix > span {
  display: flex;
  align-items: center;
  padding: 0 0.625rem;
  border: 1px solid var(--border-strong);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 0.9375rem;
}

.input-prefix > input[type="text"] {
  flex: 1 1 auto;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* An IO's start and end dates, side by side, stacking on a narrow screen. */
.terms-dates {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.terms-dates > .form-stack {
  flex: 0 1 12rem;
}

/* An amount in a detail list or table: tabular digits, so totals line up. */
.amount {
  font-variant-numeric: tabular-nums;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  text-align: left;
}

.form-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.form-inline > input:not([type]),
.form-inline > input[type="text"],
.form-inline > input[type="email"],
.form-inline > input[type="search"],
.form-inline > input[type="url"] {
  flex: 1 1 14rem;
}

/* A file picker drawn like the text inputs, with its button drawn like `.button`: never the browser's
   default control (the attachment upload, ADR 0029). */
input[type="file"] {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.3125rem 0.375rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--muted);
  background: var(--surface);
}

input[type="file"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

input[type="file"]::file-selector-button {
  margin-right: 0.625rem;
  padding: 0.3125rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--faint);
  background: var(--bg);
}

.attachment-upload {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-top: 1rem;
}

.attachment-upload .hint {
  margin: 0;
}

/* ---------- Queues (ADR 0030) ---------- */

.queue-claim {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.queue-claim-by {
  min-width: 0;
  overflow-wrap: anywhere;
}

.queue-claim-by .identity-secondary,
.queue-release .identity-secondary {
  margin: 0;
}

.queue-release,
.queue-takeover {
  margin: 0.75rem 0;
}

.queue-takeover > p {
  margin: 0 0 0.5rem;
}

.queue-release-reason {
  margin: 0.375rem 0 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-raised);
  overflow-wrap: anywhere;
}

.queue-release-form,
[data-queue-remind-form] {
  margin-top: 1rem;
}

.queue-release-form .hint,
[data-queue-remind-form] .hint {
  margin: 0;
}

/* A search or filter row above a table. */
.filter-bar {
  margin: 1rem 0 1.25rem;
}

.filter-bar > input,
.filter-bar > select {
  max-width: 24rem;
}

/* A filter applied by id (a buyer, an advertiser), named, with its own remove link (the Rep Requests list). */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.25rem 0.125rem 0.625rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8125rem;
}

.filter-chip a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
}

.filter-chip a:hover {
  background: var(--border);
  color: var(--text);
}

/* A mockup's brief (ADR 0038): plain text, its line breaks kept, long words wrapped. */
.brief-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Who can see a record now, under its heading (the Rep proposal page, ADR 0032): Draft, or visible to the client. */
.visibility-banner {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid rgba(138, 90, 0, 0.2);
  padding: 0.5625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin: 0 0 1.25rem;
}

.visibility-banner-visible {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: rgba(30, 111, 80, 0.25);
}

/* A Cancelled IO (ADR 0033): visible to the client, final and read-only. */
.visibility-banner-cancelled {
  background: var(--surface-raised);
  color: var(--muted);
  border-color: var(--border-strong);
}

/* A card whose heading carries an action at its right (the proposal page's IOs section). */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-head h2 {
  margin: 0;
}

/* A confirmation's effects, one per line, between its details and its buttons (the Rep user acts; ADR 0039
   part 5). */
.confirm-effects {
  margin: 1rem 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* The execute confirmation: the terms beside the documents, stacked on a narrow screen (ADR 0033). */
.execute-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 1.25rem;
  align-items: start;
}

.execute-layout > .card {
  margin: 0;
}

.execute-confirm {
  margin: 1rem 0 0.25rem;
  color: var(--text);
}

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

/* A picker that links one record to another, under the linked list (proposals and requests, ADR 0032). */
.link-picker {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Previous / Next under a paged table. */
.pager {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.checkbox-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  text-align: left;
  font-size: 0.875rem;
  color: var(--muted);
}

.checkbox-row input {
  margin-top: 0.2rem;
}

.auth-step {
  font-weight: 550;
  color: var(--text);
}

.auth-step-divider {
  margin-top: 0.5rem;
  padding-top: 1.125rem;
  border-top: 1px solid var(--border);
}

.dev-login {
  margin-top: 1rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dev-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  margin: 0;
}

/* A notice across the top of every page, under the topbar (every Rep's withheld email updates; ADR 0039 part 3). */
.site-banner {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-bottom: 1px solid rgba(138, 90, 0, 0.2);
  padding: 0.625rem 1.5rem;
  font-size: 0.875rem;
  text-align: center;
  overflow-wrap: anywhere;
}

/* One line per withheld update; the links read as links on the warning colour. */
.site-banner-lines {
  list-style: none;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.site-banner a {
  color: inherit;
  font-weight: 600;
}

/* ---------- Alerts ---------- */

.form-error,
.alert-error {
  background: var(--danger-bg);
  color: var(--danger-dark);
  border: 1px solid rgba(179, 55, 47, 0.25);
  padding: 0.5625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin: 0;
}

.notice,
.alert-ok {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid rgba(30, 111, 80, 0.25);
  padding: 0.5625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin: 0;
}

/* A caution that isn't a refusal (an IO's terms changed after it was sent): the warning tone. */
.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid rgba(138, 90, 0, 0.2);
  padding: 0.5625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin: 0;
}

.alert-warning p {
  margin: 0;
}

.alert-warning p + p {
  margin-top: 0.375rem;
}

.page-alert {
  margin-bottom: 1.25rem;
}

/* ---------- Data table ---------- */

/* Tables scroll sideways only on narrow screens; on desktop the container
   stays visible so row popovers aren't clipped. */
@media (max-width: 900px) {
  .table-scroll {
    overflow-x: auto;
  }
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.71875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  background: var(--surface-raised);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--surface-raised);
}

.cell-nowrap {
  white-space: nowrap;
}

/* A money column (ADR 0034): right-aligned, header included, so totals line up by their cents. */
.data-table .cell-amount {
  text-align: right;
}

/* A date range under an amount (the Rep IOs list): it may wrap at the dash, never inside a date. */
.cell-amount .cell-dates {
  white-space: normal;
}

.cell-dates > span {
  white-space: nowrap;
}

/* The Rep client requests list has ten columns (Client Requests Presentation: "its default columns are name, buyer,
   advertiser, type, working state, client deadline, internal due date, budget"): its cells pad less and its headers
   may wrap, so long names, a deadline and Open still fit a 1024-wide screen. */
.data-table[data-rep-requests] th,
.data-table[data-rep-requests] td {
  padding-inline: 0.375rem;
}

.data-table[data-rep-requests] th {
  white-space: normal;
}

/* The Rep and buyer IOs lists have seven columns, two of them whole amounts and dates: below 1180px
   their cells pad less, so a long name, the largest total and Open still fit a 1024-wide screen. */
@media (max-width: 1180px) {
  .data-table[data-rep-ios] th,
  .data-table[data-rep-ios] td,
  .data-table[data-buyer-ios] th,
  .data-table[data-buyer-ios] td {
    padding-inline: 0.625rem;
  }
}

.cell-num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* The Rep Creative assignments list has seven columns (CAN-27, ADR 0047 part 6): its flight wraps at the dash
   (cell-dates) and below 1180px its cells pad less, so long names, the longest flight and Open fit a 1024-wide
   screen. */
@media (max-width: 1180px) {
  .data-table[data-rep-assignments] th,
  .data-table[data-rep-assignments] td {
    padding-inline: 0.625rem;
  }
}

.cell-actions {
  text-align: right;
}

.cell-actions .form-inline {
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 0.125rem;
}

/* Sized to its actions and left-aligned, so rows with fewer actions line up under the first. */
.cell-actions-fit {
  width: 1%;
  text-align: left;
}

.cell-actions-fit .form-inline {
  justify-content: flex-start;
}

/* An identity cell of long unbroken addresses (Users, the roster): they wrap inside the column
   instead of widening the table. Only there: elsewhere a name breaks between words. */
.cell-wrap-anywhere {
  overflow-wrap: anywhere;
}

/* A name column that keeps room for a few words beside a wide neighbour (a credential's name). */
.cell-name-min {
  min-width: 11rem;
}

.row-deleted .cell-identity,
.row-deleted .cell-num,
.row-deleted .cell-nowrap {
  opacity: 0.55;
}

.identity-primary {
  font-weight: 550;
}

.identity-secondary {
  color: var(--muted);
  font-size: 0.8125rem;
  margin: 0;
}

/* A machine value (a secret's prefix) under a name: monospace, still muted. */
.text-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.identity-warning {
  color: var(--warning-text);
  background: var(--warning-bg);
  border-radius: 4px;
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
  display: inline-block;
  margin-top: 0.25rem;
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

/* ---------- Status badges ---------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 550;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.status-new {
  background: var(--info-bg);
  color: var(--info-text);
}
.status-deactivated {
  background: var(--warning-bg);
  color: var(--warning-text);
}
.status-deleted {
  background: var(--danger-bg);
  color: var(--danger-dark);
}
/* A finished state that is neither good nor bad news (a Closed request). */
.status-neutral {
  background: var(--border);
  color: var(--muted);
}

/* A status cell: a long pill wraps inside its column, and a detail line (an expiry) sits under it. */
.cell-subline {
  display: block;
  font-size: 0.8125rem;
}

.cell-status .status-badge {
  white-space: normal;
  align-items: baseline;
  border-radius: 0.75rem;
}

.cell-status .status-badge::before {
  flex-shrink: 0;
  transform: translateY(-0.0625rem);
}

/* ---------- Popover (details-based, no JS) ---------- */

.popover {
  position: relative;
  display: inline-block;
}

.popover > summary {
  list-style: none;
}

.popover > summary::-webkit-details-marker {
  display: none;
}

.popover-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.375rem);
  z-index: 20;
  min-width: 21rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 1rem 1.125rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.popover-panel h3 {
  margin: 0;
}

@media (max-width: 640px) {
  .container {
    padding: 1.25rem 1rem 3rem;
  }

  .topbar {
    padding: 0 1rem;
    gap: 1rem;
  }

  .topbar-identity {
    display: none;
  }

  .return-bar {
    padding: 0.5rem 1rem;
  }

  .popover-panel {
    min-width: 16rem;
  }

  /* A popover whose control moves to the left edge once its page head stacks opens rightwards,
     so it stays on screen (the Rep user page's Change email). */
  .popover-start-narrow > .popover-panel {
    right: auto;
    left: 0;
  }
}

/* ---------- Edit groups (Platform Standards › Edits; src/views/partials/edit-group.tsx) ---------- */

.edit-fields {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

/* An open group stays visibly unresolved until it is committed or cancelled
   (Platform Standards › Edits: "the group stays open and visibly unresolved"). */
.edit-group-open {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* A group in a table cell (a passkey's name): no card, but the open state still shows. */
.edit-group-compact {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.375rem;
  margin: -0.25rem -0.375rem;
}

.edit-group-compact .field-value {
  margin: 0;
}

.edit-group [data-edit-value] {
  cursor: pointer;
}

.edit-pending,
.edit-unsaved {
  display: none;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Pending until the server confirms (Platform Standards › Edits: "the interface shows the group as
   pending"): htmx marks the form for the request's duration. */
form.htmx-request .edit-pending {
  display: inline;
}

form.htmx-request .edit-unsaved {
  display: none;
}

[data-edit-changed] .edit-unsaved {
  display: inline;
  color: var(--warning-text);
}

.edit-fields:disabled a {
  pointer-events: none;
  opacity: 0.55;
}

.edit-stale {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid rgba(138, 90, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.edit-stale p {
  margin: 0;
}

/* Label and value in two columns: a card's details, and a stale edit's side-by-side values. */
.detail-list,
.edit-compare {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0;
  color: var(--text);
}

.detail-list {
  gap: 0.5rem 1.5rem;
}

.detail-list dt,
.edit-compare dt {
  font-weight: 600;
}

.detail-list dd,
.edit-compare dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-list dd ul {
  margin: 0;
  padding-left: 1.125rem;
}

.card:not(.form-stack) > * + .detail-list {
  margin-top: 0.75rem;
}

.card:not(.form-stack) > .detail-list + * {
  margin-top: 1rem;
}

/* A block value (a detail list, a paragraph) keeps Edit on its first line, not floating mid-row. */
.form-inline:has(> div.field-value) {
  align-items: baseline;
}

.field-value > :is(p, ul, dl) {
  margin: 0;
}

/* Islands: a control the browser is holding back (resend cooldown, ceremony in flight) */
.button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Membership pickers (ADR 0019 part 2) ---------- */

.picker {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.picker legend {
  font-weight: 550;
  padding: 0;
  margin-bottom: 0.25rem;
}

/* Associations apply only under Scoped Advertisers (B8); CSS hides them, so no island is needed. */
.picker:has(input[value="all_advertisers"]:checked) .advertiser-checklist {
  display: none;
}

/* ---------- Campaigns (ADR 0035) ---------- */

/* The campaign page: its edit groups beside the IO and details cards, stacked on a narrow screen. */
.campaign-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

/* The Rep Advertisers tab's rows carry nine actions (Requests, Proposals, IOs, Campaigns, Line items, Creatives,
   Mockups, Archive, Delete). At every width they wrap onto two right-aligned lines of a fixed width, so the column is sized to that
   width rather than to one long line, or to the widest action, which stacks them one per line. Below 1180px the
   cells and buttons also pad less, so the row still fits a 1024-wide screen. */
.data-table[data-rep-advertisers] .cell-actions .form-inline {
  flex-wrap: wrap;
  row-gap: 0.25rem;
  width: 25rem;
  margin-left: auto;
}

@media (max-width: 1180px) {
  .data-table[data-rep-advertisers] th,
  .data-table[data-rep-advertisers] td {
    padding-inline: 0.625rem;
  }

  .data-table[data-rep-advertisers] .cell-actions .button-small {
    padding-inline: 0.375rem;
  }

  .data-table[data-rep-advertisers] .cell-actions .form-inline {
    width: 23rem;
  }
}

/* The campaign page's line items have seven columns. A DSP line item id is up to 64 characters with no spaces, so it
   wraps anywhere inside its column instead of widening the table past its card; below 1180px the cells pad less, as
   the IOs lists' do, so the table still fits a 1024-wide screen. */
.data-table[data-rep-campaign-line-item-table] [data-rep-campaign-line-item-dsp] {
  min-width: 8rem;
}

.data-table[data-rep-campaign-line-item-table] [data-rep-campaign-line-item-dsp] .text-mono {
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .data-table[data-rep-campaign-line-item-table] th,
  .data-table[data-rep-campaign-line-item-table] td {
    padding-inline: 0.625rem;
  }
}

/* The card after the grid (the line items) keeps the stacked-card gap. */
.campaign-layout + .card {
  margin-top: 1.25rem;
}

/* The grid's columns hold their own stacks of cards; the grid's gap is the only space between them. */
.campaign-layout > div > .card:first-child {
  margin-top: 0;
}

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

/* A flush card's heading row, padded as a card's content is. */
.card-head-padded {
  padding: 1.25rem 1.5rem 0;
}

/* The Rep-only flags under a campaign's status (D4, D5): wrapped pills, never past the column. */
.campaign-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
  white-space: normal;
}

.campaign-flags .identity-warning {
  margin-top: 0;
}

/* The IO card's difference flags, one per line. */
.campaign-differences {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.375rem;
}

.campaign-differences .identity-warning {
  margin: 0;
}

/* "Differs from IO" and its tick (F5): sized to the text, hidden while the entry matches the IO; the island
   toggles them. */
.differs-notice {
  align-self: flex-start;
}

.differs-notice[hidden],
[data-differs-confirm][hidden] {
  display: none;
}

/* ---------- Line items (ADR 0035) ---------- */

/* The Campaigns tab's sub-tabs, "Campaigns | Line items": underlined like the topbar's, on the page's own rule. */
.sub-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 0 0 0.25rem;
}

.sub-tabs a {
  padding: 0.5rem 0.75rem;
  margin-bottom: -1px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.sub-tabs a:hover {
  color: var(--text);
}

.sub-tabs a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* The Queue page's kind selector: an entry per kind with queue states, five since Creatives and Creative assignments
   (CAN-28), so it wraps rather than widening the page at 390. */
.sub-tabs[data-rep-queues-kinds] {
  flex-wrap: wrap;
}

/* The Rep line items list: a DSP line item id is up to 64 characters with no spaces, so it wraps anywhere inside its
   column; below 1180px the cells pad less, as the campaigns list's do, so the table fits a 1024-wide screen. */
.data-table[data-rep-line-items] [data-rep-line-item-dsp] {
  min-width: 7rem;
}

.data-table[data-rep-line-items] [data-rep-line-item-dsp] .text-mono {
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .data-table[data-rep-line-items] th,
  .data-table[data-rep-line-items] td {
    padding-inline: 0.625rem;
  }
}

/* The trafficking group's DSP line item id, shown as stored, wraps rather than widening the card. */
[data-rep-line-item-trafficking-value] .text-mono {
  overflow-wrap: anywhere;
}

/* The line item page's status acts, a row under the banner. Each dialog opens from the row's left edge rather than
   its own button's, so it stays on screen at any width and however the row wraps. An empty row takes no space. */
.line-item-acts {
  position: relative;
  margin: 0 0 1.25rem;
}

.line-item-acts:empty {
  display: none;
}

.line-item-acts > .popover {
  position: static;
}

.line-item-acts .popover-panel {
  left: 0;
  right: auto;
  width: 28rem;
  max-width: 100%;
  min-width: 0;
}

/* The go-live dialog's DSP and id. */
[data-rep-line-item-go-live-dsp] dd {
  overflow-wrap: anywhere;
}

/* ---------- HTMX request indicators ---------- */

/* HTMX's own indicator rules (ADR 0017, amended by ADR 0037): HTMX injects these as an inline <style> unless
   `includeIndicatorStyles` is off, which the creative pages' `style-src 'self'` would block (CANA-111 F3). */
.htmx-indicator {
  opacity: 0;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  transition: opacity 200ms ease-in;
}

/* ---------- Creatives (ADR 0037) ---------- */

/* The spec flags (D8): wrapped warning pills. */
.creative-flags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  white-space: normal;
}

.creative-flags .identity-warning {
  margin: 0;
}

.card-head .creative-flags {
  justify-content: flex-end;
}

/* A media family without a size or a duration hides it (the creative-facts island); `hidden` beats the stack's flex
   display. */
[data-creative-size][hidden],
[data-creative-timing][hidden] {
  display: none;
}

/* A click-through URL is up to 2,048 characters with no spaces: it wraps inside its card. */
.click-through-value,
.click-through {
  overflow-wrap: anywhere;
}

/* The assets card: the table, then the upload and tag forms side by side, stacked on a narrow screen. */
.asset-forms {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
}

.asset-forms h3 {
  margin: 0;
}

.asset-forms-note {
  padding: 0 1.5rem 1.25rem;
}

/* A flush card's text between its heading and its table, padded as a card's content is (ADR 0037 part 17). */
.card-body-padded {
  margin: 0;
  padding: 0.75rem 1.5rem 0;
}

/* An earlier asset revision under the current assets: each set off from the one above. */
.creative-revision {
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  padding-bottom: 1rem;
}

.creative-revision ul {
  margin: 0;
  padding-left: 1.25rem;
}

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

/* A card's assign control (creatives on line items): under its table, set off as the assets card's forms are. */
.assignment-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
}

.assignment-form .form-inline select {
  min-width: 0;
  max-width: 100%;
}

.assignment-hint {
  margin: 0;
}

/* An Ended creative assignment's row: kept as history, muted. */
.data-table tr.row-ended td {
  color: var(--muted);
}

/* A go-live, resume or reopen dialog's list of the creatives it takes live. */
.dialog-creatives p,
.dialog-creatives ul {
  margin: 0;
}

.dialog-creatives ul {
  margin-top: 0.25rem;
}

/* A refusal stated inside a flush card, aligned with its padded head. */
.card-alert {
  margin: 0 1.5rem 1rem;
}

/* An image preview keeps its aspect ratio: its width and height attributes give the ratio, and it scales down to at
   most 300px wide (no style attribute: the creative pages' policy allows none). */
.creative-preview {
  display: block;
  width: auto;
  height: auto;
  max-width: min(300px, 100%);
  max-height: 300px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}

.data-table.creative-assets .cell-preview {
  width: 1%;
  max-width: 300px;
}

/* The upload form stacks its fields, so the picker takes its own height rather than the row's 14rem basis. */
[data-creative-upload] input[type="file"],
[data-rep-mockup-artifact-upload] input[type="file"] {
  flex: none;
}

/* A mockup artifact's thumbnail (ADR 0038 part 13). */
/* The thumbnail sits above the artifact's label in its File cell, so File and Actions fit down to a phone's width. */
.mockup-artifact-thumbnail {
  margin-bottom: 0.5rem;
}

/* Download above Remove…, so the Actions column stays narrow beside a long file name. */
.mockup-artifact-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.375rem;
}

.mockup-artifact-thumbnail .creative-preview {
  max-width: min(160px, 100%);
  max-height: 160px;
}

/* "Approved (on client's behalf)" (F5): a sentence, not a status name, so it isn't capitalized. */
.status-badge-as-written {
  text-transform: none;
}

/* A file without a preview: its type, and why. */
.asset-type-icon {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.asset-no-preview {
  font-weight: 400;
  color: var(--muted);
}

/* A tag's text (D6): escaped, wrapped inside the cell however long its lines, never widening the page. */
.tag-content {
  margin-top: 0.5rem;
  min-width: 0;
}

.tag-content-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

.tag-content-text {
  margin: 0.375rem 0 0;
  padding: 0.625rem 0.75rem;
  max-width: 100%;
  overflow: auto;
  max-height: 24rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}

.tag-content-all > summary {
  margin-top: 0.375rem;
  cursor: pointer;
  color: var(--accent-dark);
  font-size: 0.8125rem;
}

.data-table.creative-assets .cell-identity {
  min-width: 10rem;
}

/* A tag's row, under its asset's: no rule between the two, and the text never widens the table. */
.data-table.creative-assets tr[data-creative-asset-kind="tag"] > td {
  border-bottom: 0;
}

.data-table.creative-assets .tag-content-row > td {
  max-width: 0;
  padding-top: 0;
}

/* A filter's label stays on the same line as its control when the filter row wraps (the Rep Creatives list). */
.filter-field {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.filter-field > select {
  max-width: 24rem;
}

.filter-field-grow {
  flex: 1 1 14rem;
}

.filter-field-grow > input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 24rem;
}

.filter-bar:has(> .filter-field) {
  column-gap: 1rem;
}

/* On a narrow screen a filter whose options are long (the creatives lists' Production source) shrinks to the row
   instead of widening the page: its select narrows and shows as much of the chosen option as fits (CAN-27). */
.filter-field {
  min-width: 0;
  max-width: 100%;
}

.filter-field > select {
  flex: 0 1 auto;
  min-width: 0;
}

/* ---------- Queues (ADR 0030; CANA-186) ---------- */

/* A group's heading in the Queues page's union table: the group's name as the page groups by it, in the table's
   own text style rather than the uppercase column headings. */
.data-table .queue-group-row th {
  color: var(--text);
  font-size: 0.8125rem;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* The Queue page's union and mockup queue, and the Mockups list, keep room for a few words of an item's name beside
   the wrapping columns, and the claimant's address wraps rather than widening the table (CANA-186 Ticket 3). */
.data-table[data-rep-queues] .cell-identity,
.data-table[data-rep-mockup-queue] .cell-identity,
.data-table[data-rep-request-queue] .cell-identity,
.data-table[data-rep-mockups] .cell-identity {
  min-width: 8rem;
}

.data-table[data-rep-mockup-queue] [data-rep-mockup-queue-claim],
.data-table[data-rep-request-queue] [data-rep-request-queue-claim],
.data-table[data-rep-queues] [data-rep-queue-claim] {
  min-width: 5.5rem;
}

/* The work discharging an Owed request's item: its Draft proposals, one a line (ADR 0031 part 14). */
.queue-work-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

/* ---------- The Queue page (ADR 0030 part 13) ---------- */

/* A kind's count of work on the Queue page's kind selector; none at zero (CANA-197 D1). */
.sub-tab-count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 0.375rem;
  margin-left: 0.375rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* The close dialog (Client Requests Presentation: "closing takes the outcome in a dialog"): a native <dialog>
   rendered open, in the page or swapped into its slot by HTMX; Cancel closes it with no script. */
.dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  max-width: 32rem;
  width: calc(100% - 2rem);
  height: fit-content;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 1.25rem 1.5rem;
  z-index: 50;
}

.dialog > h2 {
  margin-top: 0;
}

/* An outbox message's content as delivered (ADR 0044 part 7): its own lines, wrapped, never wider than the card. */
.outbox-body {
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- List controls (ADR 0041 part 7) ---------- */

/* "N IOs" above a list's table: the records matching its filters. */
.list-count {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* A column header that orders the list by its fact; the arrow marks the order it walks. */
.sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sort-link:hover,
.sort-link:focus-visible {
  color: var(--text);
  text-decoration: underline;
}

.sort-link-active {
  color: var(--text);
}

.sort-indicator {
  margin-left: 0.25rem;
  font-size: 0.625rem;
}

/* A header ordering by many facts (the creatives lists' Creative column, ADR 0041 part 9) wraps between them, each
   fact's link whole, so the column keeps the width its rows need. */
.data-table th.sort-header-wrap {
  white-space: normal;
}
