/* ============================================================
 * Component styles. One block per partial under src/views/components.
 * All margins / paddings / borders use LOGICAL properties so RTL
 * mirrors without rtl.css doing per-rule overrides.
 * ============================================================ */

/* ------------------------------------------------------------ */
/* App shell: layout grid                                         */
/* ------------------------------------------------------------ */

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "topbar"
    "main";
  min-height: 100vh;
}

@media (min-width: 900px) {
  .app-shell {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "sidebar main";
  }
}

.app-shell__topbar  { grid-area: topbar; }
.app-shell__sidebar { grid-area: sidebar; }
.app-shell__main    {
  grid-area: main;
  min-width: 0;
  padding: var(--space-4);
}
@media (min-width: 640px) {
  .app-shell__main { padding: var(--space-5); }
}
@media (min-width: 900px) {
  .app-shell__main { padding: var(--space-6) var(--space-7); }
}

.app-shell--auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: var(--space-5);
}

.content-cap { max-width: var(--content-max); margin-inline: auto; }

/* ------------------------------------------------------------ */
/* Top bar (mobile + tablet only)                                 */
/* ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-h);
  padding-inline: var(--space-4);
  background: var(--surface);
  border-block-end: 1px solid var(--border);
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
}
@media (min-width: 900px) {
  .topbar { display: none; }
}
.topbar__title {
  font-weight: 650;
  color: var(--ink);
  font-size: var(--text-md);
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ------------------------------------------------------------ */
/* Sidebar                                                         */
/* ------------------------------------------------------------ */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink);
  inline-size: 100%;
  border-inline-end: 1px solid var(--border);
}

/* Mobile: hidden by default, slide in when .is-open is set on body */
.sidebar {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  block-size: 100vh;
  inline-size: min(280px, 86%);
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 180ms ease;
  box-shadow: var(--shadow-lg);
}
[dir="rtl"] .sidebar { transform: translateX(100%); }
body.is-sidebar-open .sidebar { transform: translateX(0); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2,28,20,0.6);
  z-index: 40;
}
body.is-sidebar-open .sidebar-backdrop { display: block; }

@media (min-width: 900px) {
  .sidebar {
    position: static;
    transform: none !important;
    box-shadow: none;
    inline-size: var(--sidebar-w);
    block-size: auto;
  }
  .sidebar-backdrop { display: none !important; }
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  color: var(--primary);          /* relay-green wordmark (DSM-13) */
  font-weight: 650;
}
.sidebar__brand:hover {
  background: var(--surface-2);
  text-decoration: none;
  color: var(--primary);
}
.sidebar__brand-sub {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
}
/* The callsign — the screen's one MorseBand (abrq-ui: the signature is
   finite) — sits on its own row under the wordmark. */
.sidebar__sig {
  padding: 0 var(--space-5) var(--space-2);
  opacity: 0.85;
}
.sidebar__rule {
  margin: 0 var(--space-5) var(--space-2);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3);
  flex: 1 1 auto;
  min-block-size: 0;
}
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-block-size: var(--touch-min);
  padding-inline: var(--space-3);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
  font-size: var(--text-sm);
  transition: background var(--transition), color var(--transition);
}
.sidebar__nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}
.sidebar__nav a[aria-current="page"] {
  background: var(--primary);
  color: var(--primary-ink);
}
/* Trailing "opens in a new tab" glyph (e.g. Docs) — pushed to the row end. */
.sidebar__ext {
  margin-inline-start: auto;
  display: inline-flex;
  opacity: 0.6;
}

.sidebar__foot {
  padding: var(--space-4);
  border-block-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.sidebar__signout { color: var(--muted); }
.sidebar__meta {
  font-size: var(--text-xs);
  color: var(--muted);
  font-family: var(--font-mono);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.user-menu__avatar {
  display: grid;
  place-items: center;
  inline-size: 32px;
  block-size: 32px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--primary-ink);
  font-size: var(--text-sm);
  font-weight: 700;
}
.user-menu__body { min-width: 0; }
.user-menu__name {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu__meta {
  color: var(--muted);
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------ */
/* Page header                                                     */
/* ------------------------------------------------------------ */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block-end: var(--space-6);
  flex-wrap: wrap;
}
.page-header__lead {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  /* Lead must be flexible — page titles can be long. */
  flex: 1 1 240px;
}
.page-header__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.page-header__title {
  color: var(--ink);
  font-size: var(--text-2xl);
  /* Long client names mustn't push the action bar off-screen. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.page-header__sub { color: var(--text-muted); font-size: var(--text-sm); }
.page-header__actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
@media (max-width: 640px) {
  /* Stack actions full-width on mobile so each is a comfortable tap. */
  .page-header__actions {
    inline-size: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .page-header__actions .btn { inline-size: 100%; }
  .page-header__actions form { inline-size: 100%; }
  .page-header__actions form .btn { inline-size: 100%; }
}

/* ------------------------------------------------------------ */
/* Breadcrumbs                                                     */
/* ------------------------------------------------------------ */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs__sep { color: var(--text-muted); }
[dir="rtl"] .breadcrumbs__sep { transform: scaleX(-1); }

/* ------------------------------------------------------------ */
/* Card / panel                                                    */
/* ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--space-5);
}
.card + .card { margin-block-start: var(--space-5); }
.card--compact { padding: var(--space-3); }

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-block-end: var(--space-4);
}
.card__title { font-size: var(--text-lg); color: var(--ink); }
.card__sub { color: var(--text-muted); font-size: var(--text-sm); }

/* ------------------------------------------------------------ */
/* KPI card                                                        */
/* ------------------------------------------------------------ */

.kpi {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.kpi::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  block-size: 3px;
  background: var(--primary);
}
.kpi--warn::before    { background: var(--accent); }
.kpi--danger::before  { background: var(--error); }
.kpi--neutral::before { background: var(--muted); }
.kpi__label { color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-2xl); font-weight: 600; color: var(--ink); }
.kpi__sub { color: var(--text-muted); font-size: var(--text-xs); }
/* A KPI tile may be a link (components/kpi.ejs `href`) — same chrome,
   plus a hover affordance. */
a.kpi { text-decoration: none; color: inherit; transition: border-color var(--transition); }
a.kpi:hover { text-decoration: none; border-color: var(--primary); }

/* ------------------------------------------------------------ */
/* Button                                                          */
/* ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-block-size: var(--control-h);
  min-inline-size: var(--touch-min);
  padding-inline: var(--space-4);
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
@media (max-width: 640px) { .btn { min-block-size: var(--control-h-mobile); } }
.btn:hover { text-decoration: none; }
.btn[disabled],
.btn[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { background: var(--primary); color: var(--primary-ink); filter: brightness(0.94); }
.btn--secondary { background: var(--primary-soft); color: var(--primary); border-color: var(--border); }
.btn--secondary:hover { background: var(--primary-soft); color: var(--primary); filter: brightness(0.97); }
.btn--outline { background: transparent; color: var(--ink); border-color: var(--border); }
.btn--outline:hover { background: var(--surface-2); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--error); color: var(--primary-ink); }
.btn--danger:hover { background: var(--error); color: var(--primary-ink); filter: brightness(0.92); }
/* Brass: the sanctioned-exception voice (maker-checker approvals — an
   authorized override is exceptional but NOT destructive, so danger red
   overstates it). Local token-only variant per G12; filed upstream as
   abrq-ui gap G-M3. Ink AA measured (UX P0 baseline): --primary-ink on
   --accent = 5.41 light / 8.38 dark. */
.btn--warn { background: var(--accent); color: var(--primary-ink); }
.btn--warn:hover { background: var(--accent); color: var(--primary-ink); filter: brightness(0.94); }
.btn--sm { min-block-size: 32px; padding-inline: var(--space-3); font-size: var(--text-xs); }
.btn--icon { padding-inline: var(--space-2); min-inline-size: var(--control-h); }

/* btn-link: text button, used inside dense rows */
.btn-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.btn-link:hover { color: var(--primary); text-decoration: underline; }
.btn-link--danger { color: var(--error); }
.btn-link--danger:hover { color: var(--error); filter: brightness(0.92); }

/* ------------------------------------------------------------ */
/* Badge                                                           */
/* ------------------------------------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding-inline: var(--space-2);
  padding-block: 2px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--border);
  line-height: 1.4;
}
.badge--neutral { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
/* Machine strings (feature flags, cap:* axes) — badge chrome without the
   caps transform, because case is meaningful in the value. */
.badge--code { text-transform: none; letter-spacing: 0; }
.badge--info    { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.badge--success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge--warn    { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

/* ------------------------------------------------------------ */
/* Alert                                                           */
/* ------------------------------------------------------------ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  margin-block-end: var(--space-4);
}
.alert__icon { flex-shrink: 0; margin-block-start: 2px; }
.alert--info    { background: var(--info-soft); border-color: var(--info-border); color: var(--info); }
.alert--success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert--warn    { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.alert--error   { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

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

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.field--span-2 { grid-column: span 2; }
.field__label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.field__req { color: var(--danger); }
.field__hint { font-size: var(--text-xs); color: var(--text-muted); }
.field__err  { font-size: var(--text-xs); color: var(--danger); }

.input, .textarea, .select {
  inline-size: 100%;
  min-block-size: var(--control-h);
  padding-inline: var(--space-3);
  padding-block: var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  transition: border-color var(--transition), box-shadow var(--transition);
}
@media (max-width: 640px) {
  .input, .textarea, .select { min-block-size: var(--control-h-mobile); font-size: var(--text-md); }
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
}
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  border-color: var(--primary);
  outline: 2px solid var(--ring);   /* brass key */
  outline-offset: 1px;
}
.textarea { min-block-size: 96px; resize: vertical; }

/* Input with an affix (currency-suffixed money fields — UXB-14; local
   token-only composite per G12, filed upstream as abrq-ui gap G-M4).
   The GROUP owns the border + brass focus ring; the input goes naked
   inside so there's exactly one box. */
.input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.input-group .input {
  border: 0;
  background: transparent;
  flex: 1 1 auto;
  min-width: 0;
}
.input-group .input:focus,
.input-group .input:focus-visible { outline: none; }
.input-group:focus-within {
  border-color: var(--primary);
  outline: 2px solid var(--ring);   /* brass key */
  outline-offset: 1px;
}
.input-group:has(.input[aria-invalid="true"]) { border-color: var(--danger); }
.input-group__affix {
  padding-inline-end: var(--space-3);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
}

/* Inline inputs inside table rows (catalog draft price edit, UXB-24):
   compact and width-capped so the column doesn't stretch/jitter. */
.table .input {
  min-block-size: 32px;
  padding-block: var(--space-1);
  max-inline-size: 9rem;
  font-size: var(--text-sm);
}
/* Per-row qty control in the quote catalog picker — a count, not money. */
.input--qty { max-inline-size: 5.5rem; }
.select--compact {
  min-block-size: 36px;
  padding-block: var(--space-1);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--danger);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-soft);
  min-block-size: var(--touch-min);
}
.checkbox-row input[type="checkbox"] {
  inline-size: 18px;
  block-size: 18px;
  accent-color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 640px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}
.filter-card {
  margin-block-end: var(--space-5);
  padding: var(--space-4);
}
.filter-grid--clients { grid-template-columns: 2fr 1fr auto; }
.filter-grid--licenses { grid-template-columns: 1fr 1fr auto; }
.filter-grid--invoices { grid-template-columns: 1fr auto; }
@media (max-width: 640px) {
  .filter-grid--clients,
  .filter-grid--licenses,
  .filter-grid--invoices {
    grid-template-columns: 1fr;
  }
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-block-start: var(--space-5);
  padding-block-start: var(--space-5);
  border-block-start: 1px solid var(--border);
  flex-wrap: wrap;
}
.form-actions__primary { display: flex; gap: var(--space-2); }
.form-actions__secondary { display: flex; gap: var(--space-2); margin-inline-start: auto; }
.field__label--inline { margin: 0; }

/* Loading state for forms in flight */
form[data-loading="true"] .btn--primary {
  opacity: 0.7;
  pointer-events: none;
}

.loading-state {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ------------------------------------------------------------ */
/* Data toolbar                                                   */
/* ------------------------------------------------------------ */

.data-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-block-end: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.data-toolbar__filters {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}
.data-toolbar__filters .input { max-inline-size: 320px; }
.data-toolbar__filters .select { max-inline-size: 220px; }
.data-toolbar__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}
@media (max-width: 640px) {
  .data-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .data-toolbar__filters,
  .data-toolbar__meta {
    align-items: stretch;
    flex-direction: column;
    inline-size: 100%;
  }
  .data-toolbar__filters .input,
  .data-toolbar__filters .select,
  .data-toolbar__filters .btn,
  .data-toolbar__meta .btn {
    max-inline-size: none;
    inline-size: 100%;
  }
}

/* ------------------------------------------------------------ */
/* Tabs                                                           */
/* ------------------------------------------------------------ */

.tabs {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  border-block-end: 1px solid var(--border);
  margin-block-end: var(--space-5);
}
.tabs__item {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--touch-min);
  padding-inline: var(--space-3);
  border-block-end: 2px solid transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}
.tabs__item:hover {
  color: var(--primary);
  text-decoration: none;
}
.tabs__item[aria-current="page"] {
  border-block-end-color: var(--primary);
  color: var(--primary);
}

/* ------------------------------------------------------------ */
/* Confirm dialog                                                  */
/* ------------------------------------------------------------ */

.confirm-dialog {
  inline-size: min(420px, calc(100vw - var(--space-6)));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background: transparent;
}
.confirm-dialog::backdrop { background: rgba(2, 28, 20, 0.52); }
.confirm-dialog__panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.confirm-dialog__icon {
  display: grid;
  place-items: center;
  inline-size: 40px;
  block-size: 40px;
  border-radius: var(--radius-pill);
  background: var(--warn-soft);
  color: var(--warn);
}
.confirm-dialog__body { display: flex; flex-direction: column; gap: var(--space-2); }
.confirm-dialog__title { font-size: var(--text-lg); }
.confirm-dialog__message { color: var(--text-muted); }
.confirm-dialog__actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-block-start: var(--space-2);
}
@media (max-width: 480px) {
  .confirm-dialog__panel { grid-template-columns: 1fr; }
  .confirm-dialog__actions { flex-direction: column-reverse; }
  .confirm-dialog__actions .btn { inline-size: 100%; }
}

/* ------------------------------------------------------------ */
/* Table                                                           */
/* ------------------------------------------------------------ */

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  /* Shadow gradient at the edges hints "scrollable" on overflow. */
  background-image:
    linear-gradient(to right, var(--surface), var(--surface)),
    linear-gradient(to right, var(--surface), var(--surface)),
    linear-gradient(to right, rgba(2,28,20,0.08), rgba(2,28,20,0)),
    linear-gradient(to left,  rgba(2,28,20,0.08), rgba(2,28,20,0));
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-color: var(--surface);
  background-size: 24px 100%, 24px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
}
[dir="rtl"] .table-wrap {
  /* Mirror the shadow gradients so the affordance reads the same in RTL. */
  background-position: right center, left center, right center, left center;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th, .table td {
  padding: var(--space-3) var(--space-4);
  text-align: start;
  vertical-align: top;
}
.table thead th {
  background: var(--surface-soft);
  border-block-end: 1px solid var(--border);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.table tbody tr { border-block-end: 1px solid var(--border); }
.table tbody tr:last-child { border-block-end: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.table--linked tbody tr a { color: var(--text); font-weight: 500; }
.table--linked tbody tr a:hover { color: var(--primary); text-decoration: none; }

/* Numeric columns right-align in LTR, left-align in RTL — `end` keeps it logical */
.table .num { text-align: end; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table .num--danger { color: var(--error); }
.table .num--warn { color: var(--accent); }

/* Mobile: collapse to card rows below 640 px.
   Each <td> needs data-label="..." attribute for the column name. */
@media (max-width: 640px) {
  .table-wrap { border: 0; background: transparent; }
  .table, .table thead, .table tbody, .table tr, .table th, .table td {
    display: block;
    width: 100%;
  }
  .table thead { display: none; }
  .table tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-block-end: var(--space-3);
    padding: var(--space-3);
  }
  .table tbody tr:hover { background: var(--surface); }
  .table tbody td {
    padding: var(--space-1) 0;
    border: 0;
    display: flex;
    gap: var(--space-3);
    align-items: baseline;
    justify-content: space-between;
    min-width: 0;
  }
  .table tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    flex: 0 0 auto;
  }
  .table tbody td > :last-child {
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: end;
  }
  .table tbody td:has(a[data-row-link]) { padding-block: var(--space-2); }
  .table tbody td:has(a[data-row-link])::before { display: none; }
  .table tbody td:has(a[data-row-link]) a { font-size: var(--text-md); font-weight: 600; color: var(--ink); }

  /* Fiscal print documents stay TABULAR on small screens (UXB-20): a
     customer document's line table must keep its column relationships —
     the card-collapse above is for operator lists (and depends on
     data-label attributes the doc views deliberately don't carry).
     Overflow scrolls inside .table-wrap instead. */
  .doc .table-wrap { border: 1px solid var(--border); background: var(--surface); }
  .doc .table { display: table; width: 100%; }
  .doc .table thead { display: table-header-group; }
  .doc .table tbody { display: table-row-group; }
  .doc .table tfoot { display: table-footer-group; }
  .doc .table tr { display: table-row; width: auto; }
  .doc .table th,
  .doc .table td { display: table-cell; width: auto; padding: var(--space-3) var(--space-4); }
  .doc .table tbody tr {
    background: transparent;
    border: 0;
    border-block-end: 1px solid var(--border);
    border-radius: 0;
    margin: 0;
    padding: 0;
  }
  .doc .table tbody td::before { content: none; }
  .doc .table tbody td > :last-child {
    min-width: revert;
    overflow-wrap: revert;
    text-align: revert;
  }

  /* Totals (tfoot) as a card on collapsed operator tables (UXB-06):
     the generic collapse above styles tbody rows only, leaving net/VAT/
     gross floating as bare blocks. Each totals row becomes a quiet
     label/value line; the label text is already the row's first cell. */
  .table tfoot { display: block; }
  .table tfoot tr {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-block-end: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }
  .table tfoot td { display: block; width: auto; padding: 0; border: 0; }
  .table tfoot td:empty { display: none; }
  /* Multi-value totals rows (net + VAT side by side): each value cell
     names itself via data-label so nothing reads as a bare number. */
  .table tfoot td[data-label]::before {
    content: attr(data-label) " ";
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
}

/* ------------------------------------------------------------ */
/* Empty state                                                     */
/* ------------------------------------------------------------ */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-9) var(--space-5);
  color: var(--text-muted);
}
.empty__icon {
  inline-size: 56px;
  block-size: 56px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--radius-pill);
}
.empty__title { color: var(--ink); font-size: var(--text-lg); }
.empty__body { color: var(--text-muted); max-inline-size: 36ch; }

/* ------------------------------------------------------------ */
/* Detail page primitives                                         */
/* ------------------------------------------------------------ */

.meta-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-block-end: var(--space-5);
}
/* Separators are structural, not literal "·" characters embedded in the
   item text (UXB-37 — bidi could reorder a leading dot in RTL). */
.meta-strip > * + *::before {
  content: "·";
  color: var(--muted);
  margin-inline-end: var(--space-2);
}
/* A quiet state note inside the strip (frozen/immutable hints, UXB-12) —
   one treatment instead of per-view floating paragraphs. */
.meta-strip__note {
  color: var(--muted);
  font-size: var(--text-xs);
}
.detail-divider {
  margin-block: var(--space-4);
  border: 0;
  border-block-start: 1px solid var(--border);
}
.mini-heading {
  font-size: var(--text-sm);
  margin-block-end: var(--space-2);
}
.contact-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-2);
  border-block-end: 1px solid var(--border);
}
.contact-row:last-child { border-block-end: 0; }
.badge--offset { margin-inline-start: var(--space-1); }
.inline-form--spaced { margin-block-start: var(--space-4); }
.activity-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-end: var(--space-1);
}
.activity-card__time {
  margin-inline-start: auto;
  font-size: var(--text-xs);
}
.plain-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.page-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-block-end: var(--space-5);
}
@media (max-width: 640px) {
  .page-status-row,
  .page-status-row form {
    align-items: stretch;
    flex-direction: column;
    inline-size: 100%;
  }
  .page-status-row .select { inline-size: 100%; }
}
.section-hint {
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.grid-cards--spaced { margin-block-end: var(--space-5); }

/* Document event timeline (UXB-29). A quiet inline-start rail; each
   event carries a STATIC tone dot (the live-blink was retired — abrq-ui
   2026-06-11 ruling), the kind text itself carries the meaning so colour
   is never the only indicator. Tones via billingTone('event', kind). */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  margin-inline-start: var(--space-2);
  padding-inline-start: var(--space-5);
  padding-block: var(--space-2);
  border-inline-start: 2px solid var(--border);
}
.timeline li::before {
  content: "";
  position: absolute;
  inset-inline-start: -5px;
  inset-block-start: calc(var(--space-2) + 5px);
  inline-size: 8px;
  block-size: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.timeline li[data-tone="success"]::before { background: var(--signal); }
.timeline li[data-tone="info"]::before    { background: var(--primary); }
.timeline li[data-tone="warn"]::before    { background: var(--accent); }
.timeline li[data-tone="danger"]::before  { background: var(--error); }
.timeline__kind {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
  margin-inline-end: var(--space-2);
}
[dir="rtl"] .timeline__kind {
  font-family: var(--font-arabic);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.timeline__time { color: var(--muted); font-size: var(--text-xs); }
.timeline__note { color: var(--muted); font-size: var(--text-xs); display: block; }

/* ------------------------------------------------------------ */
/* Quote builder (UXB-17 / plan P6a — approved 2026-07-24)         */
/* Draft-state layout on /billing/quotes/:id: the working column   */
/* (lines + add-item + add-discount) with a STICKY summary rail    */
/* alongside, so totals + discount state never scroll away while   */
/* building. CSS only — actions stay where they were (speed rule). */
/* ------------------------------------------------------------ */

.quote-builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
@media (min-width: 1100px) {
  .quote-builder { grid-template-columns: minmax(0, 1fr) 300px; }
  .quote-builder__aside { position: sticky; inset-block-start: var(--space-4); }
}
.qtape { display: flex; flex-direction: column; gap: var(--space-2); }
.qtape__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--text-sm);
}
.qtape__label { color: var(--muted); }
.qtape__row--total {
  border-block-start: 1px solid var(--border);
  padding-block-start: var(--space-2);
  margin-block-start: var(--space-1);
}
.qtape__total {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-xl);
  font-weight: 650;
  color: var(--primary);
}
.qtape__hint { font-size: var(--text-xs); color: var(--muted); }
.qtape__hint--warn { color: var(--accent); }

/* ------------------------------------------------------------ */
/* Skeleton                                                        */
/* ------------------------------------------------------------ */

/* Loading idiom = transmission, not a sweep. The old horizontal
   background-position shimmer was a moving horizontal gradient — adjacent
   to the banned "continuous horizontal trace" (abrq-ui §1). A flat fill
   that breathes on the sanctioned transmission rhythm (abrq-tx-loop)
   replaces it. Direction-agnostic, so no RTL override needed. */
.skel {
  display: block;
  background: var(--surface-2);
  animation: abrq-tx-loop 1.4s var(--ease) infinite;
  border-radius: var(--radius-sm);
  block-size: 12px;
}
.skel--lg { block-size: 22px; }
.skel--xl { block-size: 32px; }
.skel--block { block-size: 80px; border-radius: var(--radius); }
.skel--w-36 { inline-size: 36%; }
.skel--w-92 { inline-size: 92%; }
.skel--w-76 { inline-size: 76%; }
.skel--w-60 { inline-size: 60%; }

/* ------------------------------------------------------------ */
/* Locale switcher                                                 */
/* ------------------------------------------------------------ */

.locale-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.locale-switch a,
.locale-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 28px;
  min-inline-size: 36px;
  padding-inline: var(--space-3);
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
}
.locale-switch a:hover,
.locale-switch button:hover { text-decoration: none; color: var(--primary); }
.locale-switch a[aria-pressed="true"],
.locale-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
  pointer-events: none;
}

/* ------------------------------------------------------------ */
/* Auth card (used on /login + /change-password)                   */
/* ------------------------------------------------------------ */

.auth-card {
  inline-size: 100%;
  max-inline-size: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
@media (max-width: 480px) {
  .auth-card {
    padding: var(--space-5);
    border-radius: var(--radius);
  }
}
.auth-card__brand {
  display: flex; align-items: center; gap: var(--space-3);
  color: var(--primary);          /* relay-green wordmark (DSM-13) */
  font-weight: 650;
  font-size: var(--text-lg);
}
.auth-card__foot {
  margin-block-start: var(--space-2);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* ------------------------------------------------------------ */
/* Skip link                                                       */
/* ------------------------------------------------------------ */

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-3);
  inset-block-start: var(--space-3);
  background: var(--primary);
  color: var(--primary-ink);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  transform: translateY(-200%);
  transition: transform var(--transition);
  z-index: 100;
}
.skip-link:focus { transform: translateY(0); color: var(--primary-ink); }

/* ------------------------------------------------------------ */
/* Definition list                                                 */
/* ------------------------------------------------------------ */

.dl {
  display: grid;
  grid-template-columns: minmax(120px, 28%) 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
}
.dl dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  align-self: start;
}
.dl dd {
  margin: 0;
  /* License IDs, fingerprints, long URLs — wrap inside the cell
     instead of overflowing the card. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.dl dd code {
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
  word-break: break-all;
}
@media (max-width: 640px) {
  .dl { grid-template-columns: 1fr; gap: var(--space-1); }
  .dl dd { margin-block-end: var(--space-2); }
}

/* ------------------------------------------------------------ */
/* Code blocks                                                     */
/* ------------------------------------------------------------ */

code, pre.code {
  font-family: var(--font-mono);
}
pre.code {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  overflow-x: auto;
  font-size: var(--text-xs);
  line-height: 1.45;
  margin: 0;
  /* Code stays LTR even in RTL UI — payload JSON is structurally LTR. */
  direction: ltr;
  text-align: start;
}

/* ------------------------------------------------------------ */
/* Inline-form (collapsible action sections on detail pages)      */
/* ------------------------------------------------------------ */

.inline-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface-soft);
  margin-block-end: var(--space-3);
}
.inline-form > summary {
  cursor: pointer;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.inline-form > summary::-webkit-details-marker { display: none; }
.inline-form > summary::after {
  content: "+";
  margin-inline-start: auto;
  color: var(--text-muted);
  font-weight: 400;
  font-size: var(--text-md);
}
.inline-form[open] > summary::after { content: "−"; }
.inline-form[open] > summary { border-block-end: 1px solid var(--border); }
.inline-form > :not(summary) {
  padding: var(--space-4);
}
.inline-form--danger > summary { color: var(--danger); }
.inline-form-copy { font-size: var(--text-sm); color: var(--text-muted); margin-block-end: var(--space-3); }

/* ------------------------------------------------------------ */
/* Pagination                                                      */
/* ------------------------------------------------------------ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.pagination__nav { display: flex; gap: var(--space-2); }

/* ============================================================
 * Segmented control (.seg) — the one survivor of the retired
 * /pricing calculator's CSS (B7 removed the section; the rest of
 * its rule block was dead and deleted in UX P3, UXB-09). Sole
 * consumer today: the deliver console's window picker
 * (views/deliver/links.ejs + public/js/deliver.js .seg-custom).
 * ============================================================ */

.seg { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); }
.seg button {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: var(--text-sm);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.seg button:hover { background: var(--surface-2); }
.seg button.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ============================================================ */
/* Deliver console                                               */
/* Native mgmt section (consolidation reskin): Telegraph classes */
/* replacing the former Tailwind/Alpine/HTMX frontend. All on    */
/* tokens — never a raw hex.                                     */
/* ============================================================ */

/* Sub-navigation tabs already come from components/tabs.ejs (.tabs). */

/* --- Card head with an inline "view all" link + section grids --- */
.deliver-cols { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
@media (min-width: 900px) {
  .deliver-cols--2 { grid-template-columns: 1fr 1fr; }
  .deliver-cols--main { grid-template-columns: 2fr 1fr; }
}
.deliver-cols--2 { margin-block-start: var(--space-4); }
.deliver-cols--main { margin-block-start: var(--space-4); }
.deliver-gap-top { margin-block-start: var(--space-4); }
.deliver-badges { flex-wrap: wrap; gap: var(--space-2); margin-block-end: var(--space-4); }

/* A card whose body is a full-bleed table/list (no inner padding). */
.card--flush { padding: 0; overflow: hidden; }
.card--flush .card__head { padding: var(--space-4) var(--space-5); margin-block-end: 0; border-block-end: 1px solid var(--border); }
.card__link { font-size: var(--text-xs); color: var(--primary); font-weight: 600; }
.card__link:hover { text-decoration: underline; }
.card__empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-5); text-align: center; color: var(--muted); font-size: var(--text-sm); }

/* Toolbar strip above an in-card table (search + filter select). */
.card__toolbar {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-3); border-block-end: 1px solid var(--border);
}
@media (min-width: 640px) { .card__toolbar { flex-direction: row; align-items: center; } }
.card__toolbar .input, .card__toolbar .select { min-block-size: 36px; }
.card__toolbar .field--search { position: relative; flex: 1; }
.card__toolbar .select { flex: 0 0 auto; min-inline-size: 11rem; }
.card__filters { display: grid; grid-template-columns: 1fr; gap: var(--space-3); padding: var(--space-3); border-block-end: 1px solid var(--border); }
.card__filters .input, .card__filters .select { min-block-size: 36px; }
@media (min-width: 720px) { .card__filters { grid-template-columns: 2fr 1fr 1fr 1fr; align-items: center; } }

/* --- Metric KPI row reuses .grid-cards + .kpi (see above) --- */
.kpi__head { display: flex; align-items: center; justify-content: space-between; }

/* --- Icon buttons in dense action clusters --- */
.action-cluster { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-1); }
.action-cluster form { display: inline-flex; margin: 0; }
.btn--icon-danger:hover { color: var(--error); }

/* --- Definition-list metadata grid (release/link detail) --- */
.meta-dl {
  display: grid; grid-template-columns: 1fr; gap: 1px;
  overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--border);
}
@media (min-width: 640px) { .meta-dl--2 { grid-template-columns: 1fr 1fr; } }
.meta-dl > div { background: var(--surface); padding: var(--space-3); }
.meta-dl--2 > .meta-dl__wide { grid-column: 1 / -1; }
.meta-dl dt { font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.meta-dl dd { margin: var(--space-1) 0 0; font-family: var(--font-mono); font-size: var(--text-sm); color: var(--ink); }
.meta-dl code { font-size: var(--text-xs); word-break: break-all; }
.meta-dl .cmd { display: block; margin-block-start: var(--space-2); padding: var(--space-2); background: var(--surface-2); border-radius: var(--radius); color: var(--muted); }

/* --- Badge dot + status/channel/signature variants --- */
.badge__dot { inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; }

/* --- Bar chart (SVG, presentation via classes not inline style) --- */
.bar-chart { inline-size: 100%; }
.bar-chart__svg { block-size: 7rem; inline-size: 100%; display: block; }
.bar-chart__axis { stroke: var(--border); }
.bar-chart .bar { fill: var(--primary); }
.bar-chart .bar--empty { fill: var(--border); }
.bar-chart__labels { display: flex; justify-content: space-between; margin-block-start: var(--space-2); font-size: var(--text-xs); color: var(--muted); }
.mini-chart { block-size: 7rem; }

/* --- Segmented custom-window panel (mgmt .seg handles the buttons) --- */
.seg-custom { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-block-start: var(--space-2); }
.seg-custom[hidden] { display: none; }

/* --- Native <dialog> modal (create / extend / upload / QR) --- */
.modal {
  inline-size: min(560px, calc(100vw - var(--space-6)));
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); background: var(--surface); color: var(--text);
}
.modal::backdrop { background: rgba(2, 28, 20, 0.52); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-block-end: 1px solid var(--border); }
.modal__title { font-size: var(--text-lg); color: var(--ink); }
.modal__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-block-start: 1px solid var(--border); }
.modal__qr { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); padding: var(--space-6); }

/* --- Upload dropzone --- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-6) var(--space-4); text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2);
  transition: border-color var(--transition), background var(--transition);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--primary); }
.dropzone__lead { font-size: var(--text-sm); }
.dropzone__lead strong { color: var(--primary); }
.dropzone__hint { font-size: var(--text-xs); color: var(--muted); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-meta { min-block-size: 1.25rem; margin-block-start: var(--space-2); font-size: var(--text-xs); }
.upload-meta__name { font-family: var(--font-mono); color: var(--ink); }
.upload-meta__size { color: var(--muted); }
.upload-progress[hidden] { display: none; }
.upload-progress__track { block-size: 8px; inline-size: 100%; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-2); }
.upload-progress__bar { block-size: 100%; inline-size: 0; border-radius: var(--radius-sm); background: var(--primary); transition: width 150ms linear; }

/* --- On/off toggle switch (one-time download) --- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.toggle { position: relative; display: inline-flex; flex-shrink: 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; inline-size: 100%; block-size: 100%; margin: 0; cursor: pointer; }
.toggle__track { position: relative; inline-size: 44px; block-size: 24px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); transition: background var(--transition), border-color var(--transition); }
.toggle__track::after { content: ""; position: absolute; inset-block-start: 2px; inset-inline-start: 2px; inline-size: 18px; block-size: 18px; border-radius: 50%; background: var(--muted); transition: transform var(--transition), background var(--transition); }
.toggle input:checked + .toggle__track { background: var(--primary); border-color: var(--primary); }
.toggle input:checked + .toggle__track::after { background: var(--primary-ink); transform: translateX(20px); }
[dir="rtl"] .toggle input:checked + .toggle__track::after { transform: translateX(-20px); }
.toggle input:focus-visible + .toggle__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Bulk-select action bar (revealed by JS toggling [hidden]) --- */
.bulk-bar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); border-block-end: 1px solid var(--border); background: var(--primary-soft); font-size: var(--text-sm); }
.bulk-bar[hidden] { display: none; }
.bulk-bar form { display: flex; align-items: center; gap: var(--space-2); margin: 0; }

/* --- "New link ready" result card --- */
.result-card { border-color: var(--primary); }
.result-card__copyrow { display: flex; flex-direction: column; gap: var(--space-2); margin-block-start: var(--space-3); }
@media (min-width: 640px) { .result-card__copyrow { flex-direction: row; } }
.result-card__copyrow .input { flex: 1; }
.qr-thumb { border-radius: var(--radius); background: #fff; padding: var(--space-1); }

/* --- Public standalone pages (download / gone), auth-variant shell --- */
.deliver-public { inline-size: 100%; max-inline-size: 34rem; }
.deliver-public__brand { display: flex; align-items: center; gap: var(--space-2); color: var(--primary); font-weight: 650; }
.deliver-public__action { inline-size: 100%; margin-block-start: var(--space-5); }
.verify-box { margin-block-start: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: var(--space-4); }
.verify-box code { display: block; overflow-x: auto; white-space: nowrap; background: var(--surface); padding: var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-xs); }
.gone-icon { display: grid; place-items: center; inline-size: 48px; block-size: 48px; margin-inline: auto; border-radius: var(--radius); background: var(--surface-2); color: var(--muted); }
.deliver-public--center { text-align: center; }
.deliver-public--center .deliver-public__brand { justify-content: center; }

/* --- Rendered release-notes markdown --- */
.notes-body { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: var(--space-4); font-size: var(--text-sm); color: var(--text); }
.notes-body > :first-child { margin-block-start: 0; }
.notes-body > :last-child { margin-block-end: 0; }
.notes-body h1, .notes-body h2, .notes-body h3 { color: var(--ink); font-size: var(--text-md); margin-block: var(--space-3) var(--space-2); }
.notes-body p, .notes-body ul, .notes-body ol { margin-block: var(--space-2); }
.notes-body ul, .notes-body ol { padding-inline-start: var(--space-5); }
.notes-body code { font-family: var(--font-mono); font-size: var(--text-xs); background: var(--surface); padding: 1px 4px; border-radius: var(--radius-sm); }
.notes-body a { color: var(--primary); }

/* --- Small vanilla toast (copy feedback) --- */
.toast-host { position: fixed; inset-block-end: var(--space-4); inset-inline-end: var(--space-4); z-index: 100; display: flex; flex-direction: column; gap: var(--space-2); inline-size: min(92vw, 22rem); }
.toast { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-lg); font-size: var(--text-sm); color: var(--ink); transition: opacity 200ms ease; }
.toast--success { border-color: var(--primary); }
.toast--error { border-color: var(--error); }

/* --- Printable quote document (billing B2) ---------------------------------
   The customer-facing quote at /billing/quotes/:id/print. Renders on the
   standalone 'auth' shell, so it needs its own width + spacing rather than the
   app shell's content column. Logical properties throughout so the bilingual
   document mirrors correctly under dir="rtl". */
.doc { inline-size: min(100%, 60rem); margin-inline: auto; padding: var(--space-6) var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); }
/* A customer document is bond paper regardless of the operator's console
   theme: the views add `.light` (tokens.css re-declares the light tier in
   scope, UXB-21) and the doc carries its own paper surface so it never
   sits transparent on the console-black page. */
.doc.light {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
/* The Abrq brand row on the customer document (the favicon mark is the
   token-exempt fixed artifact — Q-M4). */
.doc__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--primary);
  font-weight: 650;
}
.doc__brand-mark { inline-size: 28px; block-size: 28px; }
.doc__brand-name { font-size: var(--text-lg); }
/* Non-final state: a quiet brass note under the number (draft / rejected /
   expired — the note text comes from the template)… */
.doc__status-note {
  color: var(--accent);
  font-size: var(--text-xs);
  margin-block-start: var(--space-1);
}
/* …and a bilingual DRAFT watermark across the page, so no photocopy or
   screenshot of a draft can pass as a final document. It is a deliberate
   OVERLAY above the content: the doc's inner surfaces (.table-wrap) are
   opaque, so an under-content layer would vanish behind the table — the
   12% opacity + pointer-events:none keep it non-interfering, and the
   status note carries the draft state in real text. The font size tracks
   the viewport so the whole stamp stays legible inside a 390px phone. */
.doc--draft { position: relative; overflow: hidden; }
.doc--draft::before {
  content: "مسودة · DRAFT";
  position: absolute;
  inset-block-start: 38%;
  inset-inline: 0;
  text-align: center;
  transform: rotate(-24deg);
  font-size: clamp(40px, 11vw, 84px);
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: var(--muted);
  opacity: 0.12;
  pointer-events: none;
}
.doc__head { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; align-items: flex-start; border-block-end: 1px solid var(--border); padding-block-end: var(--space-4); }
.doc__number { font-size: var(--text-2xl); margin: 0; font-variant-numeric: tabular-nums; }
.doc__meta { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); text-align: end; }
/* The ICV/UUID/date/currency strip on the fiscal document (UXB-34):
   a wrapping row, not stacked bare divs. */
.doc__meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
}
/* The ZATCA QR (UXB-34). The qrcode SVG carries its own white quiet-zone
   plate; this fixes its footprint so head layout and print size are
   deterministic. */
.doc__qr { flex: 0 0 auto; }
.doc__qr svg { inline-size: 132px; block-size: 132px; }
.doc__parties { display: grid; gap: var(--space-4); }
@media (min-width: 40rem) { .doc__parties { grid-template-columns: 1fr 1fr; } }
/* The doc footer closes on the dot–dash rule (Telegraph texture, UXB-22)
   instead of a solid hairline. */
.doc__rule { margin-block-start: var(--space-2); }
.doc__foot { padding-block-start: 0; }
