:root {
  --bg: var(--tg-bg, #ffffff);
  --card: var(--tg-card, #ffffff);
  --text: var(--tg-text, #16181d);
  --muted: var(--tg-hint, #707579);
  --border: var(--tg-section-separator, #e6e7eb);
  --accent: var(--tg-button, #2481cc);
  --accent-text: var(--tg-button-text, #ffffff);
  --secondary-bg: var(--tg-secondary-bg, #f4f4f5);
  --destructive: var(--tg-destructive, #e23636);
  --ok: #25a85a;
  --radius: 12px;
}

* { box-sizing: border-box; }

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: 15px;
  line-height: 1.4;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.card {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
}

.hidden { display: none !important; }

/* HEADER */
.head {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 4px 4px 18px;
  border-bottom: 1px solid var(--border);
}
.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 22px;
  flex-shrink: 0;
}
.head-info { flex: 1; min-width: 0; }
.head-org { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.head-title { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.head-meta { display: flex; gap: 14px; flex-wrap: wrap; }
.meta-item { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.meta-icon { font-size: 14px; }

/* PICKER */
.picker { padding: 18px 0 8px; }
.picker-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 280px);
  gap: 24px;
  align-items: start;
}
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; gap: 16px; }
}

/* CALENDAR */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-month {
  font-size: 15px;
  font-weight: 600;
  text-transform: capitalize;
}
.cal-nav {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cal-nav:hover { background: var(--secondary-bg); }
.cal-nav:disabled { color: var(--muted); cursor: not-allowed; }
.cal-nav:disabled:hover { background: transparent; }

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

.cal-cell {
  aspect-ratio: 1 / 1;
  border: none;
  background: transparent;
  border-radius: 50%;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  padding: 0;
  position: relative;
}
.cal-cell.empty { visibility: hidden; cursor: default; }
.cal-cell:not(.empty):not(.disabled):hover { background: var(--secondary-bg); }
.cal-cell.available {
  font-weight: 600;
}
.cal-cell.available::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.cal-cell.disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.45;
}
.cal-cell.today { box-shadow: inset 0 0 0 1px var(--accent); }
.cal-cell.active {
  background: var(--accent);
  color: var(--accent-text);
}
.cal-cell.active::after { background: var(--accent-text); }

.tz {
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
  text-align: left;
}

/* TIMES */
.times-head {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--muted);
}
.times-head.active { color: var(--text); }

.slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}
.slots:empty::after {
  content: "Нет доступных слотов";
  display: block;
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0;
}

.slot-row {
  display: flex;
  gap: 8px;
}
.slot {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.slot:hover { background: rgba(36, 129, 204, 0.08); }
.slot.active {
  flex: 0 0 40%;
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  cursor: default;
}
.slot-confirm {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.slot-confirm:hover { opacity: 0.9; }
.slot-confirm:disabled { opacity: 0.6; cursor: wait; }

/* MANAGE */
.manage {
  margin-top: 18px;
  padding: 18px;
  background: var(--secondary-bg);
  border-radius: var(--radius);
}
.manage-info { margin-bottom: 14px; }
.manage-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.manage-summary { font-size: 16px; font-weight: 600; }
.manage-actions { display: flex; flex-direction: column; gap: 8px; }

.btn {
  padding: 13px;
  border-radius: var(--radius);
  border: none;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-danger {
  background: transparent;
  color: var(--destructive);
  border: 1.5px solid var(--destructive);
}

/* RESULT */
.result {
  padding: 40px 16px;
  text-align: center;
}
.result-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 38px;
  color: white;
  margin-bottom: 16px;
}
.result-icon.ok { background: var(--ok); }
.result-icon.bad { background: var(--destructive); }
.result-title { margin: 0 0 6px; font-size: 20px; }
.result-summary { font-size: 16px; color: var(--text); margin: 0 0 4px; }
.result-hint { color: var(--muted); margin: 0; font-size: 13px; }

.error {
  margin: 12px 0 0;
  color: var(--destructive);
  font-size: 13px;
}
