/* Configuration: theme variables */
:root {
  --bg: 210 40% 98%;
  --surface-1: 0 0% 100%;
  --surface-2: 210 40% 96%;
  --surface-3: 210 40% 94%;
  --border: 214 32% 91%;

  --text: 222 47% 11%;
  --text-2: 215 25% 27%;
  --text-3: 215 16% 47%;

  --accent: 186 100% 40%;
  --accent-600: 186 100% 30%;
  --magenta: 334 100% 45%;
  --purple: 278 100% 47%;

  --success: 142 72% 45%;
  --warning: 42 96% 50%;
  --error: 0 84% 60%;
  --info: 199 92% 60%;

  /* Chart palette tokens */
  --chart-1-hex: #3B82F6;
  --chart-2-hex: #EF4444;
  --chart-3-hex: #10B981;
  --chart-4-hex: #F59E0B;
  --chart-5-hex: #8B5CF6;
  --chart-6-hex: #EC4899;
  --chart-7-hex: #06B6D4;
  --chart-8-hex: #84CC16;
}

[data-theme="dark"] {
  --bg: 220 43% 8%;
  --surface-1: 222 47% 13%;
  --surface-2: 220 28% 12%;
  --surface-3: 215 28% 17%;
  --border: 214 30% 20%;

  --text: 210 20% 92%;
  --text-2: 215 14% 63%;
  --text-3: 220 9% 46%;

  --accent: 186 100% 50%;
  --accent-600: 186 100% 42%;
  --magenta: 334 100% 55%;
  --purple: 278 100% 57%;
}

/* Base styles */
body {
  background: hsl(var(--bg));
  color: hsl(var(--text));
  font-family: sans-serif;
}

/* Color utilities */
.text-primary { color: hsl(var(--text)); }
.text-secondary { color: hsl(var(--text-2)); }
.text-tertiary { color: hsl(var(--text-3)); }
.text-accent { color: hsl(var(--accent)); }

.bg-background { background-color: hsl(var(--bg)); }
.bg-surface { background-color: hsl(var(--surface-1)); }
.border-default { border-color: hsl(var(--border)); }

/* Wildcard fallbacks for legacy classes */
[class*="text-gray"] { color: hsl(var(--text)); }
[class*="text-blue"] { color: hsl(var(--accent)); }
[class*="text-red"] { color: hsl(var(--accent)); }
[class*="bg-white"], [class*="bg-gray"] { background-color: hsl(var(--surface-1)); }
[class*="border-gray"] { border-color: hsl(var(--border)); }

/* Simple typography utilities */
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }

/* Responsive typography utilities */
.text-responsive-xl  { font-size: clamp(1rem, 1vw + 1rem, 1.25rem); }
.text-responsive-2xl { font-size: clamp(1.25rem, 1vw + 1.25rem, 1.875rem); }
.text-responsive-3xl { font-size: clamp(1.5rem, 1.5vw + 1.5rem, 2.25rem); }

/* Spacing utilities */
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.pt-6 { padding-top: 1.5rem; }
.pb-6 { padding-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mb-12 { margin-bottom: 3rem; }
.mt-10 { margin-top: 2.5rem; }
.my-8 { margin-top: 2rem; margin-bottom: 2rem; }

/* Layout utilities */
.flex { display: flex; }
.items-center { align-items: center; }
.grid { display: grid; }
.gap-8 { gap: 2rem; }
.w-full { width: 100%; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-xl { border-radius: 0.75rem; }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); }
.border { border-width: 1px; }
.border-4 { border-width: 4px; }
.border-double { border-style: double; }
.underline-on-hover:hover { text-decoration: underline; }

/* ===== Dark Theme UI additions ===== */
.btn-danger {
  background: hsl(var(--error));
  color: white;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  transition: transform .2s ease, filter .2s ease;
  box-shadow: var(--shadow-1);
}
.btn-danger:hover { transform: translateY(-2px); filter: brightness(1.05); }

.badge {
  display:inline-flex; align-items:center; gap:.375rem;
  font-size:.75rem; padding:.25rem .5rem; border-radius:.5rem;
  border:1px solid hsl(var(--border)); background:hsl(var(--surface-2));
  color:hsl(var(--text-2));
}
.badge.positive { color:hsl(var(--success)); border-color:hsl(var(--success) / .35); }
.badge.negative { color:hsl(var(--error)); border-color:hsl(var(--error) / .35); }
.badge.info { color:hsl(var(--info)); border-color:hsl(var(--info) / .35); }

.kpi {
  background: hsl(var(--surface-1));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-1);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: hsl(var(--accent) / .45); }
.kpi .kpi-label { color:hsl(var(--text)); font-size:1.2rem; font-weight:600;}
.kpi .kpi-value { font-weight:700; font-size:1.5rem; color:hsl(var(--text)); }
.kpi .kpi-delta.positive { color:hsl(var(--success)); }
.kpi .kpi-delta.negative { color:hsl(var(--error)); }
.kpi .kpi-delta.neutral  { color:hsl(var(--text-3)); }
/* ---------- Semantic text ---------- */
.text-primary  { color: hsl(var(--text)); }
.text-secondary{ color: hsl(var(--text-2)); }
.text-muted    { color: hsl(var(--text-3)); }
.text-accent   { color: hsl(var(--accent)); }

/* Status text; switch --error to --magenta later if you want brand-fuchsia */
.text-positive { color: hsl(var(--success)); }
.text-warning  { color: hsl(var(--warning)); }
.text-negative { color: hsl(var(--error)); }
.text-fuchsia  { color: hsl(var(--magenta)); } /* optional brand variant */

/* ---------- Surfaces & cards ---------- */
.surface-1 { background-color: hsl(var(--surface-1)); }
.surface-2 { background-color: hsl(var(--surface-2)); }
.surface-3 { background-color: hsl(var(--surface-3)); }
.card      { background: hsl(var(--surface-1)); border: 1px solid hsl(var(--border)); border-radius: 0.75rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; border-radius: 0.6rem; padding: 0.5rem 0.75rem;
  transition: filter .2s; border: 1px solid transparent; line-height: 1;
}
.btn:focus { outline: 2px solid hsl(var(--accent-600)); outline-offset: 2px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Button semantics tied to tokens */
.btn-primary  { background: hsl(var(--accent)); color: #000; }   /* accent typically readable on light */
.btn-primary:hover { filter: brightness(.95); }
.btn-danger   { background: hsl(var(--error)); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-success  { background: hsl(var(--success)); color: #fff; }
.btn-warning  { background: hsl(var(--warning)); color: #000; }
.btn-secondary{ background: hsl(var(--surface-2)); color: hsl(var(--text)); border-color: hsl(var(--border)); }
.btn-secondary:hover { filter: brightness(.95); }
.btn-muted   { background: hsl(var(--surface-2)); color: hsl(var(--text-3)); border-color: hsl(var(--border)); }
.btn-muted:hover { filter: brightness(.95); }
.btn-ghost    { background: transparent; color: hsl(var(--text)); border-color: hsl(var(--border)); }
.icon-btn     {
  width: 1.5rem;
  height: 1.5rem;
  font-size: .875rem;
  line-height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-subtle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  background-color: hsl(var(--surface-2));
  color: hsl(var(--info));
  border: 1px solid hsl(var(--border));
  transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-subtle:hover {
  background-color: hsl(var(--surface-3));
  color: hsl(var(--info) / 0.8);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .375rem;
  font-weight: 600; font-size: .75rem; padding: .125rem .5rem; border-radius: 999px;
  border: 1px solid transparent;
}
.badge-good { background: color-mix(in hsl, hsl(var(--success)) 15%, hsl(var(--surface-1))); color: hsl(var(--success)); border-color: color-mix(in hsl, hsl(var(--success)) 30%, hsl(var(--surface-1))); }
.badge-warn { background: color-mix(in hsl, hsl(var(--warning)) 15%, hsl(var(--surface-1))); color: hsl(var(--warning)); border-color: color-mix(in hsl, hsl(var(--warning)) 30%, hsl(var(--surface-1))); }
.badge-bad  { background: color-mix(in hsl, hsl(var(--error)) 15%, hsl(var(--surface-1))); color: hsl(var(--error)); border-color: color-mix(in hsl, hsl(var(--error)) 30%, hsl(var(--surface-1))); }

/* ---------- Progress Bars ---------- */
.progress { height: .5rem; background: hsl(var(--surface-3)); border-radius: .5rem; overflow: hidden; }
.progress > .fill { height: 100%; }
.fill.good { background: hsl(var(--success)); }
.fill.warn { background: hsl(var(--warning)); }
.fill.bad  { background: hsl(var(--error)); }
/* Horizontal KPI bars (0 → 150% of target) */
.hbar { position: relative; height: 0.75rem; background: hsl(var(--surface-3)); border-radius: 0.5rem; overflow: hidden; }
.hbar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: hsl(var(--accent)); }
.hbar-marker { position: absolute; top: -0.125rem; bottom: -0.125rem; width: 2px; background: hsl(var(--border)); opacity: .9; }

/* Fill tinting */
.hbar-fill.good { background: hsl(var(--success)); }
.hbar-fill.warn { background: hsl(var(--warning)); }
.hbar-fill.bad  { background: hsl(var(--error)); }

/* KPI row layout */
.kpi-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .5rem .75rem; }
.kpi-row .meta { display:flex; gap:.75rem; align-items:center; font-size:.85rem; }
.kpi-row .meta .label { font-weight:600; min-width:6rem; }
.kpi-row .meta .current { color:hsl(var(--text)); font-weight:600; }
.kpi-row .meta .target  { color:hsl(var(--text-2)); }
.kpi-row .meta .remain  { color:hsl(var(--text-3)); }
.kpi-row .meta .over    { font-size:.75rem; color:hsl(var(--error)); }

/* Table helpers */
.divide-y > * + * { border-top:1px solid hsl(var(--border)); }
.hover-surface-2:hover { background-color:hsl(var(--surface-2)); }
