/* ============================================================================
   Digital Media AI Orchestrator — design system
   ============================================================================

   Direction: "studio, not SaaS".

   This is a marketing production tool — it generates video, images and copy.
   Generic blue-and-white SaaS chrome fights that: it competes with the work
   for attention and makes generated media hard to judge. So:

   - Dark-first. Near-black neutrals give generated media a neutral ground.
     Light mode is a supported alternate, not the default.
   - ONE saturated accent, reserved for generation state and primary actions,
     so "something is being created" is legible at a glance. Everything else
     is neutral. An accent used everywhere signals nothing.
   - Semantic status colours are fixed to pipeline stages and mean the same
     thing in the queue, the calendar and the media grid.
   - Density is compact by default. Operators live in these screens all day.

   These tokens are the durable artifact. Markup can be rebuilt; the scale,
   ramp and semantics should survive a framework change unchanged.
   ============================================================================ */

:root {
  /* ── Neutrals ────────────────────────────────────────────────────────────
     A single cool-grey ramp. Deliberately not pure black: #000 with a bright
     accent produces halation on OLED and makes thin type hard to read. */
  --ds-neutral-0:   #08080a;   /* page ground                       */
  --ds-neutral-50:  #0e0e11;   /* sunken (wells, code, inputs)      */
  --ds-neutral-100: #141418;   /* surface — cards, panels           */
  --ds-neutral-200: #1c1c22;   /* raised — hover, popovers          */
  --ds-neutral-300: #26262e;   /* borders, dividers                 */
  --ds-neutral-400: #383842;   /* strong border, disabled fill      */
  --ds-neutral-500: #5a5a67;   /* placeholder                       */
  --ds-neutral-600: #8b8b99;   /* secondary text                    */
  --ds-neutral-700: #b4b4c0;   /* body text on dark                 */
  --ds-neutral-800: #dcdce4;   /* headings                          */
  --ds-neutral-900: #f4f4f7;   /* max contrast                      */

  /* ── Accent: electric violet ─────────────────────────────────────────────
     Reserved for: primary actions, active nav, and anything generating.
     Violet over the previous cyan because cyan reads as "system/technical";
     violet reads as "creative" and does not collide with the status ramp
     below (cyan sat between the info-blue and success-green). */
  --ds-accent-100: #ede9ff;
  --ds-accent-300: #b8a5ff;
  --ds-accent-500: #7c5cff;   /* base — buttons, active state       */
  --ds-accent-600: #6039ff;   /* hover                              */
  --ds-accent-700: #4a25db;   /* pressed                            */
  --ds-accent-glow: rgba(124, 92, 255, 0.18);

  /* ── Pipeline status ─────────────────────────────────────────────────────
     One colour per stage, used everywhere that stage appears. */
  --ds-status-draft:      #8b8b99;   /* neutral   — not yet real       */
  --ds-status-queued:     #4a9eff;   /* blue      — waiting            */
  --ds-status-generating: #7c5cff;   /* accent    — work in progress   */
  --ds-status-review:     #f5a623;   /* amber     — needs a human      */
  --ds-status-scheduled:  #00c2a8;   /* teal      — committed          */
  --ds-status-published:  #22c55e;   /* green     — done               */
  --ds-status-failed:     #f4485c;   /* red       — broken             */

  /* ── Semantic aliases ────────────────────────────────────────────────── */
  --ds-bg:             var(--ds-neutral-0);
  --ds-bg-sunken:      var(--ds-neutral-50);
  --ds-surface:        var(--ds-neutral-100);
  --ds-surface-raised: var(--ds-neutral-200);
  --ds-border:         var(--ds-neutral-300);
  --ds-border-strong:  var(--ds-neutral-400);
  --ds-text:           var(--ds-neutral-700);
  --ds-text-strong:    var(--ds-neutral-900);
  --ds-text-muted:     var(--ds-neutral-600);
  --ds-text-placeholder: var(--ds-neutral-500);
  --ds-danger:         var(--ds-status-failed);
  --ds-success:        var(--ds-status-published);
  --ds-warning:        var(--ds-status-review);

  /* ── Type ────────────────────────────────────────────────────────────────
     System stack: no webfont request, and CJK renders in the platform's own
     face rather than a Latin fallback — this product is bilingual. */
  --ds-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
             "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
             "Helvetica Neue", Arial, sans-serif;
  --ds-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
                  "Liberation Mono", monospace;

  /* Minor-third-ish scale, capped: dashboards need range, not drama. */
  --ds-text-2xs: 10px;
  --ds-text-xs:  11px;
  --ds-text-sm:  12px;
  --ds-text-md:  13px;   /* body default — compact by design */
  --ds-text-lg:  15px;
  --ds-text-xl:  18px;
  --ds-text-2xl: 22px;
  --ds-text-3xl: 28px;

  --ds-weight-normal: 400;
  --ds-weight-medium: 500;
  --ds-weight-semi:   600;
  --ds-weight-bold:   700;

  --ds-leading-tight: 1.25;
  --ds-leading-body:  1.55;

  /* ── Space: 4px base ─────────────────────────────────────────────────── */
  --ds-space-1: 4px;
  --ds-space-2: 8px;
  --ds-space-3: 12px;
  --ds-space-4: 16px;
  --ds-space-5: 20px;
  --ds-space-6: 24px;
  --ds-space-8: 32px;
  --ds-space-10: 40px;
  --ds-space-12: 48px;

  /* ── Radii ───────────────────────────────────────────────────────────── */
  --ds-radius-sm: 4px;
  --ds-radius-md: 8px;
  --ds-radius-lg: 12px;
  --ds-radius-xl: 16px;
  --ds-radius-pill: 999px;

  /* ── Elevation ───────────────────────────────────────────────────────────
     On a dark ground, shadow alone reads as mud; each level pairs a shadow
     with a subtle top highlight so the edge stays legible. */
  --ds-shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --ds-shadow-md: 0 4px 12px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.03);
  --ds-shadow-lg: 0 12px 32px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.04);
  --ds-shadow-focus: 0 0 0 3px var(--ds-accent-glow);

  /* ── Motion ──────────────────────────────────────────────────────────── */
  --ds-ease: cubic-bezier(.4, 0, .2, 1);
  --ds-duration-fast: 120ms;
  --ds-duration-base: 180ms;

  --ds-z-dropdown: 100;
  --ds-z-modal: 500;
  --ds-z-toast: 900;
  --ds-z-banner: 1000;
}

/* Light mode is opt-in via [data-theme="light"] rather than a bare media
   query: the dark canvas is a product decision, not a system preference. */
[data-theme="light"] {
  --ds-bg:             #fafafa;
  --ds-bg-sunken:      #f2f2f5;
  --ds-surface:        #ffffff;
  --ds-surface-raised: #f7f7fa;
  --ds-border:         #e2e2e8;
  --ds-border-strong:  #cacad4;
  --ds-text:           #34343d;
  --ds-text-strong:    #0e0e11;
  --ds-text-muted:     #6c6c7a;
  --ds-text-placeholder: #9a9aa8;
  --ds-shadow-sm: 0 1px 2px rgba(16,16,24,.06);
  --ds-shadow-md: 0 4px 12px rgba(16,16,24,.08);
  --ds-shadow-lg: 0 12px 32px rgba(16,16,24,.12);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================================
   Components
   ========================================================================= */

.ds-page {
  background: var(--ds-bg);
  color: var(--ds-text);
  font-family: var(--ds-font);
  font-size: var(--ds-text-md);
  line-height: var(--ds-leading-body);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.ds-h1 { font-size: var(--ds-text-3xl); font-weight: var(--ds-weight-bold);
         color: var(--ds-text-strong); line-height: var(--ds-leading-tight); margin: 0; }
.ds-h2 { font-size: var(--ds-text-xl); font-weight: var(--ds-weight-semi);
         color: var(--ds-text-strong); line-height: var(--ds-leading-tight); margin: 0; }
.ds-h3 { font-size: var(--ds-text-lg); font-weight: var(--ds-weight-semi);
         color: var(--ds-text-strong); margin: 0; }
.ds-muted { color: var(--ds-text-muted); }
.ds-mono  { font-family: var(--ds-font-mono); font-size: var(--ds-text-sm); }

/* ── Surfaces ───────────────────────────────────────────────────────────── */
.ds-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-md);
  padding: var(--ds-space-5);
}
.ds-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--ds-space-3); margin-bottom: var(--ds-space-4);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.ds-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--ds-space-2);
  font: inherit; font-weight: var(--ds-weight-medium);
  padding: var(--ds-space-2) var(--ds-space-4);
  border-radius: var(--ds-radius-md);
  border: 1px solid var(--ds-border-strong);
  background: var(--ds-surface-raised);
  color: var(--ds-text-strong);
  cursor: pointer; white-space: nowrap;
  transition: background var(--ds-duration-fast) var(--ds-ease),
              border-color var(--ds-duration-fast) var(--ds-ease),
              transform var(--ds-duration-fast) var(--ds-ease);
}
.ds-btn:hover { background: var(--ds-neutral-300); }
.ds-btn:active { transform: translateY(1px); }
.ds-btn:focus-visible { outline: none; box-shadow: var(--ds-shadow-focus); }
.ds-btn[disabled] { opacity: .45; cursor: not-allowed; }

.ds-btn-primary {
  background: var(--ds-accent-500); border-color: var(--ds-accent-500); color: #fff;
}
.ds-btn-primary:hover { background: var(--ds-accent-600); border-color: var(--ds-accent-600); }

.ds-btn-danger { color: var(--ds-danger); border-color: color-mix(in srgb, var(--ds-danger) 40%, transparent); }
.ds-btn-danger:hover { background: color-mix(in srgb, var(--ds-danger) 14%, transparent); }

.ds-btn-ghost { background: transparent; border-color: transparent; color: var(--ds-text-muted); }
.ds-btn-ghost:hover { background: var(--ds-surface-raised); color: var(--ds-text-strong); }

.ds-btn-sm { padding: var(--ds-space-1) var(--ds-space-3); font-size: var(--ds-text-sm); }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.ds-input, .ds-select {
  font: inherit;
  background: var(--ds-bg-sunken);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  color: var(--ds-text-strong);
  padding: var(--ds-space-2) var(--ds-space-3);
  min-width: 0;
  transition: border-color var(--ds-duration-fast) var(--ds-ease);
}
.ds-input::placeholder { color: var(--ds-text-placeholder); }
.ds-input:focus, .ds-select:focus {
  outline: none; border-color: var(--ds-accent-500); box-shadow: var(--ds-shadow-focus);
}
.ds-label {
  display: block; font-size: var(--ds-text-sm); font-weight: var(--ds-weight-medium);
  color: var(--ds-text-muted); margin-bottom: var(--ds-space-1);
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.ds-badge {
  display: inline-flex; align-items: center; gap: var(--ds-space-1);
  font-size: var(--ds-text-xs); font-weight: var(--ds-weight-medium);
  padding: 2px var(--ds-space-2);
  border-radius: var(--ds-radius-pill);
  border: 1px solid currentColor;
  line-height: 1.6;
  /* A badge is a single token and must never break across lines. Chinese has
     no spaces, so a narrow table column wrapped "已指定" one character per
     line into a three-line pill. */
  white-space: nowrap;
}
.ds-badge::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}
.ds-badge-draft      { color: var(--ds-status-draft); }
.ds-badge-queued     { color: var(--ds-status-queued); }
.ds-badge-generating { color: var(--ds-status-generating); }
.ds-badge-review     { color: var(--ds-status-review); }
.ds-badge-scheduled  { color: var(--ds-status-scheduled); }
.ds-badge-published  { color: var(--ds-status-published); }
.ds-badge-failed     { color: var(--ds-status-failed); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--ds-text-md); }
.ds-table th {
  text-align: left; font-size: var(--ds-text-xs); font-weight: var(--ds-weight-semi);
  text-transform: uppercase; letter-spacing: .06em; color: var(--ds-text-muted);
  padding: var(--ds-space-2) var(--ds-space-3);
  border-bottom: 1px solid var(--ds-border);
  white-space: nowrap;
}
.ds-table td {
  padding: var(--ds-space-3);
  border-bottom: 1px solid var(--ds-border);
  color: var(--ds-text);
}
.ds-table tbody tr:hover { background: var(--ds-surface-raised); }
.ds-table-wrap { overflow-x: auto; }   /* wide tables scroll, the page never does */

/* ── Stats ──────────────────────────────────────────────────────────────── */
.ds-stat-grid {
  display: grid; gap: var(--ds-space-4);
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.ds-stat { background: var(--ds-surface); border: 1px solid var(--ds-border);
           border-radius: var(--ds-radius-lg); padding: var(--ds-space-4); }
.ds-stat-label { font-size: var(--ds-text-xs); text-transform: uppercase;
                 letter-spacing: .06em; color: var(--ds-text-muted); }
.ds-stat-value { font-size: var(--ds-text-2xl); font-weight: var(--ds-weight-bold);
                 color: var(--ds-text-strong); line-height: 1.2; margin-top: var(--ds-space-1); }

/* ── Impersonation banner ────────────────────────────────────────────────
   Deliberately loud and non-dismissable. Confusing "my workspace" with "a
   customer's workspace" is the most dangerous mistake an operator can make. */
.ds-impersonation-banner {
  position: sticky; top: 0; z-index: var(--ds-z-banner);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--ds-space-3);
  background: repeating-linear-gradient(45deg,
    var(--ds-status-review), var(--ds-status-review) 12px,
    #d9930f 12px, #d9930f 24px);
  color: #1a1205; font-weight: var(--ds-weight-semi);
  padding: var(--ds-space-2) var(--ds-space-4);
  font-size: var(--ds-text-sm);
}

/* Super-admin chrome is visually distinct from the customer app, so the two
   are never confused at a glance. */
.ds-staff-bar {
  display: flex; align-items: center; gap: var(--ds-space-3);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--ds-accent-500) 22%, var(--ds-surface)), var(--ds-surface));
  border-bottom: 1px solid var(--ds-border);
  padding: var(--ds-space-3) var(--ds-space-5);
}
.ds-staff-tag {
  font-size: var(--ds-text-2xs); text-transform: uppercase; letter-spacing: .1em;
  font-weight: var(--ds-weight-bold);
  background: var(--ds-accent-500); color: #fff;
  padding: 2px var(--ds-space-2); border-radius: var(--ds-radius-sm);
}

/* Theme toggle: the icon shown is the theme you would switch TO. */
.icon-sun  { display: inline-block; }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: inline-block; }

/* ── Utility ────────────────────────────────────────────────────────────── */
.ds-row   { display: flex; align-items: center; gap: var(--ds-space-3); }
.ds-row-wrap { display: flex; align-items: center; gap: var(--ds-space-3); flex-wrap: wrap; }
.ds-col   { display: flex; flex-direction: column; gap: var(--ds-space-2); }
.ds-grow  { flex: 1; }
.ds-empty { color: var(--ds-text-muted); text-align: center; padding: var(--ds-space-8); }
.ds-error { color: var(--ds-danger); font-size: var(--ds-text-sm); }
.ds-hidden { display: none !important; }

.ds-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--ds-border-strong);
  border-top-color: var(--ds-accent-500);
  animation: ds-spin .7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ── Modal ────────────────────────────────────────────────────────────────
   Replaces prompt()/confirm() so every option is a real control, not typed
   command text. */
.ds-modal-overlay {
  position: fixed; inset: 0; z-index: var(--ds-z-modal);
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: var(--ds-space-4);
}
.ds-modal {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-lg);
  width: 100%; max-width: 440px;
  max-height: 90vh; overflow-y: auto;
  padding: var(--ds-space-5);
}
.ds-modal-title { font-size: var(--ds-text-xl); font-weight: var(--ds-weight-semi);
                  color: var(--ds-text-strong); margin: 0 0 var(--ds-space-4); }
.ds-modal-actions {
  display: flex; justify-content: flex-end; gap: var(--ds-space-2);
  margin-top: var(--ds-space-5);
}

/* Labeled field: stacked label + control. */
.ds-field { margin-bottom: var(--ds-space-4); }
.ds-field > .ds-label { margin-bottom: var(--ds-space-2); }
.ds-field .ds-input, .ds-field .ds-select { width: 100%; box-sizing: border-box; }
.ds-field-hint { font-size: var(--ds-text-xs); color: var(--ds-text-muted);
                 margin-top: var(--ds-space-1); }

/* Toggle switch — one per feature flag. */
.ds-switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--ds-space-3);
  padding: var(--ds-space-2) 0;
  border-bottom: 1px solid var(--ds-border);
}
.ds-switch-row:last-child { border-bottom: none; }
.ds-switch-label { font-size: var(--ds-text-md); color: var(--ds-text); }
.ds-switch {
  position: relative; width: 40px; height: 22px; flex-shrink: 0;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-neutral-400);
  border: none; cursor: pointer; padding: 0;
  transition: background var(--ds-duration-fast) var(--ds-ease);
}
.ds-switch[aria-checked="true"] { background: var(--ds-accent-500); }
.ds-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform var(--ds-duration-fast) var(--ds-ease);
}
.ds-switch[aria-checked="true"]::after { transform: translateX(18px); }
.ds-switch:focus-visible { outline: none; box-shadow: var(--ds-shadow-focus); }

.ds-token-box {
  font-family: var(--ds-font-mono); font-size: var(--ds-text-sm);
  background: var(--ds-bg-sunken); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md); padding: var(--ds-space-3);
  word-break: break-all; color: var(--ds-text-strong);
}

/* ============================================================================
   Reporting primitives
   ============================================================================
   Added for the staff console's usage/billing screens. Kept here rather than
   in admin.css because none of them are admin-specific: a banner, a filter
   chip and a right-aligned numeric cell are general components, and the
   customer app will want them too.
   ========================================================================= */

/* ── Banners ─────────────────────────────────────────────────────────────
   For conditions the operator must not scroll past — chiefly "these totals
   are wrong because some usage is unpriced". Loud on purpose. */
.ds-banner {
  display: flex; align-items: flex-start; gap: var(--ds-space-3);
  padding: var(--ds-space-4);
  border: 1px solid currentColor;
  border-radius: var(--ds-radius-lg);
  margin-bottom: var(--ds-space-4);
}
.ds-banner-warning { color: var(--ds-warning);
  background: color-mix(in srgb, var(--ds-warning) 10%, transparent); }
.ds-banner-danger  { color: var(--ds-danger);
  background: color-mix(in srgb, var(--ds-danger) 10%, transparent); }
.ds-banner-info    { color: var(--ds-status-queued);
  background: color-mix(in srgb, var(--ds-status-queued) 10%, transparent); }
.ds-banner-icon { flex: none; margin-top: 1px; }
.ds-banner-main { flex: 1; min-width: 0; }
.ds-banner-title { font-weight: var(--ds-weight-semi); color: currentColor;
                   font-size: var(--ds-text-md); margin: 0 0 var(--ds-space-1); }
.ds-banner-body  { color: var(--ds-text); font-size: var(--ds-text-sm); margin: 0; }
.ds-banner-list {
  margin: var(--ds-space-2) 0 0; padding: 0; list-style: none;
  display: flex; flex-wrap: wrap; gap: var(--ds-space-2);
}
.ds-banner-list li {
  font-family: var(--ds-font-mono); font-size: var(--ds-text-xs);
  background: var(--ds-bg-sunken); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-sm); padding: 1px var(--ds-space-2);
  color: var(--ds-text);
}

/* ── Filter chip ─────────────────────────────────────────────────────────
   A filter that is not visible is a filter that produces wrong readings.
   Every scoped view shows one of these with its own clear affordance. */
.ds-chip {
  display: inline-flex; align-items: center; gap: var(--ds-space-2);
  font-size: var(--ds-text-sm); font-weight: var(--ds-weight-medium);
  background: color-mix(in srgb, var(--ds-accent-500) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--ds-accent-500) 45%, transparent);
  color: var(--ds-text-strong);
  border-radius: var(--ds-radius-pill);
  padding: 2px var(--ds-space-2) 2px var(--ds-space-3);
}
.ds-chip-clear {
  font: inherit; font-size: var(--ds-text-xs);
  background: transparent; border: none; cursor: pointer;
  color: var(--ds-text-muted); padding: 0 var(--ds-space-1);
  border-left: 1px solid color-mix(in srgb, var(--ds-accent-500) 45%, transparent);
}
.ds-chip-clear:hover { color: var(--ds-text-strong); }

/* ── Segmented control ───────────────────────────────────────────────────
   For mutually-exclusive scopes (the date range). A select would hide the
   options; there are only four and they are switched constantly. */
.ds-segment {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--ds-surface); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
}
.ds-segment button {
  font: inherit; font-size: var(--ds-text-sm); font-weight: var(--ds-weight-medium);
  padding: var(--ds-space-1) var(--ds-space-3);
  border: none; background: transparent; color: var(--ds-text-muted);
  border-radius: var(--ds-radius-sm); cursor: pointer; white-space: nowrap;
}
.ds-segment button:hover { color: var(--ds-text-strong); background: var(--ds-surface-raised); }
.ds-segment button[aria-pressed="true"] { background: var(--ds-accent-500); color: #fff; }
.ds-segment button:focus-visible { outline: none; box-shadow: var(--ds-shadow-focus); }

/* ── Sub-navigation ──────────────────────────────────────────────────────
   Second-level tabs inside one screen (usage breakdowns). Underline rather
   than filled, so it never competes with the primary sidebar selection. */
.ds-subnav {
  display: flex; gap: var(--ds-space-1); flex-wrap: wrap;
  border-bottom: 1px solid var(--ds-border);
}
.ds-subnav button {
  font: inherit; font-size: var(--ds-text-md); font-weight: var(--ds-weight-medium);
  background: transparent; border: none; cursor: pointer;
  color: var(--ds-text-muted);
  padding: var(--ds-space-2) var(--ds-space-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.ds-subnav button:hover { color: var(--ds-text-strong); }
.ds-subnav button[aria-selected="true"] {
  color: var(--ds-text-strong); border-bottom-color: var(--ds-accent-500);
}
.ds-subnav button:focus-visible { outline: none; box-shadow: var(--ds-shadow-focus); }

/* ── Numeric table cells ─────────────────────────────────────────────────
   Money and counts are compared down a column, so they are right-aligned
   with tabular figures. Without this, digits of different widths make two
   similar numbers look different lengths. */
.ds-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.ds-num { text-align: right; }
.ds-pos { color: var(--ds-success); }
.ds-neg { color: var(--ds-danger); }

.ds-money { display: inline-flex; align-items: baseline; gap: 4px;
            font-family: var(--ds-font-mono); font-size: var(--ds-text-sm); }
.ds-money-cur { font-size: var(--ds-text-2xs); color: var(--ds-text-muted);
                text-transform: uppercase; letter-spacing: .04em; }

/* Rows that drill down. Cursor + hover alone is ambiguous, so these also
   take focus and respond to Enter. */
.ds-row-link { cursor: pointer; }
.ds-row-link:focus-visible { outline: 2px solid var(--ds-accent-500); outline-offset: -2px; }

/* ── Charts ──────────────────────────────────────────────────────────────
   Hand-rolled inline SVG. A chart library is a external script, and the CSP
   blocks those; for a daily bar series it would also be 200kB for nothing. */
.ds-chart { width: 100%; height: auto; display: block; overflow: visible; }
.ds-chart-bar-price { fill: var(--ds-accent-500); }
.ds-chart-bar-cost  { fill: var(--ds-status-queued); }
.ds-chart-axis  { stroke: var(--ds-border); stroke-width: 1; }
.ds-chart-grid  { stroke: var(--ds-border); stroke-width: 1; stroke-dasharray: 2 3; opacity: .6; }
.ds-chart-label { fill: var(--ds-text-muted); font-size: 9px;
                  font-family: var(--ds-font); }

.ds-legend { display: flex; align-items: center; gap: var(--ds-space-4);
             font-size: var(--ds-text-xs); color: var(--ds-text-muted); }
.ds-legend-item { display: inline-flex; align-items: center; gap: var(--ds-space-2); }
.ds-legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

/* ── Stat extras ─────────────────────────────────────────────────────── */
.ds-stat-sub { font-size: var(--ds-text-xs); color: var(--ds-text-muted);
               margin-top: var(--ds-space-1); }
.ds-stat-alert { border-color: color-mix(in srgb, var(--ds-danger) 55%, transparent); }
.ds-stat-alert .ds-stat-value { color: var(--ds-danger); }

/* ── Pager ───────────────────────────────────────────────────────────── */
.ds-pager { display: flex; align-items: center; justify-content: flex-end;
            gap: var(--ds-space-3); margin-top: var(--ds-space-3);
            font-size: var(--ds-text-sm); color: var(--ds-text-muted); }

/* Badge variant for "this is a placeholder number, do not invoice from it". */
.ds-badge-unverified { color: var(--ds-status-review); font-weight: var(--ds-weight-bold);
                       letter-spacing: .04em; }

/* ── Meter ───────────────────────────────────────────────────────────────
   A proportion bar for a table cell. Purely comparative — it carries no
   label of its own, so it always sits beside the number it illustrates
   rather than replacing it. */
.ds-meter {
  height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--ds-surface-raised);
}
.ds-meter-fill {
  height: 100%; border-radius: 3px;
  background: var(--ds-accent-500);
}
