/* Админка в новом дизайне (design-handoff: tokens.css + макеты Admin/Clients/Integrations).
   Общие части: сайдбар, заголовок, вкладки, карточки, плашки статусов, кнопки, таблицы. */
:root {
  --paper: #EFEEE7;
  --paper-2: #F7F6F1;
  --admin-bg: #F1F1EC;
  --admin-surface: #FBFBF8;
  --border: #E4E5DC;
  --border-input: #D6D8CC;
  --ink: #262B22;
  --ink-2: #4E5547;
  --muted: #5E6457;
  --moss: #3E4A2E;
  --sage: #6B7A4B;
  --sage-soft: #DCE0CC;
  --sage-mid: #C9CFB4;
  --apricot: #E9B98F;
  --apricot-soft: #F6E3D1;
  --apricot-ink: #5C3415;
  --danger: #A23B2A;
  --danger-soft: #FBF3EE;
  --danger-border: #D9A396;
  --font-display: 'Lora', Georgia, serif;
  --font-ui: 'Manrope', system-ui, sans-serif;
  --r-pill: 999px;
  --r-card-admin: 24px;
  --r-control: 12px;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--admin-bg); color: var(--ink); font-family: var(--font-ui); }
a { color: var(--moss); }
a:hover { color: var(--ink); }

/* ===== каркас: сайдбар + контент ===== */
.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar {
  flex: 1 1 232px; max-width: 100%; background: var(--admin-surface); border-right: 1px solid var(--border);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px;
}
/* на компьютере меню стоит на месте во всю высоту экрана: «Страница записи» и «Выйти» всегда видны,
   прокручивается только содержимое страницы. На телефоне меню — сверху страницы (см. @media 720px) */
@media (min-width: 721px) {
  .layout { flex-wrap: nowrap; }
  .sidebar { flex: 0 0 248px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; background: var(--moss); color: var(--paper-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-style: italic; font-size: 18px; flex: none;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 700; font-size: 15px; }
.brand-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; min-height: 44px;
  text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 15px;
}
.nav a:hover { background: #E8EADF; color: var(--ink); }
.nav a.active { background: var(--sage-soft); color: var(--ink); font-weight: 700; }
.nav svg { flex: none; }
.sidebar-bottom { margin-top: auto; }
.logout {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--border); background: transparent;
  color: var(--ink-2); font: 600 14px var(--font-ui); cursor: pointer;
}
.logout:hover { background: #E8EADF; }
/* «Предложить улучшение» — над карточкой страницы записи */
.idea-link {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink-2); font: 600 14px var(--font-ui); cursor: pointer; text-align: left;
}
.idea-link:hover { background: #E8EADF; color: var(--ink); }
/* «Не получается настроить? Напишите» — внизу справа на шагах ЮKassa и «Мой налог» */
.help-float {
  position: fixed; right: 20px; bottom: 20px; z-index: 15; display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 999px; border: 0; background: var(--ink); color: var(--paper-2);
  font: 600 14px var(--font-ui); cursor: pointer; box-shadow: 0 12px 30px -12px rgba(38, 43, 34, .6);
}
.help-float:hover { background: var(--moss); }
.help-float[hidden] { display: none; }
body.with-help-float .main { padding-bottom: 96px; }
/* полоса о подписке вверху страницы (admin-common.js) */
.sub-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-radius: 16px; font-size: 14px; line-height: 1.5; font-weight: 600; }
.sub-banner span { flex: 1 1 320px; }
.sub-banner--warn { background: var(--apricot-soft); color: var(--apricot-ink); }
.sub-banner--expired { background: #F6DCD6; color: var(--danger); }
.sub-banner--info { background: var(--sage-soft); color: var(--moss); }
/* изменения в документах платформы: «было — стало» по пунктам (кабинет психолога и владельца) */
.doc-changes { display: flex; flex-direction: column; gap: 12px; }
.doc-change { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--border); background: #fff; }
.doc-change-section { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.doc-change-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.doc-change-side { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.doc-change-side.was { background: #F6EEEA; color: #6B4B40; }
.doc-change-side.now { background: var(--sage-soft); color: var(--ink); }
.doc-change-tag { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .75; }
.doc-change-side p, .doc-change-side ul { margin: 0; }
.doc-change-side ul { padding-left: 20px; }
.doc-change-side table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-change-side th, .doc-change-side td { padding: 6px 8px; border: 1px solid rgba(0, 0, 0, .1); text-align: left; vertical-align: top; }
.doc-change-side h2 { margin: 0; font-size: 15px; }
.sub-banner .btn { flex: none; } /* кнопки «Дальше» внизу шага не уходят под плавающую кнопку */

.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px; display: flex; flex-direction: column; gap: 22px; }
.page-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 32px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs a { padding: 12px 16px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--moss); }

/* ===== карточки ===== */
.card {
  background: var(--admin-surface); border: 1px solid var(--border); border-radius: 22px; padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.card--off { border: 1.5px dashed #B4BAA3; }
.card--error { background: var(--danger-soft); border: 1.5px solid var(--danger-border); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-title { font-weight: 700; font-size: 17px; }
.card-text { font-size: 14px; color: var(--ink-2); line-height: 1.5; overflow-wrap: anywhere; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* ===== плашки статусов ===== */
.badge {
  display: inline-block; padding: 5px 11px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700;
  white-space: nowrap; background: #EFEFE8; color: var(--muted);
}
.badge--ok { background: var(--sage-soft); color: var(--moss); }
.badge--wait { background: var(--apricot-soft); color: var(--apricot-ink); }
.badge--danger { background: var(--danger); color: #fff; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(162, 59, 42, .35) } 50% { box-shadow: 0 0 0 8px rgba(162, 59, 42, 0) } }
.pulse { animation: pulse 2s infinite; }

/* ===== кнопки ===== */
.btn {
  height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  color: var(--ink); font: 600 13px var(--font-ui); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { border-color: var(--border-input); background: var(--paper-2); color: var(--ink); }
.btn--primary { border: 0; background: var(--moss); color: var(--paper-2); }
.btn--primary:hover { background: var(--ink); color: var(--paper-2); }
.btn--danger { border: 0; background: var(--danger); color: #fff; }
.btn--danger:hover { background: #87301F; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--small { height: 30px; padding: 0 10px; font-size: 12px; }

/* ===== таблицы ===== */
.table-card { background: var(--admin-surface); border: 1px solid var(--border); border-radius: var(--r-card-admin); overflow: hidden; }
.table-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 12px; font-weight: 700; }
.table td { padding: 14px 12px; border-top: 1px solid #ECECE4; vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ===== всплывающее сообщение ===== */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--paper-2); padding: 12px 18px; border-radius: 12px; font-size: 14px;
  transition: opacity .25s, transform .25s var(--ease-out); pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@keyframes up { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
.appear { animation: up .35s var(--ease-out) both; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes dlgUp { from { opacity: 0; transform: translateY(16px) scale(.98) } to { opacity: 1; transform: none } }

/* ===== карточка «Страница записи» в сайдбаре ===== */
.sidebar-bottom { display: flex; flex-direction: column; gap: 12px; }
.site-card { background: var(--moss); color: var(--paper-2); border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.site-card-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--sage-mid); }
.site-card-text { font-size: 14px; line-height: 1.5; }
.site-card a { color: var(--apricot); font-size: 14px; font-weight: 600; }
.site-card a:hover { color: #F0C9A6; }

/* ===== шапка страницы: заголовок слева, действия справа ===== */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.page-head-text { display: flex; flex-direction: column; gap: 4px; }
.page-sub { font-size: 15px; color: var(--muted); }
.page-title em { font-style: italic; color: var(--sage); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; border-radius: 12px;
  background: var(--admin-surface); border: 1px solid var(--border); color: var(--muted);
}
.search input { border: 0; background: transparent; font: 500 15px var(--font-ui); width: 190px; color: var(--ink); outline: none; }
.search:focus-within { outline: 2px solid var(--sage); outline-offset: 1px; }
.btn--big { height: 46px; padding: 0 20px; border-radius: 12px; font-size: 15px; gap: 8px; }

/* ===== поля ввода ===== */
.field { display: flex; flex-direction: column; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink); }
.field-hint { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.5; }
.input, .select, .textarea {
  height: 48px; border-radius: 14px; border: 1px solid var(--border-input); background: #fff; padding: 0 14px;
  font: 500 15px var(--font-ui); color: var(--ink); width: 100%;
}
.textarea { height: auto; padding: 12px; line-height: 1.55; resize: vertical; min-height: 84px; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--sage); outline-offset: 1px; border-color: var(--sage); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-error { color: var(--danger); font-size: 14px; font-weight: 600; }
/* ключи и пароли приложений: не поле пароля, а текст под точками — иначе менеджер паролей браузера подставляет сюда
   почту и пароль от кабинета (ключ ЮKassa, пароль приложения почты, токен бота) */
.secret-field { -webkit-text-security: disc; font-family: inherit; }
.form-ok { color: var(--moss); font-size: 14px; font-weight: 600; }

/* ===== чипы (выбор дней, времени, цены) ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 44px; min-width: 52px; padding: 0 16px; border-radius: 12px; font: 600 14px var(--font-ui); cursor: pointer;
  background: #fff; color: var(--ink); border: 1.5px solid var(--border);
}
.chip:hover { border-color: var(--border-input); }
.chip.on { background: var(--moss); color: var(--paper-2); border-color: var(--moss); }

/* ===== переключатель страниц под таблицей (pagerHtml в admin-common.js) ===== */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid #ECECE4; font-size: 13px; color: var(--muted); }
.pager:empty { display: none; }
.pager-buttons { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-buttons button { min-width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: #fff; cursor: pointer; font: 600 13px var(--font-ui); color: var(--ink); }
.pager-buttons button.on { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.pager-buttons button:disabled { opacity: .4; cursor: default; }

/* ===== окна ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(38, 43, 34, .45); display: flex; align-items: flex-start; justify-content: center;
  padding: 64px 16px; overflow-y: auto; z-index: 50; animation: fadeIn .25s both;
}
.dialog {
  max-width: 100%; background: var(--admin-surface); border-radius: 28px; padding: 28px; display: flex; flex-direction: column; gap: 20px;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .45); animation: dlgUp .35s var(--ease-out) both;
}
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 28px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
/* подтверждения (confirmDialog / copyDialog в admin-common.js): по центру экрана и поверх других окон */
.overlay--confirm { align-items: center; z-index: 60; }
.dialog--confirm { gap: 16px; }
.dialog--confirm .dialog-title { font-size: 24px; line-height: 1.2; }
.confirm-text { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ink-2); white-space: pre-line; }
.confirm-note { background: var(--apricot-soft); border-radius: 14px; padding: 14px 16px; font-size: 14px; line-height: 1.5; display: flex; flex-direction: column; gap: 8px; }
.confirm-note ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
@media (max-width: 560px) {
  .confirm-actions { flex-direction: column-reverse; }
  .confirm-actions .btn { width: 100%; }
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: #EFEFE8; cursor: pointer; font-size: 20px; color: var(--ink-2); flex: none;
}
.icon-btn:hover { background: #E4E5DC; }
.summary-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--sage-soft); border-radius: 18px; padding: 16px 18px; font-size: 15px;
}

/* ===== показатели (KPI) ===== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { background: var(--admin-surface); border: 1px solid var(--border); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-value { font-family: var(--font-display); font-size: 40px; line-height: 1; }
.kpi-sub { font-size: 13px; color: var(--muted); }
.kpi--warm { background: var(--apricot-soft); border-color: #EBC9A8; }
.kpi--warm .kpi-label, .kpi--warm .kpi-sub { color: #7A4A23; }
.kpi--warm .kpi-value { color: var(--apricot-ink); }
.bar { height: 8px; border-radius: 99px; background: #E8EADF; overflow: hidden; }
.bar > div { height: 100%; border-radius: 99px; background: var(--sage); transition: width .4s var(--ease-out); }

/* ===== боковая панель деталей (календарь, клиенты) ===== */
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split-main { flex: 999 1 600px; min-width: 0; }
.split-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--admin-surface); border: 1px solid var(--border); border-radius: var(--r-card-admin); padding: 22px;
  display: flex; flex-direction: column; gap: 16px; animation: up .35s var(--ease-out) both;
}
.panel--dark { background: var(--ink); color: var(--paper-2); border: 0; }
.panel--dashed { border: 1.5px dashed #8E9A70; }
.panel-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--sage); }
.panel--dark .panel-label { color: var(--sage-mid); }
.panel-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--admin-bg); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.btn-grid .wide { grid-column: 1 / -1; }
.btn-block { height: 44px; border-radius: 12px; font-size: 14px; width: 100%; }
.btn--danger-outline { border: 1px solid #EBC9C0; background: #fff; color: var(--danger); }
.btn--danger-outline:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--sage-soft); color: var(--moss); flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px;
}
.avatar--sm { width: 40px; height: 40px; font-size: 14px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.who-name { font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.who-sub { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.feed { display: flex; flex-direction: column; gap: 12px; }
.feed-item { display: flex; gap: 10px; font-size: 14px; line-height: 1.45; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage); margin-top: 6px; flex: none; }

/* ===== вкладки-«таблетки» со счётчиками ===== */
.pill-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-tab {
  height: 42px; padding: 0 8px 0 16px; border-radius: var(--r-pill); display: inline-flex; align-items: center; gap: 10px;
  font: 600 14px var(--font-ui); cursor: pointer; background: var(--admin-surface); color: var(--ink); border: 1px solid var(--border);
}
.pill-tab .count {
  min-width: 26px; height: 26px; padding: 0 6px; border-radius: var(--r-pill); display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; background: #EFEFE8; color: var(--ink-2);
}
.pill-tab.on { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.pill-tab.on .count { background: var(--apricot); color: var(--ink); }

@media (max-width: 720px) {
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); gap: 16px; padding: 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .layout { align-content: flex-start; }
  .nav a { padding: 8px 12px; min-height: 40px; font-size: 14px; }
  .sidebar-bottom { margin-top: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .site-card { flex: 1 1 auto; flex-direction: row; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 12px; }
  .site-card-label { display: none; }
  .site-card-text { font-size: 13px; }
  .sidebar-bottom form { flex: 0 0 auto; display: flex; }
  .logout { min-height: 40px; padding: 0 16px; }
  .idea-link { width: auto; flex: 0 0 auto; }
  .help-float { right: 12px; bottom: 12px; padding: 10px 14px; font-size: 13px; }
  .main { padding: 20px 16px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs a { white-space: nowrap; }
  .page-title { font-size: 26px; }
  .search { flex: 1 1 200px; }
  .search input { width: 100%; }
  .dialog { padding: 22px; border-radius: 22px; }
  .overlay { padding: 24px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse, .appear, .panel, .overlay, .dialog { animation: none; }
  .bar > div { transition: none; }
}