/* Панель Autodent: дизайн-система из макета заказчика (docs/design/TOKENS.md).
   Сначала телефон (375 px), потом шире. Шрифты лежат в static/fonts, внешних адресов нет. */

/* ---- Шрифты (подмножества cyrillic и latin) ---- */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/manrope-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Exo 2";
  font-style: italic;
  font-weight: 900;
  font-display: swap;
  src: url("fonts/exo2-italic-900-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Exo 2";
  font-style: italic;
  font-weight: 900;
  font-display: swap;
  src: url("fonts/exo2-italic-900-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("fonts/jetbrains-mono-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Токены ---- */

:root {
  --h: 25; /* оттенок акцента */
  --rs: 1; /* масштаб скруглений */
  --nh: 20; /* оттенок нейтральных цветов */

  --bg: oklch(0.16 0.012 var(--nh));
  --bg-bar: oklch(0.13 0.012 var(--nh) / 0.92);
  --card: oklch(0.21 0.012 var(--nh));
  --card-hi: oklch(0.25 0.015 var(--nh));
  --card-lo: oklch(0.2 0.012 var(--nh));
  --inset: oklch(0.17 0.012 var(--nh));
  --raised: oklch(0.27 0.02 var(--nh));
  --line: oklch(0.3 0.015 var(--nh));
  --line-hi: oklch(0.32 0.015 var(--nh));
  --text: oklch(0.95 0.005 var(--nh));
  --text-2: oklch(0.92 0.01 var(--nh));
  --muted: oklch(0.75 0.02 var(--nh));
  --muted-2: oklch(0.7 0.02 var(--nh));
  --nav-text: oklch(0.8 0.02 var(--nh));

  --accent: oklch(0.76 0.15 var(--h));
  --accent-strong: oklch(0.6 0.21 var(--h));
  --accent-bg: oklch(0.3 0.1 var(--h));
  --accent-grad: linear-gradient(135deg, oklch(0.62 0.21 var(--h)), oklch(0.42 0.17 var(--h)));
  --accent-text: #fff;
  --glow: oklch(0.3 0.1 var(--h) / 0.55);

  --ok: oklch(0.78 0.14 160);
  --warn: oklch(0.85 0.13 80);
  --danger: oklch(0.72 0.17 25);

  /* Пары «фон метки / цвет текста»: статусы записей, режимы, предупреждения */
  --amber-bg: oklch(0.32 0.06 75);
  --amber-fg: oklch(0.88 0.12 80);
  --green-bg: oklch(0.3 0.06 160);
  --green-fg: oklch(0.85 0.12 160);
  --blue-bg: oklch(0.3 0.07 250);
  --blue-fg: oklch(0.85 0.1 250);
  --teal-bg: oklch(0.3 0.06 195);
  --teal-fg: oklch(0.85 0.1 195);
  --grey-bg: oklch(0.29 0.012 var(--nh));
  --grey-fg: oklch(0.8 0.02 var(--nh));
  --red-bg: oklch(0.3 0.09 25);
  --red-fg: oklch(0.86 0.1 25);
  --purple-bg: oklch(0.3 0.07 310);
  --purple-fg: oklch(0.85 0.1 310);

  --r-sm: calc(8px * var(--rs));
  --r-md: calc(10px * var(--rs));
  --r-lg: calc(16px * var(--rs));
  --r-pill: calc(99px * var(--rs));

  --font: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-brand: "Exo 2", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 400px at 85% -10%, var(--glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent);
}

h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1rem 0 0.5rem;
}

p {
  margin: 0 0 0.6rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

img,
input,
select,
textarea,
button {
  max-width: 100%;
}

/* ---- Верхнее меню ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 14px;
  background: var(--bg-bar);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.brand img {
  height: 42px;
  width: auto;
  display: block;
}

.wordmark {
  font-family: var(--font-brand);
  font-style: italic;
  font-weight: 900;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #fff, oklch(0.7 0.01 var(--nh)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.wordmark .dent {
  background: none;
  color: var(--accent-strong);
  -webkit-text-fill-color: var(--accent-strong);
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1 1 100%;
  order: 3;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  padding: 9px 14px;
  border-radius: var(--r-md);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 600;
  font-size: 14px;
  color: var(--nav-text);
}

.nav a:hover {
  background: var(--raised);
  color: oklch(0.97 0 0);
}

.nav a.active {
  background: var(--accent-grad);
  color: var(--accent-text);
}

.who {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  white-space: nowrap;
}

.who a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-decoration: none;
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: oklch(0.3 0.03 235);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
}

.guestbar {
  display: flex;
  justify-content: center;
  padding: 28px 14px 0;
}

.guestbar .brand img {
  height: 64px;
}

.guestbar .brand {
  font-size: 26px;
}

/* ---- Страница и карточки ---- */

.page {
  width: 100%;
  max-width: 70rem;
  margin: 0 auto;
  padding: 18px 14px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page > * {
  margin-top: 0;
  margin-bottom: 0;
  min-width: 0;
}

.page > h1 + .muted {
  margin-top: -0.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
}

.card > :last-child {
  margin-bottom: 0;
}

.card.narrow {
  width: 100%;
  max-width: 26rem;
  margin-left: auto;
  margin-right: auto;
}

a.card {
  text-decoration: none;
  color: inherit;
}

a.card:hover {
  border-color: var(--accent-strong);
}

.muted {
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.toolbar h1,
.toolbar h2 {
  margin: 0;
  margin-right: auto;
}

.eyebrow {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-head h1 {
  margin: 6px 0 0;
}

.inline,
.inline-form {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0;
}

.inline-form input {
  width: auto;
  flex: 1 1 9rem;
}

/* ---- Главная: счётчики и блоки ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: linear-gradient(160deg, var(--card-hi), var(--card-lo));
  border: 1px solid var(--line-hi);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
}

.stat-value {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 8px;
}

.stat-num {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent);
}

.stat-num.amber {
  color: var(--warn);
}

.stat-unit {
  font-size: 13px;
  color: var(--muted-2);
}

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 14px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 96px;
}

.panel h2 {
  margin: 0;
  font-size: 16px;
}

.empty {
  color: var(--muted);
  padding: 0.5rem 0;
}

.empty.ok {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px oklch(0.78 0.14 160 / 0.7);
}

section.empty {
  border: 1px dashed var(--line-hi);
  border-radius: var(--r-lg);
  padding: 22px 16px;
  text-align: center;
}

.card.empty {
  text-align: center;
  padding: 22px 16px;
  border-style: solid;
}

.todo {
  list-style: none;
  margin: 0;
  padding: 0;
}

.todo li {
  border-top: 1px solid var(--line);
}

.todo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 14px 0;
  text-decoration: none;
  color: var(--text-2);
  line-height: 1.5;
}

.todo-row:hover {
  color: var(--accent);
}

.todo-text {
  flex: 1 1 14rem;
  min-width: 0;
}

.num {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: var(--accent-bg);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

.tag {
  flex: none;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--amber-bg);
  color: var(--amber-fg);
  font-size: 12px;
  font-weight: 600;
}

/* ---- Кнопки и поля ---- */

/* 16 px в полях: телефон не увеличивает страницу при вводе */
.btn,
button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-md);
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

.btn:hover,
button:hover {
  background: oklch(0.31 0.022 var(--nh));
  color: oklch(0.97 0 0);
}

.btn.primary {
  background: var(--accent-grad);
  color: var(--accent-text);
  border-color: transparent;
}

.btn.primary:hover {
  background: var(--accent-grad);
  color: var(--accent-text);
  filter: brightness(1.12);
}

.btn.danger {
  background: oklch(0.24 0.05 25);
  color: var(--red-fg);
  border-color: oklch(0.5 0.17 25);
}

.btn.danger:hover {
  background: var(--red-bg);
  color: var(--red-fg);
}

button.link {
  border: 0;
  background: none;
  color: var(--muted);
  min-height: 2.75rem;
  padding: 0 0.25rem;
  font-weight: 500;
}

button.link:hover {
  background: none;
  color: var(--text);
}

input,
select,
textarea {
  font: inherit;
  font-size: 16px;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-md);
  background: var(--inset);
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
  opacity: 0.8;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid oklch(0.6 0.21 var(--h) / 0.6);
  outline-offset: 1px;
  border-color: var(--accent-strong);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.25rem;
  min-height: 1.25rem;
  flex: none;
  accent-color: var(--accent-strong);
}

.form label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-2);
}

.form label input,
.form label select,
.form label textarea {
  margin-top: 0.25rem;
}

.form label.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
}

.form label.check input {
  margin: 0;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin: 0 0 1rem;
  padding: 0.75rem;
  min-width: 0;
  background: var(--card-lo);
}

legend {
  padding: 0 0.4rem;
  font-weight: 700;
}

.grid-form {
  display: block;
}

.row-form {
  display: flex;
  flex-direction: column;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.field-row > label {
  flex: 1 1 8rem;
}

.field-error {
  color: var(--danger);
  margin: 0.2rem 0 0;
}

.hint {
  font-size: 0.85rem;
}

button:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

/* ---- Быстрая запись ---- */

.q-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.q-head h1 {
  margin: 0;
}

.quick {
  max-width: 44rem;
}

.q-step {
  margin: 0 0 0.9rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card);
  min-width: 0;
}

.q-label {
  margin: 0 0 0.6rem;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* список услуг: кнопка раскрывает прокручиваемый список с отметками */
.q-select summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-md);
  background: var(--inset);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.q-select summary::-webkit-details-marker {
  display: none;
}

.q-select summary::after {
  content: "";
  flex: none;
  width: 0.55rem;
  height: 0.55rem;
  margin-left: 0.25rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
}

.q-select[open] summary {
  border-color: var(--accent-strong);
}

.q-select[open] summary::after {
  transform: rotate(-135deg);
}

.q-summary-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.q-summary-time {
  flex: none;
  color: var(--accent);
  font-weight: 700;
}

.q-list {
  margin-top: 0.5rem;
  max-height: 18rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--inset);
}

.q-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.4rem 0.9rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.q-option:last-child {
  border-bottom: 0;
}

.q-option:hover {
  background: var(--raised);
}

.q-option input {
  width: 1.4rem;
  min-height: 1.4rem;
  height: 1.4rem;
  margin: 0;
}

.q-option-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
}

.q-option-meta {
  flex: none;
  max-width: 45%;
  text-align: right;
  font-size: 13px;
  color: var(--muted);
}

.q-option.is-off {
  cursor: not-allowed;
}

.q-option.is-off .q-option-title,
.q-option.is-off .q-option-meta {
  opacity: 0.55;
}

.q-done {
  width: 100%;
  margin-top: 0.5rem;
  min-height: 3rem;
}

/* полоса дат прокручивается внутри, страница вбок не едет */
.q-days {
  position: relative;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.q-day {
  flex: none;
  flex-direction: column;
  gap: 0.1rem;
  width: 4.25rem;
  min-height: 5rem;
  padding: 0.5rem 0.25rem;
  background: var(--inset);
  scroll-snap-align: center;
}

.q-day-dow {
  font-size: 13px;
  color: var(--muted);
}

.q-day-num {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
}

.q-day-month {
  font-size: 12px;
  color: var(--muted);
}

.q-day.is-today {
  border-color: var(--accent-strong);
}

.q-day.is-selected,
.q-day.is-selected:hover {
  background: var(--accent-grad);
  border-color: transparent;
  color: var(--accent-text);
}

.q-day.is-selected .q-day-dow,
.q-day.is-selected .q-day-month {
  color: oklch(0.95 0.02 var(--h));
}

.q-day:disabled {
  opacity: 0.35;
}

.q-other {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-2);
}

.q-other input {
  margin-top: 0.25rem;
  min-height: 3rem;
}

/* сетка свободного времени */
.q-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr));
  gap: 0.5rem;
}

.q-slot {
  position: relative;
  display: block;
}

.q-slot input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.q-slot span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-md);
  background: var(--inset);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.q-slot:hover span {
  background: var(--raised);
}

.q-slot input:checked + span {
  background: var(--accent-grad);
  border-color: transparent;
  color: var(--accent-text);
}

.q-slot input:focus-visible + span {
  outline: 2px solid oklch(0.6 0.21 var(--h) / 0.6);
  outline-offset: 2px;
}

.q-empty {
  margin: 0;
  padding: 0.75rem 1rem;
  border: 1px dashed var(--line-hi);
  border-radius: var(--r-md);
  color: var(--muted);
}

.q-empty-no_posts,
.q-empty-error {
  border-style: solid;
  border-color: oklch(0.6 0.12 80);
  color: var(--amber-fg);
}

.q-field {
  display: block;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text-2);
}

.q-field:last-child {
  margin-bottom: 0;
}

.q-field input {
  margin-top: 0.25rem;
  min-height: 3rem;
}

.q-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.q-submit {
  flex: 1 1 12rem;
  min-height: 3.5rem;
  font-size: 17px;
  font-weight: 700;
}

/* ---- Сообщения ---- */

.notice {
  padding: 0.75rem 1rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line-hi);
  background: var(--card);
}

.notice p {
  margin: 0 0 0.4rem;
}

.notice p:last-child {
  margin-bottom: 0;
}

.notice.ok {
  border-color: oklch(0.5 0.12 160);
  background: oklch(0.25 0.05 160);
  color: var(--green-fg);
}

.notice.warn,
.warn-box {
  border-color: oklch(0.6 0.12 80);
  background: oklch(0.27 0.05 75);
  color: var(--amber-fg);
}

.notice.error {
  border-color: oklch(0.5 0.17 25);
  background: oklch(0.25 0.06 25);
  color: var(--red-fg);
}

.notice a {
  color: inherit;
}

.warn-box {
  padding: 0.75rem 1rem;
  border-width: 1px;
  border-style: solid;
  border-radius: var(--r-md);
}

.warn-box p:last-child {
  margin-bottom: 0;
}

/* ---- Метки и статусы ---- */

/* Цвета статусов: каждый класс задаёт пару --st-bg и --st-fg, дальше их берут метка, строка списка и блок календаря */
.status-pending,
.mode-human,
.badge.warn {
  --st-bg: var(--amber-bg);
  --st-fg: var(--amber-fg);
}

.status-confirmed,
.mode-bot,
.badge.ok {
  --st-bg: var(--green-bg);
  --st-fg: var(--green-fg);
}

.status-in_progress {
  --st-bg: var(--blue-bg);
  --st-fg: var(--blue-fg);
}

.status-done {
  --st-bg: var(--teal-bg);
  --st-fg: var(--teal-fg);
}

.status-delivered {
  --st-bg: var(--grey-bg);
  --st-fg: var(--grey-fg);
}

.status-cancelled,
.badge.bad {
  --st-bg: var(--red-bg);
  --st-fg: var(--red-fg);
}

.status-no_show {
  --st-bg: var(--purple-bg);
  --st-fg: var(--purple-fg);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line-hi);
  background: var(--st-bg, var(--grey-bg));
  color: var(--st-fg, var(--grey-fg));
}

.badge.muted {
  background: transparent;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--inset);
}

.segmented a,
.tabs a {
  padding: 0.5rem 0.85rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  color: var(--nav-text);
}

.segmented a:hover,
.tabs a:hover {
  background: var(--raised);
  color: oklch(0.97 0 0);
}

.segmented a.active,
.tabs a.active {
  background: var(--accent-grad);
  color: var(--accent-text);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tabs a {
  border-radius: var(--r-md);
  background: var(--card);
  border: 1px solid var(--line);
}

.tabs a.active {
  border-color: transparent;
}

/* ---- Списки ---- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.week-item,
.list-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--st-fg, var(--line-hi));
  border-radius: var(--r-md);
  background: var(--card-hi);
  color: var(--text);
  text-decoration: none;
}

a.list-item:hover,
a.week-item:hover {
  border-color: var(--accent-strong);
  border-left-color: var(--st-fg, var(--accent-strong));
  color: var(--text);
}

.list-item.chat-human {
  border-left-color: var(--amber-fg);
}

.list-item.chat-bot {
  border-left-color: var(--green-fg);
}

.week-item {
  margin-bottom: 0.4rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.filters label {
  flex: 1 1 10rem;
  font-size: 0.9rem;
  color: var(--text-2);
}

.facts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.1rem 1rem;
  margin: 0;
}

.facts dt {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.facts dd {
  margin: 0;
}

.prewrap {
  white-space: pre-wrap;
}

.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.item-list > li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.item-list > li:first-child {
  padding-top: 0;
}

.item-list > li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.rules-list {
  margin: 0 0 0.75rem;
  padding-left: 1.3rem;
}

.rules-list li {
  margin-bottom: 0.3rem;
}

.stack > * + * {
  margin-top: 0.75rem;
}

.secret {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1.2rem;
  padding: 0.7rem;
  background: oklch(0.27 0.05 75);
  color: var(--amber-fg);
  border: 1px dashed oklch(0.6 0.12 80);
  border-radius: var(--r-md);
  user-select: all;
}

.code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- Таблицы ---- */

.table-scroll {
  overflow-x: auto;
}

.grid-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.grid-table th,
.grid-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.grid-table th {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.grid-table tbody tr:last-child td {
  border-bottom: 0;
}

.diff {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.diff del {
  background: var(--red-bg);
  color: var(--red-fg);
  text-decoration: line-through;
}

.diff ins {
  background: var(--green-bg);
  color: var(--green-fg);
  text-decoration: none;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.status-line:last-child {
  border-bottom: 0;
}

.status-line > span:first-child {
  flex: 1 1 10rem;
  color: var(--muted);
}

/* ---- Календарь: на телефоне колонки друг под другом, на широком экране рядом ---- */

.cal-title {
  flex: 1 1 8rem;
  text-align: center;
}

.cal-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.cal-col {
  flex: 1 1 16rem;
  min-width: 0;
}

.cal-col-title {
  margin: 0 0 0.35rem;
}

.cal-grid {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  overflow: hidden;
}

.cal-hour {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--line);
  font-size: 0.7rem;
  color: var(--muted-2);
  pointer-events: none;
}

.cal-hour span {
  padding-left: 0.25rem;
}

.cal-off {
  position: absolute;
  left: 0;
  right: 0;
  background: repeating-linear-gradient(
    45deg,
    oklch(0.17 0.012 var(--nh)),
    oklch(0.17 0.012 var(--nh)) 6px,
    oklch(0.19 0.012 var(--nh)) 6px,
    oklch(0.19 0.012 var(--nh)) 12px
  );
}

.cal-lanes {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2.9rem;
  right: 0.2rem;
}

.cal-block {
  position: absolute;
  min-height: 1.6rem;
  overflow: hidden;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--line-hi);
  border-left: 3px solid var(--st-fg, var(--accent));
  border-radius: var(--r-sm);
  background: var(--st-bg, var(--card-hi));
  color: var(--text);
  text-decoration: none;
  font-size: 0.8rem;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
}

.cal-block:hover {
  border-color: var(--st-fg, var(--accent));
  color: var(--text);
}

.cal-block span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.col-actions {
  margin: 0.35rem 0 0;
}

.week {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.week-day {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 0.75rem;
  min-width: 0;
}

.week-day.today {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px oklch(0.6 0.21 var(--h) / 0.35);
}

.week-day.closed {
  background: var(--inset);
}

.week-day h2 {
  margin-bottom: 0.5rem;
}

/* ---- Диалоги, клиенты, база знаний, тренажёр ---- */

.chat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.chat-last {
  overflow-wrap: anywhere;
}

.chat-time {
  font-size: 0.85rem;
}

.thread {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.msg {
  max-width: 100%;
  padding: 0.55rem 0.8rem;
  border-radius: calc(14px * var(--rs));
  border: 1px solid var(--line);
  background: var(--card-hi);
}

.msg.in {
  align-self: flex-start;
}

.msg.out {
  align-self: flex-end;
  background: oklch(0.27 0.06 var(--h));
  border-color: oklch(0.4 0.1 var(--h));
}

.msg p {
  margin: 0.25rem 0 0;
}

.msg-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.msg-kind {
  font-style: italic;
}

.transcript {
  border-left: 3px solid var(--accent-strong);
  padding-left: 0.5rem;
}

.photo {
  display: block;
  width: 100%;
  max-width: 20rem;
  height: auto;
  border-radius: var(--r-md);
}

audio {
  width: 100%;
  max-width: 100%;
}

/* ---- Анкета ---- */

.bar {
  background: oklch(0.28 0.015 var(--nh));
  border-radius: var(--r-pill);
  height: 0.6rem;
  overflow: hidden;
  margin: 0.4rem 0;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent-grad);
}

.qcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 0.9rem;
  margin: 0 0 0.9rem;
}

.qcard p {
  margin: 0 0 0.4rem;
}

.qtext {
  font-size: 1.02rem;
}

.qwhy {
  font-size: 0.88rem;
  color: var(--muted);
}

.qfound {
  background: var(--amber-bg);
  color: var(--amber-fg);
  border-radius: var(--r-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.92rem;
}

.qerror {
  color: var(--danger);
  font-weight: 600;
}

.qnote {
  color: var(--warn);
  font-size: 0.92rem;
}

.qstatus {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-top: 0.5rem;
}

.qstatus label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.4rem;
}

.qstatus input {
  width: 1.25rem;
  min-height: 1.25rem;
  margin: 0;
  flex: none;
}

.qgroup {
  margin-top: 1.2rem;
}

.qbar {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 0.6rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-top: 1px solid var(--line);
}

.secrow strong {
  color: var(--accent);
}

/* ---- Шире телефона ---- */

@media (min-width: 40rem) {
  body {
    font-size: 15px;
  }

  h1 {
    font-size: 2rem;
  }

  .topbar {
    gap: 8px 20px;
    padding: 12px 24px;
  }

  .page {
    padding: 32px 24px 64px;
    gap: 20px;
  }

  .card {
    padding: 22px;
  }

  .stats {
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 14px;
  }

  .stat {
    padding: 18px 20px;
  }

  .stat-num {
    font-size: 36px;
  }

  .row-form {
    flex-direction: row;
    align-items: flex-end;
    gap: 0.75rem;
  }

  .row-form label {
    margin-bottom: 0;
    flex: 1 1 10rem;
  }

  .grid-form fieldset {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
  }

  .grid-form fieldset > legend {
    grid-column: 1 / -1;
  }

  .week {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .facts {
    grid-template-columns: 12rem 1fr;
  }

  .facts dt {
    margin-top: 0;
  }

  .msg {
    max-width: 80%;
  }
}

@media (min-width: 56rem) {
  .nav {
    flex: 1 1 0;
    order: 0;
  }
}

@media (min-width: 64rem) {
  .week {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
