:root {
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --border:    #dfe3e8;
  --text:      #1c2430;
  --muted:     #6b7684;
  --accent:    #2563eb;
  --danger:    #c0392b;
  --radius:    8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* --- topbar --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.topbar nav {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.topbar nav a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- treść --- */
main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

h1 { font-size: 1.6rem; margin: 0 0 1.25rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.muted { color: var(--muted); margin: 0; }

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.5rem;
  margin: 0;
}

.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

/* --- stopka --- */
footer {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.badge-dev {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.5rem;
}

/* Tabele szerokie na wąskim ekranie nie mogą rozpychać strony. */
.table-wrap { overflow-x: auto; }

/* --- pasek użytkownika --- */
.logout {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.who { color: var(--muted); font-size: 0.9rem; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  padding: 0;
  text-decoration: underline;
}

/* --- logowanie --- */
main.narrow { max-width: 380px; }

.login-wrap { margin-top: 3rem; }

.login-card { display: flex; flex-direction: column; }
.login-card h1 { font-size: 1.3rem; }

.login-card label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.login-card input {
  font: inherit;
  padding: 0.55rem 0.7rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.login-card button {
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.login-card button:disabled {
  background: var(--muted);
  cursor: not-allowed;
}

.alert-error {
  background: #fdecea;
  border: 1px solid #f5c2bd;
  color: #8f2c20;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin: 0 0 1rem;
  font-size: 0.92rem;
}

.alert-ok {
  background: #e9f7ef;
  border: 1px solid #b7e0c6;
  color: #1e6b3c;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin: 0 0 1rem;
  font-size: 0.92rem;
}

/* --- naglowek strony --- */
.page-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-head h1 { margin: 0; }
.page-head .btn { margin-left: auto; }

.count {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  vertical-align: middle;
}

.crumb { margin: 0 0 0.75rem; font-size: 0.9rem; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); }

/* --- przyciski --- */
.btn, button {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.95rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-light {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger, button.btn-danger { background: var(--danger); }

.cancel {
  color: var(--muted);
  text-decoration: none;
  align-self: center;
}

/* --- wyszukiwarka --- */
.searchbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.searchbar input {
  font: inherit;
  flex: 1 1 260px;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.searchbar .clear { color: var(--muted); font-size: 0.9rem; }

/* --- tabela --- */
table.list { width: 100%; border-collapse: collapse; font-size: 0.94rem; }

table.list th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.list td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.list tr:last-child td { border-bottom: none; }
table.list td a { color: var(--accent); text-decoration: none; font-weight: 600; }
table.list td a:hover { text-decoration: underline; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.small { font-size: 0.82rem; }

.tag {
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #eef0f3;
  color: var(--muted);
  white-space: nowrap;
}

.tag-on { background: #e5efff; color: #1d4ed8; }

/* --- podzakladki --- */
.subtabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.subtabs a {
  padding: 0.5rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subtabs a:hover { color: var(--accent); }

.subtabs a.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* --- formularz --- */
.form .field { margin-bottom: 1.1rem; }

.form label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.form input[type="text"],
.form input[type="date"],
.form select,
.form textarea {
  font: inherit;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.form textarea { resize: vertical; }

.form .field.has-error input,
.form .field.has-error select { border-color: var(--danger); }

.field-error { color: var(--danger); font-size: 0.85rem; margin: 0.3rem 0 0; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0 0; }
.req { color: var(--danger); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

@media (max-width: 620px) {
  .two-col { grid-template-columns: 1fr; }
}

.field.checkbox label { font-weight: 400; display: flex; gap: 0.5rem; align-items: center; }
.field.checkbox input { width: auto; }

.form-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 0.5rem;
}

.empty { color: var(--muted); }
.prewrap { white-space: pre-wrap; margin: 0; }

.danger-zone { border-color: #f0c9c3; }
.danger-zone h2 { color: var(--danger); }

/* --- abonament: stan biezacy --- */
.status-now h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.status-big {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
  font-variant-numeric: tabular-nums;
}

.status-big span { font-size: 1rem; font-weight: 400; color: var(--muted); }
.status-active   { color: #15803d; }
.status-susp     { color: #b45309; }
.status-none     { color: var(--muted); }
.status-negative { color: var(--danger); }

.small-intro { margin: 0 0 1.25rem; font-size: 0.9rem; }

.radio-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.radio-row label { font-weight: 400; display: flex; gap: 0.4rem; align-items: center; }
.radio-row input { width: auto; }

.tag-ok { background: #e6f4ea; color: #15803d; }

.row-current { background: #f7fbff; }

.row-actions {
  white-space: nowrap;
  text-align: right;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: baseline;
}

.row-actions a { color: var(--muted); font-size: 0.88rem; }
.row-actions form { display: inline; }
.link-btn.danger { color: var(--danger); }

/* --- ustawienia --- */
.formula pre {
  background: #f4f6f8;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.6;
  overflow-x: auto;
}

.unit-input { display: flex; align-items: center; gap: 0.6rem; }
.unit-input input { max-width: 12rem; }
.unit { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

hr.sep { border: none; border-top: 1px solid var(--border); margin: 1.75rem 0; }

/* --- wynagrodzenie --- */
.month-badge {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

table.payroll td.num { font-variant-numeric: tabular-nums; }
.row-off td { color: var(--muted); }
.negative { color: var(--danger); font-weight: 600; }

.summary dl { margin: 0; }

.sum-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.sum-row dt { color: var(--muted); }
.sum-row dd { margin: 0; font-variant-numeric: tabular-nums; }
.sum-gross dt, .sum-gross dd { color: var(--text); font-weight: 600; }

.sum-total {
  border-bottom: none;
  border-top: 2px solid var(--text);
  margin-top: 0.35rem;
  padding-top: 0.7rem;
}

.sum-total dt { color: var(--text); font-size: 1.05rem; font-weight: 700; }
.sum-total dd { font-size: 1.35rem; font-weight: 700; }

.payout .status-big span { font-size: 1rem; }
.payout h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.sum-base {
  border-top: 1px solid var(--text);
  border-bottom: 1px solid var(--border);
  padding-top: 0.6rem;
  margin-top: 0.35rem;
}

.sum-base dt, .sum-base dd { color: var(--text); font-weight: 600; }

/* --- alerty --- */
.alert-section h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.section-overdue { border-color: #f0c9c3; background: #fffaf9; }
.section-overdue h2 { color: var(--danger); }

.alert-list { list-style: none; margin: 0; padding: 0; }

.alert-item {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  align-items: baseline;
}

.alert-item:last-child { border-bottom: none; }
.alert-item.is-done .alert-title { text-decoration: line-through; color: var(--muted); }

.alert-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  flex: 1 1 320px;
}

.alert-date {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.alert-title { font-weight: 600; }
.alert-body { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 0.9rem; }
.tag-rec { background: #f3e8ff; color: #7e22ce; }

.alert-actions {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin-left: auto;
  white-space: nowrap;
}

.alert-actions form { display: inline; }
.alert-actions a { color: var(--muted); font-size: 0.88rem; text-decoration: none; }
.alert-actions a:hover { color: var(--accent); text-decoration: underline; }

.btn-check {
  background: #e6f4ea;
  color: #15803d;
  border: 1px solid #b7e0c6;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
}

.btn-check:hover { background: #d3ecdc; }

/* --- wybor dnia + filtry --- */
.daypick {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.daypick label { font-size: 0.9rem; color: var(--muted); }
.daypick input {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.note-day { margin: 0 0 1rem; font-size: 0.9rem; }

.list-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.list-head h2 { margin: 0; }

.filters { margin-left: auto; display: flex; gap: 0.75rem; }
.filters a { color: var(--muted); font-size: 0.88rem; text-decoration: none; }
.filters a.active { color: var(--text); font-weight: 600; text-decoration: underline; }

.tag-late { background: #fdecea; color: #8f2c20; font-weight: 600; }

/* --- pilnosc terminow: 3 dni zolty, 2-1 pomaranczowy, dzis/po terminie czerwony --- */
.tag-warn { background: #fef3c7; color: #854d0e; font-weight: 600; }
.tag-soon { background: #ffedd5; color: #9a3412; font-weight: 600; }
.tag-now  { background: #fdecea; color: #8f2c20; font-weight: 700; }

/* data na czerwono tylko po terminie */
.alert-date.date-late { color: var(--danger); font-weight: 700; }

/* --- checklista --- */
.inline-add { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-add input { flex: 1 1 320px; }
.inline-add button { white-space: nowrap; }

.tpl-list { margin: 0; padding-left: 1.5rem; }
.tpl-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.tpl-list li:last-child { border-bottom: none; }

.tpl-row { display: flex; gap: 0.5rem; align-items: center; flex: 1 1 320px; }
.tpl-row input {
  font: inherit;
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.tpl-actions { display: flex; gap: 0.6rem; align-items: center; margin-left: auto; }
.tpl-actions form { display: inline; }

.progress-label { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
/* <progress> zamiast diva ze stylem inline — CSP blokuje atrybut style.
   Kazda przegladarka maluje ten element wlasnymi pseudo-elementami,
   stad trzy warianty tej samej reguly. */
progress.progress-bar {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  border: none;
  border-radius: 999px;
  background: #eef0f3;
  overflow: hidden;
}

progress.progress-bar::-webkit-progress-bar {
  background: #eef0f3;
  border-radius: 999px;
}

progress.progress-bar::-webkit-progress-value {
  background: #15803d;
  border-radius: 999px;
}

progress.progress-bar::-moz-progress-bar {
  background: #15803d;
  border-radius: 999px;
}

.chk-list { list-style: none; margin: 0; padding: 0; }
.chk-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.chk-item:last-child { border-bottom: none; }
.chk-item > form:first-child { flex: 1; }
.chk-top { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.4rem; }
.chk-text { font-weight: 600; }
.chk-zrobione .chk-text { text-decoration: line-through; color: var(--muted); }
.chk-nie_dotyczy .chk-text { color: var(--muted); }
.chk-bottom { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.chk-bottom input {
  font: inherit;
  font-size: 0.9rem;
  flex: 1 1 220px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.chk-del { margin-left: auto; }

/* --- historia kontaktow --- */
.note-date-field input { max-width: 12rem; }

.note-list { list-style: none; margin: 0; padding: 0; }
.note-item {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: none; }

.note-head {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.35rem;
}

.note-date { font-weight: 700; font-variant-numeric: tabular-nums; }
.note-actions { margin-left: auto; display: flex; gap: 0.75rem; }
.note-actions a { color: var(--muted); font-size: 0.88rem; text-decoration: none; }
.note-actions a:hover { color: var(--accent); text-decoration: underline; }
.note-actions .danger-link:hover { color: var(--danger); }

.note-body { margin: 0; }

.note-quote {
  border-left: 3px solid var(--border);
  padding: 0.5rem 0 0.5rem 1rem;
  margin: 0.5rem 0 1rem;
  color: var(--text);
}
