/* Asystent — styl inspirowany systemem Apple (macOS / iOS). */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --surface-3: #e5e5ea;
  --sidebar: rgba(246, 246, 248, 0.72);
  --bar: rgba(255, 255, 255, 0.78);
  --label: #1d1d1f;
  --label-2: rgba(60, 60, 67, 0.62);
  --label-3: rgba(60, 60, 67, 0.36);
  --separator: rgba(60, 60, 67, 0.14);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06);
  --backdrop: rgba(0, 0, 0, 0.22);

  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --teal: #30b0c7;
  --indigo: #5856d6;
  --pink: #ff2d55;
  --purple: #af52de;
  --yellow: #ffcc00;
  --gray: #8e8e93;
  --accent: var(--blue);
  --accent-tint: rgba(0, 122, 255, 0.12);
  --danger: #d70015;

  /* Wykresy (sprawdzone pod kątem daltonizmu i kontrastu) */
  --chart-1: #007aff;
  --chart-2: #c75f00;
  --chart-grid: rgba(60, 60, 67, 0.12);

  --radius: 14px;
  --radius-lg: 20px;
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #3a3a3c;
    --sidebar: rgba(28, 28, 30, 0.7);
    --bar: rgba(22, 22, 24, 0.78);
    --label: #f5f5f7;
    --label-2: rgba(235, 235, 245, 0.62);
    --label-3: rgba(235, 235, 245, 0.32);
    --separator: rgba(84, 84, 88, 0.55);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.36);
    --shadow: none;
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.5);
    --blue: #0a84ff;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --teal: #40c8e0;
    --indigo: #5e5ce6;
    --pink: #ff375f;
    --purple: #bf5af2;
    --yellow: #ffd60a;
    --accent-tint: rgba(10, 132, 255, 0.2);
    --danger: #ff453a;
    --chart-1: #0a84ff;
    --chart-2: #d97400;
    --chart-grid: rgba(235, 235, 245, 0.1);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--label);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Układ ---------- */

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  padding: 18px 12px;
  background: var(--sidebar);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-right: 0.5px solid var(--separator);
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 600; font-size: 17px; }
.brand img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--label); font-weight: 500; text-decoration: none !important;
  transition: background 0.15s;
}
.nav-item:hover { background: var(--fill); }
.nav-item.active { background: var(--accent-tint); color: var(--accent); }
.nav-item .ico { width: 20px; height: 20px; flex: none; color: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.sidebar .spacer { flex: 1; }

.main { min-width: 0; padding: 36px 44px 80px; max-width: 1180px; width: 100%; }
.view { animation: viewIn 0.42s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; margin: 0; }
.page-head .sub { color: var(--label-2); font-size: 15px; margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.section-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.section-head a, .section-head button.link { font-size: 15px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }

/* ---------- Karty i listy ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card.flush { padding: 0; overflow: hidden; }
.card h3 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.muted { color: var(--label-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat .stat-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.stat .stat-ico svg { width: 17px; height: 17px; }
.stat .stat-value { font: 700 28px/1 var(--font-rounded); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .stat-label { font-size: 13px; font-weight: 600; color: var(--label-2); }
a.stat { color: inherit; text-decoration: none !important; transition: transform 0.2s var(--spring); }
a.stat:active { transform: scale(0.97); }

.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; min-height: 48px;
  position: relative;
  transition: background 0.15s, opacity 0.3s, transform 0.3s var(--spring);
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 50px; right: 0; border-top: 0.5px solid var(--separator); }
.row.plain + .row.plain::before { left: 16px; }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: var(--fill); }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 450; overflow-wrap: anywhere; }
.row .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--label-2); margin-top: 2px; align-items: center; }
.row .meta svg { width: 12px; height: 12px; display: inline; vertical-align: -1px; }
.row .trail { display: flex; align-items: center; gap: 8px; flex: none; color: var(--label-2); font-size: 14px; }
.row .chev { width: 8px; color: var(--label-3); }
.row.leaving { opacity: 0; transform: translateX(16px); }
.overdue { color: var(--red) !important; }
.soon { color: var(--orange) !important; }

.empty { padding: 26px 20px; text-align: center; color: var(--label-2); font-size: 14px; }
.empty .ico { width: 36px; height: 36px; margin: 0 auto 8px; color: var(--label-3); }

/* Okrągły checkbox jak w Przypomnieniach */
.check {
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  border: 1.6px solid var(--label-3); background: transparent;
  display: grid; place-items: center; padding: 0;
  transition: border-color 0.2s, background 0.25s var(--spring), transform 0.25s var(--spring);
}
.check:hover { border-color: var(--accent); }
.check:active { transform: scale(0.85); }
.check svg { width: 12px; height: 12px; color: #fff; transform: scale(0); transition: transform 0.35s var(--spring); }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on svg { transform: scale(1); }
.check.high { border-color: var(--orange); }
.check.high.on { background: var(--orange); }

/* Data jak ikona kalendarza */
.datebadge {
  width: 44px; flex: none; text-align: center; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); line-height: 1;
}
.datebadge .m { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 4px 0 3px; background: var(--red); color: #fff; letter-spacing: 0.04em; }
.datebadge .d { display: block; font: 600 19px/1 var(--font-rounded); padding: 4px 0 6px; }
.datebadge.none .m { background: var(--gray); }

/* ---------- Przyciski i formularze ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 980px; padding: 8px 16px;
  font-weight: 500; font-size: 15px; white-space: nowrap;
  background: var(--fill); color: var(--accent);
  transition: transform 0.2s var(--spring), background 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(0.96); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 12px; font-size: 14px; }
.btn.icon { padding: 8px; border-radius: 50%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }

.segmented {
  display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill);
  gap: 2px; overflow-x: auto; max-width: 100%; scrollbar-width: none;
}
.segmented button {
  border: 0; background: transparent; border-radius: 7px;
  padding: 5px 14px; font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background 0.2s, box-shadow 0.2s;
}
.segmented button.on { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 980px; padding: 5px 12px; font-size: 13px; font-weight: 500;
  background: var(--fill); color: var(--label);
}
.chip i { width: 8px; height: 8px; border-radius: 50%; }
.chip.on { background: var(--label); color: var(--bg); }

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--label-2); padding-left: 2px; }
.input, select.input, textarea.input {
  width: 100%; border: 0; border-radius: 10px;
  background: var(--surface-2); padding: 10px 12px; font-size: 15px;
  outline: none; transition: box-shadow 0.15s;
  appearance: none; -webkit-appearance: none;
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.45; }
.input::placeholder { color: var(--label-3); }
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px; font-weight: 450; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--fill-2); transition: background 0.25s; }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.3s var(--spring);
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }

.quick-add {
  display: flex; gap: 10px; align-items: center;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px 6px 6px 16px; margin-bottom: 14px;
}
.quick-add .plus { width: 22px; height: 22px; color: var(--accent); flex: none; }
.quick-add input.bare { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 8px 0; font-size: 15px; }
.quick-add select, .quick-add input[type="date"] {
  border: 0; background: var(--surface-2); border-radius: 8px; padding: 6px 8px; font-size: 13px; outline: none; max-width: 150px;
}

/* ---------- Arkusz (okno edycji) ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: var(--backdrop);
  display: grid; place-items: center; padding: 20px;
  animation: fadeIn 0.25s ease both;
}
.sheet-backdrop.closing { animation: fadeOut 0.2s ease both; }
.sheet {
  width: min(560px, 100%); max-height: min(86vh, 900px); overflow: auto;
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg);
  animation: sheetIn 0.45s var(--spring) both;
}
.sheet-backdrop.closing .sheet { animation: sheetOut 0.2s ease both; }
.sheet-head {
  position: sticky; top: 0; z-index: 1;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 14px 16px; background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--separator);
}
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; }
.sheet-head .l { justify-self: start; }
.sheet-head .r { justify-self: end; }
.sheet-body { padding: 20px; }
.sheet-foot { display: flex; justify-content: space-between; gap: 8px; padding: 0 20px 20px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes sheetIn { from { opacity: 0; transform: translateY(24px) scale(0.96); } }
@keyframes sheetOut { to { opacity: 0; transform: translateY(12px) scale(0.98); } }

/* ---------- Powiadomienia ---------- */

#toast-root { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; pointer-events: none; }
.toast {
  background: color-mix(in srgb, var(--label) 88%, transparent); color: var(--bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 10px 18px; border-radius: 980px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toastIn 0.45s var(--spring) both; pointer-events: auto;
  display: flex; gap: 14px; align-items: center;
}
.toast button { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 0; }
.toast.out { animation: fadeOut 0.25s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.95); } }

/* ---------- Wyszukiwarka (⌘K) ---------- */

.side-search {
  display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 7px 10px;
  border: 0; border-radius: 9px; background: var(--fill); color: var(--label-2); font-size: 14px; cursor: pointer; text-align: left;
}
.side-search svg { width: 16px; height: 16px; flex: none; }
.side-search span { flex: 1; }
.side-search kbd { font: 500 12px var(--font, inherit); color: var(--label-3); }
.side-search:hover { background: var(--surface-3); }
.palette-backdrop {
  position: fixed; inset: 0; z-index: 60; background: var(--backdrop);
  display: flex; justify-content: center; align-items: flex-start; padding: 12vh 20px 20px;
  animation: fadeIn 0.2s ease both;
}
.palette-backdrop.closing { animation: fadeOut 0.18s ease both; }
.palette {
  width: min(620px, 100%); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: sheetIn 0.35s var(--spring) both;
}
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 0.5px solid var(--separator); }
.palette-input svg { width: 20px; height: 20px; color: var(--label-3); flex: none; }
.palette-input input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 18px; }
.palette-input input::-webkit-search-cancel-button { display: none; }
.palette-input .link { display: none; }
.palette-results { overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.palette-empty { padding: 22px 12px; text-align: center; color: var(--label-2); font-size: 14px; }
.palette-group { padding: 10px 10px 4px; font-size: 12px; font-weight: 600; color: var(--label-2); }
.palette-group span { font-weight: 400; color: var(--label-3); }
.palette-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer; color: var(--label);
}
.palette-item.on { background: var(--accent-tint); }
.palette-item .pi { width: 18px; height: 18px; flex: none; color: var(--accent); }
.palette-item .pt { display: flex; flex-direction: column; min-width: 0; }
.palette-item .pn, .palette-item .pm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pn { font-weight: 500; }
.palette-item .pn.done { text-decoration: line-through; color: var(--label-2); }
.palette-item .pm { font-size: 13px; color: var(--label-2); }

/* ---------- Kalkulator ryczałtu ---------- */

.ry-cols { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.ry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.ry-field em { font-style: normal; font-weight: 400; }
.ry-input { position: relative; }
.ry-input .input { padding-right: 34px; text-align: right; font-variant-numeric: tabular-nums; width: 100%; }
.ry-input b { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-weight: 500; color: var(--label-3); pointer-events: none; }
.ry-total { display: grid; gap: 6px; justify-items: start; margin-bottom: 14px; }
.ry-total .big-number { font-size: 40px; }
.ry-total .btn { margin-top: 6px; }

/* ---------- Drobne elementy ---------- */

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--fill); color: var(--label-2); }
.links { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Notatki ---------- */

.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.note-card { cursor: pointer; display: flex; flex-direction: column; gap: 8px; min-height: 120px; transition: transform 0.25s var(--spring), box-shadow 0.2s; }
.note-card:hover { transform: translateY(-2px); }
.note-card .ntitle { font-weight: 600; }
.note-card .nbody { color: var(--label-2); font-size: 14px; white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; }
.note-card .nfoot { margin-top: auto; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--label-3); }
.note-card .nfoot svg { width: 12px; height: 12px; }
.note-card.idea { background: color-mix(in srgb, var(--yellow) 14%, var(--surface)); }
.search { position: relative; }
.search input { padding-left: 34px; min-width: 220px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--label-3); }

/* ---------- Wykresy ---------- */

.chart { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .bar { transition: opacity 0.15s; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-label { fill: var(--label-2); font-size: 11px; font-family: var(--font); }
.chart .hit { fill: transparent; cursor: default; }
.chart:hover .bar.dim { opacity: 0.35; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--surface); color: var(--label); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 8px 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -100%);
  opacity: 0; transition: opacity 0.12s;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--label-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.big-number { font: 700 32px/1.05 var(--font-rounded); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpis { display: flex; gap: 28px; flex-wrap: wrap; margin: 6px 0 16px; }
.kpis .k-label { font-size: 13px; color: var(--label-2); font-weight: 500; }
.kpis .k-value { font: 600 20px/1.2 var(--font-rounded); font-variant-numeric: tabular-nums; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--label); }
details.table-view { margin-top: 10px; font-size: 13px; }
details.table-view summary { cursor: pointer; color: var(--accent); }
details.table-view table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
details.table-view td, details.table-view th { padding: 4px 6px; text-align: right; border-bottom: 0.5px solid var(--separator); }
details.table-view td:first-child, details.table-view th:first-child { text-align: left; }

/* ---------- Logowanie ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: min(380px, 100%); padding: 32px 28px; text-align: center; animation: sheetIn 0.6s var(--spring) both; }
.auth img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin: 0 auto 14px; }
.auth h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: -0.02em; }
.auth p { color: var(--label-2); margin: 0 0 22px; font-size: 14px; }
.auth .form { text-align: left; }
.auth .err { color: var(--red); font-size: 13px; min-height: 18px; text-align: center; }

/* ---------- Pasek dolny i przycisk dodawania (telefon) ---------- */

.tabbar, .fab { display: none; }

@media (max-width: 980px) {
  .main { padding: 28px 24px 80px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: 1fr; }
  .ry-cols > [data-ry-result] { order: -1; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: calc(16px + env(safe-area-inset-top)) 16px calc(100px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 30px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .row + .row::before { left: 50px; }
  .search input { min-width: 0; }
  .stat .stat-value { font-size: 22px; }
  .stat .stat-ico { width: 26px; height: 26px; }
  .row .trail .btn .lbl { display: none; }
  .row .trail .btn.small { padding: 7px; border-radius: 50%; }
  .row .trail .money { font-size: 13px; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--bar);
    backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-top: 0.5px solid var(--separator);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 10px; font-weight: 500; color: var(--label-2); text-decoration: none !important;
    background: none; border: 0; padding: 2px 0;
  }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar .active { color: var(--accent); }

  .fab {
    display: grid; place-items: center;
    position: fixed; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 41;
    width: 54px; height: 54px; border-radius: 50%; border: 0;
    background: var(--accent); color: #fff; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent);
    transition: transform 0.25s var(--spring);
  }
  .fab:active { transform: scale(0.9); }
  .fab svg { width: 24px; height: 24px; }
  .fab-search {
    right: 84px; bottom: calc(81px + env(safe-area-inset-bottom)); width: 44px; height: 44px;
    background: var(--surface); color: var(--accent); box-shadow: var(--shadow-lg);
  }
  .fab-search svg { width: 20px; height: 20px; }
  .palette-backdrop { padding: calc(10px + env(safe-area-inset-top)) 10px 10px; }
  .palette { max-height: 60vh; }
  .palette-input .link { display: inline; }
  .palette-input input { font-size: 17px; }

  .sheet-backdrop { place-items: end center; padding: 0; }
  .sheet { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: sheetUp 0.5s var(--spring) both; }
  .sheet-backdrop.closing .sheet { animation: sheetDown 0.25s ease both; }
  #toast-root { bottom: calc(150px + env(safe-area-inset-bottom)); }
}
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.back-ico { width: 18px; height: 18px; }
svg[class=""] { width: 1em; height: 1em; display: inline-block; vertical-align: -2px; }
.note-card .nfoot { flex-wrap: wrap; }
