/* Кабинет специалиста. Светлая и тёмная темы; в Telegram Mini App берутся цвета Telegram. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #15171c;
  --muted: #6b7180;
  --border: #e4e6eb;
  --primary: #15171c;
  --on-primary: #ffffff;
  --accent: #b8913f;
  --accent-soft: #f6efe0;
  --ok: #1f9d6b;
  --ok-soft: #e3f5ec;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --danger: #d64545;
  --danger-soft: #fbe7e7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 18, 24, .04), 0 4px 16px rgba(16, 18, 24, .05);
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #171a21; --surface-2: #1f232c; --text: #eceae4; --muted: #9aa0ab;
    --border: #2a2f39; --primary: #c9a96a; --on-primary: #14161b; --accent: #c9a96a; --accent-soft: #2b2619;
    --ok: #3ccf91; --ok-soft: #15291f; --warn: #e0a84a; --warn-soft: #2d2415; --danger: #ef6b6b; --danger-soft: #331a1a;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #171a21; --surface-2: #1f232c; --text: #eceae4; --muted: #9aa0ab;
  --border: #2a2f39; --primary: #c9a96a; --on-primary: #14161b; --accent: #c9a96a; --accent-soft: #2b2619;
  --ok: #3ccf91; --ok-soft: #15291f; --warn: #e0a84a; --warn-soft: #2d2415; --danger: #ef6b6b; --danger-soft: #331a1a;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[v-cloak] { display: none; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Каркас ---------- */
.layout { min-height: 100vh; display: flex; }
.sidebar {
  width: 240px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 600; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none;
  color: var(--muted); font-weight: 500; cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--surface-2); color: var(--text); }
.nav-link .ico { width: 22px; text-align: center; font-size: 17px; }
.sidebar .spacer { flex: 1; }
.main { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
  h1 { font-size: 21px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .bottom-nav button {
    flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; padding: 6px 0;
  }
  .bottom-nav button .ico { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .75; }
  .bottom-nav button.active { color: var(--text); font-weight: 600; }
  .bottom-nav button.active .ico { filter: none; opacity: 1; }
}

/* ---------- Блоки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid > .card + .card, .stack > .card + .card { margin-top: 0; }
.grid > * { min-width: 0; }
.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 1.4fr 1fr; align-items: start; }
@media (max-width: 1100px) { .grid.kpi { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) { .grid.two { grid-template-columns: 1fr; } }
.stack > * + *, .stack > .card + .card { margin-top: 14px; }
.kpi .card { padding: 16px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (max-width: 480px) { .kpi .value { font-size: 20px; } .card { padding: 14px; } }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 14px; }
.banner.warn { background: var(--warn-soft); }
.banner.danger { background: var(--danger-soft); }
.banner.ok { background: var(--ok-soft); }
.banner .ico { font-size: 20px; line-height: 1.2; }
.banner b { display: block; }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 9px 14px; border-radius: 10px; cursor: pointer;
  font-weight: 550; text-decoration: none; white-space: nowrap; min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: none; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: var(--muted); font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 12px;
  min-height: 42px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row > .grow { flex: 1; min-width: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); padding: 7px 12px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.segmented { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 11px; }
.segmented button { border: 0; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 550; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------- Списки ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; padding-top: 2px; }
.item .time { width: 92px; flex: none; font-weight: 650; font-variant-numeric: tabular-nums; }
.item .time small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.item .side { text-align: right; flex: none; }
@media (max-width: 480px) { .item .time { width: 70px; } }
.day-head { font-weight: 650; margin: 18px 0 6px; display: flex; align-items: baseline; gap: 8px; }
.day-head:first-child { margin-top: 0; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 550; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
@media (max-width: 700px) { .hide-sm { display: none; } }
@media (min-width: 701px) { .show-sm { display: none !important; } }

/* ---------- График ---------- */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 8px; }
.chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; min-width: 0; }
.chart .bar i { display: block; width: 100%; max-width: 22px; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 2px; opacity: .85; }
.chart .bar.weekend i { opacity: .55; }
.chart .bar.today i { opacity: 1; background: var(--primary); }
.chart .bar.zero i { background: var(--border); opacity: 1; }
.chart .bar:hover i { opacity: 1; }
.chart-axis { display: flex; gap: 3px; margin-top: 6px; }
.chart-axis span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); min-width: 0; }
.tip { position: absolute; bottom: calc(100% + 4px); background: var(--text); color: var(--bg); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; z-index: 2; }
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- Модальные окна и уведомления ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { font-size: 19px; }
@media (max-width: 600px) {
  .overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 60; background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 12px; font-weight: 550; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px);
}
.toast.error { background: var(--danger); color: #fff; }
@media (max-width: 900px) { .toast { bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); } }

/* ---------- Вход и регистрация ---------- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin-bottom: 18px; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps i { flex: 1; height: 4px; border-radius: 99px; background: var(--border); }
.steps i.on { background: var(--accent); }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.option { border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; background: var(--surface); text-align: left; }
.option:hover { border-color: var(--accent); }
.option.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.link-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); padding: 8px 8px 8px 12px; border-radius: 10px; }
.link-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.steps-list { margin: 0; padding-left: 20px; }
.steps-list li { margin: 4px 0; }
.week-row { display: grid; grid-template-columns: 120px 52px 1fr; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.week-row:first-child { border-top: 0; }
.week-row .times { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.week-row input[type="time"] { width: 110px; }
@media (max-width: 600px) { .week-row { grid-template-columns: 1fr 52px; } .week-row .times { grid-column: 1 / -1; } }

/* Тестовый вход из админ-панели («🧪 Тесты») — чтобы не перепутать с настоящим */
.test-banner { position: sticky; top: 0; z-index: 50; background: #fff3cd; color: #6b4e00; text-align: center;
  font-size: 13px; padding: 6px 12px; border-bottom: 1px solid #f0d78a; }

/* Админ-панель → «🧪 Тесты» */
.api-out { margin: 0; padding: 12px; border-radius: 10px; background: var(--surface-2); max-height: 420px; overflow: auto;
  font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.tg-msg { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.tg-msg.deleted { opacity: .55; }
