:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e6eb;
  --text: #191919;
  --text-2: #5f6670;
  --text-3: #8a919b;
  --accent: #1f5fbf;
  --accent-soft: #e8f0fc;
  --good: #0a7d32;
  --good-soft: #e6f4ea;
  --warn: #a86400;
  --warn-soft: #fdf3e1;
  --bad: #c0392b;
  --bad-soft: #fbeaea;
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }

/* nawigacja */
.topbar { background: #14213d; color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar .in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 56px; }
.brand { font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: #fca311; color: #14213d; display: grid; place-items: center; font-weight: 800; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: #c9d1e0; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-size: 14px; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.on { color: #fff; background: rgba(255,255,255,.14); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #c9d1e0; white-space: nowrap; }
.who a { color: #c9d1e0; }
.role { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: rgba(255,255,255,.14); color: #fff; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* karty */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mt { margin-top: 16px; }
.mt2 { margin-top: 24px; }
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .g2, .g4 { grid-template-columns: 1fr; } .who .name { display: none; } }

/* kafle KPI */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.kpi.good .value { color: var(--good); }
.bar { height: 8px; background: #edf0f4; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: var(--series-1); border-radius: 99px; }

/* hero oszczędności */
.hero { background: linear-gradient(135deg, #14213d, #1f3a6e); color: #fff; border-radius: var(--radius); padding: 22px 24px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.hero .label { color: #b9c5dc; font-size: 13px; }
.hero .big { font-size: 30px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero .sub { color: #d5ddeb; font-size: 13px; margin-top: 4px; }
.hero .accent { color: #fcd27a; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }

/* tabele */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--surface-2); font-weight: 600; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
tr.r-paid td { color: var(--text-2); }
tr.r-holiday td { background: #fbf8ef; color: var(--text-3); }
tr.r-due td { background: var(--warn-soft); }
tr.r-next td { background: var(--accent-soft); }
tr.r-year td { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-2); padding: 6px 10px; }
.kv { width: 100%; }
.kv td { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.kv td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv tr:last-child td { border-bottom: 0; }
table.cmp th, table.cmp td { text-align: right; }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; }
table.cmp td.hl { background: var(--accent-soft); font-weight: 600; }

/* znaczniki */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.paid { background: var(--good-soft); color: var(--good); }
.pill.due { background: var(--warn-soft); color: var(--warn); }
.pill.planned { background: #eef0f3; color: var(--text-2); }
.pill.holiday { background: #f6eed6; color: #7a5b00; }
.pill.fixed { background: #e8f0fc; color: var(--accent); }
.pill.var { background: #fdeee6; color: #b2470f; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.est { color: var(--text-3); font-size: 11px; margin-left: 2px; }

/* przyciski i formularze */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #194f9f; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.xs { padding: 2px 8px; font-size: 12px; font-weight: 600; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; }
form.inline { display: inline; }
label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #ccd2da; border-radius: 8px; font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd3f5; border-color: var(--accent); }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.check input { width: 18px; height: 18px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 3px; font-weight: 400; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* komunikaty */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: var(--good-soft); color: var(--good); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.info { background: var(--accent-soft); color: var(--accent); }
.alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-radius: 10px; background: var(--warn-soft); color: #6d4300; border: 1px solid #f1d9a9; margin-bottom: 16px; }

/* dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .dh { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; }
dialog .db { padding: 16px 22px; }
dialog .df { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--text-3); }

/* wykresy */
.chartbox { position: relative; height: 320px; }
.chartbox.sm { height: 240px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button, .seg a { border: 0; background: #fff; padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--text-2); font-family: inherit; }
.seg button.on, .seg a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg a:hover { text-decoration: none; }

/* logowanie */
.loginbox { max-width: 380px; margin: 10vh auto; }
.loginbox .brand { color: var(--text); justify-content: center; margin-bottom: 20px; font-size: 20px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tabular { font-variant-numeric: tabular-nums; }
.sticky-table { max-height: 70vh; overflow: auto; }
.svgchart { position: relative; width: 100%; height: 100%; }
.svgchart svg { display: block; font-family: inherit; font-variant-numeric: tabular-nums; }
.charttip { position: absolute; display: none; pointer-events: none; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 14px rgba(16,24,40,.12); padding: 8px 10px; font-size: 13px; white-space: nowrap; z-index: 5; }
.charttip .tt { font-weight: 600; margin-bottom: 4px; }
.grid > .card + .card { margin-top: 0; }
tr.flashrow td { animation: fl 2s ease-out; } @keyframes fl { from { background: #fff3c4; } }
@media (max-width: 760px) { .who .role { display: none; } .topbar .in { gap: 10px; padding: 0 12px; } .brand span:last-child { display: none; } }
.statstrip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.statstrip .sv { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.statstrip .sv .muted { font-weight: 400; font-size: 13px; }
@media (max-width: 760px) { .statstrip { grid-template-columns: repeat(2, minmax(0, 1fr)); } .seg[data-tabs] { flex-wrap: wrap; } }
[hidden] { display: none !important; }
.charttip .tsum { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
