/* Paleta "Neon Clean": chłodny grafit, turkusowy akcent, limonkowy postęp. */
:root {
  --bg: #12161a;
  --surface: #1e252b;
  --sunken: #283139;
  --ink: #e8eef2;
  --muted: #94a3ae;
  --line: #2e3942;
  --accent: #00f5d4;
  --accent-ink: #04231f;
  --accent-soft: #0e3b3a;
  --lime: #39ff14;
  --warn: #ffb454;
  --warn-soft: #3b2d18;
  --danger: #ff7a85;
  --danger-soft: #3d2026;
  --ok: #39ff14;
  --ok-soft: #173a1c;
  --shadow: none;
  --radius: 16px;
  --av-l: 26%;
  --av-ink: 82%;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: 1.05rem; letter-spacing: -0.01em; }
h3 { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }

/* ---------- układ ---------- */

.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; min-width: 0; }
.brand img { width: 30px; height: 30px; border-radius: 9px; flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  position: relative; flex: none;
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: none; border: 0; cursor: pointer;
}
.icon-btn:hover { background: var(--sunken); }
.icon-btn svg, .nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.badge {
  position: absolute; top: 4px; right: 3px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: var(--surface);
  font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center;
}

.view {
  flex: 1; width: 100%; max-width: 1040px; margin: 0 auto;
  padding: 20px 16px calc(96px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
}
.view > header { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.cols { display: grid; gap: 16px; align-items: start; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav button {
  flex: 1; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; border-radius: 12px; cursor: pointer;
  color: var(--muted); font-size: 0.72rem; font-weight: 600;
}
.nav button[aria-current="page"] { color: var(--accent); }
.nav .nav-brand { display: none; }

@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .top { position: fixed; top: 0; right: 0; left: 232px; justify-content: flex-end; border: 0; background: none; backdrop-filter: none; pointer-events: none; padding: 18px 28px; }
  .top .brand { display: none; }
  .top .icon-btn { pointer-events: auto; background: var(--surface); border: 1px solid var(--line); }
  .nav {
    position: sticky; top: 0; bottom: auto; right: auto;
    width: 232px; height: 100dvh; flex: none;
    flex-direction: column; gap: 4px; padding: 20px 14px;
    border-top: 0; border-right: 1px solid var(--line);
    background: var(--surface); backdrop-filter: none;
  }
  .nav .nav-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; }
  .nav .nav-brand img { width: 32px; height: 32px; border-radius: 9px; }
  .nav .nav-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav button { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; min-height: 46px; font-size: 0.95rem; }
  .nav button:hover { background: var(--sunken); }
  .nav button[aria-current="page"] { background: var(--accent-soft); }
  .view { padding: 32px 28px 48px; gap: 20px; }
  .view > header { padding-right: 120px; }
  .cols { grid-template-columns: 1fr 1fr; gap: 20px; }
  h1 { font-size: 1.9rem; }
}

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

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; min-width: 0; }
.row + .row { border-top: 1px solid var(--line); }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
.row .actions { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
button.row { background: none; border: 0; border-radius: 0; text-align: left; cursor: pointer; width: 100%; }
button.row:hover .title { color: var(--accent); }
.row.unread .title::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }

.emoji {
  flex: none; width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.3rem;
  background: var(--sunken);
}
.av {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 0.9rem;
  background: hsl(var(--h) 60% var(--av-l)); color: hsl(var(--h) 55% var(--av-ink));
}
.av.sm { width: 24px; height: 24px; font-size: 0.7rem; }
.who { display: inline-flex; align-items: center; gap: 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; white-space: nowrap;
  background: var(--sunken); color: var(--muted);
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--sunken); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 0.88rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.fab { position: fixed; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 4; box-shadow: 0 6px 20px rgb(0 0 0 / 22%); min-height: 52px; border-radius: 26px; padding: 0 20px; }
@media (min-width: 900px) { .fab { position: static; box-shadow: none; min-height: 44px; border-radius: 12px; align-self: flex-start; } }

.empty { color: var(--muted); padding: 6px 0; }

.balance { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.balance.plus, .plus { color: var(--ok); }
.balance.minus, .minus { color: var(--warn); }

.code { font: 700 1.7rem/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.18em; }
.phone-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--sunken); }
.phone-box strong { font-size: 1.35rem; letter-spacing: 0.04em; }
ol.steps { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 0.92rem; }

/* ---------- formularze ---------- */

form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, legend { font-size: 0.86rem; font-weight: 600; }
.field small { color: var(--muted); }
input[type="text"], input[type="tel"], input[type="password"], select {
  width: 100%; min-height: 46px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  font-size: 16px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline { display: flex; gap: 8px; align-items: flex-end; }
.inline .field.emoji-field { flex: none; width: 76px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { position: relative; }
.check input { position: absolute; opacity: 0; inset: 0; }
.check input + span { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px 0 8px; border-radius: 20px; border: 1px solid var(--line); cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.check input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.thumb { max-width: 100%; max-height: 160px; border-radius: 10px; border: 1px solid var(--line); align-self: flex-start; }
.receipt { width: 100%; border-radius: 12px; border: 1px solid var(--line); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--sunken); }
.seg button { min-height: 40px; border: 0; border-radius: 10px; background: none; font-weight: 600; font-size: 0.9rem; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- ekran startowy ---------- */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 20px; }
.auth-hero { display: flex; flex-direction: column; gap: 10px; }
.auth-hero img { width: 56px; height: 56px; border-radius: 16px; }

/* ---------- okno modalne i toast ---------- */

dialog {
  width: min(480px, 100vw); max-width: 100vw; max-height: 92dvh;
  margin: auto auto 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border: 0; border-radius: 20px 20px 0 0;
  background: var(--surface); color: var(--ink);
  overflow-y: auto;
}
dialog[open] { display: flex; flex-direction: column; gap: 16px; }
dialog::backdrop { background: rgb(10 15 12 / 55%); }
@media (min-width: 600px) { dialog { margin: auto; border-radius: 20px; padding: 24px; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h2 { font-size: 1.2rem; padding-top: 8px; overflow-wrap: anywhere; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; }

#toast {
  position: fixed; inset: auto auto calc(90px + env(safe-area-inset-bottom)) 50%; margin: 0; border: 0; z-index: 2147483647;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 0.92rem; text-align: center;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- sprzątanie: status, kalendarz okresu, zadania, grafik ---------- */

.status { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--sunken); }
.status strong { font-size: 1rem; }
.status span { font-size: 0.86rem; color: var(--muted); }
.status.big { padding: 14px; }
.status.big strong { font-size: 1.25rem; letter-spacing: -0.01em; line-height: 1.2; }
.status.ok { background: var(--ok-soft); }
.status.ok strong { color: var(--ok); }
.status.warn { background: var(--warn-soft); }
.status.warn strong { color: var(--warn); }
.status.danger { background: var(--danger-soft); }
.status.danger strong { color: var(--danger); }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; }
.cal .dow { text-align: center; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding-bottom: 2px; }
.cal .day { height: 44px; display: grid; place-items: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal .day span { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.cal .day.past { color: var(--muted); font-weight: 400; }
.cal .day.today span { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: repeat(7, 1fr); }
.bar { display: flex; align-items: center; gap: 4px; min-width: 0; height: 32px; padding: 0 6px; border-radius: 10px; background: var(--sunken); color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.bar.open { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.bar.late { background: var(--danger-soft); color: var(--danger); }
.bar.done { background: var(--ok-soft); color: var(--ok); }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.swatch.win { background: var(--accent-soft); border: 1px solid var(--accent); }
.swatch.today { background: var(--accent); border-radius: 50%; }

.progress-row { display: flex; align-items: center; gap: 12px; }
.progress { flex: 1; height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 4px; background: var(--lime); }

.tasks { display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.task .grow { flex: 1 1 9rem; }
.task .title { font-weight: 700; overflow-wrap: break-word; }
.task .sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; color: var(--muted); font-size: 0.86rem; }
.task .actions { display: flex; gap: 6px; flex: none; margin-left: auto; }
.task.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.task.done .title { color: var(--muted); text-decoration: line-through; }
.task.done .emoji { opacity: 0.6; }

.rota-wrap { overflow-x: auto; margin: 0 -4px; }
.rota { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.rota th, .rota td { padding: 8px 6px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.rota tbody tr:last-child th, .rota tbody tr:last-child td { border-bottom: 0; }
.rota thead th { font-size: 0.78rem; color: var(--muted); font-weight: 600; vertical-align: bottom; }
.rota thead small { display: block; font-weight: 400; }
.rota tbody th { font-weight: 600; }
.rota .now { background: var(--accent-soft); }
.rota thead .now { border-radius: 10px 10px 0 0; color: var(--ink); }
.rota tbody tr:last-child .now { border-radius: 0 0 10px 10px; }

.banner { flex-direction: row; align-items: center; flex-wrap: wrap; background: var(--warn-soft); border-color: transparent; }

/* ---------- usterki ---------- */

.board { display: grid; gap: 16px; align-items: start; }
@media (min-width: 900px) { .board { grid-template-columns: repeat(3, 1fr); } }
.issue { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.issue .title { font-weight: 700; overflow-wrap: anywhere; }
.issue p { overflow-wrap: anywhere; }
.issue .sub { color: var(--muted); font-size: 0.84rem; }
.issue-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.nav button span { white-space: nowrap; }

/* ---------- avatary i ustawienia konta ---------- */

img.av { object-fit: cover; background: var(--sunken); }
.av.pic { font-size: 1.2rem; }
.av.sm.pic { font-size: 0.85rem; }
.av.lg { width: 76px; height: 76px; font-size: 1.9rem; }
.av.lg.pic { font-size: 2.4rem; }
.icon-btn .av { width: 32px; height: 32px; }
.avatar-edit { display: flex; align-items: center; gap: 16px; }
.avatar-edit .grow { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.picker button { aspect-ratio: 1; min-height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 1.25rem; font-weight: 700; cursor: pointer; padding: 0; }
.picker button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.picker.hues button { background: hsl(var(--h) 60% var(--av-l)); border-radius: 50%; }
