/* ═══════════════════════════════════════════════════
   Design System Components
   Source: https://design.seantippen.com/

   Import AFTER tokens.css in any project:
   <link rel="stylesheet" href="https://design.seantippen.com/tokens.css">
   <link rel="stylesheet" href="https://design.seantippen.com/components.css">

   Ships the handful of patterns used on every dashboard:
   nav, banded sections, subsections, cards, data tables,
   KPI bars, info rows. Anything more bespoke stays per-
   dashboard. Edit this file, push, every linked project
   picks up the change.
   ═══════════════════════════════════════════════════ */

/* ─── Base reset used by dashboards ─── */
.ds-reset, .ds-reset * { box-sizing: border-box; }

/* ─── Sticky Nav with scroll-spy ─── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in oklch, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  height: 48px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 1rem;
}
.nav::-webkit-scrollbar { display: none; }
.nav::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--color-accent),
    var(--color-secondary),
    transparent
  );
}
.nav-brand {
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: -0.2px;
  color: var(--color-text);
  margin-right: 1.5rem;
  white-space: nowrap;
}
.nav-links {
  display: flex;
  align-items: stretch;
  height: 100%;
  flex: 1;
  min-width: 0;
}
.nav a {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 0 0.6rem;
  height: 100%;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.nav a:hover { color: var(--color-text); }
.nav a.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}
.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  padding-left: 0.75rem;
}

/* ─── Banded Sections ─── */
.section { scroll-margin-top: 56px; }
.section:nth-child(odd of .section) { background: var(--color-bg); }
.section:nth-child(even of .section) { background: var(--color-surface); }
.section-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-section) 1.5rem;
}

/* ─── Section headers ─── */
.section-num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: 2px;
  opacity: 0.7;
  margin-bottom: 0.4rem;
}
.section-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}
.section-desc {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: 2rem;
  max-width: var(--measure);
}

/* ─── Subsections ─── */
.subsection { margin-bottom: 2.5rem; }
.subsection:last-child { margin-bottom: 0; }
.subsection-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}
.subsection-desc {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* ─── Flat card (no gradient, no blur) ─── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: var(--space-md);
}
.card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}
.card-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ─── KPI row — accent bar on left, no box ─── */
.kpi {
  border-left: 3px solid var(--color-accent);
  padding: 0.25rem 0 0.25rem 0.75rem;
}
.kpi-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: var(--leading-tight);
}
.kpi-delta {
  font-size: var(--text-xs);
  font-weight: 600;
  margin-left: 0.5rem;
}
.kpi-delta.up    { color: var(--color-success); }
.kpi-delta.down  { color: var(--color-danger); }
.kpi-delta.flat  { color: var(--color-text-muted); }

/* KPI grid container — responsive auto-fit */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* ─── Info row — flex label/value with bottom border ─── */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
}
.info-row:last-child { border-bottom: none; }
.info-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}
.info-value {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 600;
  text-align: right;
  font-family: var(--font-mono);
}

/* ─── Data table — no card wrapper, border-bottom rows ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table thead th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-muted);
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--color-border-emphasis);
  background: transparent;
  position: sticky;
  top: 48px;
  z-index: 5;
}
.data-table tbody td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}
.data-table tbody tr:hover {
  background: var(--color-surface-hover);
}
.data-table td.num,
.data-table th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ─── Underline search input (no box) ─── */
.search-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border-emphasis);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  padding: 0.5rem 0.25rem;
  width: 100%;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.search-input::placeholder { color: var(--color-text-muted); }
.search-input:focus {
  border-bottom-color: var(--color-accent);
}

/* ─── Badge (status pills) ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--color-border-emphasis);
  color: var(--color-text-secondary);
  background: var(--color-surface-raised);
  border-radius: var(--radius-full);
}
.badge.success { color: var(--color-success); border-color: var(--color-success); background: var(--color-success-subtle); }
.badge.warning { color: var(--color-warning); border-color: var(--color-warning); background: var(--color-warning-subtle); }
.badge.danger  { color: var(--color-danger);  border-color: var(--color-danger);  background: var(--color-danger-subtle); }
.badge.info    { color: var(--color-info);    border-color: var(--color-info);    background: var(--color-info-subtle); }

/* ─── Button (minimal) ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 0.5rem 0.9rem;
  background: var(--color-surface-raised);
  color: var(--color-text);
  border: 1px solid var(--color-border-emphasis);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.btn:hover {
  background: var(--color-surface-overlay);
  border-color: var(--color-border-strong);
}
.btn.primary {
  background: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}
.btn.primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* ─── Mobile nav — horizontal scroll already handled above ─── */
@media (max-width: 640px) {
  .section-inner { padding: calc(var(--space-section) * 0.6) 1rem; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
  .info-row { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
  .info-value { text-align: left; }
}

/* ═══════════════════════════════════════════════════
   DASHBOARD PRIMITIVES
   Added 2026-04-21. The composite patterns every
   dashboard rebuilds from scratch: delta chips, stat
   bands, dense/totals tables, progress bars, status
   pills, sparklines, tabs, segmented toggles, toolbar
   rows, filter chips, drawer, empty/error states,
   stale timestamps, skeleton rows.
   ═══════════════════════════════════════════════════ */

/* ─── Delta chip — +12% / -3% inline indicator ─── */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  letter-spacing: 0.2px;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  font-variant-numeric: tabular-nums;
}
.delta::before { font-size: 0.85em; line-height: 1; }
.delta.up   { color: var(--color-success); border-color: var(--color-success); }
.delta.up::before   { content: '\25B2'; }
.delta.down { color: var(--color-danger);  border-color: var(--color-danger); }
.delta.down::before { content: '\25BC'; }
.delta.flat { color: var(--color-text-muted); }
.delta.flat::before { content: '\2022'; }
.delta.plain { border: none; padding: 0; }

/* ─── Stat band — horizontal row of stat blocks ─── */
.stat-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.stat {
  padding: 1rem 1.25rem;
  border-right: 1px solid var(--color-border);
}
.stat:last-child { border-right: none; }
.stat-eyebrow {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--color-text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.stat-meta {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}
@media (max-width: 640px) {
  .stat { border-right: none; border-bottom: 1px solid var(--color-border); }
  .stat:last-child { border-bottom: none; }
}

/* ─── Dense data table + totals row ─── */
.data-table.dense thead th {
  padding: 0.4rem 0.6rem;
  font-size: 0.6rem;
}
.data-table.dense tbody td {
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
}
.data-table tr.total td,
.data-table tfoot td {
  font-weight: 800;
  color: var(--color-text);
  border-top: 2px solid var(--color-border-emphasis);
  padding-top: 0.75rem;
  background: var(--color-surface-hover);
}
/* Shortcut classes for colored numerics in table cells */
.data-table td.pos { color: var(--color-success); }
.data-table td.neg { color: var(--color-danger); }

/* ─── Progress bar — inline and block variants ─── */
.progress {
  display: block;
  width: 100%;
  height: 6px;
  background: var(--color-surface-hover);
  overflow: hidden;
  position: relative;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--color-accent);
  transition: width var(--duration-slow) var(--ease-out);
}
.progress.positive > span { background: var(--color-success); }
.progress.warning  > span { background: var(--color-warning); }
.progress.danger   > span { background: var(--color-danger); }
.progress.sm { height: 3px; }
.progress.lg { height: 10px; }
.progress-block { display: flex; flex-direction: column; gap: 0.35rem; }
.progress-block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.progress-block-value {
  font-family: var(--font-mono);
  color: var(--color-text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ─── Pill — status indicator with leading dot ─── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--color-border-emphasis);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border-radius: var(--radius-full);
}
.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-text-muted);
  flex-shrink: 0;
}
.pill.success::before { background: var(--color-success); }
.pill.warning::before { background: var(--color-warning); }
.pill.danger::before  { background: var(--color-danger); }
.pill.info::before    { background: var(--color-info); }
.pill.live::before    { background: var(--color-success); animation: pill-pulse 1.8s ease-in-out infinite; }
@keyframes pill-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ─── Sparkline wrapper — fixed slot for Chart.js micro-charts ─── */
.sparkline {
  display: inline-block;
  width: 80px;
  height: 24px;
  vertical-align: middle;
}
.sparkline.lg { width: 120px; height: 36px; }

/* ─── Tabs — underline style ─── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.tab:hover { color: var(--color-text); }
.tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* ─── Segmented toggle — Day | Week | Month ─── */
.segmented {
  display: inline-flex;
  border: 1px solid var(--color-border-emphasis);
  background: var(--color-surface);
}
.segmented > button {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  border-right: 1px solid var(--color-border);
  transition: color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}
.segmented > button:last-child { border-right: none; }
.segmented > button:hover { color: var(--color-text); background: var(--color-surface-hover); }
.segmented > button.active {
  color: var(--color-bg);
  background: var(--color-accent);
}

/* ─── Toolbar row — filters left, actions right ─── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1rem;
}
.toolbar-group { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }

/* ─── Filter chip — removable, selectable ─── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--color-border-emphasis);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}
.chip:hover { color: var(--color-text); border-color: var(--color-border-strong); }
.chip.active {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: var(--accent-subtle);
}
.chip-close { font-size: 0.95em; color: var(--color-text-muted); line-height: 1; cursor: pointer; }
.chip-close:hover { color: var(--color-text); }

/* ─── Drawer — right-side slide-in panel with scrim ─── */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.45);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out);
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 90vw);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border-emphasis);
  box-shadow: var(--shadow-lg);
  z-index: 501;
  transform: translateX(100%);
  transition: transform var(--duration-normal) var(--ease-out);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
}
.drawer-title { font-size: var(--text-base); font-weight: 700; color: var(--color-text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.25rem; }
.drawer-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
}
.drawer-close:hover { color: var(--color-text); }

/* ─── Empty state / Error state ─── */
.empty-state,
.error-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border-emphasis);
  background: transparent;
}
.error-state {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: var(--color-danger-subtle);
  border-style: solid;
}
.empty-state-icon,
.error-state-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 0.75rem;
  opacity: 0.55;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}
.empty-state-title,
.error-state-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.35rem;
}
.error-state-title { color: var(--color-danger); }
.empty-state-desc,
.error-state-desc {
  font-size: var(--text-sm);
  max-width: 48ch;
  margin: 0 auto 1rem;
  line-height: var(--leading-snug);
}

/* ─── Stale indicator — "updated 3m ago" ─── */
.stale {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.stale::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-text-muted);
}
.stale.fresh::before { background: var(--color-success); }
.stale.aging::before { background: var(--color-warning); }
.stale.dead::before  { background: var(--color-danger); }

/* ─── Skeleton row — table loading placeholder ─── */
.skeleton-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}
.skeleton-row > span {
  height: 0.9rem;
  background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-surface-hover) 50%, var(--color-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
