*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-muted: #f0f0ec;
  --text: #18181b;
  --text-muted: #63636e;
  --border: #e2e2dd;
  --primary: #1f2937;
  --primary-hover: #111827;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning-soft: #fffbeb;
  --warning-text: #92400e;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px 36px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* Шапка */
.header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Карточки */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.week-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 12px 0 6px;
}

.week-label:first-of-type {
  margin-top: 0;
}

/* Сетка дат */
.header-controls {
  display: flex;
  gap: 6px;
}

.dates-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

@media (min-width: 480px) {
  .dates-grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

.date-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  min-height: 58px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s;
}

.date-btn .dow {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.date-btn .day-num {
  font-size: 16px;
  font-weight: 700;
}

.date-btn .day-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.date-btn:hover:not(:disabled) {
  border-color: var(--primary);
}

.date-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.date-btn.selected .dow,
.date-btn.selected .day-sub {
  color: #d1d5db;
}

.date-btn:disabled {
  background: var(--surface-muted);
  border-color: transparent;
  color: #a1a1aa;
  cursor: not-allowed;
}

.date-btn:disabled .dow,
.date-btn:disabled .day-sub {
  color: #a1a1aa;
}

/* Сетка слотов */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (min-width: 440px) {
  .slots-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.slot-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}

.slot-btn:hover {
  border-color: var(--primary);
}

.slot-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* Поля формы */
.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text);
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
}

.field textarea {
  resize: vertical;
  min-height: 70px;
}

/* Honeypot для защиты от ботов */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #e5e5e0;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

.btn-sm {
  padding: 8px 11px;
  font-size: 13px;
  border-radius: 8px;
}

/* Сообщения и состояния */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 12px;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid #bbf7d0;
}

.alert-warning {
  background: var(--warning-soft);
  color: var(--warning-text);
  border: 1px solid #fde68a;
}

.muted-box {
  text-align: center;
  color: var(--text-muted);
  padding: 18px 10px;
  font-size: 14px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
}

.hidden {
  display: none !important;
}

/* Карточки "Проверить запись" */
.booking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface);
}

.booking-item-title {
  font-size: 15px;
  font-weight: 700;
}

.inline-confirm {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Экран успеха */
.success-box {
  text-align: center;
  padding: 12px 4px;
}

.success-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  font-size: 24px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.success-summary {
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 14px 0;
  font-size: 15px;
  font-weight: 600;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Футер */
.footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.footer-label {
  font-weight: 600;
  color: var(--text);
}

.footer-admin {
  margin-top: 8px;
  font-size: 12px;
}

.footer-admin a {
  color: #9ca3af;
}

/* ===================== АДМИНКА ===================== */
.admin-nav-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.admin-nav-row input[type="date"] {
  flex: 1;
  min-width: 140px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.work {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill.off {
  background: var(--danger-soft);
  color: var(--danger);
}

.admin-slot-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface);
}

.admin-slot-row.occupied {
  background: #fafafa;
  border-color: #d4d4d8;
}

.admin-slot-row.blocked {
  background: #f4f4f5;
  border-style: dashed;
}

.admin-slot-time {
  font-size: 16px;
  font-weight: 700;
  min-width: 52px;
  padding-top: 2px;
}

.admin-slot-info {
  flex: 1;
  min-width: 0;
}

.admin-slot-name {
  font-weight: 600;
  font-size: 15px;
  word-break: break-word;
}

.admin-slot-phone {
  font-size: 14px;
  margin-top: 2px;
}

.admin-slot-comment {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-word;
}

.admin-slot-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

/* Календарь выходных в админке */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-month-title {
  font-size: 16px;
  font-weight: 700;
  text-transform: capitalize;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-cell {
  position: relative;
  min-height: 46px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.cal-cell.empty {
  border: none;
  background: transparent;
  cursor: default;
}

.cal-cell.is-off {
  background: var(--danger-soft);
  border-color: #fca5a5;
  color: var(--danger);
}

.cal-cell.is-changed {
  box-shadow: 0 0 0 2px var(--accent);
}

.cal-cell.is-today {
  text-decoration: underline;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  bottom: 4px;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: inline-block;
}

.legend-swatch.off {
  background: var(--danger-soft);
  border-color: #fca5a5;
}

.legend-swatch.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

/* Модалка в админке */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.2);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.modal-actions .btn {
  flex: 1;
}
