/* ToxIndex Costs — minimalist academic */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --accent-border: #bfdbfe;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────────────────── */
.shell { display: flex; flex-direction: column; min-height: 100vh; }

header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.logo-mark {
  width: 26px; height: 26px;
  background: #1e40af;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}

.logo-mark svg { width: 14px; height: 14px; color: #fff; }

.logo-text { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.logo-sub  { font-size: 12px; color: var(--text-muted); margin-left: 2px; }

.header-right { display: flex; align-items: center; gap: 8px; }

/* Period pills */
.period-bar { display: flex; gap: 4px; }

.period-pill {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.1s;
  user-select: none;
}

.period-pill:hover  { border-color: #9ca3af; color: var(--text); }
.period-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* htmx in-flight indicator */
.period-pill.htmx-request { opacity: 0.6; pointer-events: none; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

main { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 24px; }

/* ── Cards ──────────────────────────────────────────────────── */
.stat-card, .chart-card, .table-card, .label-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card { padding: 16px 18px; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }

/* Chart rows */
.chart-row { margin-bottom: 16px; }

.full-chart .chart-card { padding: 18px 20px; }
.two-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two-charts .chart-card { padding: 18px 20px; }

.chart-title {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.chart-container { position: relative; height: 240px; }
.full-chart .chart-container { height: 200px; }

/* Tables row */
.tables-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.table-card { padding: 18px 20px; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em; padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 7px 10px; font-size: 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

tr:last-child td { border-bottom: none; }
th.r, td.r { text-align: right; }

tbody tr { cursor: pointer; transition: background 0.08s; }
tbody tr:hover td { background: var(--accent-light); }
tbody tr.active-row td { background: #dbeafe; }

/* Bar cells */
.bar-cell { display: flex; align-items: center; gap: 6px; }
.bar-bg { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.bar-pct { font-size: 11px; color: var(--text-faint); width: 38px; text-align: right; flex-shrink: 0; }

/* TI service badges */
.svc-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 500; font-family: ui-monospace, monospace;
  background: #f3f4f6; color: #374151;
}
.svc-crawler { background: #dbeafe; color: #1e40af; }
.svc-stack   { background: #dcfce7; color: #166534; }
.svc-tools   { background: #f3e8ff; color: #6b21a8; }
.svc-flow    { background: #fef3c7; color: #92400e; }
.svc-kiln    { background: #fee2e2; color: #991b1b; }
.svc-yard    { background: #e0f2fe; color: #075985; }
.svc-synth   { background: #f0fdf4; color: #14532d; }

/* Label cards */
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.label-card { padding: 16px; }
.label-card-title { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.label-row { display: flex; align-items: center; gap: 6px; padding: 4px 4px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.label-row:hover { background: var(--accent-light); }
.label-name { flex: 0 0 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; font-size: 11px; }
.label-bar-wrap { flex: 1; }
.label-cost { flex: 0 0 64px; text-align: right; color: var(--text-muted); font-size: 11px; }

/* Section title */
.section-title {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 4px; margin-top: 20px;
}

/* Filter bar */
.filter-bar {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  margin-bottom: 14px;
}

.filter-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 500;
  background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe;
}

.filter-tag button {
  background: none; border: none; cursor: pointer;
  color: inherit; font-size: 13px; line-height: 1; padding: 0 0 0 2px;
  opacity: 0.7;
}
.filter-tag button:hover { opacity: 1; }

.clear-all {
  background: none; border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; font-size: 11px;
  color: var(--text-muted); cursor: pointer;
}
.clear-all:hover { border-color: #9ca3af; color: var(--text); }

/* Empty state */
.empty-msg { text-align: center; padding: 48px; color: var(--text-muted); font-size: 14px; }

/* Responsive */
@media (max-width: 900px) {
  .stats-row    { grid-template-columns: repeat(2, 1fr); }
  .two-charts   { grid-template-columns: 1fr; }
  .tables-row   { grid-template-columns: 1fr; }
  .label-grid   { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  main { padding: 16px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}
