/* ============================================================
   Tablica — style. Dwa motywy: jasna „suchościeralna" (domyślna)
   i ciemna „kredowa". Karteczki wyglądają jak na tablicy.
   ============================================================ */

:root {
  --font-hand: 'Caveat', 'Segoe Script', cursive;
  --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;

  /* statusy */
  --st-zarezerwowane: #d9a406;
  --st-wplacone: #199c54;
  --st-dozwrotu: #e4572e;
  --st-odwolane: #8d99ae;

  /* karteczki */
  --note-zarezerwowane: #fff6c4;
  --note-wplacone: #ddf5e3;
  --note-dozwrotu: #ffe3d3;
  --note-odwolane: #ebebe7;

  /* motyw jasny — tablica suchościeralna */
  --bg: #e9e4d8;
  --bg-texture: radial-gradient(circle at 20% 10%, rgba(255,255,255,.5), transparent 45%),
                radial-gradient(circle at 85% 90%, rgba(255,255,255,.35), transparent 40%);
  --board: #f8f6ef;
  --panel: #ffffff;
  --panel-2: #f3f0e7;
  --ink: #2d3436;
  --muted: #837c6e;
  --line: #ddd6c6;
  --accent: #0e7a5f;
  --accent-ink: #ffffff;
  --danger: #c0392b;
  --shadow: 0 2px 6px rgba(60, 50, 20, .14);
  --shadow-lift: 0 8px 22px rgba(60, 50, 20, .22);
  --col-bg: rgba(255, 255, 255, .55);
  --note-ink: #333026;
}

body.theme-dark {
  /* motyw ciemny — tablica kredowa */
  --bg: #22302a;
  --bg-texture: radial-gradient(circle at 30% 20%, rgba(255,255,255,.05), transparent 50%),
                radial-gradient(circle at 80% 85%, rgba(255,255,255,.04), transparent 45%);
  --board: #2a3a33;
  --panel: #33453d;
  --panel-2: #2e3f37;
  --ink: #eef2ec;
  --muted: #9fb0a4;
  --line: #45564d;
  --accent: #56c596;
  --accent-ink: #10241b;
  --shadow: 0 2px 8px rgba(0, 0, 0, .35);
  --shadow-lift: 0 10px 26px rgba(0, 0, 0, .5);
  --col-bg: rgba(255, 255, 255, .05);
  --note-zarezerwowane: #f4ecb4;
  --note-wplacone: #cfeeda;
  --note-dozwrotu: #f7d8c5;
  --note-odwolane: #dcdcd6;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg-texture), var(--bg);
}

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--ink); }

.hidden { display: none !important; }

/* ---------- Przyciski ---------- */

.btn {
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  transition: transform .06s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

.btn-big { width: 100%; padding: 12px; font-size: 17px; border-radius: 12px; }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--col-bg); box-shadow: none; }

/* ---------- Pola formularzy ---------- */

label { display: block; font-weight: 700; margin-bottom: 12px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 13px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="tel"], input[type="month"], select, textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
textarea { resize: vertical; min-height: 64px; }

/* ============================================================
   Strony logowania
   ============================================================ */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-wrap { width: 100%; max-width: 430px; }

.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-logo { font-size: 44px; }
.auth-brand h1 {
  font-family: var(--font-hand);
  font-size: 56px;
  margin: 2px 0 0;
  color: var(--accent);
  letter-spacing: 1px;
}
.auth-brand p { margin: 4px 0 0; color: var(--muted); }

.auth-card {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lift);
  padding: 26px;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--panel-2);
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  padding: 9px;
  border-radius: 9px;
}
.auth-tab.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

.auth-h2 { font-family: var(--font-hand); font-size: 34px; margin: 0 0 8px; color: var(--accent); }

.auth-error { color: var(--danger); font-weight: 700; min-height: 20px; margin-bottom: 8px; font-size: 14px; }
.auth-note { color: var(--muted); font-size: 13.5px; line-height: 1.45; }

.auth-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 700;
  margin-top: 14px;
  text-align: center;
  text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

.auth-success {
  background: color-mix(in srgb, var(--st-wplacone) 12%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--st-wplacone) 40%, transparent);
  border-radius: 12px;
  padding: 14px;
}
.reset-link {
  display: inline-block;
  margin: 6px 0;
  font-weight: 800;
  color: var(--accent);
  font-size: 17px;
}

/* ============================================================
   Aplikacja — nagłówek
   ============================================================ */

.app-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1.5px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 20;
}

.brand { display: flex; align-items: baseline; gap: 8px; margin-right: 6px; }
.brand .brand-name {
  font-family: var(--font-hand);
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.brand .property { color: var(--muted); font-weight: 700; font-size: 14px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
}
.chip .big { font-size: 15px; }
.chip.chip-warn { border-color: color-mix(in srgb, var(--st-dozwrotu) 50%, transparent); color: var(--st-dozwrotu); }

.top-search { position: relative; flex: 1; min-width: 160px; max-width: 340px; }
.top-search input { margin-top: 0; border-radius: 999px; padding: 8px 14px 8px 36px; }
.top-search .search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
  max-height: 60vh;
  overflow: auto;
  z-index: 60;
}
.search-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--panel-2); }
.search-item .s-name { font-weight: 800; }
.search-item .s-meta { color: var(--muted); font-size: 13px; }
.search-item .s-arch { font-size: 12px; font-weight: 700; color: var(--muted); }

.view-switch {
  display: flex;
  gap: 4px;
  background: var(--panel-2);
  border-radius: 999px;
  padding: 4px;
}
.view-switch button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13.5px;
}
.view-switch button.active { background: var(--accent); color: var(--accent-ink); }

.topbar .spacer { flex: 1; }
.icon-btn {
  border: 1.5px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.icon-btn:hover { box-shadow: var(--shadow); }
.icon-btn:disabled { opacity: .4; cursor: default; box-shadow: none; }
a.icon-btn { text-decoration: none; color: var(--ink); }

/* ---------- Pasek abonamentu ---------- */

.billing-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  background: color-mix(in srgb, var(--st-zarezerwowane) 16%, var(--panel));
  border-bottom: 1.5px solid color-mix(in srgb, var(--st-zarezerwowane) 45%, transparent);
  font-weight: 700;
  font-size: 14px;
  z-index: 15;
}
.billing-banner.expired {
  background: color-mix(in srgb, var(--st-dozwrotu) 15%, var(--panel));
  border-bottom-color: color-mix(in srgb, var(--st-dozwrotu) 50%, transparent);
}
.billing-banner .bb-text { flex: 1; }
.billing-banner .bb-close {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 16px;
  padding: 4px 8px;
}
.billing-banner .bb-close:hover { color: var(--ink); }

.billing-box {
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.billing-box .b-state { flex: 1; font-size: 14px; }
.billing-box .b-state strong { display: block; }
.billing-box .b-state.ok strong { color: var(--st-wplacone); }
.billing-box .b-state.warn strong { color: var(--st-dozwrotu); }

/* ============================================================
   Układ główny: panel „Dziś" + tablica
   ============================================================ */

.app-main { flex: 1; display: flex; min-height: 0; }

.today-panel {
  width: 250px;
  flex-shrink: 0;
  background: var(--panel-2);
  border-right: 1.5px solid var(--line);
  padding: 14px;
  overflow-y: auto;
}
.today-panel h2 {
  font-family: var(--font-hand);
  font-size: 30px;
  margin: 0 0 2px;
  color: var(--accent);
}
.today-date { color: var(--muted); font-weight: 700; font-size: 13px; margin-bottom: 12px; }

.today-section { margin-bottom: 14px; }
.today-section h3 {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin: 0 0 6px;
}
.today-item {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 9px;
  padding: 7px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 13.5px;
  transition: box-shadow .15s;
}
.today-item:hover { box-shadow: var(--shadow); }
.today-item .t-name { font-weight: 800; }
.today-item .t-meta { color: var(--muted); font-size: 12.5px; }
.today-item.t-out { border-left-color: var(--st-zarezerwowane); }
.today-item.t-refund { border-left-color: var(--st-dozwrotu); }
.today-empty { color: var(--muted); font-size: 13px; font-style: italic; }

.today-note textarea {
  background: var(--note-zarezerwowane);
  border: 1.5px dashed color-mix(in srgb, var(--st-zarezerwowane) 55%, transparent);
  color: var(--note-ink);
  min-height: 90px;
  font-family: var(--font-hand);
  font-size: 19px;
  line-height: 1.3;
}

.print-btn { width: 100%; margin-top: 8px; font-size: 13.5px; }

/* ---------- Tablica z kolumnami ---------- */

.board {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 14px;
  overflow: auto;
  background: var(--board);
}

.column {
  display: flex;
  flex-direction: column;
  background: var(--col-bg);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  min-width: 190px;
  min-height: 0;
  transition: background .15s, border-color .15s;
}
.column.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--col-bg));
}

.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  border-bottom: 3px solid var(--col-color, var(--line));
}
.col-head h2 {
  font-family: var(--font-hand);
  font-size: 27px;
  margin: 0;
  color: var(--col-color, var(--ink));
  line-height: 1;
}
.col-count {
  font-weight: 800;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border-radius: 999px;
  padding: 2px 9px;
}
.col-sum { font-size: 12.5px; font-weight: 800; color: var(--st-dozwrotu); padding: 4px 14px 0; }

.col-body { flex: 1; overflow-y: auto; padding: 10px; }

.column[data-status="zarezerwowane"] { --col-color: var(--st-zarezerwowane); }
.column[data-status="wplacone"]      { --col-color: var(--st-wplacone); }
.column[data-status="dozwrotu"]      { --col-color: var(--st-dozwrotu); }
.column[data-status="odwolane"]      { --col-color: var(--st-odwolane); }

/* ---------- Karteczka ---------- */

.note-card {
  position: relative;
  background: var(--note-bg, var(--note-zarezerwowane));
  color: var(--note-ink);
  border-radius: 4px;
  padding: 10px 12px 9px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  transform: rotate(var(--tilt, 0deg));
  transition: transform .12s, box-shadow .15s;
  border-top: 5px solid var(--st, var(--st-zarezerwowane));
}
.note-card:hover { transform: rotate(0deg) scale(1.02); box-shadow: var(--shadow-lift); z-index: 2; }
.note-card:active { cursor: grabbing; }
.note-card.dragging { opacity: .45; }

/* „taśma klejąca" u góry karteczki */
.note-card::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 46px;
  height: 14px;
  background: rgba(255, 255, 255, .55);
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: 2px;
}

.note-card[data-status="zarezerwowane"] { --st: var(--st-zarezerwowane); --note-bg: var(--note-zarezerwowane); }
.note-card[data-status="wplacone"]      { --st: var(--st-wplacone);      --note-bg: var(--note-wplacone); }
.note-card[data-status="dozwrotu"]      { --st: var(--st-dozwrotu);      --note-bg: var(--note-dozwrotu); }
.note-card[data-status="odwolane"]      { --st: var(--st-odwolane);      --note-bg: var(--note-odwolane); opacity: .82; }

.note-name {
  font-weight: 800;
  font-size: 15.5px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
}
.note-tags { font-size: 13px; letter-spacing: 1px; white-space: nowrap; }
.note-dates { font-family: var(--font-hand); font-size: 20px; line-height: 1.1; margin: 2px 0; }
.note-meta { font-size: 12.5px; color: color-mix(in srgb, var(--note-ink) 62%, transparent); display: flex; justify-content: space-between; gap: 6px; }
.note-money { font-weight: 800; font-size: 13px; margin-top: 3px; }
.note-money .due { color: var(--st-dozwrotu); }
.note-drawing-ico { position: absolute; right: 8px; bottom: 6px; font-size: 12px; opacity: .55; }

.note-done-btn {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 5px 8px;
  border: 1.5px solid var(--st-wplacone);
  border-radius: 8px;
  background: rgba(255, 255, 255, .6);
  color: var(--st-wplacone);
  font-weight: 800;
  font-size: 12.5px;
  transition: background .15s;
}
.note-done-btn:hover { background: var(--st-wplacone); color: #fff; }

/* karteczka po terminie zwrotu delikatnie domaga się uwagi */
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--st-dozwrotu) 55%, transparent), var(--shadow); }
  50% { box-shadow: 0 0 0 6px transparent, var(--shadow); }
}
.note-card.overdue { animation: pulse-border 1.8s infinite; }

.col-empty {
  color: var(--muted);
  text-align: center;
  font-family: var(--font-hand);
  font-size: 20px;
  padding: 24px 8px;
  opacity: .75;
}

/* ============================================================
   Kalendarz obłożenia
   ============================================================ */

.calendar-view { flex: 1; overflow: auto; padding: 14px; background: var(--board); }

.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-head h2 { font-family: var(--font-hand); font-size: 32px; margin: 0; color: var(--accent); text-transform: capitalize; }

.cal-grid {
  display: grid;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
  min-width: 900px;
}
.cal-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-height: 40px;
  font-size: 12px;
  position: relative;
}
.cal-day-head {
  text-align: center;
  font-weight: 800;
  padding: 6px 0 4px;
  background: var(--panel-2);
  min-height: auto;
}
.cal-day-head .dow { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; }
.cal-day-head.weekend { color: var(--st-dozwrotu); }
.cal-day-head.today-col { background: color-mix(in srgb, var(--accent) 18%, var(--panel-2)); }
.cal-room {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  font-weight: 800;
  background: var(--panel-2);
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 3;
}
.cal-cell.today-col { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.cal-bar {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 3px;
  right: 3px;
  border-radius: 999px;
  background: var(--st-zarezerwowane);
  color: #fff;
  font-weight: 800;
  font-size: 11.5px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 2;
}
.cal-bar:hover { filter: brightness(1.08); z-index: 4; }
.cal-bar[data-status="zarezerwowane"] { background: var(--st-zarezerwowane); }
.cal-bar[data-status="wplacone"] { background: var(--st-wplacone); }
.cal-bar[data-status="dozwrotu"] { background: var(--st-dozwrotu); }
.cal-bar[data-status="odwolane"] { background: var(--st-odwolane); }

.cal-legend { display: flex; gap: 14px; margin-top: 10px; color: var(--muted); font-size: 13px; font-weight: 700; flex-wrap: wrap; }
.cal-legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* ============================================================
   Archiwum i Podsumowanie
   ============================================================ */

.list-view { flex: 1; overflow: auto; padding: 18px; background: var(--board); }
.list-view .inner { max-width: 900px; margin: 0 auto; }
.list-view h2 { font-family: var(--font-hand); font-size: 34px; color: var(--accent); margin: 0 0 4px; }
.list-sub { color: var(--muted); margin: 0 0 14px; }

.arch-month {
  font-family: var(--font-hand);
  font-size: 24px;
  color: var(--muted);
  margin: 18px 0 6px;
  text-transform: capitalize;
}
.arch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 9px 14px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.arch-row:hover { box-shadow: var(--shadow); }
.arch-row .a-dates { font-weight: 800; white-space: nowrap; color: var(--muted); font-size: 13.5px; width: 150px; }
.arch-row .a-name { font-weight: 800; flex: 1; }
.arch-row .a-meta { color: var(--muted); font-size: 13px; }

.status-chip {
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}
.status-chip[data-status="zarezerwowane"] { background: var(--st-zarezerwowane); }
.status-chip[data-status="wplacone"] { background: var(--st-wplacone); }
.status-chip[data-status="dozwrotu"] { background: var(--st-dozwrotu); }
.status-chip[data-status="odwolane"] { background: var(--st-odwolane); }

.arch-toolbar { display: flex; gap: 10px; align-items: center; }
.arch-toolbar input { margin-top: 0; flex: 1; }
.arch-toolbar .btn { white-space: nowrap; }

.bal-head { font-family: var(--font-hand); font-size: 26px; color: var(--accent); margin: 24px 0 8px; }
.bal-table-wrap { overflow-x: auto; }
.bal-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-size: 14px;
}
.bal-table th, .bal-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.bal-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--panel-2); }
.bal-table .num { text-align: right; white-space: nowrap; }
.bal-table tr.settled td { color: var(--muted); }
.bal-table tfoot td { font-weight: 800; background: var(--panel-2); border-bottom: none; }

.stats-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 14px; }
.stat-tile {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-tile .v { font-size: 34px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat-tile .l { color: var(--muted); font-weight: 700; font-size: 13px; margin-top: 4px; }

/* ============================================================
   Modale
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 20, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}

.modal {
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow-lift);
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.modal.modal-sm { max-width: 400px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 8px;
}
.modal-head h2 { font-family: var(--font-hand); font-size: 32px; margin: 0; color: var(--accent); }
.modal-close { border: none; background: none; font-size: 22px; color: var(--muted); line-height: 1; }
.modal-close:hover { color: var(--ink); }

.modal-body { padding: 6px 20px; overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1.5px solid var(--line);
}
.modal-foot .spacer { flex: 1; }

.form-row { display: flex; gap: 12px; }
.form-row > label { flex: 1; min-width: 0; }

.more-toggle {
  display: block;
  width: 100%;
  margin: 2px 0 14px;
  padding: 9px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 13.5px;
  text-align: center;
}
.more-toggle:hover { color: var(--ink); border-color: var(--accent); }

/* segmenty statusu / płatności */
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.seg button {
  border: 1.5px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 13px;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
}
.seg button.active { border-color: var(--seg-c, var(--accent)); background: color-mix(in srgb, var(--seg-c, var(--accent)) 14%, transparent); color: var(--ink); }
.seg button[data-status="zarezerwowane"].active { --seg-c: var(--st-zarezerwowane); }
.seg button[data-status="wplacone"].active { --seg-c: var(--st-wplacone); }
.seg button[data-status="dozwrotu"].active { --seg-c: var(--st-dozwrotu); }
.seg button[data-status="odwolane"].active { --seg-c: var(--st-odwolane); }

.room-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.room-chip {
  border: 1.5px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 13px;
  font-weight: 700;
  font-size: 13px;
}
.room-chip.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.rooms-none { color: var(--muted); font-size: 13px; font-style: italic; }

.tag-toggles { display: flex; gap: 8px; margin-top: 5px; }
.tag-toggle {
  border: 1.5px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 16px;
  opacity: .55;
}
.tag-toggle.active { opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.collision-warn {
  background: color-mix(in srgb, var(--st-dozwrotu) 13%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--st-dozwrotu) 55%, transparent);
  color: var(--ink);
  border-radius: 11px;
  padding: 10px 13px;
  margin-bottom: 12px;
  font-size: 13.5px;
  font-weight: 700;
}
.collision-warn strong { color: var(--st-dozwrotu); }

.hint-move-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 800;
  font-size: inherit;
  text-decoration: underline;
}

/* podpowiedzi gości */
.guest-box { position: relative; }
.guest-suggest {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow-lift);
  z-index: 30;
  overflow: hidden;
}
.guest-suggest div { padding: 9px 12px; cursor: pointer; font-size: 13.5px; }
.guest-suggest div:hover { background: var(--panel-2); }
.guest-suggest .g-name { font-weight: 800; }
.guest-suggest .g-meta { color: var(--muted); font-size: 12.5px; display: block; }

/* pisanie rysikiem */
.draw-wrap { margin-top: 5px; }
.draw-canvas {
  width: 100%;
  height: 150px;
  background: var(--note-zarezerwowane);
  border: 1.5px dashed color-mix(in srgb, var(--st-zarezerwowane) 55%, transparent);
  border-radius: 10px;
  touch-action: none;
  cursor: crosshair;
  display: block;
}
.draw-tools { display: flex; gap: 8px; margin-top: 5px; align-items: center; }
.draw-tools .hint2 { color: var(--muted); font-size: 12.5px; flex: 1; }

/* oś czasu zdarzeń */
.timeline { margin: 6px 0 10px; border-left: 2.5px solid var(--line); padding-left: 14px; }
.timeline .tl-item { position: relative; margin-bottom: 9px; font-size: 13px; }
.timeline .tl-item::before {
  content: '';
  position: absolute;
  left: -19.5px;
  top: 4px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline .tl-at { color: var(--muted); font-size: 12px; font-weight: 700; }

/* sekcja ustawień — pokoje */
.room-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.room-row input { margin-top: 0; }
.room-row .r-name { flex: 1; }
.room-row .r-cap { width: 84px; }
.room-row button { flex-shrink: 0; }

.theme-pick { display: flex; gap: 10px; margin-top: 5px; }
.theme-pick button {
  flex: 1;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-weight: 800;
  background: var(--panel);
}
.theme-pick button.active { border-color: var(--accent); }
.theme-pick .th-light { background: #f8f6ef; color: #2d3436; }
.theme-pick .th-dark { background: #2a3a33; color: #eef2ec; }

.onboard-hint {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1.5px dashed var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- Toasty (z przyciskiem Cofnij) ---------- */

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-lift);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toast-in .2s ease-out;
}
body.theme-dark .toast { background: #eef2ec; color: #22302a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.toast button {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 800;
  font-size: 14px;
  padding: 0;
}
body.theme-dark .toast button { color: #0e7a5f; }

/* ---------- Drukowanie planu dnia ---------- */

@media print {
  body.app-page * { visibility: hidden; }
  /* specyficzność musi wygrać z regułą powyżej — inaczej drukuje się pusta strona */
  body.app-page .today-panel, body.app-page .today-panel * { visibility: visible; }
  body.app-page { overflow: visible; height: auto; }
  body.app-page .today-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    max-height: none;
    border: none;
    background: #fff;
    color: #000;
    padding: 20mm 15mm;
    font-size: 14px;
  }
  body.app-page .today-panel h2 { color: #000; }
  body.app-page .today-panel h2::after { content: ' — ' attr(data-property); font-size: 18px; }
  body.app-page .today-date { color: #333; }
  body.app-page .today-item { border-color: #999; background: #fff; box-shadow: none; break-inside: avoid; }
  body.app-page .today-item .t-meta { color: #444; }
  body.app-page .today-section h3 { color: #000; }
  body.app-page .today-note textarea {
    background: #fff;
    border-color: #999;
    color: #000;
  }
  body.app-page .print-btn { display: none; }
}

/* ---------- Responsywność ---------- */

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app-main { flex-direction: column; }
  .today-panel { width: 100%; border-right: none; border-bottom: 1.5px solid var(--line); max-height: 34vh; }
  .app-page { overflow: auto; height: auto; min-height: 100vh; }
}
@media (max-width: 620px) {
  .board { grid-template-columns: 1fr; padding: 10px; }
  .form-row { flex-direction: column; gap: 0; }

  /* telefon: zwarty pasek górny, przełącznik widoków na całą szerokość */
  .topbar { padding: 8px 10px; gap: 6px; }
  .brand .property { display: none; }
  .brand .brand-name { font-size: 26px; }
  .chip { font-size: 12px; padding: 4px 9px; }
  .top-search { min-width: 130px; order: 5; flex-basis: 100%; max-width: none; }
  .view-switch { order: 6; width: 100%; justify-content: space-between; }
  .view-switch button { flex: 1; padding: 6px 4px; font-size: 12.5px; }
  .btn-primary#newCardBtn { padding: 8px 10px; font-size: 13.5px; }

  .today-panel { max-height: 40vh; }
  .modal { max-height: 96vh; border-radius: 14px; }
  .modal-body { padding: 6px 14px; }
  .modal-head, .modal-foot { padding-left: 14px; padding-right: 14px; }
  .list-view { padding: 12px; }
  .arch-toolbar { flex-wrap: wrap; }
  .arch-row { flex-wrap: wrap; gap: 4px 10px; }
  .arch-row .a-dates { width: auto; }
}

/* ============================================================
   Panel admina — konta klientów i abonamenty. Ekran „biurowy":
   spokojniejszy od tablicy, bez karteczek i przekrzywień.
   ============================================================ */

.adm-page {
  background: var(--bg);
  background-image: var(--bg-texture);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
}

.adm-top {
  background: var(--panel);
  border-bottom: 1.5px solid var(--line);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 5;
}

.adm-top-in {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.adm-title {
  font-family: var(--font-hand);
  font-size: 30px;
  color: var(--accent);
  margin: 0;
  flex: 1;
}

.adm-top-actions { display: flex; align-items: center; gap: 8px; }

.adm-search {
  border: 1.5px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  width: 240px;
}
.adm-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.adm-wrap { max-width: 1100px; margin: 0 auto; padding: 18px; }

/* --- Komunikat po akcji --- */

.adm-msg {
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-weight: 700;
  border: 1.5px solid;
}
.adm-msg-ok { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); }
.adm-msg-err { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); color: var(--danger); }

/* --- Kafelki podsumowania --- */

.adm-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.adm-tile {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.adm-tile-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.adm-tile-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.adm-tile-hint { color: var(--muted); font-size: 12px; }
.adm-tile-ok { border-left: 5px solid var(--st-wplacone); }
.adm-tile-trial { border-left: 5px solid var(--st-zarezerwowane); }
.adm-tile-exp { border-left: 5px solid var(--st-dozwrotu); }

/* --- Konta --- */

.adm-accounts { display: flex; flex-direction: column; gap: 12px; }

.adm-loading { color: var(--muted); text-align: center; padding: 24px; }

.adm-acc {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.adm-acc.is-blocked { opacity: .72; border-style: dashed; }

.adm-acc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.adm-acc-who h3 { margin: 0 0 2px; font-size: 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adm-mail { color: var(--muted); font-size: 14px; text-decoration: none; }
.adm-mail:hover { text-decoration: underline; }

.adm-tag {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.adm-tag-block { background: var(--danger); color: #fff; }

.adm-badge {
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  border: 1.5px solid;
}
.adm-badge-ok { color: var(--st-wplacone); border-color: var(--st-wplacone); background: color-mix(in srgb, var(--st-wplacone) 12%, transparent); }
.adm-badge-trial { color: var(--st-zarezerwowane); border-color: var(--st-zarezerwowane); background: color-mix(in srgb, var(--st-zarezerwowane) 14%, transparent); }
.adm-badge-exp { color: var(--st-dozwrotu); border-color: var(--st-dozwrotu); background: color-mix(in srgb, var(--st-dozwrotu) 12%, transparent); }

.adm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 26px;
  margin: 12px 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.adm-meta dt { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.adm-meta dd { margin: 0; font-size: 15px; font-weight: 700; }

.adm-acc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.adm-acc-actions .btn { font-size: 14px; padding: 7px 12px; }
.adm-acc-actions .btn:disabled { opacity: .5; cursor: default; }

/* --- Dziennik --- */

.adm-logbox { margin-top: 22px; }
.adm-log {
  margin-top: 8px;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 6px 14px;
  max-height: 320px;
  overflow-y: auto;
}
.adm-log-row {
  display: flex;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.adm-log-row:last-child { border-bottom: none; }
.adm-log-at { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- Okienko --- */

.adm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.adm-modal-card {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
  padding: 18px 20px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.adm-modal-card label { display: block; margin: 10px 0; font-weight: 700; font-size: 14px; }
.adm-modal-card input[type="text"],
.adm-modal-card input[type="date"] {
  display: block;
  width: 100%;
  margin-top: 4px;
  border: 1.5px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
}
.adm-url {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  margin: 10px 0;
}
.adm-modal-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-inline-msg { color: var(--accent); font-size: 13.5px; font-weight: 700; min-height: 18px; margin-top: 8px; }
.adm-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

@media (max-width: 700px) {
  .adm-top-in { flex-wrap: wrap; }
  .adm-title { font-size: 26px; }
  .adm-search { width: 100%; order: 3; }
  .adm-wrap { padding: 12px; }
  .adm-badge { white-space: normal; }
  .adm-acc-actions .btn { flex: 1 1 auto; }
}
