:root {
  --surface-1: #fcfcfb;
  --page: #f2f4f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --good: #0ca30c;
  --critical: #d03b3b;
  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-8: #e34948; /* red */
  --navy: #12294d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}

.page { max-width: 1440px; margin: 0 auto; padding: 20px 24px 48px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 22px; margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 9px; background: var(--navy);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px;
}
.brand h1 { font-size: 19px; margin: 0; letter-spacing: .3px; }
.brand p { margin: 2px 0 0; color: var(--text-secondary); font-size: 12.5px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
select, input[type=date] {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 13px;
  background: var(--surface-1); color: var(--text-primary); width: 100%; margin-top: 6px;
}
.btn {
  border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; font-weight: 600;
  background: var(--navy); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn.secondary { background: var(--page); color: var(--text-primary); border: 1px solid var(--border); }
.meta-line { font-size: 12px; color: var(--muted); text-align: right; }

.nav-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.nav-tabs a {
  padding: 9px 16px; border-radius: 8px; background: var(--surface-1); border: 1px solid var(--border);
  text-decoration: none; color: var(--text-secondary); font-weight: 600; font-size: 13px;
}
.nav-tabs a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
.kpi {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
}
.kpi .label { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.kpi .value { font-size: 24px; font-weight: 700; margin: 6px 0 4px; }
.kpi .delta { font-size: 12px; font-weight: 600; }
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--critical); }
.kpi .delta.flat { color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 1000px) { .grid-2, .grid-3, .grid-stats { grid-template-columns: 1fr; } }
/* Grid items default to min-width:auto (their content's intrinsic size) --
   a <canvas> used directly as a grid child (no wrapping .card) can hold that
   track open at its native pixel size, starving the sibling column instead
   of sharing space evenly. */
.grid-2 > canvas, .grid-3 > canvas { min-width: 0; max-width: 100%; }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
  overflow-x: auto;
}
.card h3 {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-secondary);
  margin: 0 0 14px;
}
.card canvas { max-height: 260px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--grid); }
td { white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; white-space: normal; }
tr.total td { font-weight: 700; border-top: 2px solid var(--baseline); border-bottom: none; }
.num-good { color: var(--good); font-weight: 700; }

.funnel-stage { margin-bottom: 8px; }
.funnel-stage .bar-row { display: flex; align-items: center; gap: 10px; }
.funnel-stage .bar-track { flex: 1; background: var(--page); border-radius: 6px; height: 26px; overflow: hidden; }
.funnel-stage .bar-fill { height: 100%; background: var(--series-1); border-radius: 6px; min-width: 3px; }
.funnel-stage .stage-label { width: 150px; flex-shrink: 0; font-size: 12.5px; color: var(--text-secondary); }
.funnel-stage .stage-value {
  width: 150px; flex-shrink: 0; font-size: 12.5px; font-weight: 700; color: var(--text-primary); white-space: nowrap;
}

.stat-box { text-align: center; }
.stat-box .n { font-size: 26px; font-weight: 700; }
.stat-box .l { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.gauge-wrap { text-align: center; padding: 6px 0 0; }
.gauge-pct { font-size: 30px; font-weight: 700; color: var(--series-1); }
.gauge-track { background: var(--page); border-radius: 8px; height: 14px; overflow: hidden; margin: 10px 0; }
.gauge-fill { background: var(--series-3); height: 100%; border-radius: 8px; }
.gauge-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-secondary); }

.insights { list-style: none; margin: 0; padding: 0; }
.insights li { display: flex; gap: 8px; padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--grid); }
.insights li:last-child { border-bottom: none; }
.insights .ok { color: var(--good); }

.info-box {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px;
  font-size: 12px; color: var(--text-secondary); margin-top: 14px; display: flex; justify-content: space-between; gap: 12px;
}
.info-box ul { margin: 6px 0 0; padding-left: 18px; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--page); color: var(--text-secondary); font-weight: 600; }

.layout { display: flex; align-items: flex-start; gap: 20px; }
.sidebar {
  flex: 0 0 268px; width: 268px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto;
}
.main-content { flex: 1; min-width: 0; }
@media (max-width: 980px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: 1 1 auto; position: static; max-height: none; }
}

.sidebar-block h4 {
  margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.sidebar-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sidebar-block-head h4 { margin: 0; }
.clear-link { font-size: 11.5px; color: var(--series-1); text-decoration: none; font-weight: 600; }

.seg-vertical { display: flex; flex-direction: column; gap: 3px; }
.seg-vertical a {
  padding: 7px 10px; border-radius: 7px; text-decoration: none; color: var(--text-secondary);
  font-size: 13px; font-weight: 600; background: var(--page);
}
.seg-vertical a.active { background: var(--series-1); color: #fff; }

.sidebar-filter { border-top: 1px solid var(--grid); padding-top: 8px; margin-top: 8px; }
.sidebar-filter:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.sidebar-filter summary {
  cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 6px; list-style: none;
}
.sidebar-filter summary::-webkit-details-marker { display: none; }
.sidebar-filter summary::before { content: '▸'; color: var(--muted); font-size: 11px; }
.sidebar-filter[open] summary::before { content: '▾'; }
.sidebar-filter-actions { font-size: 11px; margin: 6px 0; }
.sidebar-filter-actions a { color: var(--series-1); text-decoration: none; }
.sidebar-filter-list { max-height: 180px; overflow-y: auto; }
.sidebar-filter-list label {
  display: block; font-size: 12.5px; padding: 3px 0; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-filter-list input { margin-right: 6px; }
.muted-note { font-size: 12px; color: var(--muted); margin: 4px 0; }

.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .report-grid { grid-template-columns: 1fr; } }
.report-card {
  display: block; background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; text-decoration: none; color: var(--text-primary); transition: box-shadow .15s, transform .15s;
}
.report-card:not(.disabled):hover { box-shadow: 0 10px 28px rgba(11,11,11,0.10); transform: translateY(-2px); }
.report-card.disabled { opacity: .6; cursor: default; }
.report-icon { font-size: 30px; margin-bottom: 10px; }
.report-card h3 { margin: 0 0 8px; font-size: 16px; }
.report-card p { margin: 0 0 14px; font-size: 13px; color: var(--text-secondary); line-height: 1.5; min-height: 40px; }
.report-cta { font-size: 13px; font-weight: 700; color: var(--series-1); }

.pill-toggle { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; margin-bottom: 16px; }
.pill-toggle a { padding: 7px 14px; border-radius: 6px; text-decoration: none; color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.pill-toggle a.active { background: var(--series-1); color: #fff; }

.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-card {
  display: block; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 18px; text-decoration: none; color: var(--text-primary); transition: box-shadow .15s;
}
.news-card:hover { box-shadow: 0 6px 18px rgba(11,11,11,0.08); }
.news-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.news-source { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.news-date { font-size: 12px; color: var(--muted); margin-left: auto; }
.news-card h3 { margin: 0 0 6px; font-size: 15px; }
.news-card p { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .card, .kpi, .topbar, .info-box { box-shadow: none !important; }
  .page { max-width: 100%; padding: 10px; }
}

/* Raport handlowca (standalone page, no sidebar) */
.hr-topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 22px; margin-bottom: 14px;
}
.hr-brand { display: flex; align-items: center; gap: 10px; }
.hr-brand .hr-logo { font-size: 22px; }
.hr-brand h1 { font-size: 19px; margin: 0; letter-spacing: .3px; }
.hr-header-controls { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.hr-field label {
  display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; color: var(--muted);
  text-transform: uppercase; margin-bottom: 4px;
}
.hr-field { display: flex; flex-direction: column; }
.hr-field select, .hr-field input[type=date] { width: auto; min-width: 150px; margin-top: 0; }

.hr-period-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 14px; margin-bottom: 14px;
}
.hr-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.hr-seg a {
  padding: 8px 14px; border-radius: 8px; text-decoration: none; color: var(--text-secondary);
  font-size: 13px; font-weight: 600;
}
.hr-seg a.active { background: var(--series-1); color: #fff; }
.hr-daterange { font-size: 13px; color: var(--text-secondary); font-weight: 600; }

.section-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 14px;
}
.section-card > h2 { font-size: 14px; font-weight: 700; margin: 0 0 16px; color: var(--text-primary); }

.icon-kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 1100px) { .icon-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.icon-kpi { border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
.icon-badge {
  width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin: 0 auto 10px;
}
.icon-badge.blue { background: #e3edfa; }
.icon-badge.green { background: #e1f6ea; }
.icon-badge.red { background: #fbe7e7; }
.icon-badge.orange { background: #fdece0; }
.icon-badge.purple { background: #ece8f8; }
.icon-kpi .label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-transform: uppercase;
}
.icon-kpi .value { font-size: 24px; font-weight: 700; margin: 8px 0 2px; }
.icon-kpi .sub { font-size: 12px; color: var(--good); font-weight: 600; }

.wide-tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .wide-tile-grid { grid-template-columns: 1fr; } }
.wide-tile {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
}
.wide-tile .icon-badge { margin: 0; flex-shrink: 0; }
.wide-tile .label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-transform: uppercase;
}
.wide-tile .value { font-size: 22px; font-weight: 700; margin: 4px 0 2px; }
.wide-tile .sub { font-size: 12px; color: var(--text-secondary); }

.funnel-chart { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 0; }
.funnel-seg {
  height: 48px; display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: 12.5px; font-weight: 700; border-radius: 6px; text-align: center; padding: 0 8px;
}

.reason-bars .reason-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.reason-bars .reason-row:last-child { margin-bottom: 0; }
.reason-bars .reason-label { width: 160px; flex-shrink: 0; font-size: 12.5px; color: var(--text-secondary); }
.reason-bars .reason-track { flex: 1; background: var(--page); border-radius: 6px; height: 22px; overflow: hidden; }
.reason-bars .reason-fill { height: 100%; background: var(--critical); border-radius: 6px; min-width: 3px; }
.reason-bars .reason-pct { width: 36px; text-align: right; font-size: 12.5px; font-weight: 700; }
