/* Prosty, jasny wygląd – duże przyciski, czytelne na telefonie. */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1f2937;
  --primary-text: #ffffff;
  --green: #15803d;   /* zaakceptowane */
  --orange: #c2410c;  /* oczekujące */
  --red: #b91c1c;     /* odrzucone */
  --blue: #1d4ed8;    /* brak odpowiedzi – zwrócone */
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand img { border-radius: 6px; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-right form { margin: 0; }
.who { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

.container { max-width: 880px; margin: 0 auto; padding: 16px; }
h1 { font-size: 24px; margin: 8px 0 12px; }
h2 { font-size: 19px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin: 24px auto; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=email], input[type=password], input[type=text], input[type=tel], textarea, select {
  width: 100%; padding: 14px; font-size: 17px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 3px solid #93c5fd; border-color: #3b82f6; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 10px;
  font-size: 17px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-ghost { background: transparent; color: var(--text); min-height: 40px; padding: 0 10px; font-weight: 600; }
.btn-block { width: 100%; margin-top: 20px; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; background: #eef2ff; }
.alert-error { background: #fef2f2; color: var(--red); }
.alert-success { background: #f0fdf4; color: var(--green); }
.field-error { color: var(--red); font-size: 14px; margin: 4px 0 0; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--card); border: 1px solid var(--border); border-left: 5px solid var(--muted);
  border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; font-size: 14px;
}
.stat .num { font-size: 26px; font-weight: 800; }
.st-pending { border-left-color: var(--orange); }
.st-accepted { border-left-color: var(--green); }
.st-rejected { border-left-color: var(--red); }
.st-returned { border-left-color: var(--blue); }

.install-banner {
  display: block; width: calc(100% - 32px); max-width: 848px; margin: 12px auto 0;
  min-height: 48px; border: 2px dashed var(--primary); border-radius: 10px;
  background: #fff; font-size: 17px; font-weight: 700; cursor: pointer; color: var(--text);
}
.install-banner[hidden] { display: none; }

/* --- Etap 2: nawigacja, listy, odznaki, link zaproszenia --- */
.tabs { display: flex; gap: 4px; padding: 0 12px; background: var(--card); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 12px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--text); }

a { color: var(--blue); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 8px 0; }

.row-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; color: var(--text); text-decoration: none;
}
.row-card:active { background: #f3f4f6; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-main span { overflow-wrap: anywhere; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge-active { background: #dcfce7; color: var(--green); }
.badge-invited { background: #ffedd5; color: var(--orange); }
.badge-inactive { background: #e5e7eb; color: #4b5563; }

.btn-secondary { background: #fff; color: var(--text); border: 2px solid var(--text); }
.btn-danger { background: #fff; color: var(--red); border: 2px solid var(--red); }
.btn-block + .btn-block { margin-top: 10px; }

.link-box {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; background: #f3f4f6;
  border: 1px dashed #9ca3af; border-radius: 10px; padding: 12px; overflow-wrap: anywhere; user-select: all;
}
label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-top: 18px; }
label.check input { width: 22px; height: 22px; }

/* --- Etap 2b: Google --- */
.btn-google { background: #fff; color: #1f1f1f; border: 1px solid #747775; gap: 10px; font-weight: 600; margin-top: 8px; }
.btn-google:active { background: #f1f3f4; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin: 18px 0 4px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* --- Etap 3: zlecenia --- */
a.stat { color: var(--text); text-decoration: none; }
.badge-green { background: #dcfce7; color: var(--green); }
.badge-orange { background: #ffedd5; color: var(--orange); }
.badge-red { background: #fee2e2; color: var(--red); }
.badge-blue { background: #dbeafe; color: var(--blue); }
.badge-gray { background: #e5e7eb; color: #4b5563; }
.alert-red { background: #fef2f2; color: var(--red); }
.alert-blue { background: #eff6ff; color: var(--blue); }
.alert-gray { background: #f3f4f6; }

.bar-green { border-left: 5px solid var(--green); }
.bar-orange { border-left: 5px solid var(--orange); }
.bar-red { border-left: 5px solid var(--red); }
.bar-blue { border-left: 5px solid var(--blue); }
.bar-gray { border-left: 5px solid #9ca3af; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.chip { padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--border); color: var(--text); text-decoration: none; white-space: nowrap; font-size: 15px; font-weight: 600; }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }

.order-card { display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; color: var(--text); text-decoration: none; }
.order-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.order-no { font-size: 20px; font-weight: 800; color: var(--text); text-decoration: none; }
.order-meta { color: var(--muted); font-size: 15px; margin-top: 6px; }
.order-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.order-actions .btn { flex: 1; min-width: 140px; }
.msg { margin-top: 8px; }
.msg summary { cursor: pointer; }
.msg p { margin: 8px 0 0; white-space: normal; }
.msg-preview { margin: 8px 0 0; }

.message-box { background: #f9fafb; border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 12px 0; font-size: 17px; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

.btn-accept { background: var(--green); color: #fff; font-size: 19px; min-height: 56px; }
.btn-call { background: var(--green); color: #fff; font-size: 22px; min-height: 60px; margin-top: 4px; }
.phone-box { margin: 12px 0; }
details.reject > summary { list-style: none; margin-top: 10px; }
details.reject > summary::-webkit-details-marker { display: none; }
details.reject[open] > summary { display: none; }

.section-title { margin-top: 22px; display: flex; align-items: center; gap: 8px; }
.count { background: var(--orange); color: #fff; border-radius: 999px; padding: 0 9px; font-size: 14px; }
details.history { margin-top: 22px; }
details.history summary { cursor: pointer; font-weight: 700; padding: 10px 0; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 14px; }
.ev-accepted .what strong { color: var(--green); }
.ev-rejected .what strong { color: var(--red); }
.ev-expired .what strong { color: var(--blue); }
.ev-assigned .what strong { color: var(--orange); }

details.danger-zone summary { cursor: pointer; color: var(--red); font-weight: 700; }
textarea { resize: vertical; font-family: inherit; }
select { appearance: auto; }

/* poprawki: długie statusy i przyciski na wąskim ekranie */
.order-top { flex-wrap: wrap; align-items: flex-start; }
.order-top .badge, .page-head .badge { white-space: normal; text-align: center; max-width: 100%; }
.order-actions .btn { min-width: 0; padding: 0 12px; font-size: 16px; white-space: nowrap; }
input[type=datetime-local] { width: 100%; padding: 14px; font-size: 17px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; font-family: inherit; }

/* --- Etap 4: ustawienia --- */
input[type=time], input[type=number] { width: 100%; padding: 14px; font-size: 17px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; font-family: inherit; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.day-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.day-pick { margin: 0; display: inline-flex; align-items: center; justify-content: center; min-width: 52px; min-height: 46px;
  border: 2px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 700; position: relative; }
.day-pick input { position: absolute; opacity: 0; pointer-events: none; }
.day-pick:has(input:checked) { background: var(--text); border-color: var(--text); color: #fff; }
.day-pick:has(input:focus-visible) { outline: 3px solid #93c5fd; }
.holidays { list-style: none; padding: 0; margin: 0; }
.holidays li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.holidays li:last-child { border-bottom: 0; }
.two-cols { align-items: end; }

/* --- Etap 5: powiadomienia --- */
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--text); }
.bell-count { position: absolute; top: 4px; right: 2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 800; line-height: 20px; text-align: center; }
.bell-count[hidden] { display: none; }
a.who { color: var(--muted); text-decoration: none; }

.notif { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--border);
  border-left: 5px solid #d1d5db; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; color: var(--text); text-decoration: none; }
.notif.unread { background: #fffbeb; border-left-color: var(--orange); }
.notif.unread .notif-title { font-weight: 800; }
.notif-title { font-weight: 600; }
.notif-body { color: #374151; font-size: 15px; }
.notif-when { color: var(--muted); font-size: 13px; }

.choice-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 6px; }
.choice { display: flex; align-items: center; gap: 12px; margin: 0; padding: 14px; border: 2px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 600; }
.choice input { width: 22px; height: 22px; flex: none; }
.choice:has(input:checked) { border-color: var(--text); background: #f3f4f6; }
.push-box [data-push-state] { margin-top: 0; }
.facts dd { overflow-wrap: anywhere; min-width: 0; }

/* --- Etap 6: filtry, strony, historia --- */
.filters { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; display: grid; gap: 10px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-row > input[type=search], .filter-row > select { flex: 1; min-width: 0; }
input[type=search], input[type=date] { width: 100%; padding: 12px; font-size: 16px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; font-family: inherit; }
.filters select { padding: 12px; font-size: 16px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; }
.filters .dates { display: none; }
.filters.custom-dates .dates { display: flex; }
label.inline { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 600; flex: 1; min-width: 140px; }
.filters .btn { min-height: 44px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 16px 0; }
.stat.attention .num { color: var(--blue); }

.event-list { list-style: none; padding: 0; margin: 0; }
.event { display: grid; grid-template-columns: 1fr; gap: 2px; background: var(--card); border: 1px solid var(--border); border-left: 5px solid #d1d5db; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px; }
.event-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.event .when { color: var(--muted); font-size: 14px; }
.event a.order-link { font-weight: 800; color: var(--text); text-decoration: none; }
.event.ev-accepted { border-left-color: var(--green); }
.event.ev-rejected { border-left-color: var(--red); }
.event.ev-expired { border-left-color: var(--blue); }
.event.ev-assigned, .event.ev-reminder { border-left-color: var(--orange); }
.event.ev-cancelled, .event.ev-revoked { border-left-color: #6b7280; }
.event-day { margin: 18px 0 8px; font-size: 15px; color: var(--muted); }

.mini-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
@media (min-width: 640px) { .mini-stats { grid-template-columns: repeat(4, 1fr); } }
.mini-stats div { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.mini-stats strong { font-size: 22px; color: var(--text); }
@media (max-width: 480px) {
  .tabs { padding: 0 4px; gap: 0; }
  .tabs a { padding: 12px 9px; font-size: 15px; }
}

/* --- Etap 7: raporty --- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.report { width: 100%; border-collapse: collapse; font-size: 15px; }
table.report th, table.report td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.report th:first-child, table.report td:first-child { text-align: left; white-space: normal; min-width: 120px; }
table.report thead th { font-size: 13px; color: var(--muted); font-weight: 700; }
table.report tfoot th { border-top: 2px solid var(--text); border-bottom: 0; }
table.report td a { color: var(--text); font-weight: 600; }
.c-green { color: var(--green) !important; } .c-red { color: var(--red) !important; } .c-blue { color: var(--blue) !important; }
.bell.active { color: var(--blue); }
@media (max-width: 560px) {
  table.report thead { display: none; }
  table.report, table.report tbody, table.report tfoot, table.report tr { display: block; width: 100%; }
  table.report tr { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  table.report tfoot tr { border: 2px solid var(--text); }
  table.report td, table.report th { display: flex; justify-content: space-between; border: 0; padding: 2px 0; text-align: left; font-size: 15px; }
  table.report td:first-child, table.report th:first-child { grid-column: 1 / -1; font-size: 17px; margin-bottom: 4px; }
  table.report td[data-label]::before, table.report th[data-label]::before { content: attr(data-label); color: var(--muted); font-weight: 400; margin-right: 8px; }
}
