/* Správa ubytoven – základní styl. Mobil na prvním místě. */
:root {
  /* Vzhled A – „Noční směna“: tmavý, klidný, modrý akcent */
  color-scheme: dark;
  --bg: #121418;
  --surface: #1A1D23;
  --surface-2: #232730;
  --text: #ECEEF1;
  --muted: #A3AAB5;
  --border: #2A2F37;
  --brand: #8AB4FF;      /* akcent */
  --brand-ink: #121418;  /* text na akcentu */
  --ok: #4ADE80;
  --warn: #FBBF24;
  --bad: #FF8A8A;
  --bad-bg: #2A1719;
  --bad-border: #5A2A2E;
  --free: #5B6370;
  --radius: 20px;
  --tap: 48px; /* minimální výška ovládacích prvků pro palec */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--brand); }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 1.5rem; margin: 8px 0 16px; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--brand);
  color: var(--brand-ink);
}
.topbar a, .topbar .link { color: var(--brand-ink); }
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav form { margin: 0; }

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

.form { display: grid; gap: 8px; }
.form label { font-weight: 600; margin-top: 8px; }
.form input, .form select, .form textarea {
  min-height: var(--tap);
  padding: 10px 12px;
  font-size: 17px; /* 16px+ zabrání zoomu v Safari na iPhonu */
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-block { width: 100%; margin-top: 16px; }

.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.auth { max-width: 380px; margin: 10vh auto 0; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.msg { padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.msg-error { border-color: var(--bad); color: var(--bad); }
.msg-success { border-color: var(--ok); color: var(--ok); }

/* ---------- Krok 3: ubytovny, pokoje, lůžka ---------- */
.narrow { max-width: 560px; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.chip-active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip-add { border-style: dashed; color: var(--muted); }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-head h1 { margin-bottom: 0; }
.sub { margin: 2px 0 0; }
.stat { display: grid; justify-items: end; line-height: 1.2; padding-top: 8px; }
.stat-num { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
  align-items: start;
}
.room {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  scroll-margin-top: 80px;
}
.room:target { outline: 2px solid var(--brand); }
.room-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.room-head h2 { font-size: 1.15rem; margin: 0; }
.room-edit { font-size: 0.95rem; }
.room-meta { margin: 2px 0 8px; font-size: 0.95rem; }
.room-note { margin: 0 0 8px; font-size: 0.95rem; }

.beds { list-style: none; margin: 0 0 10px; padding: 0; }
.bed {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  border-top: 1px solid var(--border);
}
.bed form { margin: 0 0 0 auto; }
.bed-main { display: grid; line-height: 1.25; }
.bed-label { font-weight: 600; }
.bed-empty { padding: 8px 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; background: var(--free); }
.bed-ok .dot { background: var(--ok); }
.bed-warn .dot { background: var(--warn); }
.bed-bad .dot { background: var(--bad); }
.bed-free .dot { background: transparent; border: 2px solid var(--free); }

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--bad); }

.btn-small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }

.field { display: grid; gap: 4px; }
.field label { margin-top: 8px; }
.field small { font-size: 0.85rem; }
.field-error input, .field-error textarea { border-color: var(--bad); }
.error, .errorlist { color: var(--bad); }
.errorlist { padding-left: 18px; margin: 0; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.danger-zone { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- Krok 4: ubytovaní ---------- */
.small { font-size: 0.9rem; }
.sub-title { margin: -8px 0 12px; }
.bed { padding: 6px 0; }
.bed .btn-checkin { margin-left: auto; }
.bed .btn-checkin + form { margin-left: 0; }
.tenant-link { color: var(--text); text-decoration: none; }
.tenant-link:hover { text-decoration: underline; }
.phone { color: var(--brand); text-decoration: none; font-variant-numeric: tabular-nums; }
.phone-right { margin-left: auto; white-space: nowrap; }

.dot-ok { background: var(--ok); }
.dot-free { background: transparent; border: 2px solid var(--free); }

.topnav { gap: 14px; }

.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 10px 12px;
  font-size: 17px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.tenant-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tenant-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 60px; }
.tenant-row + .tenant-row { border-top: 1px solid var(--border); }

.card-title { font-size: 1.1rem; margin: 0 0 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
@media (max-width: 420px) {
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 8px; }
}

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.9rem; font-weight: 600; margin: 6px 0 0; }
.badge-bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.text-bad { color: var(--bad); }

.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; padding: 8px 0; border-top: 1px solid var(--border); }
.history li:first-child { border-top: 0; }

.field-check label { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.form .field-check input[type="checkbox"] { min-height: 0; width: 22px; height: 22px; padding: 0; }

/* Chybějící telefon */
.phone-missing { color: var(--warn); font-weight: 600; text-decoration: none; }
.phone-missing:hover { text-decoration: underline; }
.btn-warn { color: var(--warn); border-color: var(--warn); background: transparent; }

/* ---------- Krok 5: platby ---------- */
.stats { display: flex; gap: 20px; align-items: flex-start; }
.stat-bad { color: var(--bad); }
.bed-none .dot { background: var(--free); }
.pay-status { font-size: 0.9rem; font-weight: 600; }
.pay-ok { color: var(--ok); }
.pay-warn { color: var(--warn); }
.pay-bad { color: var(--bad); }
.btn-pay { margin-left: auto; white-space: nowrap; padding: 0 10px; }
.btn-pay-due { border-color: var(--brand); color: var(--brand); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }

.account { display: grid; gap: 4px; }
.account-line { margin: 0; }
.card.account-bad { border-color: var(--bad); }
.card.account-warn { border-color: var(--warn); }

.statement { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.95rem; }
.statement th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.statement td { padding: 8px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.statement .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-cancelled td { color: var(--muted); text-decoration: line-through; }
.row-cancelled td a, .row-cancelled .text-bad { text-decoration: none; }

/* Doklad – čitelný na obrazovce i na papíře */
.receipt { max-width: 640px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; position: relative; }
.receipt-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 2px solid var(--text); margin-bottom: 16px; }
.receipt-head h1 { font-size: 1.3rem; margin: 0 0 8px; }
.receipt-no { font-weight: 700; margin: 0; }
.receipt-amount { font-size: 1.4rem; font-weight: 700; }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 48px; color: var(--muted); font-size: 0.9rem; }
.sign-line { display: block; border-bottom: 1px solid var(--text); height: 32px; margin-bottom: 4px; }
.receipt-cancelled { opacity: 0.7; }
.stamp { color: var(--bad); font-weight: 800; border: 2px solid var(--bad); display: inline-block; padding: 4px 10px; transform: rotate(-3deg); }

@media print {
  .topbar, .no-print, .messages { display: none !important; }
  body { background: #fff; color: #000; }
  .container { padding: 0; }
  .receipt { border: 0; padding: 0; max-width: none; background: #fff; }
  .receipt, .receipt * { color: #000 !important; }
  .sign-line { border-color: #000; }
}

/* ---------- Krok 6: dlužníci, kalendář ---------- */
.dot-bad { background: var(--bad); }
.dot-warn { background: var(--warn); }
.row-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions .btn { padding: 0 12px; }
.section-title { font-size: 1.15rem; margin: 24px 0 8px; }
.copy-field {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: 15px ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { flex: 0 0 auto; }
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .topnav { flex-wrap: wrap; gap: 10px 14px; font-size: 0.95rem; }
}

/* ================= Vzhled A – Noční směna ================= */
h1, h2, .brand, .stat-num, .bed-label { letter-spacing: -0.01em; }
h1 { font-weight: 800; }

.topbar {
  background: rgba(18, 20, 24, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.topbar a, .topbar .link { color: var(--text); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; text-decoration: none; }
.brand-icon {
  width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--brand-ink);
  display: flex; align-items: center; justify-content: center; flex: 0 0 34px;
}
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-actions form { margin: 0; }
.icon-link {
  min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted) !important; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.icon-link:hover { color: var(--text) !important; }

/* Hlavní menu: na počítači v liště nahoře, na telefonu dole pod palcem */
.tabbar { display: flex; gap: 4px; }
.tabbar a {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 15px; text-decoration: none;
}
.tabbar a:hover { color: var(--text); background: var(--surface); }
.tabbar a.active { color: var(--brand); background: var(--surface); font-weight: 800; }
@media (max-width: 760px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
    background: #16191E; border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 0; border-radius: 10px; background: none !important; }
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .top-actions .label { display: none; }
}

/* Karty a tlačítka */
.card, .room, .tenant-list, .receipt { border-radius: var(--radius); }
.btn { border-radius: 12px; font-weight: 700; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 800; }
.btn:not(.btn-primary):not(.btn-danger):not(.btn-warn) { background: var(--surface-2); }
.chip { background: var(--surface); color: var(--muted); border-color: var(--border); }
.chip-active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-add { background: transparent; }

/* Tři dlaždice s čísly nahoře */
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 4px 0 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; text-decoration: none; color: var(--text); }
.tile-num { font-size: 1.4rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile-num small { color: #7C8592; font-weight: 600; font-size: 1rem; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-bad { background: var(--bad-bg); border-color: var(--bad-border); }
.tile-bad .tile-num { color: var(--bad); }
.tile-bad .tile-label { color: #F2B8B8; }
@media (min-width: 761px) { .stat-tiles { max-width: 640px; } }

/* Řádky lůžek */
.room { padding: 16px; }
.room-head h2 { font-weight: 800; }
.bed { border-top-color: var(--border); padding: 10px 0; }
.bed .dot { width: 10px; height: 10px; flex: 0 0 10px; }
.bed-ok .dot { background: var(--ok); }
.bed-warn .dot { background: var(--warn); }
.bed-bad .dot { background: #F87171; }
.bed-free .dot { border-color: var(--free); }
.bed-main { flex: 1; min-width: 0; }
.bed-label { font-weight: 700; font-size: 15px; }
.pay-status { font-size: 13px; font-weight: 700; }
.pay-bad { color: var(--bad); }
.bed-sub { font-size: 13px; color: var(--muted); }
.bed-sub a { color: var(--muted); text-decoration: none; }
.round-btn {
  width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px; margin-left: auto;
}
.btn-pay-due { border: 1px solid var(--bad-border); color: var(--bad) !important; background: transparent !important; }
.bed-warn .btn-pay-due { border-color: #5A4A1E; color: var(--warn) !important; }
.btn-checkin { background: var(--brand) !important; color: var(--brand-ink) !important; border-color: var(--brand) !important; font-weight: 800; }

.msg { background: var(--surface); }
.badge-bad { background: var(--bad-bg); }
.statement th { color: var(--muted); }

/* Patra – oddělení skupin pokojů */
.floor-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 28px 0 12px; padding-bottom: 8px;
  border-bottom: 2px solid var(--brand);
  font-size: 1.05rem; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--brand);
}
.floor-head:first-of-type { margin-top: 12px; }
.floor-count { font-size: 0.85rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted, #9aa3b2); }
