/* ============================================================
   HR таблица — дизайн-система (светлая/тёмная тема, адаптив)
   ============================================================ */
:root {
  color-scheme: light dark;   /* нативные попапы (select, date, скроллбары) следуют теме */
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f5f7fc;
  --surface-3: #eceff7;
  --border: #e6e9f2;
  --border-2: #d6dbea;
  --text: #0f172a;
  --text-2: #384357;
  --muted: #6b7690;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-700: #3730a3;
  --on-primary: #ffffff;
  --ring: rgba(79, 70, 229, .26);
  --danger: #e11d48;
  --danger-050: #fff1f4;
  --success: #0f9d6b;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-2: 0 10px 30px -10px rgba(16, 24, 40, .22);
  --shadow-3: 0 30px 70px -20px rgba(2, 6, 23, .45);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --caret: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1c;
    --surface: #111a2e;
    --surface-2: #0f1728;
    --surface-3: #17223a;
    --border: #1f2b45;
    --border-2: #2a3959;
    --text: #e7ecf6;
    --text-2: #c4cde0;
    --muted: #8b97b4;
    --primary: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;
    --ring: rgba(99, 102, 241, .38);
    --danger: #fb7185;
    --danger-050: #241220;
    --success: #34d399;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 12px 34px -12px rgba(0, 0, 0, .6);
    --shadow-3: 0 30px 80px -20px rgba(0, 0, 0, .75);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 100% -10%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: color-mix(in srgb, var(--primary) 26%, transparent); }

h1, h2, h3 { letter-spacing: -.01em; }

/* ---------- элементы форм ---------- */
button, input, select, textarea { font: inherit; color: inherit; }

button, .button-link {
  --btn-bg: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 15px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--btn-bg);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, transform .06s ease, box-shadow .16s ease, filter .16s ease;
  box-shadow: var(--shadow-1);
}
button:hover, .button-link:hover { background: var(--surface-2); border-color: var(--muted); }
button:active, .button-link:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.primary, .button-link.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-600));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px -8px var(--ring), var(--shadow-1);
}
.primary:hover, .button-link.primary:hover {
  background: linear-gradient(180deg, var(--primary), var(--primary-700));
  border-color: transparent;
  filter: brightness(1.04);
}
.danger {
  color: var(--danger);
  background: var(--surface);
  border-color: color-mix(in srgb, var(--danger) 38%, var(--border-2));
}
.danger:hover { background: var(--danger-050); border-color: var(--danger); }
.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.ghost:hover { background: var(--surface-3); border-color: transparent; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

input, select, textarea {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  font-size: 16px;                 /* ≥16px — иначе iOS Safari зумит при фокусе */
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: var(--caret);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
/* Явные цвета опций — читаемый нативный список в тёмной теме (Windows/Chromium). */
select, option, optgroup { color: var(--text); }
option, optgroup { background-color: var(--surface); }
option:checked { background-color: var(--surface-3); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
input[type="file"] { padding: 8px 12px; height: auto; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* ---------- логин ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1000px 560px at 50% -10%, color-mix(in srgb, var(--primary) 20%, transparent), transparent 60%);
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 30px;
  box-shadow: var(--shadow-2);
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card form { display: grid; gap: 14px; }
.login-card .logo { width: 54px; height: 54px; border-radius: 16px; font-size: 18px; margin-bottom: 16px; }

/* ---------- каркас ---------- */
.layout { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; }
.logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .04em;
  background: linear-gradient(145deg, #6366f1, #2563eb);
  box-shadow: 0 8px 16px -6px rgba(37, 99, 235, .55);
}
.userbar { display: flex; align-items: center; gap: 8px; }
.user { display: flex; align-items: center; gap: 10px; padding-right: 4px; }
.avatar {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff; font-weight: 700; font-size: 13px;
  background: linear-gradient(145deg, #8b5cf6, #4f46e5);
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 650; font-size: 14px; }
.user-role { font-size: 12px; color: var(--muted); }

/* ---------- контент ---------- */
.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  flex: 1;
  padding: 22px max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.page-title h1 { margin: 0; font-size: 24px; font-weight: 750; }

/* ---------- панель поиска/фильтров ---------- */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.search-row { display: flex; align-items: center; gap: 12px; }
.search { position: relative; flex: 1; }
.search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 42px; }
.count-chip {
  flex: none; height: 42px; padding: 0 14px;
  display: inline-flex; align-items: center;
  border-radius: 999px;
  background: var(--surface-3); color: var(--muted);
  font-weight: 600; font-size: 13px; white-space: nowrap;
}
.filters-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.filters-row .field { flex: 1 1 150px; min-width: 140px; }
.filters-row > button { flex: 0 0 auto; align-self: stretch; }
.filters-row .field label { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- таблица ---------- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; transition: background .12s ease; }
tbody tr.clickable:hover { background: var(--surface-2); }
td[data-label="ФИО"] { color: var(--text); font-weight: 650; }
td[data-label="Телефон"] { font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap; }
td[data-label="Дата"] { color: var(--muted); white-space: nowrap; }
td[data-label="Комментарий"] { color: var(--muted); max-width: 280px; }

/* пустое состояние */
.empty-row td { padding: 0; }
.empty { display: grid; place-items: center; gap: 6px; padding: 46px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 30px; height: 30px; opacity: .6; }

/* ---------- статусы ---------- */
.badge {
  --st: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap;
  color: var(--st);
  background: color-mix(in srgb, var(--st) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--st) 30%, transparent);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--st); }
[data-status="Новый"] { --st: #2563eb; }
[data-status="думает"] { --st: #d97706; }
[data-status="ожидаем"] { --st: #7c3aed; }
[data-status="стажировка"] { --st: #059669; }
[data-status="уволился"] { --st: #64748b; }
[data-status="ушел"] { --st: #e11d48; }

/* ---------- передача «Ответственному» ---------- */
.handoff-btn {
  margin-right: auto;                 /* оттесняем к левому краю .actions */
  display: inline-flex; align-items: center; gap: 7px; font-weight: 650;
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border-2));
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}
.handoff-btn .icon { width: 17px; height: 17px; }
.handoff-btn:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }

.handoff-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 16px; padding: 12px 16px;
  border-radius: 12px; color: #fff; font-weight: 700; font-size: 14px;
  background: linear-gradient(120deg, var(--primary), var(--primary-600));
  box-shadow: 0 8px 24px -10px var(--ring);
  animation: handoffGlow 2.2s ease-in-out infinite;
}
.handoff-banner .icon { width: 18px; height: 18px; flex: none; }
.handoff-banner-text { flex: 1; }
.handoff-banner-when { font-weight: 600; font-size: 12px; opacity: .85; white-space: nowrap; }
@keyframes handoffGlow {
  0%, 100% { box-shadow: 0 6px 18px -10px var(--ring); }
  50% { box-shadow: 0 12px 32px -6px color-mix(in srgb, var(--primary) 70%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .handoff-banner { animation: none; } }

/* Затемняем поля переданной карточки для тех, кто её больше не правит. */
.handoff-locked .field,
.handoff-locked .form-section-title,
.handoff-locked .cat-row { opacity: .55; }

/* Поле даты с кнопкой «Сейчас» (дата стажировки). */
.field .with-now { display: flex; align-items: center; gap: 8px; }
.field .with-now input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 2px 0; font-size: 16px; flex: 1; min-width: 0; }
.now-btn { height: 32px; padding: 0 12px; flex: none; }

/* Сводка структурных данных карточки (приезд, наставник, даты). */
.status-facts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px;
  margin: 0 0 16px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.status-facts .fact { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.status-facts .fact-label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.status-facts .fact-val { font-size: 14px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
@media (max-width: 640px) { .status-facts { grid-template-columns: 1fr; } }

/* ---------- формы карточки ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: 1 / -1; }

/* Inset-поля: подпись сверху, borderless-контрол внутри мягкой карточки. */
.field {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 12px 8px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); background: var(--surface); }
.field > label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.field > input, .field > select, .field > textarea {
  border: 0 !important; background: transparent !important; box-shadow: none !important;
  height: auto; min-height: 26px; padding: 2px 0; border-radius: 0; font-size: 16px;
}
.field > select { padding-right: 22px; background-position: right 0 center; }
.field > textarea { min-height: 60px; resize: vertical; }
.field > input[type="file"] { font-size: 14px; }

.actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 20px; flex-wrap: wrap; }

/* секции формы карточки */
.form-section { margin-bottom: 16px; }
.form-section-title { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px 2px; }

/* Категории прав — переключаемые чипы-чекбоксы */
.cat-field:focus-within { box-shadow: none; border-color: var(--border); background: var(--surface-2); }
.cat-field .cat-row { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.cat-box { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border: 1px solid var(--border-2); border-radius: 10px; background: var(--surface); font-weight: 700; cursor: pointer; user-select: none; }
.cat-box input { width: 17px; height: 17px; }
.cat-box:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--primary); }
.cat-box:has(input:disabled) { cursor: default; opacity: .7; }

/* поле телефона внутри inset-поля */
.field .phone-control { display: flex; align-items: center; gap: 2px; border: 0; background: transparent; }
.field .phone-prefix { padding: 0 6px 0 0; background: transparent; border: 0; color: var(--muted); font-weight: 600; }
.field .phone-control input { border: 0 !important; box-shadow: none !important; background: transparent; padding: 2px 0; font-size: 16px; }

/* карточка-герой */
.card-hero { display: flex; align-items: center; gap: 14px; padding: 4px 2px 18px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.card-hero-meta { flex: 1; min-width: 0; }
.card-hero-name { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.card-hero-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.avatar-lg { width: 54px; height: 54px; border-radius: 16px; font-size: 19px; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }

/* активность: комментарии + история */
.activity { margin-top: 8px; }
.comments h3 { display: flex; align-items: center; gap: 8px; }
.count-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 650; }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.tl-item { display: flex; gap: 10px; }
.tl-body { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px 14px 14px 14px; padding: 9px 12px; }
.tl-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.tl-author { font-weight: 650; font-size: 13px; }
.tl-time { font-size: 12px; color: var(--muted); }
.tl-text { font-size: 14px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.empty-inline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; padding: 6px 0; }
.empty-inline .icon { width: 20px; height: 20px; opacity: .6; }

/* композер комментария */
.composer { display: flex; gap: 10px; margin-top: 14px; }
.composer-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { min-height: 44px; }
.composer-actions { display: flex; justify-content: flex-end; }

/* история */
.history { margin-top: 6px; }
.history-list { display: flex; flex-direction: column; }
.history-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; position: relative; font-size: 13px; }
.history-item + .history-item { border-top: 1px dashed var(--border); }
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }
.history-text { font-weight: 600; color: var(--text-2); }
.history-detail { color: var(--muted); }
.history-time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* аватар-колонка в списке */
.col-ava { width: 46px; padding-right: 0 !important; }
thead th:first-child { width: 46px; }

/* ---------- модалка ---------- */
html.modal-open, html.modal-open body { overflow: hidden; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6, 10, 22, .5);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .15s ease;
}
.modal {
  width: min(760px, 100%);
  max-height: min(90vh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;               /* скроллится только тело, не вся модалка */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-3);
  animation: pop .2s cubic-bezier(.2, .8, .2, 1);
}
.modal-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.modal.modal-sm { width: min(460px, 100%); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-head button { height: 34px; width: 34px; padding: 0; border-radius: 10px; }

/* заголовок раздела справочника + кнопка «Добавить» */
.dict-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.dict-head h2 { margin: 0; }

/* диалог подтверждения / «было → стало» */
.confirm-text { margin: 0 0 16px; color: var(--text-2); }
.confirm-text b { color: var(--text); }

/* инструкция установки на iOS */
.ios-steps { margin: 0 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--text-2); }
.ios-steps li { line-height: 1.45; }
.ios-steps b { color: var(--text); }
.diff { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.diff-row { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.diff-label { flex: none; width: 54px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.diff-old { color: var(--danger); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.diff-new { color: var(--success); font-weight: 650; }
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
.modal-body::-webkit-scrollbar { width: 10px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; border: 3px solid var(--surface); background-clip: padding-box; }
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---------- мастер добавления ---------- */
.wizard { max-width: 560px; margin: 0 auto; padding: 6px 2px 2px; }
.wiz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.wiz-dots { display: flex; gap: 6px; }
.wiz-dots .dot { width: 28px; height: 5px; border-radius: 999px; background: var(--surface-3); transition: background .2s ease; }
.wiz-dots .dot.done { background: color-mix(in srgb, var(--primary) 45%, var(--surface-3)); }
.wiz-dots .dot.active { background: var(--primary); }
.wiz-step-num { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.wiz-title { margin: 0 0 4px; font-size: 23px; font-weight: 750; letter-spacing: -.02em; }
.wiz-sub { margin-bottom: 20px; }
.wiz-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.wiz-chip {
  height: auto; min-height: 46px; padding: 11px 18px; border-radius: 12px; font-size: 15px;
  background: var(--surface-2); border: 1px solid var(--border-2); font-weight: 600;
}
.wiz-chip:hover { border-color: var(--primary); background: var(--surface); }
.wiz-chip.active { background: linear-gradient(180deg, var(--primary), var(--primary-600)); border-color: transparent; color: #fff; box-shadow: 0 8px 18px -8px var(--ring); }
.wiz-custom { display: flex; gap: 10px; margin-bottom: 18px; }
.wiz-custom input { flex: 1; }
.wiz-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }

/* ---------- комментарии / история ---------- */
.comments { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.comments h3 { margin: 0 0 2px; font-size: 15px; font-weight: 700; }
.comment { background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 12px; padding: 11px 13px; }
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.comments .muted { font-size: 13px; }

/* ---------- админ-разделы ---------- */
.admin { display: flex; flex-direction: column; gap: 18px; }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; box-shadow: var(--shadow-1); }
.section h2 { margin: 0 0 14px; font-size: 17px; font-weight: 700; }
.section .section { box-shadow: none; background: var(--surface-2); }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; }
.checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 14px; }
.mini-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-chip { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }

/* назначения «Ответственного» */
.resp-picker { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 10px; }
.resp-list { display: flex; flex-direction: column; gap: 8px; }
.resp-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 8px 8px 12px; }
.resp-item b { color: var(--text); }
.resp-remove { height: 30px; width: 30px; padding: 0; border-radius: 8px; flex: none; }
@media (max-width: 640px) { .resp-picker { grid-template-columns: 1fr; } }

/* ---------- утилиты ---------- */
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; font-weight: 500; }
.error:empty { display: none; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }

/* ============================================================
   Адаптив — планшет
   ============================================================ */
@media (max-width: 900px) {
  .filters-row { grid-template-columns: repeat(2, 1fr); }
  .filters-row > .button-link,
  .filters-row > button { grid-column: 1 / -1; }
}

/* ============================================================
   Адаптив — телефон
   ============================================================ */
@media (max-width: 640px) {
  body { font-size: 14.5px; }

  .content { padding: 16px 14px calc(28px + env(safe-area-inset-bottom)); }
  .page-title { flex-wrap: wrap; }
  .page-title h1 { font-size: 21px; }

  .user-meta { display: none; }
  .userbar .lbl { display: none; }
  .userbar button { height: 44px; width: 44px; padding: 0; }   /* тач-цель ≥44px */
  .brand span:not(.logo) { display: none; }

  .search-row { flex-wrap: wrap; }
  .count-chip { order: 2; }
  .filters-row { grid-template-columns: 1fr 1fr; }

  /* таблица -> карточки */
  .table-wrap { border: 0; background: transparent; box-shadow: none; overflow: visible; border-radius: 0; }
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody { display: flex; flex-direction: column; gap: 12px; }
  tr.clickable {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow-1);
  }
  tr.clickable:hover { background: var(--surface); }
  tbody td { padding: 5px 0; border: 0; display: flex; justify-content: space-between; gap: 14px; align-items: center; }
  tbody td::before { content: attr(data-label); color: var(--muted); font-weight: 600; font-size: 12.5px; flex: none; }
  td.cell-empty, td.col-ava { display: none; }
  td[data-label="ФИО"] {
    order: -1; display: block;
    font-size: 16px; font-weight: 700; color: var(--text);
    padding: 0 0 10px; margin-bottom: 6px; border-bottom: 1px solid var(--border);
  }
  td[data-label="ФИО"]::before { display: none; }
  td[data-label="Комментарий"] { max-width: none; }
  .empty-row td { display: block; }

  .grid { grid-template-columns: 1fr; }

  /* модалка -> нижний лист */
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal { width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; border-bottom: 0; animation: slideup .24s ease; }
  .modal-head button { height: 44px; width: 44px; }          /* крестик — тач-цель ≥44px */
  /* липкая панель действий: отступ под Home Indicator, чтобы кнопки не уходили под него */
  .actions { position: sticky; bottom: 0; background: var(--surface); padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); margin-top: 16px; }
  .actions button, .actions .button-link { flex: 1; }
  /* хвост контента модалок без кнопок тоже не под индикатором */
  .modal-body { padding-bottom: max(20px, env(safe-area-inset-bottom)); }

  /* тач-цели ≥44px: контролы форм, чекбоксы, кнопки */
  .field > input, .field > select, .field > textarea { min-height: 40px; }
  .field .phone-control, .field .with-now { min-height: 40px; }
  .field > textarea { min-height: 72px; }
  .check { min-height: 44px; }
  button, .button-link { min-height: 44px; }
  .resp-remove { min-height: 0; }   /* компактная иконка удаления назначения — исключение */
}

@media (max-width: 380px) {
  .filters-row { grid-template-columns: 1fr; }
}
