:root {
  --border: #d0d0d0;
  --bg: #f7f7f5;
  --accent: #2f6f4f;
  --accent-dark: #1f4d36;
  --danger: #b23b3b;
  --text: #222;
  --muted: #888;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem 1rem;
  background: var(--accent-dark);
  color: white;
  flex-wrap: wrap;
}
.topbar .brand { font-weight: bold; }
.topbar nav { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.topbar nav a { color: #d9ecdf; text-decoration: none; padding: 0.2rem 0.4rem; border-radius: 4px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,0.15); color: white; }
.topbar .userbox { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.link-btn { background: none; border: none; color: #d9ecdf; text-decoration: underline; cursor: pointer; font-size: 0.9rem; padding: 0; }

main { padding: 1rem 1.2rem 3rem; max-width: 1400px; margin: 0 auto; }

.auth-box, .error-box, .panel { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; max-width: 640px; margin: 2rem auto; }
.panel { max-width: 1100px; }

.stacked-form { display: flex; flex-direction: column; gap: 0.8rem; }
.stacked-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.stacked-form input, .stacked-form select { padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 4px; font-size: 1rem; }
.stacked-form button { align-self: flex-start; }

button, .btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-dark); }
button:disabled { background: #aaa; cursor: not-allowed; }

.error { color: var(--danger); font-weight: 600; }
.success { color: var(--accent-dark); font-weight: 600; }
.warn { color: #8a6d00; background: #fff6d9; padding: 0.5rem 0.7rem; border-radius: 5px; }

.grid-header { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.grid-header h1 { margin: 0; font-size: 1.3rem; }
.month-nav a { margin-right: 0.8rem; text-decoration: none; color: var(--accent-dark); font-weight: 600; }
.edit-toggle { margin-left: auto; font-weight: 600; }

.table-wrap { overflow-x: auto; }

table.grid { border-collapse: collapse; width: 100%; background: white; }
table.grid th, table.grid td { border: 1px solid var(--border); padding: 0.35rem 0.4rem; font-size: 0.85rem; vertical-align: top; }
table.grid th { background: #eef3ee; text-align: left; }
table.grid .date-col { min-width: 130px; white-space: nowrap; font-weight: 700; }
.schedule-hint { font-size: 0.7rem; color: var(--muted); margin-top: 1px; line-height: 1.25; font-weight: normal; }
table.grid input[type="text"] { width: 100%; background: transparent; border: 1px solid transparent; padding: 0.15rem 0.25rem; font-size: 0.85rem; border-radius: 3px; text-align: center; }
table.grid input[type="text"]:hover, table.grid input[type="text"]:focus { border-color: var(--border); background: #fbfff9; }
table.grid td.entry-cell { text-align: center; }
table.grid td.entry-cell.cell-complete { background: #dcf3e0; }
table.grid .entry-checked-by { color: var(--muted); margin-top: 2px; }
table.grid td.entry-cell.cell-error { background: #fde2e2; outline: 2px solid var(--danger); outline-offset: -2px; }
table.grid th.col-removed { background: #f3f3f3; color: var(--muted); }
table.grid td.cell-removed { background: #f7f7f7; }
table.grid td.cell-removed input, table.grid td.cell-removed select { color: var(--muted); }
.removed-badge { display: inline-block; margin-top: 2px; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: #8a6d00; background: #fff6d9; border-radius: 3px; padding: 0 4px; }
.no-name { color: var(--danger); font-weight: normal; }
.save-alert { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.8rem; padding: 0.6rem 0.8rem; background: #fde2e2; border: 1px solid var(--danger); border-radius: 6px; color: #7a1f1f; font-weight: 600; }
.save-alert[hidden], .save-alert [hidden] { display: none; }
.save-alert-text { flex: 1 1 18rem; }
tr.excluded-row { background: #f0f0f0; color: var(--muted); }
tr.excluded-row .excluded-cell { text-align: center; font-style: italic; }

.col-tools { display: flex; gap: 2px; margin-top: 3px; }
.col-tools button { padding: 0 4px; font-size: 0.7rem; }
.kind-badge { display: inline-block; margin-left: 3px; font-weight: bold; color: var(--accent-dark); }
.entry-select { width: 100%; background: transparent; font-size: 0.8rem; padding: 0.15rem; border: 1px solid var(--border); border-radius: 3px; text-align: center; text-align-last: center; }
.day-tools { margin-top: 3px; }
.day-tools button { padding: 0.1rem 0.3rem; font-size: 0.7rem; }

.edit-only { display: none; }
body.edit-mode .edit-only { display: initial; }
body.edit-mode table.grid .col-tools { display: flex; }
body.edit-mode tr.excluded-row { outline: 2px dashed #c99; outline-offset: -2px; }

.add-col-box { margin-top: 1rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form input { padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 4px; }

.simple-table { border-collapse: collapse; width: 100%; background: white; margin-top: 0.5rem; }
.simple-table th, .simple-table td { border: 1px solid var(--border); padding: 0.4rem 0.5rem; font-size: 0.9rem; text-align: left; }
.simple-table th { background: #eef3ee; }

.export-actions { display: flex; gap: 0.6rem; margin: 1rem 0; }
.discreet-link { margin-top: 1.5rem; font-size: 0.8rem; }
.discreet-link a { color: var(--muted); }

/* ===== Widok "Dzis" (telefon/tablet) ===== */
.today { max-width: 560px; margin: 0 auto; }
.today-head { display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0 0.5rem; }
.today-title { flex: 1; text-align: center; min-width: 0; }
.today-kicker { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.today-title h1 { margin: 0.15rem 0 0; font-size: 1.25rem; line-height: 1.25; }
.day-arrow { flex: 0 0 44px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: white; color: var(--accent-dark); font-size: 1.7rem; line-height: 1; text-decoration: none; padding-bottom: 3px; }
.day-arrow:hover { background: #eef3ee; }
.day-arrow.is-off { visibility: hidden; }
.today-past { margin: 0 0 0.5rem; padding: 0.45rem 0.7rem; background: #fff6d9; border-radius: 6px; color: #6b5400; font-size: 0.9rem; text-align: center; }
.today-past a { color: inherit; font-weight: 700; }
.today-closed { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem; text-align: center; color: var(--muted); }
.today-closed strong { display: block; color: var(--text); font-size: 1.1rem; margin-bottom: 0.4rem; }

.today-sticky { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 0.4rem 0 0.2rem; }
.today-sticky .save-alert { position: static; margin-bottom: 0.5rem; }
.checker-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.7rem; padding: 0.6rem 0.75rem; background: white; border: 1px solid var(--border); border-radius: 10px; transition: box-shadow 0.2s, border-color 0.2s; }
.checker-bar label { font-weight: 700; font-size: 0.9rem; }
.checker-bar input { flex: 1 1 10rem; min-width: 0; font-size: 1.1rem; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; }
.checker-bar input:focus { outline: 3px solid #bfe3cb; border-color: var(--accent); }
.checker-bar.needs-name { border-color: #d29b00; box-shadow: 0 0 0 3px #fff1c2; }
.checker-hint { flex-basis: 100%; margin: 0; font-size: 0.85rem; color: #6b5400; }

.today-card { margin: 0.75rem 0; background: white; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.today-card-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0.75rem 0.9rem 0.1rem; }
.today-card-head h2 { margin: 0; font-size: 1.1rem; }
.today-card-sub { margin: 0.1rem 0.9rem 0.55rem; font-size: 0.8rem; color: var(--muted); }
.today-progress { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.today-progress.is-done { color: var(--accent); }
.today-progress.is-done::after { content: ' ✓'; }
.today-empty { margin: 0 0.9rem 0.8rem; color: var(--muted); font-size: 0.9rem; }

.today-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.5rem 0.75rem; padding: 0.7rem 0.9rem; border-top: 1px solid #ececec; transition: background 0.3s; }
.today-row.is-cleaning { grid-template-columns: minmax(0, 1fr); }
.today-row-info { min-width: 0; }
.today-row-name { display: block; font-weight: 650; font-size: 1rem; }
.today-kind { display: block; font-size: 0.75rem; color: var(--muted); }
.today-row-status { min-height: 1.15em; margin-top: 0.15rem; font-size: 0.82rem; color: var(--muted); }
.today-row.is-complete { background: #f1faf3; }
.today-row.is-complete .today-row-status { color: var(--accent-dark); font-weight: 600; }
.today-row.is-incomplete { background: #fffaea; }
.today-row.is-incomplete .today-row-status { color: #6b5400; font-weight: 600; }
.today-row.is-error { background: #fde2e2; }
.today-row.is-error .today-row-status { color: var(--danger); font-weight: 700; }

.today-temp { display: flex; align-items: center; gap: 0.3rem; }
.today-temp-input { width: 5.2rem; padding: 0.45rem 0.3rem; font-size: 1.45rem; font-variant-numeric: tabular-nums; text-align: center; border: 1px solid var(--border); border-radius: 8px; background: white; }
.today-temp-input:focus { outline: 3px solid #bfe3cb; border-color: var(--accent); }
.today-temp-input::placeholder { color: #cfcfcf; }
.today-temp-input:placeholder-shown { border-style: dashed; }
.today-row.is-error .today-temp-input { border-color: var(--danger); }
.today-unit { color: var(--muted); font-size: 0.95rem; }

.status-buttons { display: flex; flex-wrap: wrap; gap: 0.35rem; }
button.status-btn { flex: 1 1 auto; min-height: 44px; padding: 0.5rem 0.55rem; background: white; color: var(--text); border: 1px solid var(--border); border-radius: 999px; font-size: 0.9rem; white-space: nowrap; }
button.status-btn:hover { background: #eef3ee; }
button.status-btn.is-selected { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
button.status-btn.is-selected::before { content: '✓ '; }
.today-links { margin: 1rem 0 0; text-align: center; font-size: 0.9rem; color: var(--muted); }
.today-links a { color: var(--accent-dark); }

/* ===== Telefon: zwarty pasek gorny, menu przewijane w poziomie ===== */
@media (max-width: 640px) {
  .topbar { gap: 0.35rem 0.75rem; padding: 0.5rem 0.75rem 0.4rem; }
  .topbar .brand { flex: 1 1 auto; min-width: 0; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .userbox { order: 2; margin-left: 0; gap: 0.5rem; font-size: 0.8rem; }
  .topbar .userbox .user-role { display: none; }
  .topbar nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -0.75rem; padding: 0 0.75rem; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { white-space: nowrap; padding: 0.35rem 0.6rem; }
  main { padding: 0.6rem 0.75rem 2.5rem; }
  .grid-header h1 { font-size: 1.1rem; }
}

.only-print { display: none; }

table.print-grid td:not(.date-col) { text-align: center; }

@media print {
  .no-print { display: none !important; }
  .only-print { display: block; }
  body { background: white; }
  main { padding: 0; max-width: none; }
  section.print-page { page-break-after: always; }
  table.print-grid th, table.print-grid td { font-size: 10px; padding: 2px 4px; }
}
