/* ============================================================
   Customer–Vendor Intelligence — dark mode, purple accent.
   Built from the design tokens; no light-mode defaults.
   ============================================================ */

:root {
  /* Canvas + surfaces (near-black, layered grays) */
  --canvas:        #0A0A0A;
  --surface-1:     #141414;
  --surface-2:     #1C1C1C;
  --surface-3:     #242424;
  --border:        #2E2E2E;
  --border-strong: #3A3A3A;

  /* Text */
  --text:        #F2F2F2;
  --text-muted:  #A8A8A8;
  --text-dim:    #757575;

  /* Brand accent — purple ONLY for headline figures + interactive elements */
  --accent:        #8D4DFF;
  --accent-hover:  #A06BFF;
  --accent-soft:   rgba(141, 77, 255, 0.14);
  --accent-border: rgba(141, 77, 255, 0.45);

  /* Confidence bands — NEUTRAL gray lightness ramp (lighter = more confident).
     Never colored tints. */
  --band-confirmed-bg:   #E6E6E6;
  --band-confirmed-fg:   #0A0A0A;
  --band-likely-bg:      #9A9A9A;
  --band-likely-fg:      #0A0A0A;
  --band-possible-bg:    #4E4E4E;
  --band-possible-fg:    #F2F2F2;
  --band-weak-bg:        #2C2C2C;
  --band-weak-fg:        #BdBdBd;

  /* 8px spacing scale */
  --s1: 8px;  --s2: 16px; --s3: 24px; --s4: 32px; --s5: 40px; --s6: 48px;

  --radius:    10px;
  --radius-sm: 7px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Shared outer container: same for every view so they align ---- */
.container {
  max-width: 1520px;
  margin: 0 auto;
  padding: var(--s4) clamp(24px, 3vw, 32px) var(--s6);
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

button { font-family: inherit; }

/* ============================================================
   Auth gate
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s4);
}
.auth-panel {
  width: min(100%, 460px);
  padding: var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}
.brand-mark {
  width: 22px;
  height: 22px;
  margin-bottom: var(--s3);
  border-radius: 6px;
  background: var(--text);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 2px;
  background: var(--accent);
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.auth-panel h1 {
  font-size: 1.55rem;
  line-height: 1.1;
}
.auth-copy {
  margin: var(--s2) 0 0;
  color: var(--text-muted);
}
.primary-button,
.ghost-button {
  appearance: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
}
.primary-button {
  width: 100%;
  margin-top: var(--s3);
  padding: 12px var(--s2);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}
.primary-button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.ghost-button {
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
}
.ghost-button:hover {
  color: var(--text);
  background: var(--surface-2);
}
.auth-status {
  margin-top: var(--s2);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============================================================
   Header — CENTERED headline + intro, toggle pinned top-right
   ============================================================ */
.app-header {
  position: relative;
  text-align: center;
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border);
}
.app-title { font-size: 1.7rem; }
.app-subtitle {
  margin: var(--s1) auto 0;
  color: var(--text-muted);
  max-width: 70ch;
}
.app-header__controls {
  position: absolute;
  right: 0;
  top: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s1);
}
.signed-in-user {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 0.82rem;
}

/* Toggle */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__track {
  position: relative;
  width: 42px; height: 24px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: background .15s, border-color .15s;
}
.toggle__thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform .15s, background .15s;
}
.toggle input:checked + .toggle__track {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.toggle input:checked + .toggle__track .toggle__thumb {
  transform: translateX(18px);
  background: var(--accent);
}
.toggle input:focus-visible + .toggle__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.toggle__label em { color: var(--text); font-style: italic; }

/* ============================================================
   Tabs — centered
   ============================================================ */
.tabs {
  display: flex;
  justify-content: center;
  gap: var(--s1);
  margin: var(--s3) 0 var(--s4);
  flex-wrap: wrap;
}
.tab {
  appearance: none;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px var(--s2);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: color .12s, background .12s, border-color .12s;
}
.tab:hover { color: var(--text); background: var(--surface-1); }
.tab.is-active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   Views
   ============================================================ */
.view { display: none; }
.view.is-active { display: block; }

/* Section intro — centered, with breathing room */
.view-head { margin-bottom: var(--s3); text-align: center; }
.view-head__title { font-size: 1.25rem; }
.view-head__hint { margin: 6px auto 0; color: var(--text-muted); max-width: 70ch; }

/* ---- Form fields (controls + filters stay LEFT-aligned for scanning) ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field[hidden] { display: none; }
.field--grow { flex: 1 1 280px; }
.field__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.select, .input {
  appearance: none;
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px var(--s2);
  font-size: 0.95rem;
  font-family: inherit;
  min-width: 220px;
}
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%23A8A8A8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.select:focus, .input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.controls, .filters {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: var(--s3);
}

/* ---- Summary line (badge + stats), left-aligned with data ---- */
.view-summary {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s4);
}
.count-badge {
  display: inline-block;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--text);
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
}
.summary-stats { display: flex; gap: var(--s4); flex-wrap: wrap; align-items: baseline; }
.summary-stat { display: flex; flex-direction: column; gap: 2px; }
.summary-stat__num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);          /* headline figures = purple */
  line-height: 1;
}
.summary-stat__num--text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);            /* category text, not a headline figure */
}
.summary-stat__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

/* ============================================================
   Category groups (customer view)
   ============================================================ */
.groups { display: flex; flex-direction: column; gap: var(--s4); }
.group__head {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  margin-bottom: var(--s1);
}
.group__title { font-size: 1.02rem; }
.group__count { color: var(--text-dim); font-size: 0.85rem; }

/* ============================================================
   Confidence bands — neutral gray ramp
   ============================================================ */
.band {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-transform: capitalize;
}
.band--confirmed { background: var(--band-confirmed-bg); color: var(--band-confirmed-fg); }
.band--likely    { background: var(--band-likely-bg);    color: var(--band-likely-fg); }
.band--possible  { background: var(--band-possible-bg);  color: var(--band-possible-fg); }
.band--weak      { background: var(--band-weak-bg);      color: var(--band-weak-fg); }

/* ============================================================
   Dense data table — shared by all data views
   ============================================================ */
.table-meta { color: var(--text-muted); font-size: 0.88rem; margin-bottom: var(--s2); }
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table thead th {
  background: var(--surface-2);
  text-align: left;
  padding: 11px var(--s2);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--text); }
.data-table thead th.num, .data-table td.num { text-align: right; }
.th-sort-active { color: var(--accent) !important; }
.sort-arrow { color: var(--accent); }

.data-table tbody td {
  padding: 9px var(--s2);        /* dense rows */
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-1); }
.data-table td.cell-customer { font-weight: 600; white-space: nowrap; }
.data-table td.cell-vendor { color: var(--text); font-weight: 600; white-space: nowrap; }
.data-table td.cell-cat { color: var(--text-muted); }
.data-table .cell-sources { color: var(--text-muted); }
.data-table .cell-latest { color: var(--text-dim); font-family: var(--mono); font-size: 0.8rem; white-space: nowrap; }

/* Confidence cell: band primary, % secondary */
.cell-conf { display: inline-flex; align-items: center; gap: var(--s1); white-space: nowrap; }
.cell-pct { font-family: var(--mono); font-size: 0.82rem; color: var(--text-muted); }

/* Source-tier chips */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;           /* tiers are short; full label, no truncation */
}
.chip--empty { color: var(--text-dim); }

/* ============================================================
   Prose / methodology
   ============================================================ */
.prose { max-width: 72ch; margin: 0 auto; }   /* ~70–75 chars per line, centered block */
.prose p { color: var(--text-muted); margin: 0 0 var(--s2); }
.prose h3 { margin: var(--s4) 0 var(--s2); font-size: 1rem; }
.prose strong { color: var(--text); }
.prose__note {
  margin-top: var(--s3);
  padding: var(--s2);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.mini-table { border-collapse: collapse; }
.mini-table td {
  padding: 8px var(--s3) 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.mini-table td.num { font-family: var(--mono); color: var(--text); }
.band-legend { display: flex; gap: var(--s1); flex-wrap: wrap; margin: var(--s2) 0; }

/* ============================================================
   Misc
   ============================================================ */
.empty {
  color: var(--text-dim);
  padding: var(--s4);
  text-align: center;
}
.status {
  margin-top: var(--s3);
  padding: var(--s2);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
