/* Enlázate design system: components. Requires base.css (tokens) first.
   Loaded by marketing, legal, auth and dashboard pages. Spec and usage rules:
   docs/design-system.md. Bump ASSET_VER in src/assets.js when editing.

   Class components (.btn, .card, .notice, …) work on any page. Bare elements
   (button, input, select, label, table) are only styled inside the product
   shell, <body class="app"> (src/dash/shared.js layout()), so marketing
   widgets such as the carousel controls are not caught by them. :where()
   keeps those element rules at element specificity, so any class wins. */

/* =========================================================== buttons ====
   Three tiers, nothing else:
     primary    .btn / app <button>          filled accent; ONE per view
     secondary  .btn.ghost / button.ghost    accent outline
     tertiary   .plain                       text button, neutral
   Modifiers: .danger (colour), .small / .lg (size), .block (full width),
   .icon-btn (square icon-only). Heights come from tokens, never from
   padding + font metrics. */
.btn, :where(.app) button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); max-width: 100%; padding: 6px var(--btn-px); margin: 0;
  border: 1px solid var(--accent); border-radius: var(--radius-pill);
  background: var(--accent); color: var(--on-accent);
  font: 600 var(--text-base)/1.2 var(--font-ui); letter-spacing: 0; text-align: center; text-decoration: none;
  /* labels stay on one line wherever they fit; a label longer than the
     whole column (German at 320px) wraps, balanced, instead of overflowing */
  white-space: normal; text-wrap: balance; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform 50ms;
}
.btn:hover, :where(.app) button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn:active, :where(.app) button:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"], :where(.app) button:disabled { opacity: .45; cursor: default; transform: none; pointer-events: none; }

/* secondary */
.btn.ghost, :where(.app) button.ghost { background: transparent; color: var(--accent-dark); border-color: var(--accent); }
.btn.ghost:hover, :where(.app) button.ghost:hover { background: var(--accent-soft); border-color: var(--accent-dark); }

/* tertiary: a text button. Neutral; add .danger for an inline delete. */
.btn.plain, :where(.app) button.plain {
  min-height: auto; padding: 0; border: 0; background: none; color: var(--accent-dark); text-align: left;
  font-weight: 600; text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 1px;
}
.btn.plain:hover, :where(.app) button.plain:hover { background: none; color: var(--ink); }
.btn.plain.small, :where(.app) button.plain.small { min-height: auto; padding: 0; font-size: var(--text-sm); }

/* danger: filled = irreversible confirmation; .plain.danger = inline delete;
   .ghost.danger = reversible-but-destructive (archive, unpublish). */
.btn.danger, :where(.app) button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover, :where(.app) button.danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); }
.btn.ghost.danger, :where(.app) button.ghost.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.ghost.danger:hover, :where(.app) button.ghost.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn.plain.danger, :where(.app) button.plain.danger { background: none; color: var(--danger); }
.btn.plain.danger:hover, :where(.app) button.plain.danger:hover { color: var(--danger-dark); }

/* sizes */
.btn.small, :where(.app) button.small { min-height: var(--control-h-sm); padding: 4px var(--btn-px-sm); font-size: var(--text-sm); }
.btn.lg { min-height: var(--control-h-lg); padding: 8px var(--btn-px-lg); font-size: var(--text-md); }
.btn.block, :where(.app) button.block { display: flex; width: 100%; }

/* icon-only square button: borderless at rest, the icon carries the meaning.
   Always give it an aria-label. */
.icon-btn, :where(.app) button.icon-btn {
  min-height: var(--control-h-sm); width: var(--control-h-sm); padding: 0;
  background: transparent; border-color: transparent; color: var(--ink-soft); font-size: var(--text-md);
}
.icon-btn:hover, :where(.app) button.icon-btn:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent-dark); }
.icon-btn.danger:hover, :where(.app) button.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

.icon { flex: none; vertical-align: -.125em; }

/* ======================================================= action rows ====
   How buttons share space (docs/design-system.md → "Action rows"):
   - .actions: buttons hug their labels, one 12px gap, left-aligned. Put the
     primary LAST; give it .push to pin it right on wide screens.
   - On phones every child takes an equal share of the row, so a pair is
     two equal halves and a single action is full width; three or more
     stack as full-width rows, primary last (bottom).
   - .actions.stacked: always full-width rows on phones (use when two labels
     are too long to share a 358px row as halves).
   - .row-actions: compact actions at the end of a table row or list item. */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.actions > .push { margin-left: auto; }
/* a form/card footer reads as a footer: one step more than field → field */
:is(form, .card) > .actions:last-child { margin-top: var(--space-5); }
.actions > form { display: contents; }
/* two equal actions with no ranking beyond tier (Cancelar | Conectar, Copiar | WhatsApp) */
.actions.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.actions.pair > * { min-width: 0; margin: 0; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); white-space: nowrap; }

/* toolbar at the top of a card holding a list: a search form + secondary
   actions; every control one height, a fixed gap below. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); margin-bottom: var(--space-4); }
.toolbar-search { display: flex; gap: var(--space-2); flex: 1 1 280px; min-width: 0; margin: 0; }
.toolbar-search input { flex: 1; min-width: 0; }
.toolbar-search button, .toolbar-search .btn { flex: none; }
.toolbar-actions { display: flex; gap: var(--space-2); margin-left: auto; }

@media (max-width: 640px) {
  .actions > *, .actions > form > * { flex: 1 1 0; min-width: min(100%, max-content); white-space: nowrap; }
  .actions > :is(.icon-btn, .plain), .actions > form > :is(.icon-btn, .plain) { flex: none; min-width: 0; }
  .actions > .push { margin-left: 0; }
  .actions:has(> :nth-child(3)), .actions.stacked { flex-direction: column; align-items: stretch; }
  /* a full-width row may wrap its label: a long CTA (price included) must
     never run past a 320px card */
  .actions.stacked > *, .actions.stacked > form > * { flex: none; width: 100%; white-space: normal; }
  .actions > :is(.icon-btn, .plain) { width: auto !important; align-self: flex-start; }
  .actions:has(> :nth-child(3)) > * { flex: none; width: 100%; white-space: normal; }
  .toolbar-actions { margin-left: 0; width: 100%; }
  .toolbar-actions > * { flex: 1 1 0; }
}

/* =============================================================== forms ==
   One field height (--control-h) for input, select and date/time; one
   label → field gap; one field → field gap (.stack / .row). */
:where(.app) label, .label {
  display: block; margin: 0 0 var(--space-4); font: 600 var(--text-sm)/1.4 var(--font-ui); color: var(--ink);
}
:where(.app) :is(input, select, textarea), .input {
  display: block; width: 100%; min-height: var(--control-h); margin: 6px 0 0; padding: 0 var(--field-px);
  border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--surface);
  font: 400 var(--text-base)/1.4 var(--font-ui); color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
:where(.app) textarea, textarea.input { padding: 10px var(--field-px); min-height: 96px; resize: vertical; line-height: var(--leading); }
:where(.app) :is(input, select, textarea):focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
:where(.app) :is(input, select, textarea)::placeholder { color: var(--muted); opacity: 1; }
:where(.app) :is(input, select, textarea):disabled { background: var(--row-hover); color: var(--muted); }
/* one select design: custom chevron, never the native one */
:where(.app) select, select.input {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2375705f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
/* compact select for dense desktop rows (table cells, toolbars): 32px, 44 on phones */
:where(.app) select.small, select.input.small { min-height: var(--control-h-sm); font-size: var(--text-sm); padding-right: 28px; background-position: right 10px center; }
/* iOS Safari: native date/time inputs have an intrinsic min-width that
   ignores width:100% and centre their value. */
:where(.app) input:is([type=date], [type=time]) { -webkit-appearance: none; appearance: none; min-width: 0; }
:where(.app) input:is([type=date], [type=time])::-webkit-date-and-time-value { text-align: left; }
:where(.app) input[type=color] { padding: 4px; cursor: pointer; }
/* controls that are not part of a label (tables, toolbars, inline rows) sit
   on the row's centre line, with no label gap */
:where(.app) :is(td, .toolbar, .row-actions, .inline-field) :is(input, select) { margin-top: 0; }

/* checkbox / radio: 20px, accent-coloured, label text beside it */
:where(.app) input:is([type=checkbox], [type=radio]) {
  display: inline-block; width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; flex: none;
  accent-color: var(--accent); box-shadow: none; cursor: pointer;
}
:where(.app) label.checkbox, .checkbox {
  display: flex; align-items: flex-start; gap: var(--space-3); flex-wrap: nowrap; min-width: 0;
  font-weight: 400; font-size: var(--text-base); line-height: 1.4; cursor: pointer;
}
:where(.app) label.checkbox > input { margin-top: 1px; }
:where(.app) label.checkbox > :not(input) { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.hint { margin: 6px 0 0; max-width: var(--prose-max); color: var(--muted); font: 400 var(--text-sm)/1.5 var(--font-ui); }
label + .hint { margin-top: calc(-1 * var(--space-2)); }
.hint:not(:last-child) { margin-bottom: var(--space-3); }
.stack > .hint, .stack > * > .hint:last-child { margin-bottom: 0; }

/* layout of fields: .stack is the default vertical rhythm; .row puts
   single-line fields side by side (never a textarea next to a field). */
.stack { display: grid; gap: var(--space-4); }
.stack > *, .row > *, .row-3 > * { margin: 0; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.row > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
/* inside a .stack the stack's gap is the only spacing */
.stack > :is(.row, .row-3) { margin: 0; }
@media (max-width: 640px) { .row, .row-3 { grid-template-columns: minmax(0, 1fr); } }

/* single-row upload: [choose file] file-name ........ [upload] */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.file-pick { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: var(--space-2) 0 var(--space-4); }
.file-pick .file-name { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: var(--text-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pick > .push { margin-left: auto; }
input.visually-hidden:focus-visible ~ .file-pick .btn,
input.visually-hidden:focus-visible + .btn { outline: 2px solid var(--accent); outline-offset: 3px; }
.file-pick:last-child { margin-bottom: 0; }
/* phones: file name on its own line, then [choose] [upload] as equal halves */
@media (max-width: 640px) { .file-pick > :is(.btn, button) { flex: 1 1 0; white-space: nowrap; } .file-pick .file-name { flex-basis: 100%; order: -1; } }

/* ============================================================== cards ===
   A card is one object: 24px padding (16px on phones), 16px apart, one
   title style. Its first/last child never adds to the padding. */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-5); margin: 0 0 var(--space-4); box-shadow: var(--shadow-sm); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card.warm { background: linear-gradient(180deg, var(--surface-warm), var(--surface)); }
.card-title { display: block; margin: 0 0 var(--space-3); font: 600 var(--text-md)/var(--leading-tight) var(--font-display); color: var(--ink); }
/* title on the left, one secondary action on the right */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.card-head > .card-title { margin: 0; }
.card-head > :not(.card-title) { flex: none; }
/* single-purpose card (login, upgrade, checkout): one readable column */
.card.narrow, .narrow { max-width: var(--form-max); }
/* a stack of cards in a grid: the grid gap is the only spacing */
.card-grid { display: grid; gap: var(--space-4); }
.card-grid > .card { margin: 0; }
@media (max-width: 640px) { .card { padding: var(--space-4); } }

/* ============================================================ brand ====
   The wordmark: one treatment on every header (site and app). */
.brand { display: inline-flex; align-items: center; gap: var(--space-3); flex: none; color: var(--accent); text-decoration: none;
  font: 600 var(--text-base)/1 var(--font-brand); letter-spacing: .28em; text-transform: uppercase; }
.brand img { width: 28px; height: 28px; border-radius: var(--radius-sm); flex: none; }

/* ========================================================= page head ====
   [.back link] → h1 → .page-meta (pills, status) → content. Pills never go
   inside the h1 (they would inherit the display face and wrap). */
.back { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--space-6);
  color: var(--muted); font: 400 var(--text-sm)/1.4 var(--font-ui); text-decoration: none; }
.back:hover { color: var(--accent-dark); }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-2) 0 var(--space-5); }
.lede { margin: var(--space-1) 0 var(--space-5); max-width: var(--prose-max); color: var(--ink-soft); font-size: var(--text-md); line-height: 1.5; }
.fine { color: var(--muted); font: 400 var(--text-xs)/1.5 var(--font-ui); }
.eyebrow { margin: 0 0 var(--space-2); color: var(--accent); font: 600 var(--text-xs)/1.4 var(--font-ui);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; }
.muted { color: var(--muted); font-size: var(--text-sm); }
.text-muted { color: var(--muted); }
.prose { max-width: var(--prose-max); }
.url-chip { display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; padding: 6px var(--space-3);
  border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-dark);
  font: 600 var(--text-sm)/1.4 var(--font-ui); text-decoration: none; overflow-wrap: anywhere; }
a.url-chip:hover { background: var(--accent-line); }
.check-list { list-style: none; margin: var(--space-3) 0; padding: 0; display: grid; gap: var(--space-2); }
.check-list li { position: relative; padding-left: 24px; text-wrap: balance; }
.check-list li::before { content: ''; position: absolute; left: 0; top: .2em; width: 16px; height: 16px;
  background: currentColor; color: var(--success);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; }

.nowrap { white-space: nowrap; }

/* order / plan summary: label left, value right, total under a hairline */
.summary-list { display: grid; grid-template-columns: auto 1fr; row-gap: var(--space-2); margin: 0 0 var(--space-4); }
.summary-list dd { padding-left: var(--space-4); }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary-list .total { padding-top: var(--space-3); border-top: 1px solid var(--border-soft); color: var(--ink); font-size: var(--text-md); }
.price { margin: 0 0 var(--space-3); font: 600 var(--text-xl)/1.1 var(--font-display); color: var(--ink); font-variant-numeric: lining-nums; }
.price small { font: 400 var(--text-sm)/1.4 var(--font-ui); color: var(--muted); }

/* segmented control: 2–4 mutually exclusive views (e.g. Móvil / Escritorio) */
.segmented { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); }
.segmented > button, .segmented > a { min-height: calc(var(--control-h-sm) - 6px); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--ink-soft); font: 600 var(--text-sm)/1 var(--font-ui); text-decoration: none; }
.segmented > :is(button, a):hover { background: var(--row-hover); color: var(--ink); }
.segmented > [aria-pressed="true"], .segmented > [aria-current] { background: var(--accent-soft); color: var(--accent-dark); }

.check-list.deny { color: var(--ink-soft); }
.check-list.deny li::before { color: var(--muted); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E") center / contain no-repeat; }

/* tooltip: a small info button; the text shows on hover/focus (and stays
   while hovered so it can be read), is announced via aria-describedby and
   never widens the page (hidden until shown, capped to the viewport). */
.tip { position: relative; display: inline-flex; vertical-align: middle; }
.tip-btn, :where(.app) button.tip-btn { min-height: 0; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: help; }
.tip-btn:hover, .tip-btn:focus-visible, :where(.app) button.tip-btn:hover { background: var(--accent-soft); color: var(--accent-dark); }
.tip-text { display: none; position: absolute; left: 50%; bottom: calc(100% + 6px); z-index: 5; width: max-content;
  max-width: min(280px, calc(100vw - 2 * var(--space-4))); padding: var(--space-2) var(--space-3); transform: translateX(-50%);
  border-radius: var(--radius-sm); background: var(--ink); color: var(--surface);
  font: 400 var(--text-sm)/1.45 var(--font-ui); text-align: left; white-space: normal; letter-spacing: 0; text-transform: none; }
.tip:hover .tip-text, .tip:focus-within .tip-text { display: block; }
/* near the viewport's left edge the bubble hugs the button instead */
th:first-child .tip-text, .card-title .tip-text, label .tip-text { left: 0; transform: none; }
/* inside a table (a horizontal scroller on desktop) the bubble opens
   downwards, over the rows, where the scroller cannot clip it */
th .tip-text { top: calc(100% + 6px); bottom: auto; }

/* bordered inset for secondary facts inside a card (account, return URL) */
.inset { margin: 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.inset dd { min-width: 0; overflow-wrap: anywhere; }

/* titled group of fields inside one form card */
.form-group + .form-group { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--border-soft); }
.form-group > .card-title { margin-bottom: var(--space-4); }

/* disclosure (secondary detail): a summary with a chevron, never the UA ▶ */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ====================================================== pills + chips ===
   .pill = status (read-only, UI font regardless of context).
   .chip = tag / filter. Interactive chips are <a>/<button> inside .gf-chips. */
.pill { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 24px; padding: 0 10px;
  border-radius: var(--radius-pill); font: 700 var(--text-xs)/1 var(--font-ui); letter-spacing: .01em; white-space: nowrap;
  background: var(--border-soft); color: var(--ink-soft); }
.pill.published, .pill.success { background: var(--success-bg); color: var(--success); }
.pill.paid, .pill.accent { background: var(--accent-soft); color: var(--accent-dark); }
.pill.danger { background: var(--danger-bg); color: var(--danger-ink); }
.pill.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 24px; padding: 0 10px;
  border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent-dark);
  font: 600 var(--text-xs)/1 var(--font-ui); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* interactive filter chips (<a>/<button> inside .gf-chips): count in <b> */
.gf-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.gf-chips .chip { min-height: var(--control-h-sm); padding: 0 var(--space-3); gap: var(--space-2);
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font: 400 var(--text-sm)/1 var(--font-ui); text-decoration: none; cursor: pointer; }
.gf-chips .chip b { font-weight: 600; color: var(--muted); }
.gf-chips .chip:hover { border-color: var(--accent); }
.gf-chips .chip.active, .gf-chips .chip[aria-pressed="true"], .gf-chips .chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }

/* ============================================================= tables ===
   Desktop: a plain table. Phones: each row becomes a structured list item
   (docs/design-system.md → "Tables on phones"), never a stack of
   label/value pairs:
       ┌──────────────────────────────┬──────────────┐
       │ first cell = row title       │ row actions  │
       ├──────────────────────────────┴──────────────┤
       │ LABEL value   (one line per remaining cell) │
       └─────────────────────────────────────────────┘
   The first cell needs no label; the cell holding .row-actions (or
   td.cell-actions) goes top-right; other cells show their data-label as a
   short inline caption (data-label="" for self-explanatory content such as
   chips). Numeric tables opt out with .keep. */
:where(.app) table, table.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
:where(.app) :is(th, td), table.table :is(th, td) { padding: var(--space-3); text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--border-soft); }
:where(.app) th, table.table th { color: var(--muted); font: 700 var(--text-xs)/1.3 var(--font-ui);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; white-space: nowrap; }
:where(.app) :is(th, td):first-child { padding-left: 0; }
:where(.app) :is(th, td):last-child { padding-right: 0; }
:where(.app) tbody tr:last-child > * { border-bottom: 0; }
:where(.app) tbody tr:hover { background: var(--row-hover); }
:where(.app) td.num, :where(.app) th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* the row title: name on top, secondary line under it */
.cell-title b, .cell-title strong { display: block; font-weight: 600; color: var(--ink); }
.cell-title .muted { display: block; overflow-wrap: anywhere; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 640px) {
  :where(.app) table:not(.keep), :where(.app) table:not(.keep) :is(thead, tbody) { display: block; width: 100%; }
  :where(.app) table:not(.keep) thead tr { position: absolute; left: -9999px; }
  :where(.app) table:not(.keep) tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--space-3); row-gap: var(--space-2); align-items: center;
    padding: var(--space-4) 0; border-bottom: 1px solid var(--border-soft); }
  :where(.app) table:not(.keep) tbody tr:first-child { padding-top: 0; }
  :where(.app) table:not(.keep) tbody tr:last-child { border-bottom: 0; padding-bottom: 0; }
  :where(.app) table:not(.keep) tbody tr:hover { background: none; }
  :where(.app) table:not(.keep) td { grid-column: 1 / -1; display: block; min-width: 0; padding: 0; border: 0; text-align: left; }
  :where(.app) table:not(.keep) td:first-child { grid-column: 1; grid-row: 1; font-size: var(--text-base); }
  :where(.app) table:not(.keep) td:is(.cell-actions, :has(> .row-actions)) { grid-column: 2; grid-row: 1; align-self: start; }
  :where(.app) table:not(.keep) td:is(.cell-actions, :has(> .row-actions)):empty { display: none; }
  :where(.app) table:not(.keep) td:not(:first-child)[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: inline-block; min-width: var(--cell-caption-w, 5.5em); margin-right: var(--space-2);
    color: var(--muted); font: 700 var(--text-xs)/1.3 var(--font-ui); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
  :where(.app) table:not(.keep) td.num { text-align: left; }
}

/* ======================================================== feedback ====== */
.notice { margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); border: 1px solid var(--notice-line);
  border-radius: var(--radius); background: var(--notice-bg); color: var(--notice-ink); font-size: var(--text-sm); line-height: 1.5; }
.notice.error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-ink); }
.notice.success { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.notice { text-wrap: wrap; }
.field-error { display: block; margin-top: var(--space-1); color: var(--danger); font: 400 var(--text-sm)/1.4 var(--font-ui); }
:where(.app) :is(input, select, textarea)[aria-invalid="true"] { border-color: var(--danger); }
.saved-flag { color: var(--success); font: 600 var(--text-sm)/1.4 var(--font-ui); white-space: nowrap; }
.saved-flag[data-state="dirty"] { color: var(--accent-dark); }
.saved-flag[data-state="saving"] { color: var(--muted); }
.saved-flag[data-state="error"] { color: var(--danger); }

/* designed empty state: icon, title, one line, one primary action */
.empty-state, .empty { max-width: none; margin: 0 0 var(--space-4); padding: var(--space-6) var(--space-5); text-align: center; }
.empty-state > *, .empty > * { max-width: var(--form-max); margin-inline: auto; }
.empty-state > .icon { display: block; margin: 0 auto var(--space-3); color: var(--accent); font-size: 32px; }
.empty-state .empty-title, .empty .empty-title { margin: 0 auto var(--space-2); color: var(--ink); font: 600 var(--text-md)/var(--leading-tight) var(--font-display); }
.empty-state > p:not(.empty-title), .empty .muted { max-width: 44ch; margin: 0 auto var(--space-5); color: var(--muted); }
.empty-state .actions { justify-content: center; }
@media (max-width: 640px) { .empty-state, .empty { padding: var(--space-5) var(--space-4); } }
.empty-state form { text-align: left; }

/* ============================================================== stats ===
   Big-number tiles: a fixed grid so every row's columns line up. */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin: 0 0 var(--space-4); }
.stats > * { display: flex; flex-direction: column; justify-content: flex-start; gap: var(--space-1); margin: 0;
  padding: var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  text-align: center; box-shadow: var(--shadow-sm); font-size: var(--text-sm); color: var(--ink-soft); text-wrap: balance; }
.stats b { display: block; font: 600 var(--text-xl)/1.1 var(--font-display); color: var(--ink); font-variant-numeric: lining-nums tabular-nums; }
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ======================================================= touch targets ==
   Phones: every interactive control is at least 44px tall. Compact
   desktop sizes grow; inline text buttons gain height, not visual weight. */
@media (max-width: 640px) {
  .btn, .btn.small, .icon-btn, :where(.app) button, :where(.app) button.small, :where(.app) button.icon-btn { min-height: var(--tap-min); }
  .icon-btn, :where(.app) button.icon-btn { width: var(--tap-min); }
  .btn.plain, :where(.app) button.plain, .btn.plain.small, :where(.app) button.plain.small { min-height: var(--tap-min); }
  .segmented > :is(button, a) { min-height: calc(var(--tap-min) - 6px); }
  :where(.app) select.small { min-height: var(--tap-min); }
  .gf-chips .chip { min-height: var(--tap-min); }
}
