/* ABELA Design System v1.0 — Graphite & Rust
 *
 * Established 2026-05-10 from PRODUCT.md + Operating Console prototype.
 * Tokens, type scale, and primitive components for the Operating Console
 * design language. Loaded globally in base.html.
 *
 * Surface coverage: show-detail v2 (live), shows list (Slice 2), other
 * pages (Slice 3+). Bootstrap 5 still loaded for legacy surfaces; this
 * file is additive. Do not redefine Bootstrap selectors — use ABELA's
 * `.ds-*` prefix where collisions are possible.
 *
 * Reference: docs/DESIGN.md (full token rationale and component contracts).
 */

:root {
  /* ── Color tokens (OKLCH, Graphite & Rust) ───────────────────────── */

  /* Surface — neutral graphite, faintly warm */
  --ds-bg:        oklch(98.5% 0.002 90);   /* page background */
  --ds-bg-2:      oklch(96.5% 0.003 90);   /* rails, panel surface */
  --ds-bg-3:      oklch(94.0% 0.004 90);   /* hover, sunken, code */
  --ds-bg-4:      oklch(91.0% 0.005 90);   /* deeper sunken (rare) */

  /* Lines */
  --ds-rule:      oklch(88.0% 0.005 90);   /* default border */
  --ds-rule-2:    oklch(80.0% 0.007 90);   /* hover border, divider */

  /* Ink (text + foreground) */
  --ds-ink:       oklch(22.0% 0.005 90);   /* primary text, near-black neutral */
  --ds-ink-2:     oklch(40.0% 0.006 90);   /* secondary text */
  --ds-ink-3:     oklch(57.0% 0.008 90);   /* tertiary, labels, muted */
  --ds-ink-4:     oklch(70.0% 0.007 90);   /* quietest (kbd, hints) */
  --ds-ink-5:     oklch(82.0% 0.006 90);   /* ghost text, disabled */

  /* Brand accent — defaults to burnt orange / rust, overridden per tenant.
   *
   * The base.html sets --crm-accent from agency_settings.accent_color (a hex
   * value like #d63350 for MANO's pink, or whatever a white-label tenant
   * picks). We read that value as our base accent and derive hover + soft
   * variants from it via oklch(from ...) so the whole accent family follows
   * the tenant's choice. Falls back to the Graphite & Rust default if the
   * white-label hook isn't present (e.g. on logged-out pages).
   */
  --ds-accent:        var(--crm-accent, oklch(54.0% 0.155 50));
  --ds-accent-2:      oklch(from var(--ds-accent) calc(l + 0.08) c h);
  --ds-accent-soft:   oklch(from var(--ds-accent) 95% 0.030 h);
  --ds-accent-fg:     oklch(98.0% 0.005 90);   /* text on accent */

  /* Semantic */
  --ds-pos:        oklch(50.0% 0.110 130);     /* olive — positive/done */
  --ds-pos-soft:   oklch(95.0% 0.025 130);
  --ds-warn:       oklch(62.0% 0.140 80);      /* warm amber */
  --ds-warn-soft:  oklch(96.0% 0.030 80);
  --ds-neg:        oklch(54.0% 0.150 25);      /* warm red */
  --ds-info: oklch(48% 0.09 250);
  --ds-info-soft: oklch(95% 0.02 250);
  --ds-neg-soft:   oklch(96.0% 0.030 25);

  /* ── Typography ──────────────────────────────────────────────────── */

  --ds-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                  system-ui, sans-serif;
  --ds-font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', 'Cascadia Mono',
                  Menlo, monospace;

  /* Fixed rem scale per product.md (tighter ratio, no fluid). */
  --ds-text-xs:   11px;     /* labels, kbd, meta */
  --ds-text-sm:   12.5px;   /* small ui text */
  --ds-text-base: 13.5px;   /* default body */
  --ds-text-md:   15px;     /* slightly larger body */
  --ds-text-lg:   18px;     /* section title */
  --ds-text-xl:   24px;     /* page title */
  --ds-text-2xl:  32px;     /* big number */

  /* Weights */
  --ds-fw-normal: 400;
  --ds-fw-medium: 500;
  --ds-fw-semi:   600;
  --ds-fw-bold:   700;

  --ds-lh-tight:  1.15;
  --ds-lh-snug:   1.35;
  --ds-lh-normal: 1.45;
  --ds-lh-relaxed: 1.6;

  /* ── Spacing ─────────────────────────────────────────────────────── */
  /* Step ratio ~1.5 (4 → 6 → 8 → 12 → 16 → 24 → 32). Vary on purpose. */
  --ds-space-1:  4px;
  --ds-space-2:  6px;
  --ds-space-3:  8px;
  --ds-space-4:  12px;
  --ds-space-5:  16px;
  --ds-space-6:  20px;
  --ds-space-7:  24px;
  --ds-space-8:  32px;
  --ds-space-9:  48px;
  --ds-space-10: 64px;

  /* ── Radius ──────────────────────────────────────────────────────── */
  --ds-radius-xs: 3px;
  --ds-radius-sm: 4px;
  --ds-radius:    6px;
  --ds-radius-lg: 10px;
  --ds-radius-pill: 999px;

  /* ── Elevation (subtle, mostly avoid) ────────────────────────────── */
  --ds-shadow-sm: 0 1px 2px oklch(22% 0.005 90 / 0.04);
  --ds-shadow-md: 0 2px 6px oklch(22% 0.005 90 / 0.06);

  /* ── Motion ──────────────────────────────────────────────────────── */
  /* Per product.md: 150–250ms, ease-out exponential. */
  --ds-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ds-dur-fast:    150ms;
  --ds-dur-default: 200ms;
  --ds-dur-slow:    300ms;

  /* Z-index scale */
  --ds-z-rail: 10;
  --ds-z-overlay: 100;
  --ds-z-modal: 1050;  /* matches Bootstrap modal stack */
  --ds-z-toast: 1080;
}

/* ─── Reduced motion ────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  :root {
    --ds-dur-fast:    0ms;
    --ds-dur-default: 0ms;
    --ds-dur-slow:    0ms;
  }
}

/* ─── Font-size toggle ──────────────────────────────────────────────────
 *
 * User-requested: three steps for the type scale, applied via
 * [data-font-size] on <html>. Persisted in localStorage by the small
 * controller in /static/js/font-size-toggle.js (loaded in base.html).
 * Default is implicit (no attribute). Compact and comfortable each shift
 * the entire scale by ~1px per step. Affects every surface that uses
 * --ds-text-*; legacy Bootstrap surfaces are unchanged.
 */

html[data-font-size="compact"] {
  --ds-text-xs:   10px;
  --ds-text-sm:   11.5px;
  --ds-text-base: 12.5px;
  --ds-text-md:   14px;
  --ds-text-lg:   16.5px;
  --ds-text-xl:   22px;
  --ds-text-2xl:  29px;
}

html[data-font-size="comfortable"] {
  --ds-text-xs:   12px;
  --ds-text-sm:   13.5px;
  --ds-text-base: 14.5px;
  --ds-text-md:   16px;
  --ds-text-lg:   19.5px;
  --ds-text-xl:   26px;
  --ds-text-2xl:  35px;
}

/* Toggle UI — three small connected buttons, sits inside the right rail */
.ds-fontsize {
  display: inline-flex;
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-bg);
  overflow: hidden;
}
.ds-fontsize button {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 4px 9px;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-xs);
  color: var(--ds-ink-3);
  cursor: pointer;
  transition: background var(--ds-dur-fast) var(--ds-ease-out),
              color var(--ds-dur-fast) var(--ds-ease-out);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--ds-fw-medium);
  border-right: 1px solid var(--ds-rule);
}
.ds-fontsize button:last-child { border-right: 0; }
.ds-fontsize button:hover { background: var(--ds-bg-2); color: var(--ds-ink); }
.ds-fontsize button:focus-visible {
  outline: 2px solid var(--ds-accent);
  outline-offset: -2px;
  z-index: 1;
}
.ds-fontsize button[aria-pressed="true"] {
  background: var(--ds-accent-soft);
  color: var(--ds-accent);
}
.ds-fontsize button .ds-fontsize-label {
  font-family: var(--ds-font-sans);
}
.ds-fontsize button .ds-fontsize-mark {
  font-family: var(--ds-font-mono);
  margin-left: 4px;
  font-size: 9px;
  opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════════════════
 * Primitive component classes
 * Use these on detail-v2 and any future Operating Console surface.
 * Bootstrap classes still work elsewhere.
 * ═══════════════════════════════════════════════════════════════════ */

/* Utility — monospace and tabular numerics */
.ds-mono { font-family: var(--ds-font-mono); font-feature-settings: 'zero', 'ss05'; }
.ds-num  { font-variant-numeric: tabular-nums; }

/* ── Pills (status badges) ──────────────────────────────────────────── */
.ds-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-size: var(--ds-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px var(--ds-space-3);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-accent-soft);
  color: var(--ds-accent);
  font-weight: var(--ds-fw-semi);
  font-family: var(--ds-font-sans);
  line-height: 1.4;
  white-space: nowrap;
}
.ds-pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.ds-pill.is-muted   { background: var(--ds-bg-3); color: var(--ds-ink-3); }
.ds-pill.is-muted::before { background: var(--ds-ink-4); }
.ds-pill.is-pos     { background: var(--ds-pos-soft); color: var(--ds-pos); }
.ds-pill.is-pos::before { background: var(--ds-pos); }
.ds-pill.is-warn    { background: var(--ds-warn-soft); color: var(--ds-warn); }
.ds-pill.is-warn::before { background: var(--ds-warn); }
.ds-pill.is-neg     { background: var(--ds-neg-soft); color: var(--ds-neg); }
.ds-pill.is-neg::before { background: var(--ds-neg); }
.ds-pill.is-info    { background: var(--ds-info-soft); color: var(--ds-info); }
.ds-pill.is-info::before { background: var(--ds-info); }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.ds-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  background: var(--ds-bg-2);
  color: var(--ds-ink);
  border: 1px solid var(--ds-rule);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  font-weight: var(--ds-fw-medium);
  padding: 5px 11px;
  border-radius: var(--ds-radius-sm);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
  transition: background var(--ds-dur-fast) var(--ds-ease-out),
              border-color var(--ds-dur-fast) var(--ds-ease-out),
              color var(--ds-dur-fast) var(--ds-ease-out);
  white-space: nowrap;
}
.ds-btn:hover { background: var(--ds-bg-3); border-color: var(--ds-rule-2); }
.ds-btn:focus-visible {
  outline: 2px solid var(--ds-accent);
  outline-offset: 1px;
}
.ds-btn:active { background: var(--ds-bg-4); }
.ds-btn:disabled,
.ds-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.ds-btn--primary {
  background: var(--ds-ink);
  color: var(--ds-bg);
  border-color: var(--ds-ink);
}
.ds-btn--primary:hover { background: var(--ds-accent); border-color: var(--ds-accent); color: var(--ds-accent-fg); }
.ds-btn--primary:focus-visible { outline-color: var(--ds-accent); }

.ds-btn--ghost {
  background: transparent;
  border-color: transparent;
}
.ds-btn--ghost:hover { background: var(--ds-bg-2); border-color: var(--ds-rule); }

.ds-btn--sm  { font-size: var(--ds-text-xs); padding: 3px 8px; }
.ds-btn--lg  { font-size: var(--ds-text-md); padding: 8px 14px; }

.ds-btn--block { width: 100%; justify-content: center; }

/* ── Keyboard hint ──────────────────────────────────────────────────── */
.ds-kbd {
  font-family: var(--ds-font-mono);
  font-size: 10.5px;
  color: var(--ds-ink-3);
  background: var(--ds-bg-3);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius-xs);
  padding: 1px 5px 0;
  line-height: 1.4;
  white-space: nowrap;
}

/* ── Copy-on-tap ────────────────────────────────────────────────────── */
.ds-copy {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-bottom: 1px dashed transparent;
  padding: 1px 0;
  transition: border-color var(--ds-dur-fast) var(--ds-ease-out),
              color var(--ds-dur-fast) var(--ds-ease-out);
}
.ds-copy:hover { border-bottom-color: var(--ds-rule-2); color: var(--ds-accent); }
.ds-copy:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; border-radius: 2px; }
.ds-copy.is-copied { color: var(--ds-pos); }
.ds-copy::after {
  content: "⎘";
  font-size: var(--ds-text-xs);
  color: var(--ds-ink-4);
  opacity: 0;
  transition: opacity var(--ds-dur-fast);
}
.ds-copy:hover::after,
.ds-copy:focus-visible::after { opacity: 1; }

/* ── Data table ─────────────────────────────────────────────────────── */
.ds-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--ds-bg);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius);
  overflow: hidden;
  font-size: var(--ds-text-base);
}
.ds-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: var(--ds-fw-semi);
  color: var(--ds-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--ds-space-3) var(--ds-space-4);
  border-bottom: 1px solid var(--ds-rule);
  background: var(--ds-bg-2);
}
.ds-table td {
  padding: var(--ds-space-3) var(--ds-space-4);
  border-bottom: 1px solid var(--ds-rule);
  color: var(--ds-ink);
  vertical-align: middle;
}
.ds-table tr:last-child td { border-bottom: 0; }
.ds-table td.ds-table-key {
  color: var(--ds-ink-3);
  width: 130px;
  font-size: var(--ds-text-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--ds-fw-medium);
}
.ds-table td.is-empty {
  color: var(--ds-ink-4);
  font-style: italic;
}

/* ── Data grid (for the "lookup-fast" facts section) ────────────────── */
.ds-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius);
  background: var(--ds-bg-2);
  overflow: hidden;
}
.ds-grid-cell {
  padding: var(--ds-space-3) var(--ds-space-4);
  border-right: 1px solid var(--ds-rule);
  border-bottom: 1px solid var(--ds-rule);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.ds-grid-cell:nth-child(4n) { border-right: 0; }
.ds-grid-cell:nth-last-child(-n+4) { border-bottom: 0; }
.ds-grid-cell .ds-grid-key {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ds-ink-3);
  font-weight: var(--ds-fw-medium);
}
.ds-grid-cell .ds-grid-val {
  font-size: var(--ds-text-md);
  font-weight: var(--ds-fw-medium);
  color: var(--ds-ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-grid-cell .ds-grid-val.ds-mono { font-size: var(--ds-text-base); }
.ds-grid-cell .ds-grid-val .ds-grid-sub {
  font-size: var(--ds-text-xs);
  color: var(--ds-ink-3);
  margin-left: var(--ds-space-1);
  font-weight: var(--ds-fw-normal);
}

/* ── Section header ─────────────────────────────────────────────────── */
.ds-sec-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--ds-space-8) 0 var(--ds-space-3);
}
.ds-sec-h h2 {
  font-size: var(--ds-text-sm);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ds-ink-3);
  font-weight: var(--ds-fw-semi);
  margin: 0;
  font-family: var(--ds-font-sans);
}
.ds-sec-h .ds-sec-meta { font-size: var(--ds-text-xs); color: var(--ds-ink-4); }

/* ── Stage track ────────────────────────────────────────────────────── */
.ds-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius);
  overflow: hidden;
}
.ds-track-step {
  padding: var(--ds-space-3) var(--ds-space-4);
  border-right: 1px solid var(--ds-rule);
  background: var(--ds-bg-2);
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  min-width: 0;
}
.ds-track-step:last-child { border-right: 0; }
.ds-track-step .ds-track-phase {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ds-ink-3);
  font-weight: var(--ds-fw-semi);
}
.ds-track-step .ds-track-lbl {
  font-size: var(--ds-text-base);
  color: var(--ds-ink-2);
  font-weight: var(--ds-fw-medium);
}
.ds-track-step.is-done .ds-track-lbl { color: var(--ds-ink); }
.ds-track-step.is-done::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 12px;
  color: var(--ds-pos);
  font-size: var(--ds-text-sm);
  font-weight: var(--ds-fw-semi);
}
.ds-track-step.is-current { background: var(--ds-accent-soft); }
.ds-track-step.is-current .ds-track-phase { color: var(--ds-accent); }
.ds-track-step.is-current .ds-track-lbl { color: var(--ds-accent); font-weight: var(--ds-fw-semi); }

/* ── Inline workspace (former modals → <details>) ───────────────────── */
.ds-ws {
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius);
  background: var(--ds-bg);
  margin-bottom: var(--ds-space-3);
  overflow: hidden;
}
.ds-ws[open] { background: var(--ds-bg-2); }
.ds-ws > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px var(--ds-space-4);
  display: flex;
  align-items: center;
  gap: var(--ds-space-4);
  user-select: none;
}
.ds-ws > summary::-webkit-details-marker { display: none; }
.ds-ws > summary:focus-visible {
  outline: 2px solid var(--ds-accent);
  outline-offset: -2px;
  border-radius: var(--ds-radius);
}
.ds-ws-chev {
  color: var(--ds-ink-3);
  display: inline-flex;
  font-size: var(--ds-text-md);
  line-height: 1;
  transition: transform var(--ds-dur-fast) var(--ds-ease-out);
  flex-shrink: 0;
}
.ds-ws[open] .ds-ws-chev { transform: rotate(90deg); }
.ds-ws-name {
  font-weight: var(--ds-fw-medium);
  color: var(--ds-ink);
  flex: 1;
  font-size: 13.5px;
  min-width: 0;
}
.ds-ws-meta {
  color: var(--ds-ink-3);
  font-size: var(--ds-text-sm);
  white-space: nowrap;
}
.ds-ws-body {
  padding: 0 var(--ds-space-4) var(--ds-space-4) var(--ds-space-8);
  color: var(--ds-ink-2);
  font-size: var(--ds-text-base);
  line-height: var(--ds-lh-relaxed);
}
.ds-ws-empty {
  padding: var(--ds-space-4);
  background: var(--ds-bg-3);
  border-radius: var(--ds-radius-sm);
  color: var(--ds-ink-3);
  font-size: var(--ds-text-sm);
}

/* ── Activity row ───────────────────────────────────────────────────── */
.ds-activity-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--ds-space-5);
  padding: 7px 0;
  border-bottom: 1px solid var(--ds-rule);
  font-size: var(--ds-text-base);
}
.ds-activity-row:last-child { border-bottom: 0; }
.ds-activity-row .ds-activity-when {
  color: var(--ds-ink-3);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 1px;
}
.ds-activity-row .ds-activity-what strong {
  color: var(--ds-ink);
  font-weight: var(--ds-fw-medium);
  margin-right: var(--ds-space-2);
}
.ds-activity-row .ds-activity-what { color: var(--ds-ink-2); }

/* ── Empty state inline ─────────────────────────────────────────────── */
.ds-empty {
  color: var(--ds-ink-4);
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════
 * Bootstrap form-control overrides for forms inside .ds-ws-body
 * Forms in inline workspaces still use Bootstrap classes; this re-skins
 * them to match the Operating Console without modifying form HTML.
 * Slice 2 will replace these with dedicated .ds-input primitives.
 * ═══════════════════════════════════════════════════════════════════ */

.ds-ws-body .form-control,
.ds-ws-body .form-select {
  background: var(--ds-bg);
  border: 1px solid var(--ds-rule);
  color: var(--ds-ink);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-base);
  border-radius: var(--ds-radius-sm);
  padding: 6px var(--ds-space-3);
  transition: border-color var(--ds-dur-fast) var(--ds-ease-out),
              box-shadow var(--ds-dur-fast) var(--ds-ease-out);
  box-shadow: none;
}
.ds-ws-body .form-control:focus,
.ds-ws-body .form-select:focus {
  border-color: var(--ds-accent);
  box-shadow: 0 0 0 3px var(--ds-accent-soft);
  outline: 0;
}
.ds-ws-body .form-control::placeholder { color: var(--ds-ink-4); }
.ds-ws-body .form-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ds-ink-3);
  font-weight: var(--ds-fw-medium);
  margin-bottom: var(--ds-space-1);
}
.ds-ws-body .btn-primary {
  background: var(--ds-ink);
  border-color: var(--ds-ink);
  color: var(--ds-bg);
  font-weight: var(--ds-fw-medium);
}
.ds-ws-body .btn-primary:hover { background: var(--ds-accent); border-color: var(--ds-accent); }
.ds-ws-body .btn-outline-secondary {
  border-color: var(--ds-rule);
  color: var(--ds-ink-2);
}
.ds-ws-body .btn-outline-secondary:hover {
  background: var(--ds-bg-3);
  border-color: var(--ds-rule-2);
  color: var(--ds-ink);
}
.ds-ws-body .alert-danger {
  background: var(--ds-neg-soft);
  border: 1px solid var(--ds-neg);
  color: var(--ds-neg);
  border-radius: var(--ds-radius-sm);
}
.ds-ws-body .alert-success {
  background: var(--ds-pos-soft);
  border: 1px solid var(--ds-pos);
  color: var(--ds-pos);
  border-radius: var(--ds-radius-sm);
}
.ds-ws-body table {
  font-size: var(--ds-text-base);
  color: var(--ds-ink);
}
.ds-ws-body table thead th {
  background: var(--ds-bg-3);
  color: var(--ds-ink-3);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--ds-fw-semi);
  border-color: var(--ds-rule);
}
.ds-ws-body table td,
.ds-ws-body table th {
  border-color: var(--ds-rule);
  vertical-align: middle;
}


/* ── Avance checklist (The Cut) ───────────────────────────── */
.ds-checklist { list-style: none; margin: 0 0 var(--ds-space-6); padding: 0; border: 1px solid var(--ds-rule); border-radius: 6px; }
.ds-checklist-row { display: flex; align-items: center; gap: var(--ds-space-3); padding: var(--ds-space-3) var(--ds-space-4); border-bottom: 1px solid var(--ds-rule); }
.ds-checklist-row:last-child { border-bottom: 0; }
.ds-checklist-row.is-pending .ds-checklist-label { color: var(--ds-ink-4); }
.ds-check { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ds-accent); font-size: var(--ds-text-md); line-height: 1; }
.ds-checklist-row.is-pending .ds-check { color: var(--ds-ink-4); }
.ds-check:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; border-radius: 3px; }
.ds-checklist-label { font-size: var(--ds-text-base); }
.ds-checklist-date { margin-left: auto; color: var(--ds-ink-3); font-size: var(--ds-text-sm); }
.ds-pill--quiet { background: var(--ds-bg-3); color: var(--ds-ink-2); border-color: var(--ds-rule); }


/* ── Dashboard (Operating Console) ────────────────────────────── */
.dash-shell { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: var(--ds-space-8); align-items: start; max-width: 1280px; }
.dash-rail { position: sticky; top: var(--ds-space-5); display: flex; flex-direction: column; gap: var(--ds-space-7); }
.dash-head { display: flex; align-items: baseline; gap: var(--ds-space-4); margin-bottom: var(--ds-space-6); }
.dash-head h1 { font-size: var(--ds-text-lg); font-weight: var(--ds-fw-semi); margin: 0; }
.dash-head .dash-month { color: var(--ds-ink-3); font-size: var(--ds-text-sm); }
.dash-head form { margin-left: auto; }

.ds-tbl { width: 100%; border-collapse: collapse; font-size: var(--ds-text-base); }
.ds-tbl th { text-align: left; color: var(--ds-ink-3); font-weight: var(--ds-fw-medium); font-size: var(--ds-text-xs); letter-spacing: 0.06em; text-transform: uppercase; padding: 0 var(--ds-space-4) var(--ds-space-3); border-bottom: 1px solid var(--ds-rule); }
.ds-tbl td { padding: var(--ds-space-3) var(--ds-space-4); border-bottom: 1px solid var(--ds-rule); vertical-align: baseline; }
.ds-tbl tbody tr:last-child td { border-bottom: 0; }
.ds-tbl tbody tr { transition: background var(--ds-dur-fast) var(--ds-ease-out); }
.ds-tbl tbody tr:hover { background: var(--ds-bg-2); }
.ds-tbl .num { text-align: right; }
.ds-tbl a.rowlink { color: inherit; text-decoration: none; font-weight: var(--ds-fw-medium); }
.ds-tbl a.rowlink:hover { color: var(--ds-accent); }
.ds-tbl .muted { color: var(--ds-ink-3); }

.dash-money { border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); padding: var(--ds-space-5); display: grid; gap: var(--ds-space-5); }
.dash-money-row .lbl { font-size: var(--ds-text-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ds-ink-3); display: flex; justify-content: space-between; }
.dash-money-row .val { font-size: var(--ds-text-xl); font-weight: var(--ds-fw-semi); line-height: var(--ds-lh-tight); margin-top: var(--ds-space-1); }

.dash-pend { display: flex; flex-direction: column; gap: var(--ds-space-3); }
.dash-pend-row { display: flex; flex-direction: column; gap: 2px; padding: var(--ds-space-3) var(--ds-space-4); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); text-decoration: none; color: inherit; transition: border-color var(--ds-dur-fast) var(--ds-ease-out); }
.dash-pend-row:hover { border-color: var(--ds-rule-2); }
.dash-pend-row .t { font-weight: var(--ds-fw-medium); font-size: var(--ds-text-base); }
.dash-pend-row .m { color: var(--ds-ink-3); font-size: var(--ds-text-sm); }

.dash-notes { display: flex; flex-direction: column; gap: var(--ds-space-3); }
.dash-note { padding: var(--ds-space-3) var(--ds-space-4); background: var(--ds-bg-2); border-radius: var(--ds-radius); font-size: var(--ds-text-sm); }
.dash-note .who { color: var(--ds-ink-3); font-size: var(--ds-text-xs); margin-top: 2px; }

.ds-empty { color: var(--ds-ink-3); font-size: var(--ds-text-sm); padding: var(--ds-space-6) 0; }

@media (max-width: 1100px) { .dash-shell { grid-template-columns: 1fr; } .dash-rail { position: static; } }


/* ── Shows list: friendlier rows (Diego, 2026-06-10) ──────────── */
.lv2-stage-quick { font-size: 10px; cursor: pointer; border: 0; transition: filter var(--ds-dur-fast) var(--ds-ease-out); }
.lv2-stage-quick:hover { filter: brightness(0.94); }
.lv2-stage-quick:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; }
.lv2-table tbody tr { transition: background var(--ds-dur-fast) var(--ds-ease-out); }
.lv2-table tbody tr:hover { background: var(--ds-bg-2); }
.lv2-table tbody tr.is-past { color: var(--ds-ink-3); }
.lv2-table tbody tr.is-past .lv2-td-link { color: var(--ds-ink-3); }


/* ── Reports (Operating Console) ─────────────────────────────── */
.rep-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: var(--ds-space-8) var(--ds-space-9); align-items: start; }
.rep-h3 { font-size: var(--ds-text-sm); font-weight: var(--ds-fw-semi); color: var(--ds-ink-2); margin: 0 0 var(--ds-space-4); }
.rep-filters { display: flex; gap: var(--ds-space-3); align-items: center; flex-wrap: wrap; margin-bottom: var(--ds-space-5); }
.rep-sin-tc { background: var(--ds-warn-soft); border: 1px solid oklch(82% 0.06 80); border-radius: var(--ds-radius); padding: var(--ds-space-3) var(--ds-space-4); font-size: var(--ds-text-sm); color: oklch(38% 0.10 80); margin-bottom: var(--ds-space-5); }
.rep-sin-tc .rowlink { color: inherit; font-weight: var(--ds-fw-medium); }

/* Period comparison under the Finanzas totals grid */
.rep-compare { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--ds-space-5); }
.rep-compare-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--ds-space-4); font-size: var(--ds-text-sm); padding: var(--ds-space-2) 0; border-top: 1px solid var(--ds-rule); }
.rep-compare-lbl { color: var(--ds-ink-2); min-width: 240px; }
.rep-compare-metric { color: var(--ds-ink-3); }
.rep-delta { font-family: var(--ds-font-mono); font-weight: var(--ds-fw-medium); font-variant-numeric: tabular-nums; }
.rep-delta.is-up { color: var(--ds-pos); }
.rep-delta.is-down { color: var(--ds-neg); }
.rep-delta.is-flat { color: var(--ds-ink-4); }


/* ── .ds-page: Operating Console page wrapper (Dashboard, Reports) ──
   Same treatment as .v2-shell: own font, ink, background; escapes the
   legacy Bootstrap main padding + gray. Fixes the mixed-chrome regression. */
.ds-page {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-base);
  line-height: var(--ds-lh-normal);
  color: var(--ds-ink);
  background: var(--ds-bg);
  margin: -1.5rem;
  padding: var(--ds-space-8);
  min-height: calc(100vh - 60px);
}
.ds-page h1, .ds-page h2, .ds-page h3 { font-family: var(--ds-font-sans); }

/* ds-styled native controls inside Operating Console pages
   (same recipe as .ds-ws-body .form-select) */
.ds-page .form-select, .ds-page .form-control {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  color: var(--ds-ink);
  background-color: var(--ds-bg-2);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius-sm);
  box-shadow: none;
}
.ds-page .form-select:hover, .ds-page .form-control:hover { border-color: var(--ds-rule-2); }
.ds-page .form-select:focus, .ds-page .form-control:focus {
  border-color: var(--ds-accent);
  outline: 2px solid var(--ds-accent);
  outline-offset: 1px;
  box-shadow: none;
}

/* Pill text contrast at 11px: darken label ink, keep the semantic dot.
   (is-warn was ~3.2:1 on its soft bg — under the 4.5:1 AA floor) */
.ds-pill.is-warn { color: oklch(46% 0.12 80); }
.ds-pill.is-pos  { color: oklch(42% 0.10 130); }
.ds-pill.is-info { color: oklch(40% 0.09 250); }
.ds-pill.is-neg  { color: oklch(44% 0.13 25); }

/* Tables breathe on small screens instead of breaking layout */
.ds-tblwrap { overflow-x: auto; }


/* ── .ds-page bridge: legacy Bootstrap primitives read as Operating Console.
   Lets remaining surfaces (Contacts/Talent/Calendar/Admin) migrate by
   wrapper alone; full template rewrites can follow surface by surface. ── */
.ds-page .table {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-base);
  color: var(--ds-ink);
  border-color: var(--ds-rule);
  margin-bottom: 0;
}
.ds-page .table thead th, .ds-page .table > :not(caption) > * > th {
  color: var(--ds-ink-3);
  font-weight: var(--ds-fw-medium);
  font-size: var(--ds-text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--ds-rule);
  background: transparent;
}
.ds-page .table td { border-color: var(--ds-rule); vertical-align: baseline; }
.ds-page .table-hover > tbody > tr:hover > * { background: var(--ds-bg-2); box-shadow: none; }
.ds-page .card {
  background: oklch(100% 0.002 90);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius);
  box-shadow: none;
}
.ds-page .card .card-header { background: var(--ds-bg-2); border-bottom: 1px solid var(--ds-rule); }
.ds-page .nav-tabs { border-bottom: 1px solid var(--ds-rule); }
.ds-page .nav-tabs .nav-link {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  color: var(--ds-ink-3);
  border: 0;
  border-bottom: 2px solid transparent;
}
.ds-page .nav-tabs .nav-link:hover { color: var(--ds-ink); border-color: var(--ds-rule-2); }
.ds-page .nav-tabs .nav-link.active {
  color: var(--ds-accent);
  background: transparent;
  border-bottom: 2px solid var(--ds-accent);
  font-weight: var(--ds-fw-semi);
}
.ds-page .badge { font-family: var(--ds-font-sans); font-weight: var(--ds-fw-medium); }
.ds-page h1, .ds-page h2, .ds-page h3, .ds-page h4, .ds-page h5 {
  font-family: var(--ds-font-sans);
  color: var(--ds-ink);
}
.ds-page .text-muted { color: var(--ds-ink-3) !important; }
.ds-page .modal-content { font-family: var(--ds-font-sans); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius-lg); }


/* ── Talent detail (tv2): 3-zone artist page ─────────────────── */
.tv2-shell { display: grid; grid-template-columns: 250px minmax(0,1fr) 280px; gap: var(--ds-space-8); align-items: start; max-width: 1380px; }
.tv2-rail { position: sticky; top: var(--ds-space-5); display: flex; flex-direction: column; gap: var(--ds-space-6); }
.tv2-back { font-size: var(--ds-text-sm); color: var(--ds-ink-3); text-decoration: none; }
.tv2-back:hover { color: var(--ds-accent); }
.tv2-id { display: flex; flex-direction: column; align-items: flex-start; gap: var(--ds-space-2); }
.tv2-id h1 { font-size: var(--ds-text-lg); font-weight: var(--ds-fw-semi); margin: var(--ds-space-2) 0 0; }
.tv2-sub { color: var(--ds-ink-3); font-size: var(--ds-text-sm); }
.tv2-photo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 1px solid var(--ds-rule-2); }
.tv2-photo--initials { display: flex; align-items: center; justify-content: center; background: var(--ds-accent); color: var(--ds-accent-fg); font-size: 28px; font-weight: var(--ds-fw-semi); }
.tv2-socials { display: flex; gap: var(--ds-space-2); flex-wrap: wrap; }
.tv2-avail { border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); padding: var(--ds-space-5); }
.tv2-inactive { background: var(--ds-warn-soft); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); padding: var(--ds-space-4) var(--ds-space-5); font-size: var(--ds-text-sm); color: oklch(46% 0.12 80); margin-bottom: var(--ds-space-6); }
@media (max-width: 1100px) { .tv2-shell { grid-template-columns: 1fr; } .tv2-rail { position: static; } }


/* ── Contact detail (cv2) ────────────────────────────────────── */
.cv2-artists { display: flex; gap: var(--ds-space-3); flex-wrap: wrap; }
.cv2-artist { display: inline-flex; align-items: baseline; gap: var(--ds-space-3); padding: var(--ds-space-3) var(--ds-space-4); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); text-decoration: none; color: var(--ds-ink); font-size: var(--ds-text-sm); transition: border-color var(--ds-dur-fast) var(--ds-ease-out); }
.cv2-artist:hover { border-color: var(--ds-accent); color: var(--ds-accent); }
.cv2-artist .ds-mono { color: var(--ds-ink-3); }
.ds-copy.is-copied { color: var(--ds-pos) !important; }


/* ── Talent list thumbs ──────────────────────────────────────── */
.tlist-photo { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; display: inline-block; }
.tlist-photo--initials { display: inline-flex; align-items: center; justify-content: center; background: var(--ds-accent); color: var(--ds-accent-fg); font-size: 11px; font-weight: var(--ds-fw-semi); }


/* ── FullCalendar in the Operating Console ───────────────────── */
.ds-page .fc {
  --fc-border-color: var(--ds-rule);
  --fc-page-bg-color: transparent;
  --fc-today-bg-color: var(--ds-accent-soft);
  --fc-button-bg-color: var(--ds-bg-2);
  --fc-button-border-color: var(--ds-rule-2);
  --fc-button-text-color: var(--ds-ink);
  --fc-button-hover-bg-color: var(--ds-bg-3);
  --fc-button-hover-border-color: var(--ds-rule-2);
  --fc-button-active-bg-color: var(--ds-accent);
  --fc-button-active-border-color: var(--ds-accent);
  --fc-event-border-color: transparent;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
}
.ds-page .fc .fc-toolbar-title { font-size: var(--ds-text-lg); font-weight: var(--ds-fw-semi); text-transform: capitalize; }
.ds-page .fc .fc-toolbar { gap: var(--ds-space-3); flex-wrap: wrap; }
.ds-page .fc .fc-button { font-size: var(--ds-text-sm); border-radius: var(--ds-radius-sm); box-shadow: none !important; text-transform: capitalize; }
.ds-page .fc .fc-col-header-cell-cushion { color: var(--ds-ink-3); font-size: var(--ds-text-xs); letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; font-weight: var(--ds-fw-medium); }
.ds-page .fc .fc-daygrid-day-number { color: var(--ds-ink-2); font-family: var(--ds-font-mono); font-size: var(--ds-text-sm); text-decoration: none; }
.ds-page .fc .fc-day-today .fc-daygrid-day-number { color: var(--ds-accent); font-weight: var(--ds-fw-semi); }
.ds-page .fc .fc-day-other .fc-daygrid-day-top { opacity: 0.45; }
.ds-page .fc .fc-daygrid-day-frame { min-height: 92px; }
.ds-page .fc .fc-daygrid-more-link { font-size: 10.5px; color: var(--ds-accent); font-weight: var(--ds-fw-medium); }
.ds-page .fc .fc-popover { border: 1px solid var(--ds-rule-2); border-radius: var(--ds-radius); box-shadow: var(--ds-shadow-md); background: var(--ds-bg); }
.ds-page .fc .fc-popover-header { background: var(--ds-bg-2); font-size: var(--ds-text-sm); padding: var(--ds-space-2) var(--ds-space-3); }

/* Calendar page chrome */
.cal-topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--ds-space-5); padding-bottom: var(--ds-space-5); border-bottom: 1px solid var(--ds-rule); margin-bottom: var(--ds-space-5); }
.cal-crumbs { display: flex; gap: var(--ds-space-2); color: var(--ds-ink-3); font-size: var(--ds-text-sm); margin-bottom: var(--ds-space-1); }
.cal-topbar h1 { font-size: var(--ds-text-lg); font-weight: var(--ds-fw-semi); margin: 0; letter-spacing: -0.005em; }
.cal-seg { display: inline-flex; border: 1px solid var(--ds-rule); border-radius: var(--ds-radius-sm); overflow: hidden; }
.cal-seg a { padding: 5px 13px; font-size: var(--ds-text-sm); color: var(--ds-ink-2); text-decoration: none; background: var(--ds-bg); transition: background var(--ds-dur-fast) var(--ds-ease-out); }
.cal-seg a + a { border-left: 1px solid var(--ds-rule); }
.cal-seg a:hover { background: var(--ds-bg-2); color: var(--ds-ink); }
.cal-seg a.is-active { background: var(--ds-ink); color: var(--ds-bg); font-weight: var(--ds-fw-medium); }
.cal-shell { border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); background: var(--ds-bg); padding: var(--ds-space-5); }

/* Event chips — dense, stage-tinted, calm */
.ds-page .fc .cal-evt { background: transparent; border: 1px solid transparent; border-radius: 3px; padding: 0; cursor: pointer; transition: filter var(--ds-dur-fast) var(--ds-ease-out); }
.ds-page .fc .cal-evt:hover { filter: brightness(0.96); }
.cal-evt-inner { display: flex; align-items: center; gap: 4px; padding: 1px 5px 1px 6px; font-size: 10.5px; line-height: 1.5; overflow: hidden; white-space: nowrap; }
.cal-evt-inner::before { content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; background: currentColor; opacity: 0.7; }
.cal-evt-name { font-weight: var(--ds-fw-semi); overflow: hidden; text-overflow: ellipsis; }
.cal-evt-city { opacity: 0.7; font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
.ds-page .fc .cal-evt--tbc { background: var(--ds-warn-soft); color: oklch(40% 0.10 80); border-color: oklch(86% 0.05 80); }
.ds-page .fc .cal-evt--confirmed { background: var(--ds-pos-soft); color: oklch(36% 0.08 130); border-color: oklch(84% 0.05 130); }
.ds-page .fc .cal-evt--settled { background: var(--ds-info-soft); color: oklch(36% 0.07 250); border-color: oklch(85% 0.04 250); }
.ds-page .fc .cal-evt--lost, .ds-page .fc .cal-evt--cancelled { background: var(--ds-bg-3); color: var(--ds-ink-3); border-color: var(--ds-rule); }

/* Legend + popover */
.cal-legend { display: flex; align-items: center; gap: var(--ds-space-3); margin-top: var(--ds-space-4); flex-wrap: wrap; }
.cal-legend-hint { color: var(--ds-ink-4); font-size: var(--ds-text-xs); margin-left: auto; }
.cal-pop { position: fixed; z-index: 1080; width: 280px; background: var(--ds-bg); border: 1px solid var(--ds-rule-2); border-radius: var(--ds-radius); box-shadow: var(--ds-shadow-md); padding: var(--ds-space-4); display: none; }
.cal-pop.is-open { display: block; }
.cal-pop-title { font-weight: var(--ds-fw-semi); font-size: var(--ds-text-md); margin: var(--ds-space-2) 0 var(--ds-space-2); }
.cal-pop-row { display: flex; justify-content: space-between; gap: var(--ds-space-3); font-size: var(--ds-text-sm); padding: 3px 0; }
.cal-pop-key { color: var(--ds-ink-3); }
.cal-pop-val { text-align: right; }
.cal-pop-link { display: inline-block; margin-top: var(--ds-space-3); font-size: var(--ds-text-sm); color: var(--ds-accent); text-decoration: none; font-weight: var(--ds-fw-medium); }
.cal-pop-link:hover { text-decoration: underline; }


/* ── New Show modal (Operating Console) ──────────────────────── */
.nsm-modal { font-family: var(--ds-font-sans); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius-lg); }
.nsm-modal .modal-header { background: var(--ds-bg-2); border-bottom: 1px solid var(--ds-rule); }
.nsm-modal .modal-title { font-size: var(--ds-text-md); font-weight: var(--ds-fw-semi); }
.nsm-modal .modal-footer { border-top: 1px solid var(--ds-rule); }
.nsm-modal .form-label { font-size: var(--ds-text-sm); color: var(--ds-ink-2); font-weight: var(--ds-fw-medium); margin-bottom: 4px; }
.nsm-modal .form-control, .nsm-modal .form-select, .nsm-modal .input-group-text {
  font-size: var(--ds-text-base); border-color: var(--ds-rule); border-radius: var(--ds-radius-sm);
}
.nsm-modal .form-control:focus, .nsm-modal .form-select:focus {
  border-color: var(--ds-accent); box-shadow: none; outline: 2px solid var(--ds-accent); outline-offset: 1px;
}
.nsm-cluster { padding: var(--ds-space-4) 0 var(--ds-space-5); }
.nsm-cluster + .nsm-cluster { border-top: 1px solid var(--ds-rule); }
.nsm-cluster-h { font-size: var(--ds-text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ds-ink-3); font-weight: var(--ds-fw-medium); margin-bottom: var(--ds-space-4); }
.nsm-req { color: var(--ds-accent); }
.nsm-dup { background: var(--ds-warn-soft); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); padding: var(--ds-space-3) var(--ds-space-4); font-size: var(--ds-text-sm); color: oklch(46% 0.12 80); margin-bottom: var(--ds-space-3); }

/* ── New Show modal · "Desde oferta" capture mode ─────────────── */
/* Segmented control: pick a capture mode, not two competing actions. */
.nsm-seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--ds-bg-3); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius-sm); margin-bottom: var(--ds-space-5); }
.nsm-seg__btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--ds-text-sm); font-weight: var(--ds-fw-medium); color: var(--ds-ink-2);
  background: transparent; border: 0; border-radius: var(--ds-radius-xs);
  padding: 5px 14px; cursor: pointer;
  transition: background var(--ds-dur-fast) var(--ds-ease-out), color var(--ds-dur-fast) var(--ds-ease-out);
}
.nsm-seg__btn:hover { color: var(--ds-ink); }
.nsm-seg__btn[aria-selected="true"] { background: var(--ds-bg); color: var(--ds-ink); box-shadow: var(--ds-shadow-sm); }
.nsm-seg__btn:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 1px; }

/* Offer entry region: a calm bordered surface, distinct from the form. */
.nsm-offer { background: var(--ds-bg-2); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); padding: var(--ds-space-5); }
.nsm-offer__hint { font-size: var(--ds-text-sm); line-height: var(--ds-lh-normal); color: var(--ds-ink-3); margin: 0 0 var(--ds-space-4); }
.nsm-offer__row { display: flex; gap: var(--ds-space-3); margin-top: var(--ds-space-3); align-items: stretch; }
.nsm-offer__row .form-control { flex: 1 1 auto; min-width: 0; }
.nsm-offer__row .btn { flex: none; white-space: nowrap; }

/* Status line: color is redundant to the text, never the sole signal. */
.nsm-offer__status { display: none; align-items: center; gap: 7px; margin-top: var(--ds-space-4); font-size: var(--ds-text-sm); line-height: var(--ds-lh-snug); }
.nsm-offer__status.is-active { display: inline-flex; }
.nsm-offer__status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.nsm-offer__status.is-pos { color: var(--ds-pos); }
.nsm-offer__status.is-warn { color: oklch(46% 0.12 80); }
.nsm-offer__status.is-neg { color: var(--ds-neg); }
.nsm-offer__status.is-busy { color: var(--ds-ink-3); }
.nsm-offer__status.is-busy::before {
  background: transparent; width: 13px; height: 13px;
  border: 2px solid var(--ds-rule-2); border-top-color: var(--ds-ink-2); border-radius: 50%;
  animation: nsm-spin 0.7s linear infinite;
}
@keyframes nsm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .nsm-offer__status.is-busy::before { animation: none; } }

/* Applied banner: feedback lands on the Manual form, where the eye now is. */
.nsm-applied { display: flex; align-items: center; gap: 8px; background: var(--ds-pos-soft); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); padding: var(--ds-space-3) var(--ds-space-4); font-size: var(--ds-text-sm); color: var(--ds-pos); margin-bottom: var(--ds-space-5); }
.nsm-applied .bi { font-size: 1rem; flex: none; }


/* ── Payment ledger · "Cobros y pagos" (show detail) ──────────── */
.pmt { padding: var(--ds-space-2) 0 var(--ds-space-4); }
.pmt-balance { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ds-space-5); margin-bottom: var(--ds-space-5); }
@media (max-width: 700px) { .pmt-balance { grid-template-columns: 1fr; gap: var(--ds-space-4); } }
.pmt-bal { border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); padding: var(--ds-space-4); background: var(--ds-bg-2); }
.pmt-bal-h { font-size: var(--ds-text-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--ds-ink-3); margin-bottom: var(--ds-space-3); }
.pmt-bal-line { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; font-size: var(--ds-text-base); color: var(--ds-ink-2); }
.pmt-bal-line span:last-child { color: var(--ds-ink); }
.pmt-bal-line.is-strong { margin-top: 3px; padding-top: var(--ds-space-3); border-top: 1px solid var(--ds-rule); font-weight: var(--ds-fw-semi); font-size: var(--ds-text-md); }
.pmt-bal-line.is-strong span { color: var(--ds-ink); }

.pmt-agreed { display: flex; align-items: center; gap: var(--ds-space-3); flex-wrap: wrap; margin-bottom: var(--ds-space-4); }
.pmt-agreed-label { font-size: var(--ds-text-sm); color: var(--ds-ink-3); }
.pmt-agreed-val { font-size: var(--ds-text-md); font-weight: var(--ds-fw-medium); }
.pmt-agreed-edit { display: flex; gap: var(--ds-space-2); align-items: center; flex-wrap: wrap; }
.pmt-chips { display: flex; gap: var(--ds-space-2); margin-top: var(--ds-space-2); flex-basis: 100%; }

.pmt-input { font-size: var(--ds-text-base); padding: 5px 8px; border: 1px solid var(--ds-rule); border-radius: var(--ds-radius-sm); background: var(--ds-bg); color: var(--ds-ink); font-family: var(--ds-font-sans); }
.pmt-input:focus { outline: 2px solid var(--ds-accent); outline-offset: 1px; border-color: var(--ds-accent); }

.pmt-list { border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); overflow: hidden; margin-bottom: var(--ds-space-4); }
.pmt-row { display: grid; grid-template-columns: 88px auto 1fr auto 28px; align-items: center; gap: var(--ds-space-3); padding: var(--ds-space-3) var(--ds-space-4); }
.pmt-row + .pmt-row { border-top: 1px solid var(--ds-rule); }
.pmt-row:hover { background: var(--ds-bg-2); }
.pmt-date { color: var(--ds-ink-3); font-size: var(--ds-text-sm); }
.pmt-tag { display: inline-flex; gap: 6px; align-items: center; }
.pmt-kind { color: var(--ds-ink-2); font-size: var(--ds-text-sm); }
.pmt-meta { color: var(--ds-ink-3); font-size: var(--ds-text-sm); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmt-amount { text-align: right; font-weight: var(--ds-fw-medium); color: var(--ds-ink); }
.pmt-del { border: 0; background: transparent; color: var(--ds-ink-4); font-size: 18px; line-height: 1; cursor: pointer; border-radius: var(--ds-radius-sm); width: 24px; height: 24px; }
.pmt-del:hover { color: var(--ds-neg); background: var(--ds-neg-soft); }
.pmt-del:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 1px; }

.pmt-empty { color: var(--ds-ink-3); font-size: var(--ds-text-sm); padding: var(--ds-space-5) var(--ds-space-4); border: 1px dashed var(--ds-rule); border-radius: var(--ds-radius); margin-bottom: var(--ds-space-4); text-align: center; }
.pmt-add { display: flex; gap: var(--ds-space-2); flex-wrap: wrap; align-items: center; padding: var(--ds-space-4); background: var(--ds-bg-2); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius); }
.pmt-msg { font-size: var(--ds-text-sm); margin-top: var(--ds-space-2); min-height: 1.1em; }
.pmt-msg.is-neg { color: var(--ds-neg); }


/* ── View transitions (cross-document, progressive enhancement) ──
   A calm cross-fade between full-page navigations where the browser
   supports it (Chrome/Edge today); instant fallback elsewhere.

   The whole page cross-fades as one (root). We deliberately do NOT give
   the sidebar its own view-transition-name: isolating it snapshots the
   element, whose height varies page to page (a tall Reports page stretches
   the flex rail), so the browser animated that size difference — the rail
   appeared to resize on nav. As part of the root fade its near-identical
   pixels read as static while only the content visibly changes.

   A clicked show row carries view-transition-name: deal-<id>, matched on
   the detail page's title so the row morphs into the header. */
@view-transition { navigation: auto; }

/* Calm easing on every transition group — the root cross-fade and the
   deal-<id> row→detail morph all settle on the same exponential curve. */
::view-transition-group(*) {
  animation-duration: var(--ds-dur-default);
  animation-timing-function: var(--ds-ease-out);
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--ds-dur-default);
  animation-timing-function: var(--ds-ease-out);
}

/* Visible, modal-safe page motion. The main content fades in and lifts 8px on
   each navigation; the black rail is a static sibling and never animates. A
   bare root opacity cross-fade was invisible because the rail is pixel-
   identical across pages, so navigation looked like a hard cut.

   This is a plain entrance animation, NOT a view-transition-name on <main>:
   naming <main> would make it a stacking context, and the export / new-show
   modals live inside it while Bootstrap appends their backdrop to <body> — the
   dialog would paint under the backdrop and lock the page. The entrance
   transform is transient (gone in 200ms, while modals are closed), so it never
   establishes a lingering stacking context to trap a fixed modal. */
main.ds-page-enter {
  animation: ds-page-in var(--ds-dur-default) var(--ds-ease-out) backwards;
}
@keyframes ds-page-in { from { opacity: 0; transform: translateY(8px); } }

/* Honor the OS reduced-motion setting: no transition animation at all. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}


/* ── Command palette (Cmd/Ctrl+K) ────────────────────────────────── */
.cmdk { position: fixed; inset: 0; z-index: var(--ds-z-modal); display: flex; align-items: flex-start; justify-content: center; }
.cmdk[hidden] { display: none; }
.cmdk-backdrop { position: absolute; inset: 0; background: oklch(22% 0.005 90 / 0.32); backdrop-filter: blur(2px); }
.cmdk-panel {
  position: relative; margin-top: 12vh; width: min(560px, 92vw);
  background: var(--ds-bg); border: 1px solid var(--ds-rule-2);
  border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-md);
  overflow: hidden; animation: cmdk-in var(--ds-dur-default) var(--ds-ease-out);
}
@keyframes cmdk-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cmdk-panel { animation: none; } }

.cmdk-inputwrap { display: flex; align-items: center; gap: var(--ds-space-3); padding: var(--ds-space-4) var(--ds-space-5); border-bottom: 1px solid var(--ds-rule); }
.cmdk-inputicon { color: var(--ds-ink-3); font-size: 15px; }
.cmdk-input { flex: 1; border: 0; outline: 0; background: transparent; font-family: var(--ds-font-sans); font-size: var(--ds-text-md); color: var(--ds-ink); }
.cmdk-input::placeholder { color: var(--ds-ink-4); }
.cmdk-esc { font-family: var(--ds-font-mono); font-size: 10px; color: var(--ds-ink-4); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius-xs); padding: 1px 5px; }

.cmdk-results { max-height: min(52vh, 420px); overflow-y: auto; padding: var(--ds-space-2); }
.cmdk-group { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ds-ink-3); font-weight: var(--ds-fw-semi); padding: var(--ds-space-3) var(--ds-space-3) var(--ds-space-2); }
.cmdk-item { display: flex; align-items: center; gap: var(--ds-space-3); padding: var(--ds-space-3); border-radius: var(--ds-radius-sm); cursor: pointer; color: var(--ds-ink); }
.cmdk-item.is-selected { background: var(--ds-accent-soft); }
.cmdk-itemicon { color: var(--ds-ink-3); font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.cmdk-item.is-selected .cmdk-itemicon { color: var(--ds-accent); }
.cmdk-label { flex: 1; font-size: var(--ds-text-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-sub { font-size: var(--ds-text-xs); color: var(--ds-ink-3); font-family: var(--ds-font-mono); text-transform: lowercase; }
.cmdk-empty { padding: var(--ds-space-7); text-align: center; color: var(--ds-ink-3); font-size: var(--ds-text-sm); }

.cmdk-foot { display: flex; gap: var(--ds-space-5); padding: var(--ds-space-3) var(--ds-space-5); border-top: 1px solid var(--ds-rule); background: var(--ds-bg-2); font-size: var(--ds-text-xs); color: var(--ds-ink-3); }
.cmdk-foot kbd { font-family: var(--ds-font-mono); font-size: 10px; border: 1px solid var(--ds-rule); border-radius: var(--ds-radius-xs); padding: 0 4px; margin-right: 2px; }

/* Sidebar trigger (sits in the dark rail) */
.cmdk-trigger {
  display: flex; align-items: center; gap: var(--ds-space-3); width: 100%;
  margin-bottom: var(--ds-space-3); padding: 7px 11px;
  background: oklch(100% 0 0 / 0.06); border: 1px solid oklch(100% 0 0 / 0.12);
  border-radius: var(--ds-radius-sm); color: oklch(100% 0 0 / 0.72);
  font-family: var(--ds-font-sans); font-size: var(--ds-text-sm); cursor: pointer;
  transition: background var(--ds-dur-fast) var(--ds-ease-out);
}
.cmdk-trigger:hover { background: oklch(100% 0 0 / 0.12); color: #fff; }
.cmdk-trigger span { flex: 1; text-align: left; }
.cmdk-trigger kbd { font-family: var(--ds-font-mono); font-size: 10px; color: oklch(100% 0 0 / 0.6); border: 1px solid oklch(100% 0 0 / 0.18); border-radius: var(--ds-radius-xs); padding: 0 4px; }


/* ── "Ir a…" quick-nav overlay (bare g) — reuses the .cmdk shell ──── */
.navgoto-panel { width: min(420px, 92vw); }
.navgoto-h {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ds-ink-3); font-weight: var(--ds-fw-semi);
  padding: var(--ds-space-4) var(--ds-space-5) var(--ds-space-3);
  border-bottom: 1px solid var(--ds-rule);
}
.navgoto .cmdk-sub { margin-left: var(--ds-space-3); }
.navgoto-key {
  margin-left: auto; font-family: var(--ds-font-mono); font-size: 10px;
  color: var(--ds-ink-3); background: var(--ds-bg-2);
  border: 1px solid var(--ds-rule); border-bottom-width: 2px;
  border-radius: var(--ds-radius-xs); padding: 1px 6px; text-transform: none;
}
.cmdk-item.is-selected .navgoto-key { color: var(--ds-accent); border-color: var(--ds-rule-2); }


/* ── Keyboard table navigation (j/k) + shortcuts legend ──────────── */
.lv2-table tbody tr.is-keyselected,
.ds-tbl tbody tr.is-keyselected { background: var(--ds-accent-soft); box-shadow: inset 2px 0 0 var(--ds-accent); }

.keynav-legend { position: fixed; inset: 0; z-index: var(--ds-z-modal); display: flex; align-items: center; justify-content: center; background: oklch(22% 0.005 90 / 0.32); backdrop-filter: blur(2px); }
.keynav-legend[hidden] { display: none; }
.keynav-legend-card { background: var(--ds-bg); border: 1px solid var(--ds-rule-2); border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-md); padding: var(--ds-space-6) var(--ds-space-7); min-width: 280px; }
.keynav-legend-h { font-size: var(--ds-text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ds-ink-3); font-weight: var(--ds-fw-semi); margin-bottom: var(--ds-space-4); }
.keynav-legend dl { display: grid; grid-template-columns: auto 1fr; gap: var(--ds-space-3) var(--ds-space-5); margin: 0; align-items: center; }
.keynav-legend dt { white-space: nowrap; }
.keynav-legend dd { margin: 0; color: var(--ds-ink-2); font-size: var(--ds-text-sm); }
.keynav-legend kbd { font-family: var(--ds-font-mono); font-size: 11px; color: var(--ds-ink-2); background: var(--ds-bg-2); border: 1px solid var(--ds-rule); border-bottom-width: 2px; border-radius: var(--ds-radius-xs); padding: 1px 6px; }


/* ── Sparklines (inline trend marks) ─────────────────────────────── */
.spark-cell { color: var(--ds-accent); width: 92px; }
.spark { display: block; overflow: visible; }
.spark-empty { color: var(--ds-ink-4); }


/* ── Export column picker (draggable checkbox list in the export modal) ── */
.export-colgrid { display: flex; flex-direction: column; gap: 1px; max-height: 248px; overflow-y: auto; margin: var(--ds-space-3) 0 var(--ds-space-2); border: 1px solid var(--ds-rule); border-radius: var(--ds-radius-sm); padding: 4px; }
.export-col { display: flex; align-items: center; gap: 8px; font-size: var(--ds-text-sm); color: var(--ds-ink); cursor: pointer; padding: 5px 7px; border-radius: var(--ds-radius-xs); user-select: none; }
.export-col:hover { background: var(--ds-bg-2); }
.export-col.dragging { opacity: 0.5; background: var(--ds-accent-soft); }
.export-col span { flex: 1; }
.export-col input { cursor: pointer; }
.export-grip { color: var(--ds-ink-4); cursor: grab; font-size: 13px; }
.export-col:active .export-grip { cursor: grabbing; }
