/* ===== Tokeny ===== */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f7f7f4;
  --border: #e3e2dd;
  --border-strong: #cfceC7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #8a8983;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --track: #ebeae5;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --area-finanse: #2a78d6;
  --area-relacje: #eb6834;
  --area-zdrowie: #1baf7a;
  --area-podroze: #eda100;
  --area-duch: #e87ba4;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --radius: 14px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131312;
    --surface: #1e1e1c;
    --surface-2: #262624;
    --border: #2f2f2c;
    --border-strong: #454541;
    --text: #f4f4f1;
    --text-2: #c3c2b7;
    --text-3: #8b8a83;
    --accent: #3987e5;
    --track: #2c2c29;
    --area-finanse: #3987e5;
    --area-relacje: #d95926;
    --area-zdrowie: #199e70;
    --area-podroze: #c98500;
    --area-duch: #d55181;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131312;
  --surface: #1e1e1c;
  --surface-2: #262624;
  --border: #2f2f2c;
  --border-strong: #454541;
  --text: #f4f4f1;
  --text-2: #c3c2b7;
  --text-3: #8b8a83;
  --accent: #3987e5;
  --track: #2c2c29;
  --area-finanse: #3987e5;
  --area-relacje: #d95926;
  --area-zdrowie: #199e70;
  --area-podroze: #c98500;
  --area-duch: #d55181;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

/* ===== Baza ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hide-sm { display: inline; }
@media (max-width: 640px) { .hide-sm { display: none; } }

/* ===== Górny pasek ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 12px; min-height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand__mark { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--area-finanse), var(--area-relacje), var(--area-zdrowie), var(--area-podroze), var(--area-duch), var(--area-finanse)); }
.brand__name { display: none; }
@media (min-width: 900px) { .brand__name { display: inline; } }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px; white-space: nowrap;
  color: var(--text-2); font-weight: 500; border: 1px solid transparent;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.is-active { background: var(--text); color: var(--bg); }
.tab__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; }
.tab.is-active .tab__dot { box-shadow: 0 0 0 2px var(--bg); }
.topbar__tools { margin-left: auto; display: flex; gap: 6px; }

/* ===== Strona ===== */
.page { max-width: 1200px; margin: 0 auto; padding: 20px 16px 80px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head__title { display: flex; align-items: center; gap: 12px; }
.area-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex: none; }
.grid { display: grid; gap: 14px; }
.grid--areas { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid--2 { grid-template-columns: 1fr; }
@media (min-width: 860px) { .grid--2 { grid-template-columns: 1fr 1fr; } }
.grid--kpi { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .grid--kpi { grid-template-columns: repeat(4, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.section { margin-top: 26px; }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section__head h2 { display: flex; align-items: center; gap: 10px; }
.count { font-size: .8rem; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 8px; border-radius: 999px; }

/* ===== Karty ===== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card--area { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 10px; color: inherit; transition: transform .12s ease, border-color .12s ease; }
.card--area::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.card--area:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.card__title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: var(--text-2); }
.card__meta b { color: var(--text); font-weight: 600; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi__label { font-size: .8rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi__value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi__sub { font-size: .85rem; color: var(--text-2); }

/* ===== Nagłówek dnia ===== */
.hero { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .hero { grid-template-columns: 1.4fr 1fr; } }
.hero__date { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.hero__date small { display: block; font-size: .9rem; font-weight: 500; color: var(--text-2); margin-top: 2px; }
.ring { display: flex; align-items: center; gap: 14px; }
.ring svg { flex: none; }
.ring__value { font-size: 1.6rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

/* ===== Paski postępu ===== */
.bar { position: relative; height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); border-radius: 999px; background: var(--c, var(--accent)); transition: width .3s ease; }
.bar--thin { height: 5px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-size: .85rem; }
.bar-row .mono { min-width: 3.2em; text-align: right; }

/* ===== Listy ===== */
.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--border); }
.row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 550; overflow-wrap: anywhere; }
.row__sub { font-size: .82rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.row__actions { display: flex; gap: 2px; flex: none; opacity: .55; }
.row:hover .row__actions, .row:focus-within .row__actions { opacity: 1; }
.row.is-done .row__title { text-decoration: line-through; color: var(--text-3); }
.empty { color: var(--text-3); font-size: .9rem; padding: 10px 0; }
.check { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--c, var(--accent)); flex: none; cursor: pointer; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 20px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.chip--good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.chip--warn { color: #9a6a00; border-color: color-mix(in srgb, var(--warning) 60%, transparent); }
:root[data-theme="dark"] .chip--warn { color: var(--warning); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip--warn { color: var(--warning); } }
.chip--crit { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.chip--area { color: var(--text); }
.chip--area::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.prio--high { color: var(--critical); font-weight: 700; }
.prio--low { color: var(--text-3); }

/* ===== Miary ===== */
.metric { display: flex; flex-direction: column; gap: 8px; }
.metric__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.metric__value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric__value small { font-size: .9rem; font-weight: 500; color: var(--text-2); margin-left: 4px; }
.spark { display: block; width: 100%; height: 44px; }
.spark path { fill: none; stroke: var(--c, var(--accent)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .spark__area { fill: var(--c, var(--accent)); opacity: .08; stroke: none; }
.spark .spark__dot { fill: var(--c, var(--accent)); stroke: var(--surface); stroke-width: 2; }
.spark .spark__target { stroke: var(--text-3); stroke-dasharray: 3 4; stroke-width: 1; }
.entry-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; }
.history { font-size: .82rem; }
.history table { width: 100%; border-collapse: collapse; }
.history td { padding: 4px 0; border-top: 1px solid var(--border); }
.history td:last-child { text-align: right; }
details > summary { cursor: pointer; color: var(--text-2); font-size: .85rem; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; }
details[open] > summary::before { content: "▾ "; }

/* ===== Notatki ===== */
.note { padding: 12px 0; }
.note__body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.note__date { font-size: .8rem; color: var(--text-2); font-weight: 600; }

/* ===== Przyciski i formularze ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 550; cursor: pointer; line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 4px 10px; font-size: .85rem; }
.btn--icon { width: 32px; height: 32px; padding: 0; border-color: transparent; background: transparent; color: var(--text-2); border-radius: 8px; font-size: 1.1rem; }
.btn--icon:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { color: var(--critical); }
.btn--block { width: 100%; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea, .input {
  padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); width: 100%; min-width: 0;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; border-color: var(--accent); }
.field textarea { min-height: 110px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field input[type="range"] { padding: 0; border: 0; accent-color: var(--accent); }
.field .hint { font-size: .78rem; color: var(--text-3); }
.error { color: var(--critical); font-size: .85rem; margin-top: 6px; }

/* ===== Modal ===== */
.modal { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(0,0,0,.35); backdrop-filter: blur(2px); }
.modal__form { margin: 0; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; }
.modal__body { padding: 8px 20px; max-height: 70vh; overflow: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.modal__foot .btn--danger { margin-right: auto; }

/* ===== Ekran logowania ===== */
.auth { min-height: calc(100vh - 40px); display: grid; place-items: center; }
.auth .card { width: min(400px, 100%); }
.auth h1 { margin-bottom: 4px; }
.auth p { margin-bottom: 16px; }

/* ===== Toast ===== */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 10px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ===== Drobiazgi ===== */
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.year-bar { margin-top: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: .82rem; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
@media print { .topbar, .btn, .row__actions { display: none !important; } .page { padding: 0; } }

/* ===== Konto, administracja, komunikaty ===== */
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--text); color: var(--bg); display: inline-grid; place-items: center; font-size: .75rem; font-weight: 700; }
.btn--ghost.is-active { background: var(--surface-2); }
.banner { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .9rem; border: 1px solid var(--border); background: var(--surface); display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.banner--warn { border-color: color-mix(in srgb, var(--warning) 60%, transparent); background: color-mix(in srgb, var(--warning) 12%, var(--surface)); }
.banner--crit { border-color: color-mix(in srgb, var(--critical) 50%, transparent); background: color-mix(in srgb, var(--critical) 10%, var(--surface)); }
.banner a { font-weight: 600; }
.checkbox { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; margin: 4px 0 8px; }
.checkbox input { margin-top: 3px; accent-color: var(--accent); }
.settings h2 { margin-bottom: 10px; }
.settings .card > .actions { margin-top: 4px; }
.card--danger { border-color: color-mix(in srgb, var(--critical) 40%, var(--border)); }
.btn--danger-solid { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn--danger-solid:hover { background: color-mix(in srgb, var(--critical) 85%, black); }
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.plan { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; background: var(--surface-2); }
.plan.is-current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.plan__name { font-weight: 600; }
.plan__price { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.plan__price small { font-size: .85rem; font-weight: 500; color: var(--text-2); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.table td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr.is-blocked td { opacity: .6; }
.table .btn { white-space: nowrap; }
.grid > * { min-width: 0; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; gap: 0; } }

/* ===== Przełącznik motywu ===== */
.btn--theme { color: var(--text-2); }
.btn--theme:hover { color: var(--text); }
.topbar__tools .btn--theme { margin-right: 2px; }
.topbar, .page, .card, .btn, .field input, .field select, .field textarea, .input, .bar > i { transition: background-color .2s ease, border-color .2s ease, color .2s ease; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

/* ===== Kluczowe rezultaty (miary intencji) ===== */
.kr-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; border-left: 2px solid var(--border); padding-left: 10px; }
.kr { display: grid; grid-template-columns: minmax(0, 1.4fr) auto minmax(60px, 1fr) 3.2em; gap: 10px; align-items: center; font-size: .85rem; }
.kr__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.kr__value { white-space: nowrap; }
.kr__pct { text-align: right; }
.metric-group + .metric-group { margin-top: 18px; }
@media (max-width: 560px) { .kr { grid-template-columns: minmax(0, 1fr) auto; } .kr__bar, .kr__pct { display: none; } }

/* ===== Rutyny ===== */
.tab--routines { gap: 6px; margin-left: 4px; border-left: 1px solid var(--border); border-radius: 0 999px 999px 0; padding-left: 14px; }
.tab--routines.is-active { border-color: transparent; border-radius: 999px; }
.routine-check { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); cursor: pointer; }
.routine-group .routine-check:first-of-type { border-top: 0; }
.routine-check__name { flex: 1; font-weight: 550; }
.routine-check.is-done .routine-check__name { color: var(--text-3); text-decoration: line-through; }
.routine-check--compact { border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px 6px 8px; background: var(--surface-2); }
.routine-check--compact.is-done { background: color-mix(in srgb, var(--c) 10%, var(--surface)); border-color: color-mix(in srgb, var(--c) 40%, transparent); }
.routine-check--compact .routine-check__name { flex: none; }
.routine-inline { display: flex; flex-wrap: wrap; gap: 8px; }
.chip--streak { color: var(--text); border-color: color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.routine { border-left: 4px solid var(--c); }
.routine.is-inactive { opacity: .7; }
.routine__stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 12px 0 10px; }
@media (min-width: 700px) { .routine__stats { grid-template-columns: repeat(4, 1fr); } }
.routine__stats .kpi__value { font-size: 1.4rem; }
.routine__stats .kpi__value small { font-size: .9rem; font-weight: 500; }
.days7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 6px 0 10px; max-width: 420px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; line-height: 1.1; }
.day__dow { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.day__num { font-weight: 650; font-size: .95rem; color: var(--text); }
.day.is-done { background: var(--c); border-color: var(--c); color: color-mix(in srgb, #fff 85%, var(--c)); }
.day.is-done .day__num { color: #fff; }
.day.is-today { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 45%, transparent); }
.day.is-off { opacity: .45; }
.heat { display: grid; grid-template-columns: 2.2em repeat(var(--weeks, 12), 1fr); gap: 3px; margin-top: 8px; max-width: 520px; }
.heat__label { font-size: .68rem; color: var(--text-3); display: flex; align-items: center; }
.heat__cell { aspect-ratio: 1; border-radius: 3px; background: var(--track); cursor: pointer; }
.heat__cell.is-done { background: var(--c); }
.heat__cell.is-missed { background: color-mix(in srgb, var(--critical) 22%, var(--track)); }
.heat__cell.is-future { background: transparent; border: 1px dashed var(--border); cursor: default; }
.heat__cell.is-today { outline: 2px solid var(--text); outline-offset: -1px; }
.weekdays { display: flex; flex-wrap: wrap; gap: 6px; }
.weekday { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer; font-size: .85rem; }
.weekday:has(input:checked) { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.weekday input { position: absolute; opacity: 0; width: 0; height: 0; }
