:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --ink: #16212c;
  --muted: #5b6b7c;
  --primary: #123a5e;
  --primary-dark: #0b2740;
  --line: #e1e8ee;
  --teal: #1f8a7a;
  --teal-bg: #e6f4f1;
  --amber: #c9791a;
  --amber-bg: #fbf0dd;
  --danger: #b23a2e;
  --danger-bg: #fbeae8;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--primary);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 {
  font-size: 1.05rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: 0.01em;
}
.topbar .who { font-size: 0.78rem; opacity: 0.75; margin-top: 2px; }
.topbar button {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}
.pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--amber);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--primary-dark), var(--primary) 60%);
}
.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 26px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-card h1 {
  font-size: 1.3rem;
  margin: 0 0 4px;
  color: var(--primary-dark);
}
.login-card p.sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 22px;
}
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
  margin: 14px 0 6px;
}
input, select, textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18,58,94,0.12);
}
textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  width: 100%;
  margin-top: 20px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--line); color: var(--ink); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--primary); width: auto; padding: 8px 4px; margin-top: 8px; }

.error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-top: 14px;
}

/* ---------- Main list ---------- */
.content { flex: 1; padding: 14px 14px 100px; max-width: 640px; margin: 0 auto; width: 100%; }

/* ---------- Tyzdenny pasik ---------- */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 4px 10px;
}
.week-label {
  font-weight: 650;
  font-size: 0.92rem;
  color: var(--primary-dark);
  text-transform: capitalize;
}
.week-arrow {
  background: var(--surface);
  border: 1px solid var(--line);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.1rem;
  color: var(--primary);
}
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.week-day {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 8px 2px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.week-day-name { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.week-day-num { font-size: 1rem; font-weight: 650; color: var(--ink); }
.week-day.is-today { border-color: var(--primary); }
.week-day.is-today .week-day-num { color: var(--primary); }
.week-day.is-selected { background: var(--primary); }
.week-day.is-selected .week-day-name,
.week-day.is-selected .week-day-num { color: #fff; }
.week-dots { display: flex; gap: 3px; min-height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-amber { background: var(--amber); }
.dot-teal { background: var(--teal); }
.dot-gray { background: var(--muted); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  margin: 16px 0 4px;
}
.checkbox-row input { width: auto; }

.status-plain { background: var(--line); color: var(--muted); }
.entry-time { color: var(--primary); font-weight: 700; }

.day-group { margin-bottom: 18px; }
.day-heading {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 18px 4px 8px;
}

.entry-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  margin-bottom: 10px;
}
.entry-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.entry-name { font-weight: 650; font-size: 1rem; }
.entry-meta { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }
.entry-note { font-size: 0.85rem; color: var(--ink); margin-top: 8px; background: var(--bg); padding: 8px 10px; border-radius: 8px; }

.status-chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pending { background: var(--amber-bg); color: var(--amber); }
.status-done { background: var(--teal-bg); color: var(--teal); }

.entry-actions { display: flex; gap: 8px; margin-top: 12px; }
.entry-actions button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 9px;
  font-size: 0.82rem;
  font-weight: 650;
}
.act-done { background: var(--teal); color: #fff; }
.act-undo { background: var(--line); color: var(--ink); }
.act-delete { background: var(--danger-bg); color: var(--danger); }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 0.9rem;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.6rem;
  box-shadow: 0 8px 24px rgba(18,58,94,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

/* ---------- Bottom sheet / modal ---------- */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(10,20,30,0.45);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 88vh;
  overflow-y: auto;
}
.sheet h2 { margin: 0 0 4px; font-size: 1.15rem; color: var(--primary-dark); }
.sheet .close-x {
  position: absolute;
  background: none; border: none; font-size: 1.3rem; color: var(--muted);
}
.sheet-header { display: flex; justify-content: space-between; align-items: center; }

.row-2 { display: flex; gap: 10px; }
.row-2 > div { flex: 1; }

.tabbar {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
}
.tabbar button {
  flex: 1;
  border: none;
  background: none;
  padding: 12px 0 calc(env(safe-area-inset-bottom) + 10px);
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--muted);
}
.tabbar button.active { color: var(--primary); }

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}
.user-row .role-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 6px 4px 12px;
  color: var(--primary-dark);
}

.hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

@media (min-width: 640px) {
  .content { padding-top: 24px; }
}
