/* Wydatki – panel WWW */
:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --surface-2: #F0EFEA;
  --ink: #1C1B19;
  --ink-2: #5E5C57;
  --ink-3: #8E8B84;
  --line: #E4E2DB;
  --accent: #0F766E;
  --accent-ink: #FFFFFF;
  --accent-soft: #DDF1EE;
  --ok: #15803D;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --bad: #B91C1C;
  --bad-soft: #FEE2E2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 27, 25, .05), 0 1px 1px rgba(28, 27, 25, .03);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413; --surface: #1D1D1B; --surface-2: #262624; --ink: #F2F1EC; --ink-2: #B5B2AA; --ink-3: #85827B;
    --line: #33322F; --accent: #2DD4BF; --accent-ink: #0B1F1D; --accent-soft: #123A36;
    --ok: #4ADE80; --warn: #FBBF24; --warn-soft: #3A2E10; --bad: #F87171; --bad-soft: #3B1717;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- layout --- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; color: var(--ink); }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 16px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.sidebar-foot form { margin-top: 6px; }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }

/* --- cards / grid --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi-label { font-size: 13px; color: var(--ink-2); }
.kpi-value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.kpi-sub { font-size: 13px; color: var(--ink-3); }
.chart-box { position: relative; height: 260px; }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }

/* --- buttons / forms --- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 550; cursor: pointer; line-height: 1.3; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--bad); }
.btn-link { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input, select { min-width: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.field { margin-bottom: 16px; }
.field-error { color: var(--bad); font-size: 13px; margin: 5px 0 0; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.amount-input { font-size: 22px !important; font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- alerts --- */
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.alert-success { background: var(--accent-soft); color: var(--accent); }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-info { background: var(--surface-2); color: var(--ink-2); }

/* --- table --- */
.table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table tr[data-href] { cursor: pointer; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; padding: 0 10px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.table tbody tr:hover { background: var(--surface-2); }

.cat { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.badge { display: inline-block; padding: 1px 7px; font-size: 12px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); font-weight: 600; }

/* --- budgets --- */
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--ok); }
.bar.warning > span { background: var(--warn); }
.bar.exceeded > span { background: var(--bad); }
.budget { padding: 12px 0; border-bottom: 1px solid var(--line); }
.budget:last-child { border-bottom: 0; }
.budget-head { display: flex; justify-content: space-between; gap: 10px; }
.status-exceeded { color: var(--bad); font-weight: 600; }
.status-warning { color: var(--warn); font-weight: 600; }

/* --- auth --- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth h1 { margin: 14px 0 6px; }

/* --- filters / pager --- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; margin-bottom: 16px; }
.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 16px 0 0; flex-wrap: wrap; }
.pagination a { display: block; padding: 5px 10px; border-radius: 7px; border: 1px solid var(--line); color: var(--ink-2); }
.pagination .active a { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.month-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.month-nav a { padding: 5px 10px; border-radius: 7px; color: var(--ink-2); }
.month-nav a:hover { background: var(--surface-2); text-decoration: none; }
.month-nav strong { padding: 0 8px; min-width: 130px; text-align: center; }
details.inline summary { cursor: pointer; list-style: none; }
details.inline summary::-webkit-details-marker { display: none; }
details.inline[open] { background: var(--surface-2); border-radius: 10px; padding: 12px; margin: 8px 0; }

/* --- mobile --- */
.topbar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 6px; border-right: 0; border-top: 1px solid var(--line); z-index: 10; }
  .brand, .sidebar-foot { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 2px; flex: 1; min-width: 0; }
  .main { padding: 20px 16px 96px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
  .page-head h1 { font-size: 22px; }
  .page-head .row { width: 100%; }
  .page-head .row .btn { flex: 1; justify-content: center; }
  .filters { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
  .kpi-value { font-size: 24px; }
  .grid[style*="180px"] { grid-template-columns: 1fr !important; }
  .table td, .table th { padding-left: 6px; padding-right: 6px; }
}
.status-ok { color: var(--ok); font-weight: 600; }

/* --- przychody --- */
.amount-income { color: var(--ok); }
.amount-expense { color: var(--ink); }
.amount-negative { color: var(--bad); }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 16px; gap: 2px; }
.segmented label { margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.kpi-rows { display: grid; gap: 4px; margin-top: 10px; font-size: 14px; }
.kpi-rows div { display: flex; justify-content: space-between; gap: 12px; }