/* ==========================================================================
   Telangar — component patterns for T-041 (panel/static/css/components.css)
   Consumes tokens.css only. Logical properties only (RTL-first, LTR-ready).
   ========================================================================== */

.tl {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--lh-md);
  color: var(--foreground);
  background: var(--background);
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  /* T-123: theme change fades instead of snapping */
  transition: background-color 600ms ease, color 600ms ease;
}
.tl *, .tl *::before, .tl *::after { box-sizing: border-box; }
.tl h1, .tl h2, .tl h3, .tl p { margin: 0; }
.tl a { color: var(--primary-strong); text-decoration: none; }
.tl a:hover { text-decoration: underline; }
.tl .ltr { direction: ltr; unicode-bidi: isolate; }
/* T-119: inline-block only for inline content. On a <td>/<th> it pulls the
   cell out of the table and the browser merges neighbouring cells into one
   anonymous cell, shifting every later column. */
.tl .ltr:not(td, th) { display: inline-block; }
.tl .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; }
.tl .muted { color: var(--muted-foreground); }
.tl svg.i { width: var(--icon-md); height: var(--icon-md); flex: none; stroke: currentColor; fill: none; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.tl svg.i.sm { width: var(--icon-sm); height: var(--icon-sm); }
.tl { container: tl / inline-size; }
.tl :focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-xs); }
.tl a, .tl button, .tl label.switch { cursor: pointer; touch-action: manipulation; }
[dir="rtl"] .tl svg.flip, .tl[dir="rtl"] svg.flip { transform: scaleX(-1); }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100%; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-foreground);
  border-inline-end: 1px solid var(--sidebar-border);
  padding: var(--space-6) var(--space-4); display: flex; flex-direction: column; gap: var(--space-6);
}
.brand { display: flex; align-items: center; gap: var(--space-3); padding-inline: var(--space-2); font-weight: var(--weight-bold); font-size: var(--text-xl); }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; color: var(--primary-foreground); }
.nav-caption { font-size: 11px; letter-spacing: 0.06em; font-weight: var(--weight-semibold); color: var(--muted-foreground); padding-inline: var(--space-3); margin-block-end: var(--space-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3); height: 44px; padding-inline: var(--space-3);
  border-radius: var(--radius-sm); color: var(--muted-foreground); font-weight: var(--weight-medium);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item[aria-current="page"] { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); font-weight: var(--weight-semibold); }
.sidebar-foot { margin-block-start: auto; display: flex; flex-direction: column; gap: var(--space-3); }

.main { display: flex; flex-direction: column; min-width: 0; }
.content { padding: var(--space-6) var(--space-10) var(--space-10); display: flex; flex-direction: column; gap: var(--section-gap); }

/* ---------- Global alert bar (above the whole dashboard) ---------- */
.alertbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-10); min-height: 60px;
  background: var(--danger-soft); color: var(--danger-fg);
  border-block-end: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.alertbar .alert-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--danger); color: #fff; flex: none; }
.alertbar strong { color: var(--foreground); font-weight: var(--weight-semibold); }
.alertbar .alert-meta { color: var(--muted-foreground); font-size: var(--text-sm); }
.alertbar .spacer { flex: 1; }
.alertbar.warning { background: var(--warning-soft); color: var(--warning-fg); }
.alertbar.warning .alert-icon { background: var(--warning); color: #231800; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: var(--space-4); }
.page-head .titles { display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.page-title { font-size: var(--text-3xl); line-height: var(--lh-3xl); font-weight: var(--weight-heading); }
[data-surface="tonal"] .page-title { font-size: var(--text-4xl); line-height: var(--lh-4xl); }
.page-title .tone { color: var(--primary-strong); }
.crumbs { display: flex; gap: var(--space-2); align-items: center; font-size: var(--text-sm); color: var(--muted-foreground); }
.crumbs .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--neutral); }
.crumbs [aria-current] { color: var(--foreground); }
.live { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--muted-foreground);
  height: var(--control-h); padding-inline: var(--space-3); border-radius: var(--radius-pill); background: var(--surface-2); }
.live .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

/* ---------- Card ---------- */
.card {
  background: var(--card); color: var(--card-foreground);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: var(--card-pad); display: flex; flex-direction: column; gap: var(--space-4);
  transition: box-shadow var(--dur-lift) var(--ease-soft), transform var(--dur-lift) var(--ease-soft);
}

/* T-123 Shafaq: the elevated card is frosted glass over the aurora (§4). */
[data-surface="elevated"] .card {
  position: relative;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  backdrop-filter: blur(32px) saturate(180%);
  box-shadow: var(--glass-shadow);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  [data-surface="elevated"] .card { background: var(--card); }
}
/* Only a card that is itself a link lifts and catches the light. */
[data-surface="elevated"] a.card { color: inherit; text-decoration: none; overflow: hidden; }
[data-surface="elevated"] a.card:hover { transform: translateY(-5px); }
[data-surface="elevated"] a.card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 36%, var(--glass-sheen) 50%, transparent 64%);
  transform: translateX(calc(-120% * var(--dir))); opacity: 0;
}
[data-surface="elevated"] a.card:hover::after {
  opacity: 1; transform: translateX(calc(120% * var(--dir)));
  transition: transform 1.1s var(--ease-soft), opacity 200ms ease;
}

/* Cards enter softly, one after another (§6). backwards, not both: a held
   end transform would block the hover lift. */
@keyframes tl-enter {
  from { opacity: 0; transform: translateY(22px) scale(0.985); }
}
.content > .card, .content > * > .card, .bare-card {
  animation: tl-enter var(--dur-enter) var(--ease-soft);
  animation-fill-mode: backwards;
}
.content > :nth-child(2) > .card, .content > .card:nth-child(2) { animation-delay: 70ms; }
.content > :nth-child(3) > .card, .content > .card:nth-child(3) { animation-delay: 140ms; }
.content > :nth-child(4) > .card, .content > .card:nth-child(4) { animation-delay: 210ms; }
.content > :nth-child(5) > .card, .content > .card:nth-child(5) { animation-delay: 280ms; }
.content > :nth-child(n+6) > .card, .content > .card:nth-child(n+6) { animation-delay: 350ms; }
[data-surface="tonal"] .card { background: var(--surface-tonal); }
.card-head { display: flex; align-items: center; gap: var(--space-3); }
.card-title { font-size: var(--text-lg); line-height: var(--lh-lg); font-weight: var(--weight-semibold); flex: 1; display: flex; align-items: center; gap: var(--space-2); }
[data-surface="tonal"] .card-title { font-size: var(--text-xl); font-weight: var(--weight-regular); }
.card-sub { font-size: var(--text-sm); color: var(--muted-foreground); }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card.flush > .card-head { padding: var(--card-pad) var(--card-pad) var(--space-4); }

/* ---------- Badge (status label: soft bg + strong text + dot) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding-inline: 9px 11px;
  border-radius: 10px; font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral-fg);
}
[data-surface="tonal"] .badge { border-radius: var(--radius-pill); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok     { background: var(--success-soft); color: var(--success-fg); }
.badge.warn   { background: var(--warning-soft); color: var(--warning-fg); }
.badge.crit   { background: var(--danger-soft);  color: var(--danger-fg); }
.badge.info   { background: var(--info-soft);    color: var(--info-fg); }
[data-surface="tonal"] .card .badge.neutral { background: var(--card); }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding-inline: 6px; border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: var(--weight-bold); background: var(--neutral-soft); color: var(--neutral-fg); }
.count.warn { background: var(--warning-soft); color: var(--warning-fg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-h); min-height: 48px; padding-inline: var(--space-6); border-radius: var(--radius-button);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-bold); cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; background: var(--primary); color: var(--primary-foreground);
  box-shadow: 0 16px 30px -16px var(--primary);
  transition: transform var(--dur-soft) var(--ease-soft), box-shadow var(--dur-soft) var(--ease-soft),
    background var(--dur-soft) var(--ease-soft);
}
.btn:hover:not([disabled]) { transform: translateY(-2px); }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
/* Second-tier buttons: inner glass surface, glass edge (§8). */
.btn.outline, .btn.ghost, .btn.danger-outline {
  min-height: 44px; padding-inline: var(--space-5); box-shadow: none; font-weight: var(--weight-semibold);
}
.btn.outline { background: var(--surface-2); color: var(--foreground); border-color: var(--glass-border); }
.btn.ghost { background: transparent; color: var(--foreground); }
.btn.danger-outline { background: var(--surface-2); color: var(--danger-fg); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
/* T-135 (Shafaq §11.2): purple has one meaning only -- on the customer's behalf. */
.btn.imp { background: var(--impersonate); color: var(--impersonate-foreground); border-color: var(--impersonate); }
.imp-note {
  margin: 0; padding: var(--space-3) var(--space-4); border-radius: 14px; font-size: var(--text-sm); line-height: 1.9;
  background: var(--impersonate-soft); border: 1px solid var(--impersonate); color: var(--impersonate);
}
/* A link styled as a button keeps the button's text colour, not the link
   colour (.tl a would otherwise win and, with Shafaq, equal the fill). */
.tl a.btn { text-decoration: none; color: var(--primary-foreground); }
.tl a.btn.outline, .tl a.btn.ghost { color: var(--foreground); }
.tl a.btn.danger-outline { color: var(--danger-fg); }
/* The admin dashboard's primary action is navy, not green (§8). */
.tl:not(.app):not(.bare) .btn:not(.outline):not(.ghost):not(.danger-outline),
.tl:not(.app):not(.bare) a.btn:not(.outline):not(.ghost):not(.danger-outline) {
  background: var(--admin-ink); color: var(--admin-ink-foreground);
  box-shadow: 0 16px 30px -16px var(--admin-ink);
}
.btn .soon { font-size: 10px; font-weight: var(--weight-semibold); padding: 1px 6px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--neutral-fg); }

/* ---------- Grid ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--section-gap); }
.span-2 { grid-column: span 2; }

/* ---------- Runner card ---------- */
.runner-name { display: flex; align-items: center; gap: var(--space-3); }
.runner-avatar { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--foreground); flex: none; }
[data-surface="tonal"] .runner-avatar { background: var(--card); border-radius: 50%; }
.runner-avatar.lost { background: var(--danger-soft); color: var(--danger-fg); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; text-align: end; }
.chips { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.chip { font-size: var(--text-xs); padding: 2px 10px; border-radius: var(--radius-pill); background: var(--surface-2);
  border: 1px solid var(--glass-border); color: var(--muted-foreground); }
.chip[aria-pressed="true"], .chip.is-selected { background: var(--foreground); color: var(--background); border-color: transparent; }
[data-surface="tonal"] .chip { background: var(--card); border-radius: var(--radius-pill); }
.heartbeat { display: flex; align-items: baseline; gap: var(--space-2); }
.heartbeat .big { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: var(--weight-display); }
.heartbeat.lost .big { color: var(--danger-fg); }

/* ---------- Queue summary (Invoice-list summary bar) ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: flex; align-items: center; gap: var(--space-4); padding-inline: var(--space-5); border-inline-start: 1px dashed var(--border); }
.stat:first-child { border-inline-start: 0; padding-inline-start: 0; }
.ring { width: 52px; height: 52px; flex: none; position: relative; display: grid; place-items: center; color: var(--foreground); }
.ring svg.track { position: absolute; inset: 0; width: 52px; height: 52px; transform: rotate(-90deg); }
.ring .bg { stroke: var(--surface-2); }
[data-surface="tonal"] .ring .bg { stroke: var(--card); }
.stat .num { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: var(--weight-display); }
[data-surface="tonal"] .stat .num { font-size: var(--text-3xl); line-height: var(--lh-3xl); }
.stat .label { font-size: var(--text-sm); color: var(--muted-foreground); }
.stat .sub { margin-block-start: 4px; }
.trend { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.trend.up { color: var(--warning-fg); }
.trend.flat { color: var(--muted-foreground); }
.trend.down { color: var(--success-fg); }
.queue-foot { display: flex; align-items: center; gap: var(--space-4); padding-block-start: var(--space-4); border-block-start: 1px solid var(--border); font-size: var(--text-sm); color: var(--muted-foreground); }

/* number that changed on the 15s poll: flash only that number */
.changed { border-radius: 4px; animation: tl-flash var(--dur-flash) var(--ease-out); }
@keyframes tl-flash { 0% { background: color-mix(in srgb, var(--primary) 28%, transparent); } 100% { background: transparent; } }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-table); }
.table th { text-align: start; font-weight: var(--weight-semibold); color: var(--muted-foreground); background: var(--surface-2);
  height: 40px; padding-inline: var(--cell-px); white-space: nowrap; }
[data-surface="tonal"] .table th { background: transparent; border-block-end: 1px solid var(--border); }
.table td { height: var(--row-h); padding-inline: var(--cell-px); border-block-end: 1px dashed var(--border); white-space: nowrap; }
.table tr:last-child td { border-block-end: 0; }
.table .num { text-align: end; }
.table .overdue { font-weight: var(--weight-semibold); color: var(--danger-fg); }
.table .overdue.mid { color: var(--warning-fg); }
.table-foot { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--card-pad); border-block-start: 1px solid var(--border); font-size: var(--text-sm); color: var(--muted-foreground); }
.table-foot .spacer { flex: 1; }

/* switch (Dense)
   Markup: <label class="switch"><input type="checkbox" …><span class="track"></span><span>…</span></label>
   Off = grey, knob at inline-start; on = green, knob at inline-end (mirrors in RTL). */
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch .track { width: 52px; height: 26px; border-radius: 999px; background: var(--input); position: relative; flex: none;
  transition: background 550ms var(--ease-soft); }
.switch .track::after { content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: inset-inline-start 550ms var(--ease-soft); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { inset-inline-start: 29px; }
.switch input:focus-visible + .track { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ---------- Empty state (never a blank page) ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-10) var(--space-6); }
.empty .empty-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success-fg); margin-block-end: var(--space-2); }
.empty .empty-icon svg.i { width: 26px; height: 26px; }
.empty .empty-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
[data-surface="tonal"] .empty .empty-title { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: var(--weight-light); }
.empty .empty-title .tone { color: var(--primary-strong); }

/* ---------- Failures by class ---------- */
.fail-total { display: flex; align-items: baseline; gap: var(--space-3); }
.fail-total .big { font-size: var(--text-4xl); line-height: var(--lh-4xl); font-weight: var(--weight-display); }
.fail-list { display: flex; flex-direction: column; gap: 2px; }
.fail-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) 28px; align-items: center; gap: var(--space-3); padding: 7px var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.fail-row.key { background: var(--warning-soft); }
.fail-row .cls { display: flex; flex-direction: column; line-height: 18px; }
.fail-row .owner { font-size: 11px; color: var(--muted-foreground); }
.fail-row .bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
[data-surface="tonal"] .fail-row .bar { background: var(--card); }
.fail-row .bar > span { display: block; height: 100%; border-radius: inherit; background: var(--chart-2); }
.fail-row.key .bar > span { background: var(--warning); }
.fail-row .n { text-align: end; font-weight: var(--weight-semibold); }
.fail-row.zero { color: var(--muted-foreground); }
.fail-row.zero .n { font-weight: var(--weight-regular); }
.note { font-size: var(--text-xs); color: var(--muted-foreground); }

/* ---------- Live / stale indicator (the dashboard's own health) ---------- */
.live.stale { background: var(--warning-soft); color: var(--warning-fg); }
.live.stale .pulse { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 25%, transparent); }
.is-stale .num, .is-stale .big { opacity: 0.55; }   /* numbers we can no longer vouch for */

/* ---------- Mobile top bar (hidden on wide containers) ---------- */
.topbar { display: none; align-items: center; gap: var(--space-3); height: 60px; padding-inline: var(--space-4);
  background: var(--sidebar); border-block-end: 1px solid var(--sidebar-border); position: sticky; inset-block-start: 0; z-index: var(--z-sticky); }
.topbar .brand { padding: 0; flex: 1; font-size: var(--text-lg); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-sm); background: transparent; border: 0; color: var(--foreground); }

/* ---------- Responsive: container queries on .tl ---------- */
@container tl (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--space-5); }
  .stat:nth-child(3) { border-inline-start: 0; padding-inline-start: 0; }
}
@container tl (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }          /* becomes a drawer behind .topbar's menu button */
  .topbar { display: flex; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .content { padding: var(--space-5) var(--space-4) var(--space-8); }
  .alertbar { flex-wrap: wrap; padding: var(--space-4); align-items: flex-start; }
  .alertbar .spacer { display: none; }
  .alertbar .btn { flex: 1 1 100%; }
  .page-head { flex-direction: column; align-items: stretch; }
  .live { align-self: flex-start; }
  .queue-foot { flex-direction: column; align-items: flex-start; gap: var(--space-2); }
  .page-title { font-size: var(--text-2xl); line-height: var(--lh-2xl); }
  [data-surface="tonal"] .page-title { font-size: var(--text-3xl); line-height: var(--lh-3xl); }
}
@container tl (max-width: 600px) {
  /* table → stacked cards; no horizontal scroll */
  .table thead { display: none; }
  .table, .table tbody { display: block; }
  .table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4);
    padding: var(--space-4) var(--card-pad); border-block-end: 1px dashed var(--border); position: relative; }
  .table tr:last-child { border-block-end: 0; }
  .table td { height: auto; padding: 0; border: 0; display: flex; flex-direction: column; gap: 2px; text-align: start; }
  .table td.num { text-align: start; }
  .table td[data-label]::before { content: attr(data-label); font-size: var(--text-xs); color: var(--muted-foreground); font-weight: var(--weight-regular); }
  .table td.row-title { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: var(--space-2); font-size: var(--text-md); }
  .table td.row-menu { position: absolute; inset-block-start: var(--space-2); inset-inline-end: var(--space-2); }
  .table td.row-menu .btn { width: 44px; height: 44px; }
  .stat .num { font-size: var(--text-xl); }
  .ring, .ring svg.track { width: 44px; height: 44px; }
  .stat { gap: var(--space-3); padding-inline: var(--space-3); }
}
@container tl (max-width: 600px) { .table td.hide-sm { display: none; } }
@container tl (min-width: 601px) { .table td.row-title .chip { display: none; } }

/* T-063: drafts -- read-only article view. Logical properties only. */
.draft-lede { margin-block: 0 var(--space-4); max-inline-size: 72ch; }
.draft-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--section-gap); margin-block-end: var(--section-gap); align-items: start; }
.draft-body { font-size: var(--text-md); line-height: var(--lh-lg); max-inline-size: 72ch; }
.draft-body p { margin-block: 0 var(--space-4); }
.draft-meta .kv dd { text-align: start; }
.draft-subhead { margin-block: var(--space-6) var(--space-3); }
.draft-sources { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); font-size: var(--text-sm); }
.draft-sources li { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.claim-list { margin: 0; padding-inline-start: var(--space-6); display: grid; gap: var(--space-4); }
.claim { padding-block-end: var(--space-4); border-block-end: 1px dashed var(--border); }
.claim:last-child { border-block-end: 0; }
.claim p { margin: 0 0 var(--space-2); }
.claim-text { font-weight: var(--weight-medium); }
.claim-evidence { font-size: var(--text-sm); }
.claim-flags { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; font-size: var(--text-sm); }
.claim[data-evidence="missing"] { border-inline-start: 3px solid var(--danger); padding-inline-start: var(--space-3); }
.draft-warning { display: flex; gap: var(--space-2); align-items: flex-start; margin-block: 0 var(--section-gap);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--warning-soft); color: var(--warning-fg); }
.drafts-table td.row-title { flex-wrap: wrap; white-space: normal; }
.drafts-table td.row-title a { min-inline-size: 0; overflow-wrap: anywhere; }
@container tl (max-width: 900px) { .draft-layout { grid-template-columns: minmax(0, 1fr); } }


/* T-109: finance forms -- one column on phones, stacked labels. */
.finance-form { display: grid; gap: var(--space-2); max-inline-size: 32rem; margin-block-start: var(--space-4); }
.finance-form input, .finance-form select { font: inherit; padding: var(--space-2); }
.finance-decision { display: inline-block; margin-inline-end: var(--space-2); }
.table tr[data-stale="true"] td { background: var(--warning-soft); }

/* T-114: element picker. The iframe is the sanitized source page; its own
   highlight style travels inside srcdoc, so nothing here reaches into it. */
.picker-facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-3); margin: 0; }
.picker-facts dd { margin: 0; overflow-wrap: anywhere; }
.picker-views { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-block: var(--space-4); }
.picker-views a[aria-current="page"] { font-weight: var(--weight-semibold); text-decoration: underline; }
.picker-form fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); display: flex; gap: var(--space-3); flex-wrap: wrap; }
.picker-form details { display: grid; gap: var(--space-2); }
.picker-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.picker-links { padding-inline-start: var(--space-4); overflow-wrap: anywhere; }
.picker-url { padding-inline: var(--card-pad); overflow-wrap: anywhere; }
.picker-frame { display: block; inline-size: 100%; block-size: 70vh; border: 0; border-block-start: 1px solid var(--border); background: #fff; }
.picker-done { margin-block: var(--space-4); }

/* ---------- T-123 Shafaq: form fields (§8) ----------
   Inner glass surface, field border from --input (3:1), soft green halo on focus. */
.tl :is(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="submit"], [type="button"], [type="file"], [type="range"], [type="color"]), select, textarea) {
  min-height: 48px; padding: var(--space-2) 14px;
  border: 1px solid var(--input); border-radius: 16px;
  background: var(--surface-2); color: var(--foreground); font: inherit;
  transition: border-color var(--dur-soft) var(--ease-soft), box-shadow var(--dur-soft) var(--ease-soft);
}
.tl textarea { min-height: 96px; }
.tl :is(input, select, textarea):focus-visible {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

@media (prefers-reduced-motion: reduce) {
  .tl { transition: none; }
  .content > .card, .content > * > .card, .bare-card { animation: none; }
  .btn:hover:not([disabled]), [data-surface="elevated"] a.card:hover { transform: none; }
  [data-surface="elevated"] a.card::after { display: none; }
}

/* Moved from admin.css in T-169: the customer panel uses the same source-set
   editor, form grid and master-detail layout. */
/* T-166 / T-167: shared source-set editor and form grid -- one look for the
   catalog form, topic templates, source categories and customer topics. */
.src-set-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-block-end: var(--space-3); }
.src-set-head .card-title { margin: 0; }
.src-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: var(--space-2); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.src-chips li { display: flex; align-items: center; gap: var(--space-2); min-inline-size: 0; padding-block: var(--space-1); padding-inline: var(--space-3) var(--space-1); border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--glass-border); font-size: var(--text-sm); }
.src-chips li.is-dim { opacity: .65; }
.src-chip-name { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-chips .inline-form { display: contents; }
.src-chip-remove { flex: none; inline-size: 28px; block-size: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted-foreground); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.src-chip-remove:hover, .src-chip-remove:focus-visible { background: var(--danger-soft); color: var(--danger); outline: 0; }
.src-empty { margin-block: 0 var(--space-3); }
.src-picker > summary { list-style: none; display: inline-flex; cursor: pointer; }
.src-picker > summary::-webkit-details-marker { display: none; }
.src-picker[open] > summary { margin-block-end: var(--space-3); }
.src-picker-form { display: grid; gap: var(--space-2); }
.src-search { inline-size: 100%; min-block-size: 42px; }
.src-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: var(--space-1) var(--space-3); max-block-size: 18rem; overflow-y: auto; margin: 0; padding: var(--space-2); list-style: none; border: 1px solid var(--glass-border); border-radius: var(--radius-md, 12px); background: var(--surface-1); }
.src-options li[hidden] { display: none; }
.src-options .check { display: flex; align-items: center; gap: var(--space-2); min-block-size: 36px; }
.src-picker-form > .btn { justify-self: start; min-inline-size: 10rem; }
.ui-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-3) var(--space-4); align-items: start; }
.ui-field { display: grid; gap: var(--space-1); min-inline-size: 0; }
.ui-field.wide { grid-column: 1 / -1; }
.ui-field label { font-size: var(--text-sm); font-weight: 600; color: var(--muted-foreground); }
.ui-field input, .ui-field select, .ui-field textarea { inline-size: 100%; min-block-size: 42px; }
.ui-field .muted { margin: 0; font-size: var(--text-xs); }
.ui-form > .btn { grid-column: 1 / -1; justify-self: start; min-inline-size: 10rem; }
.tpl-archive { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; text-align: start; gap: var(--space-3); }
.tpl-archive .muted { margin: 0; }

/* T-168: master-detail -- list on the start side, detail on the end side;
   stacked on narrow screens with the list first. */
.md-layout { display: grid; grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.md-list { display: grid; gap: var(--space-1); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.md-list a { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-block-size: 44px; padding-inline: var(--space-3); border-radius: var(--radius-md, 12px); color: inherit; text-decoration: none; }
.md-list a:hover, .md-list a:focus-visible { background: var(--surface-2); outline: 0; }
.md-list a[aria-current="true"] { background: var(--primary); color: var(--primary-foreground); }
.md-list a[aria-current="true"] .badge { background: transparent; color: inherit; }
.md-new { border-block-start: 1px solid var(--glass-border); padding-block-start: var(--space-3); }
.md-detail { display: grid; gap: var(--space-4); min-inline-size: 0; }
.md-detail .card { margin: 0; }
@media (max-width: 860px) {
  .md-layout { grid-template-columns: minmax(0, 1fr); }
}
.md-subtitle { margin-block: var(--space-4) var(--space-2); font-size: var(--text-sm); color: var(--muted-foreground); }

/* T-172 / Shafaq 12.6: inline edit opens under its own list row. */
.row-edit > td { padding-block-start: 0; }
.row-edit-form {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
}
@media (prefers-reduced-motion: no-preference) {
  .row-edit-form { animation: row-edit-in var(--dur-lift) var(--ease-soft) backwards; }
}
.row-edit-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
@keyframes row-edit-in { from { opacity: 0; transform: translateY(-6px); } }

/* T-172 / T-175 (Shafaq 12.5): list filter bar -- fields wrap, full width under 560px. */
.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-2); margin-block-end: var(--space-4); }
.filter-bar select, .filter-bar input { min-height: 44px; }
.filter-bar .ui-field { flex: 1 1 180px; }
@container tl (max-width: 560px) { .filter-bar .ui-field { flex-basis: 100%; } }
.chip-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.check-set { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.check-set legend { font-weight: 700; margin-block-end: var(--space-2); }
.check-set .check { display: flex; align-items: center; gap: var(--space-2); min-block-size: 44px; }
.check-set .field-hint { flex-basis: 100%; }
.field-label { font-weight: 700; }

/* T-173 (Shafaq 12.2-12.4): the topic's one "sources" section and the tabbed
   "add source" dialog. Tokens only, logical properties only. */
.notice.info { background: var(--info-soft); border: 1px solid var(--info); }
.topic-src-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-block-end: var(--space-4); }
.topic-src-head .card-title { margin: 0; }
.topic-src-head p { margin: var(--space-1) 0 0; }
.group-chips { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2); margin: 0 0 var(--space-4); padding: 0; list-style: none; }
.group-chip { display: flex; align-items: flex-start; min-inline-size: 0; max-inline-size: 100%; border-radius: 22px; background: var(--primary-soft); border: 1px solid var(--glass-border); }
.group-chip.is-own { background: var(--surface-2); }
.group-chip-box { min-inline-size: 0; }
.group-chip-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-block-size: 44px; padding-inline: var(--space-4) var(--space-1); cursor: pointer; list-style: none; }
.group-chip-head::-webkit-details-marker { display: none; }
.group-chip-name { font-weight: 700; overflow-wrap: anywhere; }
.group-chip-count { font-size: var(--text-sm); color: var(--muted-foreground); }
.group-chip-chevron { display: inline-flex; }
.group-chip-box[open] .group-chip-chevron { transform: rotate(-90deg); }
.group-chip-x { flex: none; display: inline-grid; place-items: center; inline-size: 44px; block-size: 44px; border-radius: 50%; color: var(--danger-fg); }
.group-chip-x:hover, .group-chip-x:focus-visible { background: var(--danger-soft); outline: 0; }
.group-feeds { display: grid; gap: var(--space-2); margin: 0; padding-block: 0 var(--space-3); padding-inline: var(--space-4); list-style: none; }
.group-feed { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.group-feed-name { overflow-wrap: anywhere; }
.group-feed.is-removed .group-feed-name { text-decoration: line-through; opacity: .62; }
.st.st-warn { color: var(--warning-fg); }
.st.st-warn::before { border-radius: 2px; }
.tl .btn.restore-btn { border-color: var(--primary); color: var(--primary-strong); }
.topic-src-table td { min-inline-size: 0; }
.topic-src-table td.row-title, .topic-src-table .st { white-space: normal; }
.src-cell { display: flex; flex-direction: column; gap: 2px; min-inline-size: 0; }
.src-cell .mono { font-size: var(--text-xs); overflow-wrap: anywhere; }
.origin { display: inline-flex; align-items: center; min-block-size: 28px; padding-inline: var(--space-3); border-radius: var(--radius-pill); font-size: 12.5px; white-space: normal; }
.origin.is-direct { background: var(--surface-2); }
.origin.is-group { background: var(--primary-soft); color: var(--primary-strong); }
.topic-src-hint { margin: var(--space-2) 0 0; font-size: var(--text-sm); }
.topic-src-empty { display: grid; justify-items: start; gap: var(--space-3); }
.topic-src-empty p { margin: 0; }

.dlg.add-dlg { max-inline-size: 640px; }
.add-dlg-head p { margin: 0; }
.tabbar { position: sticky; inset-block-start: 0; z-index: 1; display: flex; gap: var(--space-2); background: var(--card); border-block-end: 1px solid var(--border); }
.tabbar-tab { display: inline-flex; align-items: center; min-block-size: 44px; padding-inline: var(--space-3); border-block-end: 3px solid transparent; color: var(--foreground); font-weight: 600; text-decoration: none; }
.tabbar-tab[aria-selected="true"] { border-block-end-color: var(--primary); }
.add-panel { display: grid; gap: var(--space-3); min-inline-size: 0; }
.add-panel .filter-bar input[type="search"] { flex: 2 1 200px; }
.add-panel .filter-bar select { flex: 1 1 140px; }
.add-panel .src-options { grid-template-columns: minmax(0, 1fr); max-block-size: 24rem; }
.add-panel .src-options .check { flex-wrap: wrap; }
.ok-text { color: var(--success-fg); font-size: var(--text-sm); font-weight: 700; }
.src-options li[aria-disabled="true"] { opacity: .62; }
.src-reason { display: block; padding-inline-start: var(--space-6); font-size: var(--text-xs); }
.group-cards { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.group-card { display: grid; gap: var(--space-1); padding-block: var(--space-3); padding-inline: var(--space-4); border-radius: 18px; background: var(--surface-2); }
.group-card-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.group-card-name { font-weight: 700; overflow-wrap: anywhere; }
.group-card-act { margin-inline-start: auto; }
.group-card-meta, .group-card-overlap { margin: 0; font-size: var(--text-sm); overflow-wrap: anywhere; }
@container tl (max-width: 560px) {
  .add-panel .filter-bar input[type="search"], .add-panel .filter-bar select { flex-basis: 100%; }
  .dlg.add-dlg { max-inline-size: none; border-end-start-radius: 0; border-end-end-radius: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .group-chip-chevron { transition: transform 600ms var(--ease-soft); }
  .tabbar-tab { transition: border-color 450ms var(--ease-soft); }
  .dlg.add-dlg { animation: add-dlg-up 450ms var(--ease-soft) backwards; }
}
@keyframes add-dlg-up { from { opacity: 0; transform: translateY(16px); } }
