:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.2vw, 0.9375rem);
  --text-base: clamp(1rem, 0.95rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.1vw, 2.125rem);

  --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;

  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --content: 1180px;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* DARK — domyślny „performance lab” */
:root,
[data-theme='dark'] {
  --bg: #0b0f11;
  --surface: #12181b;
  --surface-2: #171f22;
  --surface-3: #1e282c;
  --border: #26343a;
  --divider: #1d272b;
  --text: #e7eeef;
  --text-muted: #90a1a6;
  --text-faint: #5f7278;
  --primary: #2fd4b0;
  --primary-soft: rgba(47, 212, 176, 0.14);
  --fat: #ff7a66;
  --fat-soft: rgba(255, 122, 102, 0.16);
  --lean: #4ea8ff;
  --lean-soft: rgba(78, 168, 255, 0.16);
  --warn: #f0b429;
  --warn-soft: rgba(240, 180, 41, 0.16);
  --danger: #f2557a;
  --grid: rgba(255, 255, 255, 0.06);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

[data-theme='light'] {
  --bg: #f4f6f6;
  --surface: #ffffff;
  --surface-2: #f8fafa;
  --surface-3: #eef2f3;
  --border: #d9e1e3;
  --divider: #e6eced;
  --text: #10181b;
  --text-muted: #5a6a70;
  --text-faint: #8b9aa0;
  --primary: #0f8a74;
  --primary-soft: rgba(15, 138, 116, 0.1);
  --fat: #d0492f;
  --fat-soft: rgba(208, 73, 47, 0.1);
  --lean: #1f6fbe;
  --lean-soft: rgba(31, 111, 190, 0.1);
  --warn: #a9740b;
  --warn-soft: rgba(169, 116, 11, 0.12);
  --danger: #bd2c50;
  --grid: rgba(16, 24, 27, 0.07);
  --shadow: 0 12px 32px rgba(16, 24, 27, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  font-variant-numeric: tabular-nums lining-nums;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 12% -8%, var(--primary-soft), transparent 70%),
    radial-gradient(700px 380px at 92% -6%, var(--lean-soft), transparent 70%);
  z-index: 0;
}
main {
  position: relative;
  z-index: 1;
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 var(--space-6) var(--space-16);
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
canvas,
svg {
  display: block;
  max-width: 100%;
}
button {
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}
a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.muted {
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.eyebrow {
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
}

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--divider);
}
.topbar__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);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.brand__mark {
  width: 30px;
  height: 30px;
  color: var(--primary);
  flex: none;
}
.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand__text strong {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  letter-spacing: 0.18em;
}
.brand__text span {
  font-size: var(--text-xs);
  color: var(--text-faint);
}
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
}
.chip--live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 var(--primary);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in oklab, var(--primary) 60%, transparent);
  }
  70% {
    box-shadow: 0 0 0 7px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}
.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  font-size: var(--text-sm);
  font-weight: 500;
  background: var(--surface);
}
.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.btn--icon {
  padding: 0.4rem;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
}

/* HERO */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-8);
  flex-wrap: wrap;
  padding: var(--space-12) 0 var(--space-8);
  border-bottom: 1px solid var(--divider);
}
.hero h1 {
  font-size: var(--text-xl);
  margin: var(--space-2) 0 var(--space-5);
}
.hero__meta {
  list-style: none;
  display: flex;
  gap: var(--space-8);
  flex-wrap: wrap;
}
.hero__meta li {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hero__meta span {
  font-size: var(--text-xs);
  color: var(--text-faint);
}
.hero__meta b {
  font-size: var(--text-sm);
  font-weight: 600;
}
.hero__latest {
  text-align: right;
}
.badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
}
.badge--new {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid color-mix(in oklab, var(--primary) 35%, transparent);
}
.hero__date {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin-top: var(--space-3);
}
.hero__span {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* VERDICT */
.verdict {
  margin-top: var(--space-8);
  background: linear-gradient(140deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-8);
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr) minmax(220px, auto);
  gap: var(--space-8);
  align-items: center;
}
.verdict__ring {
  position: relative;
  width: 148px;
  height: 148px;
}
.verdict__ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring__track {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 10;
}
.ring__value {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: stroke-dashoffset 1s cubic-bezier(0.16, 1, 0.3, 1);
}
.verdict__ringlabel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.verdict__ringlabel b {
  font-family: var(--font-display);
  font-size: 1.9rem;
  display: block;
  line-height: 1;
}
.verdict__ringlabel span {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.verdict__copy h2 {
  font-size: var(--text-lg);
  margin: var(--space-2) 0 var(--space-3);
}
.verdict__copy p:last-child {
  color: var(--text-muted);
  font-size: var(--text-sm);
  max-width: 56ch;
}
.verdict__stats {
  display: grid;
  gap: var(--space-3);
  padding-left: var(--space-8);
  border-left: 1px solid var(--divider);
}
.verdict__stats div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-6);
  align-items: baseline;
}
.verdict__stats dt {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.verdict__stats dd {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
}

/* SECTIONS */
.section {
  margin-top: var(--space-16);
}
.section__head {
  margin-bottom: var(--space-5);
}
.section__head h2 {
  font-size: var(--text-lg);
}
.section__head p {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}
.grid {
  display: grid;
  gap: var(--space-5);
}
.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.card__head h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.legend {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot--weight {
  background: var(--text-muted);
}
.dot--fat {
  background: var(--fat);
}
.dot--lean {
  background: var(--lean);
}
.dot + .dot {
  margin-left: var(--space-3);
}
.chartbox {
  height: 300px;
  position: relative;
}
.chartbox--sm {
  height: 200px;
}

/* KPI */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--space-4);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent, var(--border));
}
.kpi__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
.kpi__value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}
.kpi__value small {
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-weight: 500;
}
.kpi__deltas {
  display: flex;
  gap: var(--space-4);
  font-size: var(--text-xs);
  margin-top: auto;
  padding-top: var(--space-3);
}
.kpi__deltas span {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.kpi__deltas em {
  font-style: normal;
  color: var(--text-faint);
  font-size: 0.6875rem;
  letter-spacing: 0.03em;
}
.kpi__deltas b {
  font-weight: 600;
}
.good {
  color: var(--primary);
}
.bad {
  color: var(--danger);
}
.flat {
  color: var(--text-faint);
}
.kpi__spark {
  position: relative;
  height: 34px;
  width: 100%;
}
.kpi__spark canvas {
  position: absolute;
  inset: 0;
}

/* QUALITY GRID */
.qgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
}
.qcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}
.qcard__title {
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-display);
}
.qcard__sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}
.stackbar {
  display: flex;
  height: 12px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--surface-3);
}
.stackbar i {
  display: block;
  height: 100%;
}
.stackbar i.fat {
  background: var(--fat);
}
.stackbar i.lean {
  background: var(--lean);
}
.qcard__rows {
  margin-top: var(--space-4);
  display: grid;
  gap: var(--space-2);
  font-size: var(--text-xs);
}
.qcard__rows div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  color: var(--text-muted);
}
.qcard__rows b {
  color: var(--text);
  font-weight: 600;
}
.tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-3);
}
.tag--ok {
  background: var(--primary-soft);
  color: var(--primary);
}
.tag--warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.tag--bad {
  background: var(--fat-soft);
  color: var(--fat);
}

/* BULLETS */
.bullets {
  display: grid;
  gap: var(--space-6);
}
.bullet {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 110px;
  gap: var(--space-5);
  align-items: center;
}
.bullet__label b {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
}
.bullet__label span {
  font-size: var(--text-xs);
  color: var(--text-faint);
}
.bullet__track {
  position: relative;
  height: 26px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.bullet__norm {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--primary-soft);
  border-left: 1px solid color-mix(in oklab, var(--primary) 45%, transparent);
  border-right: 1px solid color-mix(in oklab, var(--primary) 45%, transparent);
}
.bullet__fill {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
}
.bullet__prev {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 2px;
  background: var(--text-faint);
}
.bullet__now {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 2px;
}
.bullet__val {
  text-align: right;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
}
.bullet__val span {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* SEGMENTS */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.seg__item {
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.seg__item--wide {
  grid-column: 1 / -1;
}
.seg__name {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.seg__val {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
}
.seg__val small {
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-weight: 500;
}
.seg__delta {
  font-size: var(--text-xs);
  font-weight: 600;
}
.symmetry {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-top: 1px solid var(--divider);
  padding-top: var(--space-3);
}

/* ECW */
.ecw {
  margin-top: var(--space-5);
  border-top: 1px solid var(--divider);
  padding-top: var(--space-4);
  display: grid;
  gap: var(--space-2);
  font-size: var(--text-xs);
}
.ecw div {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
}
.ecw b {
  color: var(--text);
  font-weight: 600;
}

/* GOAL */
.card--goal {
  background: linear-gradient(120deg, var(--surface-2), var(--surface));
}
.goal__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-6);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}
.goal__head h2 {
  font-size: var(--text-lg);
}
.goal__head p {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.goal__bar {
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  position: relative;
  overflow: hidden;
}
.goal__bar i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--lean), var(--primary));
  border-radius: var(--radius-full);
  transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}
.goal__scale {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.goal__scale b {
  color: var(--text);
  display: block;
  font-family: var(--font-display);
}
.goal__eta {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--divider);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.goal__eta b {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-base);
  color: var(--text);
}

/* NOTES */
.notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
}
.note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent, var(--primary));
  border-radius: var(--radius-md);
  padding: var(--space-5);
}
.note h3 {
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}
.note p {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* FOOT */
.foot {
  margin-top: var(--space-16);
  padding-top: var(--space-6);
  border-top: 1px solid var(--divider);
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: grid;
  gap: var(--space-2);
}

@media (max-width: 900px) {
  .verdict {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .verdict__stats {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--divider);
    padding-top: var(--space-4);
  }
  .bullet {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  .bullet__val {
    text-align: left;
  }
  .hero__latest {
    text-align: left;
  }
}

@media print {
  body::before,
  .topbar {
    display: none !important;
  }
  main {
    max-width: none;
    padding: 0;
  }
  .hero {
    padding-top: 0;
  }
  .section {
    margin-top: var(--space-10);
  }
  .card,
  .verdict,
  .kpi,
  .qcard,
  .note,
  .bullet,
  .seg__item,
  .section__head {
    break-inside: avoid;
  }
  .section,
  .verdict,
  .foot {
    break-inside: avoid-page;
  }
  .kpis {
    grid-template-columns: repeat(4, 1fr);
  }
  .grid--2 {
    grid-template-columns: 1fr 1fr;
  }
  .qgrid,
  .notes {
    grid-template-columns: repeat(3, 1fr);
  }
  .chartbox {
    height: 240px;
  }
  .chartbox--sm {
    height: 170px;
  }
  .kpi__value {
    font-size: 1.5rem;
  }
  .card,
  .kpi,
  .qcard,
  .note,
  .verdict {
    box-shadow: none;
  }
  .print-only {
    display: block !important;
  }
}

.print-only {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
