:root {
  --bg: #f6f5fb;
  --card: #ffffff;
  --ink: #23202e;
  --muted: #7a7590;
  --accent: #7c5cff;
  --accent-dark: #5a3fd6;
  --line: #e7e4f0;
  --ok: #1f9d55;
  --warn: #d9822b;
  --danger: #d64545;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  overflow-x: hidden; /* защита от случайного горизонтального скролла страницы */
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { display: block; }
.brand-text { line-height: 1; }
.brand-accent { color: var(--accent); }
.topbar nav { display: flex; align-items: center; gap: 8px; }
.inline { display: inline; margin: 0; }
.link-btn { background: none; border: none; color: var(--accent-dark); cursor: pointer; font-size: inherit; padding: 0; }

/* Меню кабинета — «таблетки» с активной вкладкой */
.dnav-item {
  padding: 8px 14px; border-radius: 9px; color: var(--muted);
  font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap;
  border: none; background: none; cursor: pointer; font-family: inherit;
}
.dnav-item:hover { background: #f1eefb; color: var(--ink); text-decoration: none; }
.dnav-item.active { background: var(--accent); color: #fff; }
.dnav-item.active:hover { background: var(--accent-dark); color: #fff; }
.dnav-logout { color: var(--danger); margin-left: 4px; }
.dnav-logout:hover { background: #fdecec; color: var(--danger); }

.container { max-width: 860px; margin: 0 auto; padding: 26px 18px 60px; }
.foot { text-align: center; color: var(--muted); padding: 20px; }

h1 { font-size: 26px; margin: 0 0 6px; }
h2 { font-size: 19px; margin: 24px 0 10px; }
.muted { color: var(--muted); }

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

.btn, button.btn {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  padding: 11px 18px; border-radius: 10px; font-size: 15px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-sm {
  background: var(--accent); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 14px;
}
/* .btn.btn-* — двойной класс, чтобы перебить button.btn по специфичности */
.btn.btn-ghost { background: #efeaff; color: var(--accent-dark); }
.btn.btn-ghost:hover { background: #e2d9ff; }
.btn-sm.btn-ghost { background: #efeaff; color: var(--accent-dark); }
.btn.btn-danger { background: var(--danger); }
.btn.btn-danger:hover { background: #c23b3b; }
.btn-sm.btn-danger { background: var(--danger); color: #fff; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; background: #fff;
  font-family: inherit;
}
textarea { resize: vertical; }
.req { color: var(--danger); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

.contacts { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.contact-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font-size: 14px; font-weight: 600; color: var(--ink);
}
.contact-chip:hover { border-color: var(--accent); color: var(--accent-dark); text-decoration: none; }
.contact-chip svg { display: block; }

.linkbox { border: 1px solid var(--line); background: #faf9ff; border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; }
.linkbox-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.linkbox-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.linkbox-url {
  flex: 1; min-width: 200px; font-weight: 600; word-break: break-all;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.linkbox-row .btn-sm { flex: 0 0 auto; border: none; cursor: pointer; }

.ivrow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ivrow input[type="time"] { width: auto; flex: 0 0 auto; }
.ivdash { color: var(--muted); }
.iv-del { flex: 0 0 auto; font-size: 13px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font-size: 14px; color: var(--ink); cursor: pointer;
}
.check input { width: auto; }
.check span { color: var(--ink); }

.error { background: #fdecec; color: var(--danger); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.note { background: #eef7ff; color: #2b6cb0; padding: 10px 14px; border-radius: 10px; }

/* Записи карточками (для телефона) */
.booking-cards { display: none; }
.bcard { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fff; }
.bcard-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.bcard-head b { font-size: 16px; }
.bcard-line { font-size: 14px; margin: 3px 0; word-break: break-word; }
.bcard-actions { display: flex; gap: 8px; margin-top: 12px; }
.bcard-actions .btn { flex: 1; padding: 11px; font-size: 15px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; }

.book-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.book-toolbar .tabs { margin-bottom: 0; }
.book-tools { display: flex; align-items: center; gap: 8px; }
.book-tools input[type="date"] { width: auto; padding: 7px 10px; font-size: 14px; }
.book-tools .btn-sm { border: none; cursor: pointer; white-space: nowrap; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 600;
}
.tab:hover { border-color: var(--accent); text-decoration: none; }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.badge {
  display: inline-block; vertical-align: middle; margin-left: 8px; font-size: 13px;
  background: #e4f5ea; color: var(--ok); padding: 2px 10px; border-radius: 999px; font-weight: 600;
}

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.pending { background: #fff3e0; color: var(--warn); }
.pill.confirmed { background: #e4f5ea; color: var(--ok); }
.pill.cancelled { background: #f1f0f4; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  display: block; text-align: center; padding: 16px 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; font-weight: 600;
}
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile small { display: block; color: var(--muted); font-weight: 400; margin-top: 4px; }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.slot { padding: 10px; text-align: center; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.slot input { display: none; }
.slot.selected { border-color: var(--accent); background: #efeaff; }

/* Календарь расписания в кабинете */
.cal-head { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 14px; }
.cal-title { font-size: 18px; text-transform: capitalize; min-width: 180px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { margin-bottom: 6px; }
.cal-dow-cell { text-align: center; color: var(--muted); font-size: 13px; font-weight: 600; padding: 4px 0; }
.cal-cell {
  min-height: 74px; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 5px 6px;
  cursor: pointer; background: #fff; transition: border-color .12s, background .12s;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-empty { border: none; background: transparent; cursor: default; }
.cal-daynum { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.cal-cell.has-hours { background: #f3efff; border-color: #d9ccff; }
.cal-cell.today .cal-daynum { color: var(--accent-dark); }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.past { opacity: 0.55; }
.cal-cell.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Календарь расписания горизонтально прокручивается на узких экранах, чтобы время оставалось читаемым */
.cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cal-scroll .cal-grid { min-width: 520px; }
.cal-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 3px; min-width: 0;
  background: #fff; border: 1px solid #d9ccff; border-radius: 7px;
  font-size: 11.5px; padding: 2px 4px 2px 6px; margin-bottom: 3px; font-weight: 600;
}
.cal-chip span { white-space: nowrap; }
.cal-x { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
/* Дни публичного календаря записи (кликабельные кружки/клетки) */
.cal-day {
  display: flex; align-items: center; justify-content: center;
  min-height: 46px; border-radius: 10px; font-size: 15px; font-weight: 600;
  text-decoration: none;
}
a.cal-day { background: #f3efff; color: var(--accent-dark); border: 1px solid #d9ccff; cursor: pointer; }
a.cal-day:hover { background: #e6ddff; text-decoration: none; }
a.cal-day.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.cal-day.disabled { color: #c8c4d4; background: transparent; border: 1px solid transparent; }
.cal-day.today { outline: 2px solid var(--accent); outline-offset: -2px; }

.legend-box { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; border: 1px solid var(--line); }
.legend-box.has-hours { background: #f3efff; border-color: #d9ccff; }
.legend-box.today { border-color: var(--accent); }
@media (max-width: 560px) {
  .cal-cell { min-height: 58px; padding: 3px; }
  .cal-chip { font-size: 10px; }
}

.date-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.date-chip { white-space: nowrap; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.date-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.steps { color: var(--muted); font-size: 14px; margin-bottom: 14px; }

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .topbar nav {
    width: 100%; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 4px; scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a, .topbar nav .link-btn { white-space: nowrap; font-size: 14px; }
  .dnav-item { padding: 8px 12px; }
  .dnav-logout { margin-left: 0; }

  .container { padding: 18px 14px 48px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  .card { padding: 16px 15px; }

  /* Широкие таблицы — горизонтальная прокрутка вместо разъезжания */
  .card > table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }

  /* Записи: на телефоне — карточки вместо таблицы */
  .booking-table { display: none; }
  .booking-cards { display: block; }

  .btn, button.btn { padding: 12px 18px; } /* удобнее попадать пальцем */
  .btn-block { padding: 13px; }
  input, select, textarea { font-size: 16px; } /* iOS не зумит поля при 16px+ */
}

@media (max-width: 400px) {
  .brand { font-size: 16px; }
  .cal-day { min-height: 40px; font-size: 14px; }
}
