/* =========================================================
   MDL BWA Dashboard — Shared Design System
   Common base for all three mockup variants.
   ========================================================= */

:root {
  /* Colors — neutral palette */
  --c-bg: #fafbfc;
  --c-surface: #ffffff;
  --c-surface-2: #f4f6f8;
  --c-border: #e5e7eb;
  --c-border-strong: #d1d5db;
  --c-text: #0f172a;
  --c-text-muted: #64748b;
  --c-text-subtle: #94a3b8;

  /* Status / direction */
  --c-pos: #059669;           /* green, positive / growth */
  --c-pos-bg: #ecfdf5;
  --c-pos-border: #a7f3d0;
  --c-neg: #dc2626;            /* red, negative */
  --c-neg-bg: #fef2f2;
  --c-neg-border: #fecaca;
  --c-warn: #d97706;           /* amber, caution */
  --c-warn-bg: #fffbeb;
  --c-info: #2563eb;           /* blue */
  --c-info-bg: #eff6ff;

  /* Brand-ish accent */
  --c-accent: #0f172a;         /* dark charcoal — print-safe */
  --c-accent-2: #1e40af;       /* steel blue */

  /* Location colors (stable, consistent across charts) */
  --loc-regensburg: #2563eb;
  --loc-senden: #059669;
  --loc-muehldorf: #d97706;
  --loc-ingolstadt: #db2777;
  --loc-nuernberg: #7c3aed;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text",
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --fs-12: 0.75rem;
  --fs-13: 0.8125rem;
  --fs-14: 0.875rem;
  --fs-16: 1rem;
  --fs-18: 1.125rem;
  --fs-20: 1.25rem;
  --fs-24: 1.5rem;
  --fs-28: 1.75rem;
  --fs-36: 2.25rem;
  --fs-48: 3rem;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Shadows */
  --sh-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-md: 0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-lg: 0 8px 24px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);

  /* Transitions */
  --t-fast: 120ms ease;
  --t-med: 220ms ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6, p { margin: 0; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }

/* ---------- Typography utilities ---------- */
.txt-xs { font-size: var(--fs-12); }
.txt-sm { font-size: var(--fs-13); }
.txt-base { font-size: var(--fs-14); }
.txt-md { font-size: var(--fs-16); }
.txt-lg { font-size: var(--fs-18); }
.txt-xl { font-size: var(--fs-20); }
.txt-2xl { font-size: var(--fs-24); }
.txt-3xl { font-size: var(--fs-28); }
.txt-4xl { font-size: var(--fs-36); }

.fw-regular { font-weight: 400; }
.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }

.t-muted { color: var(--c-text-muted); }
.t-subtle { color: var(--c-text-subtle); }
.t-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.t-num { font-variant-numeric: tabular-nums; }
.t-uc { text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Layout helpers ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}
@media (max-width: 640px) {
  .container { padding: 0 var(--sp-4); }
}

.stack-1 > * + * { margin-top: var(--sp-1); }
.stack-2 > * + * { margin-top: var(--sp-2); }
.stack-3 > * + * { margin-top: var(--sp-3); }
.stack-4 > * + * { margin-top: var(--sp-4); }
.stack-6 > * + * { margin-top: var(--sp-6); }
.stack-8 > * + * { margin-top: var(--sp-8); }

.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-tight { display: flex; align-items: center; gap: var(--sp-2); }
.row-wide { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.flex-1 { flex: 1 1 auto; }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (max-width: 960px) {
  .grid-4, .grid-5, .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: 1fr; }
}

/* ---------- Card ---------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--sh-sm);
}
.card--pad-lg { padding: var(--sp-6); }
.card--pad-sm { padding: var(--sp-4); }
.card--flat { box-shadow: none; }
.card--muted { background: var(--c-surface-2); }

.card h3 {
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-2);
}

/* ---------- Buttons & toggles ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 8px 14px;
  font-size: var(--fs-13);
  font-weight: 500;
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn:hover { background: var(--c-surface-2); border-color: var(--c-border-strong); }
.btn--primary { background: var(--c-accent); color: white; border-color: var(--c-accent); }
.btn--primary:hover { background: #1f2937; border-color: #1f2937; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--sm { padding: 6px 10px; font-size: var(--fs-12); }

.segment {
  display: inline-flex;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.segment button {
  font-family: inherit;
  padding: 6px 12px;
  font-size: var(--fs-13);
  font-weight: 500;
  border: 0;
  background: transparent;
  color: var(--c-text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.segment button.is-active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--sh-sm);
}
.segment button:not(.is-active):hover { color: var(--c-text); }

/* ---------- Chip / badge ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--fs-12);
  font-weight: 500;
  border-radius: var(--r-full);
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border);
  white-space: nowrap;
}
.chip--pos { background: var(--c-pos-bg); color: var(--c-pos); border-color: var(--c-pos-border); }
.chip--neg { background: var(--c-neg-bg); color: var(--c-neg); border-color: var(--c-neg-border); }
.chip--warn { background: var(--c-warn-bg); color: var(--c-warn); border-color: #fde68a; }
.chip--info { background: var(--c-info-bg); color: var(--c-info); border-color: #bfdbfe; }

/* ---------- Delta indicator ---------- */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-13);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.delta--pos { color: var(--c-pos); }
.delta--neg { color: var(--c-neg); }
.delta--neutral { color: var(--c-text-muted); }
.delta svg { width: 12px; height: 12px; }

/* ---------- Info / tooltip ---------- */
.infobox {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--c-info-bg);
  border: 1px solid #bfdbfe;
  border-radius: var(--r-md);
  color: #1e3a8a;
  font-size: var(--fs-13);
  line-height: 1.55;
}
.infobox--warn { background: var(--c-warn-bg); border-color: #fde68a; color: #7c2d12; }
.infobox__icon { flex: 0 0 auto; font-size: 16px; }
.infobox__body { flex: 1 1 auto; }
.infobox strong { font-weight: 600; }

/* ---------- Tables ---------- */
.tbl {
  width: 100%;
  font-size: var(--fs-13);
  font-variant-numeric: tabular-nums;
}
.tbl th, .tbl td {
  padding: var(--sp-3) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--c-border);
}
.tbl th {
  font-weight: 500;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: var(--fs-12);
}
.tbl td.num, .tbl th.num { text-align: right; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--c-surface-2); }

/* ---------- Global header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--c-border);
}
.app-header__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .app-header__inner { padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); }
}
.app-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 600;
  font-size: var(--fs-16);
}
.app-brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--c-accent);
  color: white;
  font-weight: 700;
  font-size: var(--fs-13);
  letter-spacing: -0.02em;
}
.app-nav { display: flex; gap: var(--sp-1); margin-left: auto; }
.app-nav a {
  padding: 6px 10px;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--c-text-muted);
  border-radius: var(--r-md);
  transition: background var(--t-fast), color var(--t-fast);
}
.app-nav a:hover { background: var(--c-surface-2); color: var(--c-text); }
.app-nav a.is-active { background: var(--c-surface-2); color: var(--c-text); }

/* ---------- Period picker ---------- */
.period-picker {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 6px 4px 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: var(--fs-13);
}
.period-picker select {
  font-family: inherit;
  font-size: var(--fs-13);
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: var(--c-text);
  cursor: pointer;
}

/* ---------- Sparkline ---------- */
.sparkline {
  width: 100%;
  height: 36px;
  overflow: visible;
}

/* ---------- Divider ---------- */
.divider {
  height: 1px;
  background: var(--c-border);
  margin: var(--sp-6) 0;
}

/* ---------- Skeletons / empty ---------- */
.hint {
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface-2);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-13);
  color: var(--c-text-muted);
}

/* ---------- Mobile helpers ---------- */
.hide-mobile { display: initial; }
.show-mobile { display: none; }
@media (max-width: 640px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: initial; }
}

/* ---------- Page sections ---------- */
.page { padding: var(--sp-6) 0 var(--sp-16); }
.page-section { margin-top: var(--sp-8); }
.page-section:first-child { margin-top: var(--sp-4); }
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.section-title h2 {
  font-size: var(--fs-18);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.section-title p {
  font-size: var(--fs-13);
  color: var(--c-text-muted);
}

/* ---------- Interpolated badge ---------- */
.badge-interpolated {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-warn);
  background: var(--c-warn-bg);
  border: 1px solid #fde68a;
  border-radius: var(--r-sm);
}
