/* Domowe Finanse – jasny interfejs, granatowa nawigacja, turkusowo-zielone akcenty. */
:root {
  --navy: #172b49; --navy-2: #203b60; --navy-3: #2a4a74; --nav-text: #c8d5e5;
  --teal: #159c91; --teal-dark: #0b7d74; --teal-soft: #e5f5f2; --teal-line: #b9e4dd;
  --ink: #172538; --muted: #6b7a90; --line: #e6ebf1; --line-2: #d6dde7;
  --bg: #f4f7fa; --surface: #fff; --surface-2: #f8fafc;
  --red: #c4372b; --red-soft: #fff0ee; --amber: #b7791f; --amber-soft: #fff7e6;
  --blue: #2c6ecb; --blue-soft: #eaf2fd; --green: #1d8a4e; --green-soft: #e8f6ee;
  --radius: 14px; --radius-sm: 9px; --shadow: 0 3px 14px rgba(27, 54, 80, .06);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar: 248px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.5 var(--font); }
a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; letter-spacing: -.6px; margin: 0; line-height: 1.2; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -.2px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round;
  stroke-linejoin: round; flex: none; vertical-align: middle; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
.eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: 1.2px; color: var(--teal); margin: 0 0 4px;
  text-transform: uppercase; }
.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- układ ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { background: var(--navy); color: #fff; padding: 22px 14px 18px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 0 10px 26px; font-weight: 800;
  font-size: 19px; letter-spacing: -.5px; line-height: 1.1; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 38px; height: 38px; border-radius: 11px; background: var(--teal); display: grid; place-items: center; }
.brand .logo .icon { stroke: #fff; width: 22px; height: 22px; }
.brand small { display: block; color: #63d1c4; font-size: 19px; }
.nav { display: grid; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--nav-text);
  font-weight: 550; }
.nav a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--teal); color: #fff; }
.nav .sub { display: grid; gap: 2px; margin: 0 0 4px 30px; }
.nav .sub a { padding: 7px 12px; font-size: 13.5px; font-weight: 500; }
.nav .sub a.active { background: var(--navy-3); color: #fff; }
.nav-label { color: #8ea2bb; font-size: 10.5px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
  padding: 16px 12px 6px; }
.sidebar-foot { margin-top: auto; padding: 18px 10px 0; color: #9fb0c5; font-size: 12px; }
.sidebar-foot a { color: #c8d5e5; }
.nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(16,33,54,.35); z-index: 35; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { min-height: 66px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex;
  align-items: center; gap: 12px; padding: 10px 28px; position: sticky; top: 0; z-index: 30; flex-wrap: wrap; }
.topbar form { margin: 0; }
.topbar .spacer { flex: 1; }
.topbar label.inline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.topbar select, .topbar .search input { height: 38px; }
.search { position: relative; }
.search input { padding-left: 34px !important; width: 220px; }
.search .icon { position: absolute; left: 10px; top: 10px; color: var(--muted); }
.menu-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 600; }
.user-chip .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.content { width: 100%; max-width: 1560px; margin: 0 auto; padding: 26px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px;
  flex-wrap: wrap; }
.page-head .title { display: flex; align-items: center; gap: 12px; }
.page-head .title .icon { color: var(--teal); width: 26px; height: 26px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-head .sub { margin-top: 4px; }

/* ---------- formularze i przyciski ---------- */
.input, select, input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=month], input[type=search], textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 8px 11px; min-height: 38px; width: 100%; }
select { padding-right: 28px; }
textarea { min-height: 70px; resize: vertical; }
input[type=color] { padding: 3px; height: 38px; width: 60px; }
.input:focus, select:focus, input:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal); }
input.check, input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--teal); vertical-align: middle; }
label { font-weight: 600; font-size: 13px; }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field .help, .helptext { color: var(--muted); font-size: 12px; font-weight: 400; }
.field .errorlist, .errorlist { color: var(--red); margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.check-row { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; font-weight: 500; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: #c4ced9; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0c7c2; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon-only { width: 32px; height: 32px; padding: 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
button.link { background: none; border: 0; color: var(--teal-dark); cursor: pointer; padding: 0; font: inherit; font-weight: 600; }

/* ---------- karty / panele ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; min-width: 0; }
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush .panel-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 18px; }
.grid.kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.grid + .grid, .grid + .panel, .panel + .grid { margin-top: 18px; }
.kpi-card { display: flex; gap: 14px; align-items: flex-start; }
.kpi-card .kpi-icon { width: 46px; height: 46px; border-radius: 13px; background: var(--teal-soft); color: var(--teal);
  display: grid; place-items: center; flex: none; }
.kpi-card .kpi-icon .icon { width: 24px; height: 24px; }
.kpi-card .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi-card .value { font-size: 25px; font-weight: 800; letter-spacing: -.6px; margin: 2px 0; white-space: nowrap; }
.kpi-card .meta { font-size: 12.5px; color: var(--muted); }
.delta { font-weight: 700; font-size: 12.5px; }
.delta.good { color: var(--green); } .delta.bad { color: var(--red); } .delta.neutral { color: var(--muted); font-weight: 500; }
.progress { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; background: var(--teal); border-radius: 8px; width: 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; }
.empty .icon { width: 34px; height: 34px; color: var(--line-2); margin-bottom: 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 650; }
.cat-icon { width: 30px; height: 30px; border-radius: 9px; background: var(--teal-soft); color: var(--teal);
  display: inline-grid; place-items: center; flex: none; }
.cat-icon .icon { width: 17px; height: 17px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }
.chart-box { position: relative; height: 260px; }
.chart-box.small { height: 200px; }
.chart-box.donut { height: 210px; max-width: 230px; }
.donut-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center; }
.budget-switch li.current { background: var(--teal-soft); border-radius: 10px; padding-left: 10px; padding-right: 10px; }

/* ---------- komunikaty ---------- */
.messages { display: grid; gap: 8px; margin-bottom: 18px; }
.msg { padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.msg.success { background: var(--green-soft); border-color: #bfe4cf; color: #135c34; }
.msg.error { background: var(--red-soft); border-color: #f1c5bf; color: #8b241b; }
.msg.info { background: var(--blue-soft); border-color: #c7dcf7; color: #1d4e91; }
.msg.warning { background: var(--amber-soft); border-color: #f1dcae; color: #7a4f0e; }
.msg .grow { flex: 1; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast div { background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.18);
  font-weight: 600; font-size: 13.5px; max-width: 360px; }
.toast div.error { background: var(--red); }
.toast div.ok { background: var(--green); }

/* ---------- pigułki statusów ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 12px;
  font-weight: 700; white-space: nowrap; }
.pill b { font-weight: 900; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.info { background: var(--blue-soft); color: var(--blue); }
.pill.muted { background: #eef1f5; color: var(--muted); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--navy); color: #fff; font-size: 10.5px; font-weight: 800; }

/* ---------- zakładki i filtry ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 650; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--teal-dark); border-bottom-color: var(--teal); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 20px; padding: 5px 12px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 130px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- tabele ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
.data { font-size: 13.5px; }
.data th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 9px 10px;
  border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data tbody tr:hover td { background: #fbfcfd; }
.data td.num, .data th.num { text-align: right; }
.data tfoot td { font-weight: 800; background: var(--teal-soft); border-top: 2px solid var(--teal-line); }
.data .group-row td { background: var(--surface-2); font-weight: 800; font-size: 12px; color: var(--navy);
  text-transform: uppercase; letter-spacing: .6px; }
.data tr.inactive td { color: var(--muted); }

/* tabela roczna */
.grid-wrap { overflow: auto; max-height: calc(100vh - 230px); border-radius: var(--radius); }
.ygrid { font-size: 13px; border-collapse: separate; border-spacing: 0; }
.ygrid th, .ygrid td { border-bottom: 1px solid var(--line); border-right: 1px solid #f0f3f7; white-space: nowrap; }
.ygrid thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 3; font-size: 12px; color: var(--ink);
  padding: 8px; text-align: right; font-weight: 700; }
.ygrid thead tr.groups th { top: 0; text-align: center; color: var(--navy); font-size: 10.5px; letter-spacing: .8px;
  text-transform: uppercase; background: #eef3f7; border-right: 2px solid #fff; }
.ygrid thead tr.cats th { top: 31px; max-width: 130px; white-space: normal; line-height: 1.25; vertical-align: bottom; }
.ygrid thead tr.cats th a { color: var(--ink); }
.ygrid .sticky-l { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; font-weight: 650;
  min-width: 110px; box-shadow: 1px 0 0 var(--line); }
.ygrid thead .sticky-l { z-index: 5; background: var(--surface-2); }
.ygrid .sticky-r { position: sticky; right: 0; z-index: 2; background: var(--teal-soft); font-weight: 800; text-align: right;
  min-width: 105px; box-shadow: -1px 0 0 var(--teal-line); }
.ygrid thead .sticky-r { z-index: 5; background: #d9f0ec; }
.ygrid td { padding: 0; text-align: right; min-width: 92px; }
.ygrid td.sticky-l { padding: 6px 10px; }
.ygrid td.sticky-r { padding: 6px 10px; }
.ygrid tr.current td.sticky-l { color: var(--teal-dark); }
.ygrid tr.current td { background: #f6fbfa; }
.ygrid tfoot td { position: sticky; bottom: 0; background: var(--navy); color: #fff; font-weight: 800; padding: 8px 10px;
  z-index: 2; }
.ygrid tfoot td.sticky-l { background: var(--navy); color: #fff; z-index: 4; }
.ygrid tfoot td.sticky-r { background: var(--teal-dark); color: #fff; z-index: 4; }
.cell { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 0 8px; height: 34px; }
.cell input { border: 0; background: transparent; text-align: right; width: 100%; min-width: 70px; height: 32px;
  padding: 0 2px; font: inherit; font-variant-numeric: tabular-nums; border-radius: 0; min-height: 0; }
.cell input:focus { outline: 2px solid var(--teal); outline-offset: -1px; background: #fff; }
.cell.suggested input::placeholder { color: #9aa8b8; font-style: italic; }
.cell .badge { cursor: pointer; }
.cell.multi { cursor: pointer; }
.cell.multi:hover { background: var(--teal-soft); }
.cell .flag { position: absolute; left: 3px; top: 3px; width: 6px; height: 6px; border-radius: 50%; }
.cell .flag.unpaid { background: var(--amber); }
.cell.saving input { color: var(--muted); }
.cell.saved { animation: saved 1.1s ease; }
.cell.error { box-shadow: inset 0 0 0 2px var(--red); background: var(--red-soft); }
@keyframes saved { 0% { background: #c9efe0; } 100% { background: transparent; } }

/* widok miesięczny */
.mtable { font-size: 13.5px; }
.mtable th { position: sticky; top: 66px; z-index: 2; }
.mtable td { padding: 6px 8px; }
.mtable .cat-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.mtable .cat-cell .name { font-weight: 650; }
.mtable .cat-cell .sub { font-size: 11.5px; color: var(--muted); }
.mtable input.amount, .mtable input.date, .mtable select.status { height: 34px; min-height: 0; padding: 4px 8px; font-size: 13.5px; }
.mtable input.amount { width: 120px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.mtable input.date { width: 140px; }
.mtable select.status { width: 170px; }
.mtable .suggest { color: var(--muted); font-style: italic; white-space: nowrap; }
.mtable .suggest button { margin-left: 4px; }
.mtable tr.entry-row.is-suggestion input.amount { border-style: dashed; background: #fbfcfd; }
.mtable tr.entry-row.ghost input.amount { background: var(--surface-2); }
.mtable tr.entry-row td.state { width: 26px; text-align: center; }
.mtable tr.entry-row.saving td.state::after { content: "…"; color: var(--muted); }
.mtable tr.entry-row.saved td.state::after { content: "✓"; color: var(--green); font-weight: 900; }
.mtable tr.entry-row.error td { background: var(--red-soft); }
.mtable tr.entry-row.error td.state::after { content: "!"; color: var(--red); font-weight: 900; }
.mtable tr.details-row td { background: var(--surface-2); padding: 12px 14px 14px; }
.mtable tr.cont td.first { border-top: 0; }
.mtable tbody.cat-block { border-bottom: 1px solid var(--line); }
.mtable .meter-cell { font-size: 12.5px; white-space: nowrap; }
.mtable .meter-cell .usage { color: var(--green); font-weight: 700; }
.details-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; }
.details-grid .field { margin: 0; }
.details-grid .wide { grid-column: span 2; }
.details-grid input, .details-grid textarea, .details-grid select { min-height: 34px; padding: 5px 9px; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.input-error { border-color: var(--red) !important; background: var(--red-soft) !important; }
.field-msg { color: var(--red); font-size: 12px; }
.save-status { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-status.ok { color: var(--green); } .save-status.err { color: var(--red); }
.summary-strip { display: flex; gap: 24px; flex-wrap: wrap; padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.summary-strip .item .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.summary-strip .item .value { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kbd { font-family: ui-monospace, monospace; font-size: 11px; padding: 1px 5px; border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 4px; background: #fff; color: var(--muted); }

/* panel boczny (szczegóły komórki) */
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw); background: var(--surface);
  box-shadow: -10px 0 40px rgba(16, 33, 54, .18); z-index: 90; display: flex; flex-direction: column; transform: translateX(100%);
  transition: transform .18s ease; }
.drawer.open { transform: none; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.drawer .entry-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; display: grid;
  grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.drawer .entry-card .full { grid-column: 1 / -1; }
.backdrop { position: fixed; inset: 0; background: rgba(16, 33, 54, .35); z-index: 80; }

/* dane do przelewu */
.payee { display: grid; gap: 4px; }
.copy-line { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.copy-line code { font-size: 13.5px; background: var(--surface-2); padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); }
.pre { white-space: pre-line; }

/* logowanie */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 15% -10%, #dff3ef 0, transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { color: var(--navy); padding: 0 0 22px; justify-content: center; font-size: 22px; }
.auth-card .brand small { color: var(--teal); font-size: 22px; }
.auth-card form { display: grid; gap: 12px; }
.auth-card .btn { height: 44px; }

/* ---------- responsywność ---------- */
@media (max-width: 1280px) {
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .details-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .grid.main-side, .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
  .search input { width: 160px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: 12px 0 40px rgba(0,0,0,.25); }
  body.nav-open .nav-backdrop { display: block; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 8px 14px; gap: 8px; }
  .content { padding: 18px 14px 50px; }
  .search { display: none; }
  .mtable th { top: 0; }
  .grid-wrap { max-height: none; }
  .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  h1 { font-size: 22px; }
  .grid.kpi { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .kpi-card .value { font-size: 22px; }
  .donut-wrap { grid-template-columns: minmax(0, 1fr); }
  .chart-box.donut { margin: 0 auto; }
  .user-chip .name, .topbar .hide-sm { display: none; }
  .page-head { align-items: flex-start; }
  /* widok miesięczny jako karty */
  .mtable thead { display: none; }
  .mtable, .mtable tbody, .mtable tr, .mtable td { display: block; width: 100%; }
  .mtable tbody.cat-block { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--surface); }
  .mtable tr.entry-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 10px 12px; }
  .mtable tr.entry-row td { border: 0; padding: 0; }
  .mtable tr.entry-row td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
  .mtable tr.entry-row td.cat, .mtable tr.entry-row td.actions-cell { grid-column: 1 / -1; }
  .mtable tr.entry-row td.state { display: none; }
  .mtable input.amount, .mtable input.date, .mtable select.status { width: 100%; }
  .mtable tr.group-row { display: none; }
  .details-grid { grid-template-columns: minmax(0, 1fr); }
  .details-grid .wide { grid-column: auto; }
  .summary-strip { gap: 14px; }
}
@media print {
  .sidebar, .topbar, .page-head .actions, .row-actions, .btn { display: none !important; }
  .shell { display: block; }
  .panel { box-shadow: none; }
}
.panel.narrow { max-width: 620px; }
.panel.medium { max-width: 920px; }
.inline-form { display: inline; }
.details-grid .full-span { grid-column: 1 / -1; display: grid; }
.meter-entry { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.meter-entry input[type=text] { width: 90px; height: 30px; min-height: 0; padding: 3px 7px; }
.meter-entry input[type=date] { width: 132px; height: 30px; min-height: 0; padding: 3px 7px; }
.hint { font-size: 12px; color: var(--muted); }
.ygrid.hist td.pad { padding: 6px 10px; }
.ygrid .group-row td { background: var(--surface-2); font-size: 12px; color: var(--navy); }
.ygrid tfoot tr + tr td { bottom: auto; position: static; background: #22406a; }
.pager { margin-top: 14px; justify-content: center; }
.dot-inline { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); margin-right: 8px; }
.mt { margin-top: 18px; }
.w-date { width: 150px !important; } .w-num { width: 120px !important; }
.panel .btn-row .input { min-height: 32px; height: 32px; padding: 4px 8px; }
.grow-input { flex: 1; min-width: 120px; }
.w-pos { width: 64px !important; }
.list form.btn-row.grow { flex: 1; }
.payee-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; display: grid; gap: 6px; }
.payee-card.inactive { background: var(--surface-2); opacity: .85; }
.payee-card .panel-head { margin: 0; }
li.inactive { opacity: .6; }
details summary { cursor: pointer; color: var(--teal-dark); }
.panel.focus { box-shadow: 0 0 0 2px var(--teal); }
section.panel.inactive { opacity: .75; }
.mt-xs { margin-top: 6px; }
.pad-x { padding: 0 20px 14px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.msg code, .small code { background: rgba(0,0,0,.05); padding: 1px 5px; border-radius: 4px; }
.topbar select { width: auto; min-width: 110px; }
.grid > .panel + .panel, .grid > section + section { margin-top: 0; }
.grid > aside > .panel + .panel { margin-top: 18px; }
.mtable th { position: static; }
@media (max-width: 1500px) { .search input { width: 170px; } }
.toolbar select { width: auto; }
@media (max-width: 720px) {
  .mtable tr.entry-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .mtable tr.entry-row td { min-width: 0; }
  .mtable tr.entry-row td:empty { display: none; }
  .mtable .cat-cell { min-width: 0; }
  .mtable tr.entry-row td.meter-cell { grid-column: 1 / -1; white-space: normal; }
  .meter-entry { flex-wrap: wrap; }
  .mtable tr.details-row td { display: block; }
  .mtable tr.details-row td:first-child { display: none; }
  .panel.flush .table-wrap { overflow-x: visible; }
  .mtable { table-layout: auto; }
  .summary-strip .item.grow { display: none; }
}
