:root {
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #f8f9fb; --text: #16181d; --muted: #5f6673; --line: #e4e7ec;
  --side-bg: #111827; --side-text: #c9d1dd; --side-muted: #7d8899; --side-active: #ffffff; --side-hover: #1f2937;
  --accent: #2557d6; --accent-soft: #e8eefc; --good: #137a3a; --bad: #b42318; --warn: #a15c07;
  --good-soft: #e6f4ea; --bad-soft: #fdecea; --warn-soft: #fff4e0;
  --p1: #b42318; --p2: #a15c07; --p3: #5f6673;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f14; --surface: #161a22; --surface-2: #1b2029; --text: #e8eaee; --muted: #9aa3b2; --line: #262b36;
    --side-bg: #0a0c10; --side-hover: #161a22;
    --accent: #7aa2ff; --accent-soft: #1d2740; --good: #5cd28a; --bad: #ff7b72; --warn: #f0b45b;
    --good-soft: #13281c; --bad-soft: #2c1615; --warn-soft: #2b2112; --p1: #ff7b72; --p2: #f0b45b; --p3: #9aa3b2;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* układ: boczne menu + treść */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.side .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
.side .brand:hover { text-decoration: none; }
.side .brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #3b82f6, #6366f1); display: grid; place-items: center; font-size: 12px; color: #fff; }
.side .group { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--side-muted); padding: 14px 10px 6px; }
.side a.item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--side-text); font-size: 14px; }
.side a.item:hover { background: var(--side-hover); text-decoration: none; color: #fff; }
.side a.item.active { background: var(--side-hover); color: var(--side-active); font-weight: 600; }
.side a.item .count { margin-left: auto; font-size: 11px; background: var(--bad); color: #fff; border-radius: 999px; padding: 0 7px; }
.side .sub { margin: 2px 0 6px 18px; border-left: 1px solid #263041; padding-left: 6px; display: flex; flex-direction: column; gap: 1px; }
.side .sub a.item { font-size: 13.5px; padding: 5px 10px; }
.side .spacer { flex: 1; }
.side form { margin: 0; }
.side button.item { all: unset; display: block; padding: 7px 10px; border-radius: 8px; color: var(--side-muted); font-size: 14px; cursor: pointer; }
.side button.item:hover { background: var(--side-hover); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3b82f6; flex: none; }
.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: 1240px; margin: 0 auto; padding: 26px 32px 60px; }

/* typografia */
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.subtitle { color: var(--muted); margin: 0 0 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* karty i siatki */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 16px; align-items: start; margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 24px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.delta { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.up { color: var(--good); } .down { color: var(--bad); }

/* asystent */
.assistant-head { display: flex; align-items: center; gap: 12px; margin: 26px 0 12px; }
.assistant-head .avatar { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; display: grid; place-items: center; font-weight: 700; }
.assistant-head h2 { margin: 0; }
.insight { display: grid; grid-template-columns: 4px 1fr; padding: 0; overflow: hidden; }
.insight .bar { background: var(--p3); }
.insight.p1 .bar { background: var(--p1); } .insight.p2 .bar { background: var(--p2); }
.insight .body { padding: 16px 18px; }
.insight .meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.insight h3 { font-size: 16px; margin: 0 0 6px; }
.insight p { margin: 0 0 8px; }
.insight ul { margin: 6px 0 10px; padding-left: 18px; }
.insight li { margin: 2px 0; font-size: 14px; word-break: break-word; }
.insight .todo { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-size: 14px; }
.insight .more { display: inline-block; margin-top: 8px; font-size: 13.5px; font-weight: 600; }

/* tabele */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.url { word-break: break-word; }
tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.critical, .badge.bad, .badge.p1 { background: var(--bad-soft); color: var(--bad); }
.badge.high, .badge.warn, .badge.p2 { background: var(--warn-soft); color: var(--warn); }
.badge.medium, .badge.info, .badge.p3 { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--good-soft); color: var(--good); }
.badge.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.notice { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--good-soft); color: var(--good); }
.notice.info { background: var(--accent-soft); color: var(--accent); }

/* przyciski, zakładki, filtry */
.btn { display: inline-block; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; font: inherit; cursor: pointer; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs, .chips { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a, .chips a { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; background: var(--surface); }
.tabs a.active, .chips a.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.tabs a:hover, .chips a:hover { text-decoration: none; }
.chart-box { position: relative; height: 280px; }
.bar-inline { height: 8px; border-radius: 999px; background: var(--accent); display: inline-block; vertical-align: middle; }

/* formularze */
form.card-form label.field { display: block; font-weight: 600; margin: 18px 0 4px; }
form.card-form .help { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=url], textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
.rows { display: grid; gap: 6px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 2fr; gap: 6px; }
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; width: 90px; display: inline-block; vertical-align: middle; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; }
.login { max-width: 360px; margin: 12vh auto; }

/* raporty (markdown) */
.report { line-height: 1.65; }
.report h1 { font-size: 22px; } .report h2 { font-size: 18px; margin-top: 26px; } .report h3 { margin-top: 18px; }
.report table { margin: 12px 0; }
.report blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.report code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* telefon */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: none; }
  .app.nav-open .side { display: flex; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--side-bg); color: #fff; position: sticky; top: 0; z-index: 5; }
  .topbar button { all: unset; cursor: pointer; font-size: 20px; padding: 2px 6px; }
  .content { padding: 16px 14px 40px; }
  .grid.two { grid-template-columns: 1fr; }
  .grid.kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .row3 { grid-template-columns: 1fr; }
  .kpi .value { font-size: 20px; }
}
