:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f0;
  --text: #1f2733;
  --text-muted: #6b7688;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-lg: 0 10px 30px rgba(17, 24, 39, .18);
  --radius: 12px;

  --st-new-bg: #e0edff;      --st-new-fg: #1d4ed8;
  --st-prog-bg: #fef3c7;     --st-prog-fg: #b45309;
  --st-done-bg: #dcfce7;     --st-done-fg: #15803d;
  --st-cancel-bg: #fee2e2;   --st-cancel-fg: #b91c1c;
  --st-clar-bg: #ede9fe;     --st-clar-fg: #6d28d9;
  --st-unpr-bg: #e5e7eb;     --st-unpr-fg: #4b5563;
  --st-cxl-bg: #e2e8f0;      --st-cxl-fg: #475569;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #1a212b;
    --surface-2: #212a36;
    --border: #2c3644;
    --text: #e6ebf2;
    --text-muted: #93a0b3;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, .55);

    --st-new-bg: #1e3356;      --st-new-fg: #93c5fd;
    --st-prog-bg: #4a3610;     --st-prog-fg: #fcd34d;
    --st-done-bg: #14361f;     --st-done-fg: #86efac;
    --st-cancel-bg: #451a1a;   --st-cancel-fg: #fca5a5;
    --st-clar-bg: #2e2350;     --st-clar-fg: #c4b5fd;
    --st-unpr-bg: #2b3240;     --st-unpr-fg: #b6c0cf;
    --st-cxl-bg: #33404f;      --st-cxl-fg: #9aa7b8;
  }
}

* { box-sizing: border-box; }

/* Фикс: атрибут hidden должен скрывать даже элементы с display: flex/grid */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

/* ---- Шапка ---- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand__logo { font-size: 30px; }
.brand__title { margin: 0; font-size: 19px; font-weight: 700; }
.brand__subtitle { margin: 0; font-size: 13px; color: var(--text-muted); }
.header-actions { display: flex; gap: 10px; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ---- Кнопки ---- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .04s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--icon {
  padding: 6px 9px;
  font-size: 13px;
  line-height: 1;
}
.btn--sm { padding: 5px 12px; font-size: 13px; }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--st-cancel-bg); border-color: var(--danger); }

/* ---- Статистика ---- */
.stats {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.stats > .stat, .stats > .revenue-tile { flex: 1 1 0; min-width: 124px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .12s, transform .06s;
  border-left: 4px solid var(--border);
}
.stat:hover { transform: translateY(-2px); }
.stat.is-active { border-color: var(--primary); }
.stat--waiting { border-left-color: var(--st-new-fg); }
.stat--clarifying { border-left-color: var(--st-clar-fg); }
.stat--unprocessed { border-left-color: var(--st-unpr-fg); }
.stat--progress { border-left-color: var(--st-prog-fg); }
.stat--done { border-left-color: var(--st-done-fg); }
.stat--rejected { border-left-color: var(--st-cancel-fg); }
.stat--cancelled { border-left-color: var(--st-cxl-fg); }
.stat__value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat__label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Плитка выручки — выделена, не кликабельна */
.revenue-tile {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.revenue-tile__value { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.revenue-tile__label { font-size: 13px; opacity: .85; margin-top: 2px; }
.cell-money { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Панель инструментов ---- */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar__search { flex: 1; min-width: 220px; }
.toolbar__filter { width: 200px; }

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

/* ---- Таблица ---- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 900px; }
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.row-open { cursor: pointer; }
.cell-id { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cell-name { font-weight: 600; }
.cell-muted { color: var(--text-muted); font-size: 13px; }
.cell-actions { text-align: right; white-space: nowrap; }

/* ---- Статус-бейдж / селект ---- */
.status-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 30px 5px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background-color: var(--surface);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%238a94a6" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.status-select:hover:not(:disabled) { border-color: var(--primary); }
.status-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring, rgba(59,130,246,.25)); }
.status--waiting { background-color: var(--st-new-bg); color: var(--st-new-fg); }
.status--clarifying { background-color: var(--st-clar-bg); color: var(--st-clar-fg); }
.status--unprocessed { background-color: var(--st-unpr-bg); color: var(--st-unpr-fg); }
.status--in_progress { background-color: var(--st-prog-bg); color: var(--st-prog-fg); }
.status--done { background-color: var(--st-done-bg); color: var(--st-done-fg); }
.status--rejected { background-color: var(--st-cancel-bg); color: var(--st-cancel-fg); }
.status--cancelled { background-color: var(--st-cxl-bg); color: var(--st-cxl-fg); }

/* ---- Подсветка строк заявок по статусу ---- */
.row--waiting     { background: color-mix(in srgb, var(--st-new-fg) 7%, transparent); }
.row--clarifying  { background: color-mix(in srgb, var(--st-clar-fg) 8%, transparent); }
.row--unprocessed { background: color-mix(in srgb, var(--st-unpr-fg) 9%, transparent); }
.row--in_progress { background: color-mix(in srgb, var(--st-prog-fg) 9%, transparent); }
.row--done        { background: color-mix(in srgb, var(--st-done-fg) 9%, transparent); }
.row--rejected    { background: color-mix(in srgb, var(--st-cancel-fg) 9%, transparent); }
.row--cancelled   { background: color-mix(in srgb, var(--st-cxl-fg) 9%, transparent); }
.row--waiting     td:first-child { box-shadow: inset 4px 0 0 var(--st-new-fg); }
.row--clarifying  td:first-child { box-shadow: inset 4px 0 0 var(--st-clar-fg); }
.row--unprocessed td:first-child { box-shadow: inset 4px 0 0 var(--st-unpr-fg); }
.row--in_progress td:first-child { box-shadow: inset 4px 0 0 var(--st-prog-fg); }
.row--done        td:first-child { box-shadow: inset 4px 0 0 var(--st-done-fg); }
.row--rejected    td:first-child { box-shadow: inset 4px 0 0 var(--st-cancel-fg); }
.row--cancelled   td:first-child { box-shadow: inset 4px 0 0 var(--st-cxl-fg); }

/* Автор заявки в шапке формы */
.form-author { color: var(--text-muted); font-size: 13px; align-self: center; }
.check--wide { width: 100%; }

/* ---- Пустое состояние ---- */
.empty { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.empty p { margin: 0 0 14px; font-size: 15px; }

/* ---- Модальное окно ---- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(15, 20, 27, .5); backdrop-filter: blur(2px); }
.modal__dialog {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
}
.modal__dialog--sm { max-width: 420px; }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.modal__head h2 { margin: 0; font-size: 17px; }
.modal__close { background: none; border: none; font-size: 26px; line-height: 1; color: var(--text-muted); cursor: pointer; }
.modal__close:hover { color: var(--text); }

/* ---- Форма ---- */
.form { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.field__label b { color: var(--danger); }
.field__error { font-size: 12px; color: var(--danger); min-height: 1px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.field--narrow { max-width: 120px; }
.input.is-invalid { border-color: var(--danger); outline-color: var(--danger); }
.form__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.amount-modal__text { margin: 0; font-size: 14px; color: var(--text-muted); }
.hint { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; }

/* ---- Города ---- */
.city-add { display: flex; gap: 10px; }
.city-add .input { flex: 1; }
.city-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.city-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
}
.city-item.is-closed { opacity: .7; }
.city-item--empty { justify-content: center; color: var(--text-muted); }
.city-item__name { flex: 1; font-weight: 600; }
.city-item__badge {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
}
.city-item__badge.open { background: var(--st-done-bg); color: var(--st-done-fg); }
.city-item__badge.closed { background: var(--st-cancel-bg); color: var(--st-cancel-fg); }

/* ---- Уведомление ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: var(--danger); }

/* ---- Экран входа ---- */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login__card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; }
.login__logo { font-size: 44px; text-align: center; }
.login__title { margin: 0; font-size: 20px; text-align: center; }
.login__subtitle { margin: 0 0 6px; font-size: 14px; color: var(--text-muted); text-align: center; }
.login__error { color: var(--danger); font-size: 13px; min-height: 1em; text-align: center; }
.btn--block { width: 100%; justify-content: center; }

/* ---- Пользовательский чип в шапке ---- */
.user-chip { position: relative; display: flex; flex-direction: column; align-items: flex-end; padding: 4px 10px; border-radius: 10px; cursor: pointer; line-height: 1.2; }
.user-chip:hover { background: var(--surface-2); }
.user-chip__name { font-weight: 600; font-size: 14px; }
.user-chip__role { font-size: 12px; color: var(--text-muted); }
.user-menu { position: absolute; top: 100%; right: 0; margin-top: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 170px; overflow: hidden; display: none; z-index: 20; }
.user-chip.is-open .user-menu { display: block; animation: pop .15s ease both; }
.user-menu__item { display: block; width: 100%; text-align: left; padding: 10px 14px; background: none; border: none; font-size: 14px; color: var(--text); cursor: pointer; }
.user-menu__item:hover { background: var(--surface-2); }

/* ---- Баннер смены пароля ---- */
.banner { background: var(--st-prog-bg); color: var(--st-prog-fg); text-align: center; padding: 9px 16px; font-size: 14px; }
.linklike { background: none; border: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; padding: 0; font-weight: 600; }
.field__hint { font-weight: 400; color: var(--text-muted); font-size: 12px; }

/* ---- Отключённые поля ---- */
.input:disabled, .status-select:disabled { opacity: .6; cursor: not-allowed; background: var(--surface-2); }

/* ---- Пагинация ---- */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
.pager__info { font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cell-clip { text-align: center; font-size: 13px; color: var(--text-muted); white-space: nowrap; }

/* ---- Вложения ---- */
.att-list { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.att-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.att-item--empty { justify-content: center; color: var(--text-muted); font-size: 13px; }
.att-item__name { flex: 1; color: var(--primary); text-decoration: none; font-size: 14px; word-break: break-all; }
.att-item__name:hover { text-decoration: underline; }
.att-item__meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.att-upload { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.att-hint { font-size: 12px; color: var(--text-muted); }

/* ---- Список пользователей ---- */
.user-new { border: 1px solid var(--border); border-radius: 10px; padding: 4px 12px; }
.user-new summary { cursor: pointer; padding: 8px 0; font-weight: 600; font-size: 14px; }
.user-new__body { display: flex; flex-direction: column; gap: 12px; padding: 8px 0 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.user-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.user-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.user-item.is-off { opacity: .6; }
.user-item__info { flex: 1; min-width: 0; }
.user-item__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-item__name { font-weight: 600; }
.user-item__role { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--st-new-bg); color: var(--st-new-fg); }
.user-item__role.role-admin { background: var(--st-cancel-bg); color: var(--st-cancel-fg); }
.user-item__role.role-director { background: var(--st-done-bg); color: var(--st-done-fg); }
.user-item__off { font-size: 12px; color: var(--danger); }
.user-item__sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.user-item__actions { display: flex; gap: 6px; flex-shrink: 0; }
.modal__dialog--lg { max-width: 640px; }

/* ---- Лента слотов времени (как в референсе: время + загрузка) ---- */
.sched__date { max-width: 200px; margin-bottom: 8px; }
.timeslots {
  display: flex; gap: 4px; overflow-x: auto; padding: 2px 0 8px;
  scrollbar-width: thin;
}
.slot {
  flex: 0 0 auto; min-width: 56px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); cursor: pointer;
  font-variant-numeric: tabular-nums; transition: border-color .1s, background .1s, transform .04s;
}
.slot__time { font-size: 13px; font-weight: 600; }
.slot__count { font-size: 12px; color: var(--text-muted); line-height: 1; }
.slot:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-1px); }
.slot--busy { background: var(--st-prog-bg); border-color: var(--st-prog-fg); }
.slot--busy .slot__count { color: var(--st-prog-fg); font-weight: 700; }
.slot--full { background: var(--st-cancel-bg); border-color: var(--st-cancel-fg); }
.slot--full .slot__count { color: var(--st-cancel-fg); font-weight: 700; }
.slot.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.slot.is-active .slot__time, .slot.is-active .slot__count { color: #fff; }
.slot:disabled { opacity: .5; cursor: not-allowed; }
.slot--custom { border-style: dashed; }
/* Полоска-подсказка над лентой */
.slot-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.slot-legend span { display: inline-flex; align-items: center; gap: 5px; }
.slot-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; border: 1px solid var(--border); }
.slot-legend .lg-free { background: var(--surface); }
.slot-legend .lg-busy { background: var(--st-prog-bg); border-color: var(--st-prog-fg); }
.slot-legend .lg-full { background: var(--st-cancel-bg); border-color: var(--st-cancel-fg); }

/* ---- Заявка отдельной страницей (широкая, многоколоночная) ---- */
#form-view { max-width: 1160px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.page-head__title { margin: 0; font-size: 20px; }
.form--page {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px 26px; gap: 16px;
}
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.sched-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.sched-controls .sched__date { margin-bottom: 0; }
.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; }
.flags { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.flag { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.flag input { width: 16px; height: 16px; }
.form--page .timeslots { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.form--page .slot { padding: 9px 4px; font-size: 14px; }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
.form--page .form__actions {
  position: sticky; bottom: 0; background: var(--surface);
  padding-top: 14px; margin: 6px -26px -24px; padding: 14px 26px 22px;
  border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}

/* ---- Панель фильтров ---- */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  margin-bottom: 16px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.filter { display: flex; flex-direction: column; gap: 4px; flex: 1 1 130px; }
.filter__label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.filter__reset { flex: 0 0 auto; height: 38px; align-self: flex-end; }

/* ---- Кликабельное имя клиента ---- */
.client-link { background: none; border: none; padding: 0; font: inherit;
  color: var(--primary); font-weight: 600; cursor: pointer; text-align: left; }
.client-link:hover { text-decoration: underline; }

/* ---- Карточка клиента ---- */
.client-summary { display: flex; flex-wrap: wrap; gap: 22px; padding: 4px 0 10px; }
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv__label { font-size: 12px; color: var(--text-muted); }
.kv__value { font-weight: 700; font-size: 17px; }
.client-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.status-chip { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.client-sub { font-size: 14px; margin: 10px 0 6px; color: var(--text-muted); }
.client-req-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.client-req { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); flex-wrap: wrap; }
.client-req--empty { justify-content: center; color: var(--text-muted); }
.client-req--open { cursor: pointer; transition: border-color .12s, background .12s; }
.client-req--open:hover { border-color: var(--primary); }
.client-req__id { font-weight: 700; font-variant-numeric: tabular-nums; }
.client-req__meta { flex: 1; font-size: 13px; color: var(--text-muted); min-width: 120px; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .app-header__inner, .container { padding-left: 14px; padding-right: 14px; }
  .field-row { flex-direction: column; }
  .field--narrow { max-width: none; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .user-item { flex-direction: column; align-items: stretch; }
  .filter { flex-basis: 100%; }
}

/* ==================== Многостраничный сайт: шапка и меню ==================== */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.site-header__inner { max-width: 1280px; margin: 0 auto; padding: 10px 22px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand__logo { font-size: 24px; }
.brand__title { font-weight: 700; font-size: 15px; white-space: nowrap; }
.site-nav { display: flex; align-items: center; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav-link { text-decoration: none; color: var(--text-muted); font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: 8px; background: none; border: none; cursor: pointer; font-family: inherit; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { color: var(--primary); background: var(--st-new-bg); }
.nav-drop { position: relative; }
.nav-drop__menu { position: absolute; top: 100%; left: 0; margin-top: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 170px; display: none; z-index: 40; overflow: hidden; }
.nav-drop.is-open .nav-drop__menu { display: block; animation: pop .15s ease both; }
.nav-drop__btn { display: inline-flex; align-items: center; }
.nav-drop__item { display: block; padding: 9px 14px; text-decoration: none; color: var(--text); font-size: 14px; }
.nav-drop__item:hover { background: var(--surface-2); }
.site-header__actions { display: flex; align-items: center; gap: 14px; }
.page { max-width: 1280px; margin: 0 auto; padding: 22px; }
.page__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page__title { margin: 0; font-size: 22px; }
.muted { color: var(--text-muted); }
@media (max-width: 820px) {
  .site-header__inner { flex-wrap: wrap; gap: 10px; }
  .brand__title { font-size: 14px; }
}

.report-controls { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.report-controls .filter { flex: 0 0 auto; }


/* ==================== Карточки формы заявки ==================== */
.form-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.form-topbar__left, .form-topbar__right { display: flex; align-items: center; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; }
.card--grow { display: flex; flex-direction: column; flex: 1; }
.card--grow .card__body { flex: 1; }
.field--grow { flex: 1; display: flex; flex-direction: column; }
.input--grow { flex: 1; min-height: 120px; resize: vertical; }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__head { padding: 12px 18px 4px; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; background: none; }
.card__icon { font-size: 16px; }
.card__body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.card__body .form--page { padding: 0; border: none; box-shadow: none; background: none; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } }

/* ==================== Календарь дат ==================== */
.datefield { cursor: pointer; }
.datefield::-webkit-calendar-picker-indicator { opacity: 0; display: none; }
.datepicker { z-index: 100; width: 284px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 12px; user-select: none; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-title { font-weight: 700; font-size: 15px; }
.dp-nav { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 18px; line-height: 1; }
.dp-nav:hover { background: var(--surface-2); border-color: var(--primary); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd { margin-bottom: 4px; }
.dp-wdc { text-align: center; font-size: 12px; color: var(--text-muted); padding: 4px 0; }
.dp-day { border: none; background: none; color: var(--text); border-radius: 8px; padding: 8px 0; cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums; }
.dp-day:hover:not(.dp-empty) { background: var(--surface-2); }
.dp-day.is-weekend { color: var(--danger); }
.dp-day.is-today { outline: 1px solid var(--primary); outline-offset: -1px; }
.dp-day.is-selected { background: var(--primary); color: #fff; font-weight: 700; }
.dp-empty { visibility: hidden; cursor: default; }
.dp-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.dp-link { background: none; border: none; color: var(--primary); cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 6px; }
.dp-link:hover { text-decoration: underline; }

/* ==================== Флаги-переключатели ==================== */
.flags-bar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; }
.pill { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; user-select: none; transition: all .15s ease; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill__dot { display: none; }
.pill:hover { border-color: var(--primary); transform: translateY(-1px); }
.pill:has(input:checked) { background: var(--st-new-bg); border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.pill:has(input:disabled) { opacity: .55; cursor: not-allowed; }

/* ==================== Блок времени ==================== */
.timeinfo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.timeinfo__box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.timeinfo__box--accent { background: linear-gradient(135deg, rgba(37,99,235,.12), rgba(37,99,235,.02)); border-color: var(--primary); }
.timeinfo__label { font-size: 12px; color: var(--text-muted); }
.timeinfo__val { font-size: 26px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.timeinfo__sub { font-size: 12px; color: var(--text-muted); min-height: 14px; }
.timedrop { position: relative; }
.timedrop__btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit; cursor: pointer; transition: border-color .15s; }
.timedrop__btn:hover:not(:disabled) { border-color: var(--primary); }
.timedrop__btn:disabled { opacity: .6; cursor: not-allowed; }
.timedrop__caret { color: var(--text-muted); transition: transform .18s; }
.timedrop.is-open .timedrop__caret { transform: rotate(180deg); }
.timedrop__menu {
  position: absolute; z-index: 200; top: calc(100% + 6px); right: 0;
  width: min(340px, 86vw);
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 8px; animation: pop .16s ease;
}
.timedrop__menu[hidden] { display: none; }
.timedrop--up .timedrop__menu { top: auto; bottom: calc(100% + 6px); }
.timedrop__item {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 2px; border: 1px solid transparent; background: var(--surface-2);
  color: var(--text); border-radius: 8px; cursor: pointer; font-variant-numeric: tabular-nums;
  transition: border-color .1s, background .1s, transform .04s;
}
.timedrop__item:hover { border-color: var(--primary); transform: translateY(-1px); }
.timedrop__item.is-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.timedrop__t { font-size: 13px; font-weight: 600; }
.timedrop__c { font-size: 10px; line-height: 1; min-height: 10px; color: var(--text-muted); }
.timedrop__item.is-busy { background: var(--st-prog-bg); }
.timedrop__item.is-busy .timedrop__t, .timedrop__item.is-busy .timedrop__c { color: var(--st-prog-fg); }
.timedrop__item.is-full { background: var(--st-cancel-bg); }
.timedrop__item.is-full .timedrop__t, .timedrop__item.is-full .timedrop__c { color: var(--st-cancel-fg); }
.timedrop__item.is-active .timedrop__t, .timedrop__item.is-active .timedrop__c { color: #fff; }

/* ==================== Анимации ==================== */
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes inUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.anim-pop { animation: pop .16s ease; }
.anim-in { animation: inUp .34s cubic-bezier(.22,.61,.36,1) both; animation-delay: var(--d, 0s); }
.datepicker { animation: pop .16s ease; }
.btn { transition: background .14s, border-color .14s, transform .05s, box-shadow .14s; }
.btn:hover { transform: translateY(-1px); }
.stat { transition: border-color .14s, transform .12s, box-shadow .14s; }
.input, .status-select { transition: border-color .14s, box-shadow .14s; }
.table tbody tr { transition: background .12s; }
.modal__dialog { animation: pop .18s ease; }
.toast { transition: opacity .2s, transform .2s; }
@media (prefers-reduced-motion: reduce) {
  .anim-in, .anim-pop, .datepicker, .timedrop__menu, .modal__dialog, .nav-drop__menu, .user-menu { animation: none !important; }
  .btn:hover, .stat:hover, .pill:hover { transform: none !important; }
}

.city-item__meta { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.city-add { flex-wrap: wrap; }
.city-new { margin-bottom: 16px; }


/* ==================== Иконки (SVG) ==================== */
.ic { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.ic svg { width: 1em; height: 1em; display: block; }
.card__icon { font-size: 18px; color: var(--primary); }
.brand__logo { font-size: 22px; color: var(--primary); }
.login__logo { font-size: 46px; color: var(--primary); display: flex; justify-content: center; margin-bottom: 6px; }
.pill .ic, .btn--icon .ic { font-size: 15px; }
.cell-clip .ic { font-size: 14px; vertical-align: -2px; }

/* ==================== Автозаполнение / кнопки полей ==================== */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 40px var(--surface) inset;
  box-shadow: 0 0 0 40px var(--surface) inset;
  caret-color: var(--text);
  transition: background-color 100000s ease-in-out 0s;
}
.att-input { font-size: 13px; color: var(--text-muted); }
.att-input::file-selector-button {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; margin-right: 10px; transition: background .12s, border-color .12s;
}
.att-input::file-selector-button:hover { background: var(--surface-2); border-color: var(--primary); }
input[type=number] { appearance: textfield; -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ==================== Мобильная адаптация ==================== */
html { -webkit-text-size-adjust: 100%; }

/* Планшеты и крупные телефоны */
@media (max-width: 768px) {
  .page { padding: 16px 14px; }
  .site-header__inner { flex-wrap: wrap; row-gap: 8px; padding: 9px 14px; gap: 10px; }
  /* Навигация переносится на отдельную строку под брендом и действиями */
  .site-nav { order: 3; flex-basis: 100%; gap: 4px; }
  .site-header__actions { margin-left: auto; gap: 10px; }
  .user-chip__role { display: none; }            /* компактный профиль */
  .user-chip__name { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Крупнее шрифт полей — iOS не зумит при фокусе (нужно >=16px) */
  .input, .status-select, .timedrop__btn, .att-input { font-size: 16px; }

  .form-topbar { flex-wrap: wrap; }
  .form-topbar__left, .form-topbar__right { flex-wrap: wrap; }
  .form-topbar__right { width: 100%; }
  .form-topbar__right .btn { flex: 1; justify-content: center; }
  .form-author { flex-basis: 100%; align-self: flex-start; }

  /* Фильтры списка — по два в ряд, кнопка сброса на всю ширину */
  .filter { flex: 1 1 calc(50% - 6px); }
  .filter__reset { flex-basis: 100%; align-self: stretch; }

  /* Крупнее зоны нажатия у мелких кнопок */
  .btn--sm { padding: 8px 13px; }
  .btn--icon { padding: 8px 11px; }

  .page__title { font-size: 20px; }
  .stat__value { font-size: 22px; }
  .table th, .table td { padding: 10px 11px; }
  .report-controls .filter { flex: 1 1 calc(50% - 6px); }
}

/* Телефоны */
@media (max-width: 560px) {
  .filter { flex-basis: 100%; }
  .report-controls .filter { flex-basis: 100%; }
  /* Элемент города/источника: имя на своей строке, метки и кнопки — ниже */
  .city-item { flex-wrap: wrap; }
  .city-item__name { flex-basis: 100%; }
  .client-summary { gap: 14px; }
  .modal { padding: 10px; }
  .modal__dialog--sm { max-width: 100%; }
  .form { padding: 16px; }
}

/* Узкие телефоны */
@media (max-width: 430px) {
  .brand__title { display: none; }               /* остаётся логотип */
  .timedrop__menu { grid-template-columns: repeat(4, 1fr); width: min(320px, 92vw); }
  .quick-dates .btn { flex: 1; }
}

/* ==================== История изменений заявки ==================== */
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }
.hist-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 11px; border-left: 2px solid var(--primary); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.hist-when { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.hist-text { font-size: 13px; line-height: 1.4; word-break: break-word; }
.hist-old { color: var(--text-muted); text-decoration: line-through; }
.hist-new { color: var(--text); font-weight: 600; }
.hist-empty { color: var(--text-muted); text-align: center; border-left-color: transparent; }

/* ==================== Пометки-флаги в списке заявок ==================== */
.flag-badges { display: inline-flex; gap: 4px; margin-left: 8px; vertical-align: middle; }
.flag-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 7px; border-radius: 999px; white-space: nowrap;
}
.flag-badge .ic { font-size: 12px; }
.flag-badge--urgent { background: var(--st-cancel-bg); color: var(--st-cancel-fg); }
.flag-badge--callback { background: var(--st-prog-bg); color: var(--st-prog-fg); }
.flag-badge--review { background: var(--st-clar-bg); color: var(--st-clar-fg); }
.flag-badge--claim { background: var(--st-cancel-bg); color: var(--st-cancel-fg); }
/* Срочные строки — заметный левый акцент поверх статусной подсветки */
tr.is-urgent td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
tr.is-urgent .cell-id::after { content: "!"; color: var(--danger); font-weight: 800; margin-left: 3px; }

/* ==================== Кастомная прокрутка (под стиль сайта) ==================== */
.table-wrap, .stats { scrollbar-width: thin; scrollbar-color: var(--border) var(--surface-2); }
.table-wrap::-webkit-scrollbar, .stats::-webkit-scrollbar { height: 10px; }
.table-wrap::-webkit-scrollbar-track, .stats::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 999px; }
.table-wrap::-webkit-scrollbar-thumb, .stats::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 999px; border: 2px solid var(--surface-2);
}
.table-wrap:hover::-webkit-scrollbar-thumb, .stats:hover::-webkit-scrollbar-thumb { background: var(--text-muted); }
.table-wrap::-webkit-scrollbar-thumb:hover, .stats::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ==================== Кастомные чекбоксы (выбор городов и т.п.) ==================== */
.check { gap: 8px; padding: 3px 2px; }
.check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 18px; height: 18px; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); cursor: pointer;
  display: inline-grid; place-content: center;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.check input[type="checkbox"]::before {
  content: ""; width: 11px; height: 11px; transform: scale(0);
  transition: transform .12s ease; background: #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.check input[type="checkbox"]:hover { border-color: var(--primary); }
.check input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--st-new-bg); }
.check input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
.check input[type="checkbox"]:checked::before { transform: scale(1); }

/* ==================== Претензии ==================== */
.claim-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.claim-item {
  display: flex; flex-direction: column; gap: 5px; padding: 10px 12px;
  border: 1px solid var(--border); border-left: 3px solid var(--danger);
  border-radius: 8px; background: var(--surface-2);
}
.claim-item.is-resolved { border-left-color: var(--st-done-fg); opacity: .85; }
.claim-item__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.claim-item__meta { font-size: 12px; color: var(--text-muted); }
.claim-item__text { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.claim-item__resolved { font-size: 12px; color: var(--text-muted); }
.claim-status { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.claim-status--open { background: var(--st-cancel-bg); color: var(--st-cancel-fg); }
.claim-status--resolved { background: var(--st-done-bg); color: var(--st-done-fg); }
.claim-item .btn--sm { align-self: flex-start; margin-top: 2px; }
.claim-empty { border: none; background: none; padding: 8px; color: var(--text-muted); text-align: center; }
.claim-add { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.claim-add .form__actions { margin: 0; }

.user-item__role.role-okk { background: var(--st-clar-bg); color: var(--st-clar-fg); }
.user-item__role.role-city_admin { background: var(--st-prog-bg); color: var(--st-prog-fg); }
