/* =========================================================
   OpenAI Data Partnerships — Dashboard
   Custom palette: deep charcoal + electric teal (AI infra vibe)
   ========================================================= */

:root {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.82rem + 0.25vw, 0.9375rem);
  --text-base: 1rem;
  --text-lg: clamp(1.125rem, 1rem + 0.5vw, 1.25rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  --text-2xl: clamp(1.875rem, 1.4rem + 1.5vw, 2.5rem);

  /* Spacing */
  --space-1: 0.25rem;  --space-2: 0.5rem;  --space-3: 0.75rem;
  --space-4: 1rem;     --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem;     --space-10: 2.5rem; --space-12: 3rem;
  --space-16: 4rem;    --space-20: 5rem;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;

  /* Transition */
  --tx: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --font-body: 'Inter', -apple-system, Helvetica, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --content: 1280px;
}

/* LIGHT */
:root, [data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #ececee;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-muted: #52525b;
  --text-faint: #a1a1aa;
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-soft: #ccfbf1;
  --accent: #6366f1;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(24,24,27,0.04), 0 1px 3px rgba(24,24,27,0.06);
  --shadow-md: 0 4px 16px rgba(24,24,27,0.07);
  --shadow-lg: 0 16px 48px rgba(24,24,27,0.12);

  /* modality badges */
  --mod-text-bg: #dbeafe;   --mod-text-fg: #1e40af;
  --mod-image-bg: #fce7f3;  --mod-image-fg: #9d174d;
  --mod-audio-bg: #fef3c7;  --mod-audio-fg: #92400e;
  --mod-video-bg: #ede9fe;  --mod-video-fg: #5b21b6;
  --mod-code-bg: #d1fae5;   --mod-code-fg: #065f46;
  --mod-struct-bg: #e0e7ff; --mod-struct-fg: #3730a3;
}

/* DARK */
[data-theme="dark"] {
  --bg: #09090b;
  --surface: #18181b;
  --surface-2: #1f1f23;
  --surface-3: #27272a;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --primary: #2dd4bf;
  --primary-hover: #5eead4;
  --primary-soft: #134e4a;
  --accent: #818cf8;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.6);

  --mod-text-bg: #172554;   --mod-text-fg: #93c5fd;
  --mod-image-bg: #500724;  --mod-image-fg: #fbcfe8;
  --mod-audio-bg: #451a03;  --mod-audio-fg: #fcd34d;
  --mod-video-bg: #2e1065;  --mod-video-fg: #c4b5fd;
  --mod-code-bg: #064e3b;   --mod-code-fg: #6ee7b7;
  --mod-struct-bg: #1e1b4b; --mod-struct-fg: #a5b4fc;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  transition: background var(--tx), color var(--tx);
}
input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); }
img, svg { max-width: 100%; display: block; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
}
.brand { display: flex; align-items: center; gap: var(--space-3); color: var(--primary); }
.brand-title { font-size: var(--text-lg); font-weight: 600; color: var(--text); line-height: 1.2; }
.brand-sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.lang-switch {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  padding: 6px 10px;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.lang-btn:hover { color: var(--text); }

.lang-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.theme-toggle {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: all var(--tx);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }

/* Container */
.container {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-16);
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  transition: all var(--tx);
}
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.kpi-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.kpi-value { font-size: var(--text-xl); font-weight: 700; color: var(--text); margin-top: var(--space-2); font-family: var(--font-mono); }
.kpi-sub { font-size: var(--text-xs); color: var(--text-faint); margin-top: var(--space-1); }
.kpi.accent { border-color: var(--primary); background: linear-gradient(135deg, var(--surface), color-mix(in oklab, var(--primary) 8%, var(--surface))); }
.kpi.accent .kpi-value { color: var(--primary); }

/* Tabs */
.tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-bottom: var(--space-6);
  overflow-x: auto;
}
.tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: all var(--tx);
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-panel { display: none; animation: fadeIn 220ms ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from {opacity: 0; transform: translateY(4px);} to {opacity: 1; transform: none;} }

/* Filters */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-5);
}
.filter-group { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.filter-group.grow { flex: 1 1 320px; }
.filter-label {
  font-size: var(--text-xs); font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.filter-row-inline {
  display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-end;
}
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.chip {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: all var(--tx);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
[data-theme="dark"] .chip.active { color: #09090b; }

.search-input, .select-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  transition: all var(--tx);
}
.search-input:focus, .select-input:focus {
  border-color: var(--primary); background: var(--surface);
  outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 15%, transparent);
}
.range-input { width: 220px; accent-color: var(--primary); }
.range-value { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

.results-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-4);
  padding: 0 var(--space-2);
}
.results-count { font-size: var(--text-sm); color: var(--text-muted); font-weight: 500; }
.btn-ghost {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-radius: var(--r-sm);
  transition: all var(--tx);
}
.btn-ghost:hover { color: var(--danger); background: var(--surface-2); }

/* Partner grid */
.partner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-4);
}
.partner-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3);
  cursor: pointer;
  transition: all var(--tx);
  text-align: left;
  width: 100%;
}
.partner-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3);
}
.card-name { font-size: var(--text-lg); font-weight: 600; color: var(--text); line-height: 1.25; }
.card-cat {
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.card-desc {
  font-size: var(--text-sm); color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  font-size: var(--text-xs); color: var(--text-faint);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px dashed var(--border);
}
.card-meta-item { display: flex; align-items: center; gap: var(--space-1); }
.card-money {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary);
}
.card-badges { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.mod-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mod-badge.text { background: var(--mod-text-bg); color: var(--mod-text-fg); }
.mod-badge.image { background: var(--mod-image-bg); color: var(--mod-image-fg); }
.mod-badge.audio { background: var(--mod-audio-bg); color: var(--mod-audio-fg); }
.mod-badge.video { background: var(--mod-video-bg); color: var(--mod-video-fg); }
.mod-badge.code { background: var(--mod-code-bg); color: var(--mod-code-fg); }
.mod-badge.structured { background: var(--mod-struct-bg); color: var(--mod-struct-fg); }

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
}
.empty-state .big { font-size: var(--text-lg); color: var(--text); margin-bottom: var(--space-2); }

/* Section head */
.section-head { margin-bottom: var(--space-5); }
.section-head h2 { font-size: var(--text-xl); font-weight: 600; }
.section-sub { color: var(--text-muted); font-size: var(--text-sm); margin-top: var(--space-2); max-width: 70ch; }

/* Benchmark */
.benchmark-controls { margin-bottom: var(--space-4); }
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  min-height: 460px;
}
.chart-legend {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}
.legend-item {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); color: var(--text-muted); font-weight: 500;
}
.legend-swatch {
  width: 12px; height: 12px; border-radius: 3px;
}

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  overflow-x: auto;
}
.deals-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.deals-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.deals-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.deals-table tr { cursor: pointer; transition: background var(--tx); }
.deals-table tbody tr:hover { background: var(--surface-2); }
.deals-table tbody tr:last-child td { border-bottom: none; }
.ai-badge {
  display: inline-block; font-weight: 600;
  padding: 2px 8px; border-radius: var(--r-sm);
  font-size: var(--text-xs);
  background: var(--surface-3);
}
.ai-badge.openai { background: var(--primary-soft); color: var(--primary-hover); }
[data-theme="dark"] .ai-badge.openai { color: var(--primary); }
.td-money { font-family: var(--font-mono); font-weight: 600; color: var(--text); white-space: nowrap; }
.td-struct { max-width: 420px; color: var(--text-muted); font-size: var(--text-xs); }

/* Program tab */
.program-hero {
  background: linear-gradient(135deg, var(--surface), color-mix(in oklab, var(--primary) 10%, var(--surface)));
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--space-8);
  margin-bottom: var(--space-6);
}
.program-hero h1 { font-size: var(--text-2xl); font-weight: 700; line-height: 1.15; }
.program-hero p { font-size: var(--text-base); color: var(--text-muted); margin-top: var(--space-3); max-width: 70ch; }

.tracks-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.track-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--space-6);
}
.track-tag { font-size: var(--text-xs); font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: 0.08em; }
.track-card h3 { font-size: var(--text-lg); font-weight: 600; margin: var(--space-2) 0 var(--space-3); }
.track-card p { color: var(--text-muted); font-size: var(--text-sm); }
.track-meta { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-faint); }

.key-diff-note {
  background: var(--surface-2, var(--surface));
  border-left: 3px solid var(--primary);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
}
.key-diff-label {
  font-size: var(--text-xs); font-weight: 600; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: var(--space-2);
}
.key-diff-note p { font-size: var(--text-sm); color: var(--text-muted); line-height: 1.55; margin: 0; }

.req-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.req-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--space-5);
}
.req-card h4 { font-size: var(--text-sm); font-weight: 600; color: var(--primary); margin-bottom: var(--space-2); }
.req-card p { font-size: var(--text-sm); color: var(--text-muted); }

.snowflake-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--space-6); margin-top: var(--space-8);
}
.snowflake-box h3 { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-3); }
.snowflake-box .note {
  background: color-mix(in oklab, var(--warning) 10%, transparent);
  border-left: 3px solid var(--warning);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  margin: var(--space-4) 0;
}
.snowflake-box ul { padding-left: var(--space-5); font-size: var(--text-sm); color: var(--text-muted); line-height: 1.7; }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: var(--space-4);
}
.modal[aria-hidden="false"] { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  animation: fadeBg 160ms ease;
}
@keyframes fadeBg { from {opacity: 0;} to {opacity: 1;} }
.modal-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
  animation: slideUp 220ms cubic-bezier(0.16,1,0.3,1);
}
@keyframes slideUp { from {opacity: 0; transform: translateY(12px);} to {opacity: 1; transform: none;} }
.modal-close {
  position: absolute; top: var(--space-4); right: var(--space-4);
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: all var(--tx);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-title { font-size: var(--text-xl); font-weight: 700; padding-right: var(--space-8); }
.modal-sub { color: var(--text-muted); margin-top: var(--space-1); font-size: var(--text-sm); }
.modal-badges { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-4) 0; }
.modal-section { margin-top: var(--space-5); }
.modal-section h4 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.modal-section p { font-size: var(--text-sm); color: var(--text); line-height: 1.65; }
.modal-section .money-highlight {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--primary);
  font-weight: 600;
}
.source-list { display: flex; flex-direction: column; gap: var(--space-2); }
.source-list a {
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  word-break: break-all;
  transition: all var(--tx);
}
.source-list a:hover { color: var(--primary); background: var(--surface-3); text-decoration: none; }

/* Footer */
.app-footer {
  border-top: 1px solid var(--border);
  margin-top: var(--space-20);
  background: var(--surface);
}
.footer-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  justify-content: space-between; align-items: center;
  font-size: var(--text-xs); color: var(--text-faint);
}

/* Responsive */
@media (max-width: 640px) {
  .container { padding: var(--space-5) var(--space-4) var(--space-12); }
  .header-inner { padding: var(--space-3) var(--space-4); }
  .brand-title { font-size: var(--text-base); }
  .filter-row-inline { flex-direction: column; align-items: stretch; }
  .range-input { width: 100%; }
  .modal-panel { padding: var(--space-5); }
  .partner-grid { grid-template-columns: 1fr; }
  .td-struct { display: none; }
}
