:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #dfe3e8;
  --text: #1f2530;
  --text-muted: #6b7280;
  --accent: #2f6f4f;
  --accent-dark: #234f38;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --ok: #1a7f37;
  --ok-bg: #e3f6e8;
  --gray-bg: #eceef0;
  --blue: #1b5fad;
  --blue-bg: #e5eefb;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body { overflow-x: hidden; max-width: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent-dark); }
a:hover { color: var(--accent); }

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #1c2431;
  color: #dfe3e8;
  padding: 20px 0;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 18px;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  border-bottom: 1px solid #303a4a;
  margin-bottom: 10px;
}

.sidebar__logo {
  height: 32px;
  width: 32px;
  border-radius: 8px;
  display: block;
}

.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: #c3cad6;
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover { background: #232d3d; color: #fff; }

.sidebar nav a.active {
  background: #232d3d;
  color: #fff;
  border-left-color: var(--accent);
}

.sidebar__foot {
  margin-top: 24px;
  padding: 12px 20px 0;
  border-top: 1px solid #303a4a;
  font-size: 12.5px;
  color: #8891a0;
}

.sidebar__foot form { margin-top: 8px; }

.sidebar__foot button {
  background: none;
  border: none;
  color: #c3cad6;
  cursor: pointer;
  padding: 0;
  font-size: 12.5px;
  text-decoration: underline;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 32px 60px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.page-head h1 {
  font-size: 20px;
  margin: 0;
}

.page-head .actions { display: flex; gap: 8px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.panel h2 {
  font-size: 15px;
  margin: 0 0 12px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

@media (max-width: 780px) {
  .layout { flex-direction: column; min-height: 0; }
  .sidebar { width: 100%; padding: 0; }
  .sidebar__brand, .sidebar__foot { display: none; }
  .sidebar nav { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sidebar nav a { white-space: nowrap; padding: 10px 14px; border-left: none; border-bottom: 3px solid transparent; }
  .sidebar nav a.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .main { padding: 14px; }
  .cal-viewport { max-width: none; }
  .month-cal { padding: 6px; }
  .month-cal__num { font-size: 12px; }
}

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 150px;
  flex: 1;
}

.stat-tile__value { font-size: 24px; font-weight: 700; }
.stat-tile__label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em; }

tbody tr:hover { background: #fafbfc; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--pending { background: var(--warn-bg); color: var(--warn); }
.badge--confirmed { background: var(--ok-bg); color: var(--ok); }
.badge--blocked { background: var(--gray-bg); color: #4b5563; }
.badge--completed { background: var(--blue-bg); color: var(--blue); }
.badge--cancelled, .badge--expired, .badge--no_show { background: #f3f3f3; color: #9ca3af; }

.badge--unpaid { background: var(--danger-bg); color: var(--danger); }
.badge--paid_cash, .badge--paid_transfer, .badge--paid_online { background: var(--ok-bg); color: var(--ok); }
.badge--partial { background: var(--warn-bg); color: var(--warn); }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover { background: #f2f3f5; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }

.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: #8f1f18; }

.btn--sm { padding: 4px 10px; font-size: 12.5px; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }

.form-row input[type=text],
.form-row input[type=email],
.form-row input[type=tel],
.form-row input[type=number],
.form-row input[type=date],
.form-row input[type=password],
.form-row input[type=time],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* 16px, not smaller — iOS Safari auto-zooms the page on focus for any
     input under 16px, which is the "приближение" this is fixing. */
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.form-row textarea { resize: vertical; min-height: 70px; }
.form-row .hint { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* Calendar on wide screens: same month-grid + day-list as mobile, just laid
   out side by side instead of stacked full-width (which stretched the
   day-list rows across the whole desktop viewport). Mobile (<=780px) is
   untouched — this block only applies above that breakpoint. */
@media (min-width: 781px) {
  .cal-layout { display: flex; align-items: flex-start; gap: 32px; max-width: 900px; }
  .cal-layout__month { flex: 0 0 480px; }
  .day-list { flex: 1; min-width: 300px; margin-top: 0; }
}

.checkbox-line { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 13.5px; }
.checkbox-line input { margin: 0; }

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 16px;
  margin-top: 6px;
}

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13.5px;
}

.flash--error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3c9c5; }
.flash--ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe3c8; }

.alert {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f3c9c5;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13.5px;
}

.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}

.filters .form-row { margin-bottom: 0; min-width: 140px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1c2431;
}

.login-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px 30px;
  width: 320px;
}

.login-box h1 { font-size: 18px; margin: 0 0 4px; }
.login-box .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.login-box .btn { width: 100%; text-align: center; }

/* Calendar — one Apple-Calendar-style month, swipe up/down over
   the grid to change month, no toolbar; just the month + a "+" for adding. */
.fab-add {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.fab-add:hover { background: var(--accent-dark); }

/* Status colors, shared by the day-list dots. */
.cal-cell--pending { background: var(--warn-bg); }
.cal-cell--confirmed { background: var(--ok-bg); }
.cal-cell--blocked { background: var(--gray-bg); }
.cal-cell--completed { background: var(--blue-bg); }

.cal-month-label { font-size: 17px; font-weight: 600; margin: 0 0 10px; text-align: left; }

/* Scroll-snap carousel: prev/current/next month stacked, native scrolling
   does the swiping — immediate 1:1 motion, and scroll-snap-stop:always means
   it can only ever settle fully on a month, never half way. */
.cal-viewport {
  max-width: 480px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  height: 380px;
  scrollbar-width: none;
  transition: height 0.15s ease;
}

.cal-viewport::-webkit-scrollbar { display: none; }

.cal-slide {
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.month-cal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.month-cal__weekdays, .month-cal__week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.month-cal__weekdays span {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  padding-bottom: 6px;
}

.month-cal__day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}

.month-cal__day--empty { visibility: hidden; }

.month-cal__day:hover { background: var(--bg); }

.month-cal__num { font-size: 13.5px; }

.month-cal__bar {
  width: 60%;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.month-cal__day.is-today .month-cal__num {
  background: var(--danger);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.month-cal__day.is-selected { background: var(--ok-bg); outline: 1px solid var(--accent); }

/* Day list — bookings for the selected day only; free units never appear. */
.day-list { margin-top: 20px; }
.day-list__title { font-size: 16px; margin: 0 0 10px; }

.day-list__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 8px;
}

.day-list__row:hover { border-color: var(--accent); }

.day-list__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.08);
}

.day-list__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.day-list__title-line { font-weight: 600; font-size: 13.5px; }
.day-list__sub { display: block; }
.day-list__price { font-weight: 600; white-space: nowrap; }

/* Quick-add bottom sheet — slides up over the whole viewport, iOS-style. */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}

.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  inset: 0;
  background: #fff;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  z-index: 41;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sheet.is-open { transform: translateY(0); }

.sheet__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.sheet__title { font-weight: 600; font-size: 15px; }

.sheet__icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--gray-bg);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

.sheet__icon-btn--ok { background: var(--accent); color: #fff; }

.sheet__body { padding: 18px 16px 40px; max-width: 480px; width: 100%; margin: 0 auto; }

.form-row--checkbox label { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); }
.form-row--checkbox input[type=checkbox] { width: 16px; height: 16px; }

/* Units */
.unit-photos { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.unit-photo { position: relative; width: 120px; height: 90px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.unit-photo img,
.unit-photo video { width: 100%; height: 100%; object-fit: cover; display: block; }
.unit-photo-actions {
  position: absolute; bottom: 4px; left: 4px; right: 4px;
  display: flex; gap: 4px; justify-content: center;
}
.unit-photo-actions form { display: inline; }
.unit-photo button { background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 4px; padding: 2px 7px; cursor: pointer; font-size: 11px; }
.unit-photo button:disabled { opacity: 0.35; cursor: not-allowed; }

.rates-table td, .rates-table th { font-size: 13px; }

.audit-log { font-size: 12.5px; }
.audit-log li { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.audit-log li:last-child { border-bottom: none; }

.copy-ok { color: var(--ok); font-size: 12px; margin-left: 8px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag-list .tag { background: var(--gray-bg); padding: 3px 8px; border-radius: 999px; font-size: 12px; }
.tag-list .tag button { border: none; background: none; cursor: pointer; margin-left: 4px; color: var(--text-muted); }
