/* ============================================================
   PEARL MOTO — Shared Design System
   Mirrors the Sales_V2.html token system.
   Load this BEFORE page-specific styles in <head>.
   All rules here are either:
     • CSS custom properties on :root (zero specificity conflict)
     • New utility classes (.chip--, .num, .kpi-label etc.)
       that don't exist in legacy pages — purely additive.
   ============================================================ */

/* --- Design tokens ----------------------------------------- */
:root {
  /* Palette */
  --ds-bg:            #f5f7fb;
  --ds-surface:       #ffffff;
  --ds-border:        #e5e7eb;
  --ds-text:          #0f172a;
  --ds-muted:         #64748b;
  --ds-primary:       #2563eb;
  --ds-primary-dark:  #1d4ed8;
  --ds-good:          #16a34a;
  --ds-warn:          #d97706;
  --ds-bad:           #dc2626;
  --ds-info:          #2563eb;

  /* Shape & depth */
  --ds-radius:        14px;
  --ds-radius-sm:     8px;
  --ds-shadow:        0 6px 18px rgba(15, 23, 42, 0.08);
  --ds-shadow-sm:     0 2px 6px rgba(15, 23, 42, 0.06);

  /* Typography */
  --ds-font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ds-font-base:     14px;
  --ds-lh:            1.5;
}

/* --- Chip / status badge system ----------------------------
   Usage: <span class="ds-chip ds-chip--good">On Track</span>
   Five semantic states matching Sales V2.
   ---------------------------------------------------------- */
.ds-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.ds-chip--good { background: #dcfce7; color: #166534; }
.ds-chip--warn { background: #fef3c7; color: #92400e; }
.ds-chip--bad  { background: #fee2e2; color: #991b1b; }
.ds-chip--info { background: #dbeafe; color: #1e40af; }
.ds-chip--gray { background: #e5e7eb; color: #4b5563; }

/* --- Number cell utility -----------------------------------
   Apply to <td> or <th> containing numeric values.
   Ensures right-alignment and column-aligned digits.
   ---------------------------------------------------------- */
.ds-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- Label utility -----------------------------------------
   For filter labels, column sub-headers, section captions.
   Matches Sales V2 filter-control label treatment exactly.
   ---------------------------------------------------------- */
.ds-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--ds-muted);
}

/* --- Table header standard ---------------------------------
   Subtle grey header — the Sales V2 canonical treatment.
   Apply class="ds-thead" to the <thead> element, or
   wrap the table in a container with class="ds-table-wrap".
   ---------------------------------------------------------- */
.ds-thead th,
.ds-table-wrap thead th {
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* --- KPI card typography -----------------------------------
   Three-tier label / value / meta hierarchy.
   ---------------------------------------------------------- */
.ds-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--ds-muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.ds-kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ds-text);
  margin-top: 4px;
  line-height: 1.1;
}
.ds-kpi-meta {
  font-size: 11px;
  color: var(--ds-muted);
  margin-top: 4px;
}

/* --- Widget panel standard ---------------------------------
   White panel with consistent header / body split.
   ---------------------------------------------------------- */
.ds-widget {
  background: var(--ds-surface);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow);
  border: 1px solid var(--ds-border);
  margin-bottom: 16px;
  overflow: hidden;
}
.ds-widget__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ds-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ds-widget__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ds-text);
}
.ds-widget__body  { padding: 16px; }
.ds-widget__flush { padding: 0; }
