:root {
  --accent: #2b57ff;
  --ink: #1a1a2e;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f8fc;
}

* { box-sizing: border-box; }

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

.top {
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.who-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}
.who-bar a { color: var(--accent); }
.who-bar form { display: inline; }

.linkish {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.brand {
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  font-size: 18px;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

h1 { font-size: 24px; margin: 8px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 10px; }
p { margin: 0 0 14px; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  display: inline-block;
  text-align: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}

.btn-light {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label { font-weight: 600; }

.choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 400;
}

input[type="text"],
select,
textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
}

.track {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: center;
  background: #fff;
  border: 1px dashed var(--accent);
  border-radius: 12px;
  padding: 18px;
  margin: 16px 0;
}

.note { color: var(--muted); font-size: 14px; }
.error { color: #b45309; font-size: 14px; }

.status-line { font-size: 16px; }
.body { white-space: pre-wrap; }

.msg {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
}
.who { color: var(--accent); font-weight: 600; }

/* Кнопка «Открыть обращение» — внутри формы, чтобы номер уходил телом POST.
   display:contents убирает форму из потока, кнопка остаётся элементом flex. */
.actions form { display: contents; }

.card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 520px) {
  .actions { flex-direction: row; }
  .choices { flex-direction: row; gap: 18px; }
}


/* --- Рабочее место сотрудника --- */

.queue {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.qrow {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}
.qrow:hover { border-color: var(--accent); }
.qrow-urgent { border-left-color: #dc2626; }

.qhead {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.qid { font-weight: 700; }

.qmeta { color: var(--muted); font-size: 14px; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge-Новое { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.badge-В-работе { background: #fef9c3; border-color: #fde68a; color: #92400e; }
.badge-Решено { background: #dcfce7; border-color: #bbf7d0; color: #15803d; }
.badge-urgent { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }

.logline {
  font-size: 14px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.logline:last-child { border-bottom: none; }

select { background: #fff; }

.bottom {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px 40px;
  font-size: 14px;
}
.bottom a { color: var(--muted); }
.bottom a:hover { color: var(--accent); }


/* --- Очередь: фильтры-счётчики --- */

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  text-decoration: none;
  color: var(--ink);
}
.chip:hover { border-color: var(--accent); }
.chip-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.chip-n {
  font-weight: 700;
  font-size: 13px;
  opacity: .75;
}
.chip-alert:not(.chip-on) { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }

.sortbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  margin-bottom: 4px;
}
.sortlink { color: var(--muted); text-decoration: none; border-bottom: 1px dashed var(--line); }
.sortlink:hover { color: var(--accent); }
.sortlink-on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

/* --- Очередь: карточка обращения --- */

.qcard {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.qcard-urgent { border-left-color: #dc2626; }

.qtop {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.qid {
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.qid:hover { color: var(--accent); }

.qage { margin-left: auto; white-space: nowrap; }

.qsnippet {
  margin: 8px 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.qmeta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 14px;
}
.warnish { color: #b45309; }

.qactions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.qactions form { display: flex; gap: 8px; align-items: center; margin: 0; }
.assign-form select {
  width: auto;
  min-width: 150px;
  padding: 7px 10px;
  font-size: 14px;
}

.btn-small {
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 8px;
}

/* --- Вход --- */

.login-wrap { max-width: 420px; margin: 0 auto; }
.login-sub { margin-bottom: 4px; }

.alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  margin-top: 14px;
}

.demo {
  margin-top: 20px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
}
.demo-head { font-weight: 600; margin-bottom: 4px; }

.demo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.demo-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
}
.demo-btn:hover { border-color: var(--accent); color: var(--accent); }
.demo-btn span { font-weight: 400; font-size: 12px; color: var(--muted); }

.demo-warn { margin-bottom: 0; color: #b45309; }

@media (min-width: 640px) {
  .qactions { flex-wrap: nowrap; }
}


/* --- Рабочее место эксперта --- */

.card-internal {
  background: #fffdf5;
  border-color: #fde68a;
}

.note-item {
  border-left: 3px solid #fde68a;
  padding: 6px 0 6px 12px;
  font-size: 15px;
}
.note-item > div { margin-top: 2px; overflow-wrap: anywhere; }

.card-transfer { border-color: #fecaca; }

.msg-them {
  background: #eff6ff;
  border-left: 3px solid var(--accent);
}

.page-head .badge { align-self: center; }


/* --- Кризисный сценарий --- */

.crisis-banner {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-left: 4px solid #ea580c;
  border-radius: 12px;
  padding: 18px 20px;
  margin: 16px 0;
}
.crisis-banner h1 { margin-top: 0; }
.crisis-compact { padding: 14px 16px; }
.crisis-head { font-weight: 700; margin-bottom: 6px; }

.help-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 14px 0;
}

.help-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.help-name { font-weight: 600; font-size: 14px; }

.help-value {
  display: inline-block;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  margin: 2px 0;
}
.help-value:hover { text-decoration: underline; }

.card-contact { border-color: #fdba74; }
.card-contact h2 { margin-top: 0; }

.ok-banner {
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: #15803d;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  margin: 14px 0;
}

.contact-box {
  background: #fff;
  border: 1px solid #fdba74;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
}
.contact-value {
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* Кризисная очередь оператора */

.crisis-queue {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0 20px;
}
.crisis-queue-head {
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c2410c;
}
.crisis-queue .qcard { margin-top: 10px; }

.qcard-crisis { border-left-color: #ea580c; }

.badge-crisis {
  background: #ffedd5;
  border-color: #fdba74;
  color: #c2410c;
}
.badge-contact {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

@media (min-width: 560px) {
  .help-block { flex-direction: row; flex-wrap: wrap; }
  .help-item { flex: 1 1 200px; }
}


/* --- Развилка «помогло / не помогло» --- */

.verdict {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 18px 20px;
  margin: 16px 0;
}
.verdict h2 { margin-top: 0; }
.verdict-actions { margin: 12px 0; }
.verdict-actions .btn { width: 100%; }

.verdict-no summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  padding: 6px 0;
}
.verdict-no summary:hover { color: var(--accent); }
.verdict-no form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.card-rating { border-color: #bfdbfe; }
.card-rating h2 { margin-top: 0; }

.rating-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.rating-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}
.rating-opt:hover { border-color: var(--accent); }

.badge-Возвращено { background: #fef9c3; border-color: #fde68a; color: #92400e; }
.badge-Ответ-готов { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.badge-Завершено { background: #dcfce7; border-color: #bbf7d0; color: #15803d; }


/* --- Линейка этапов для заявителя --- */

.timeline-card { padding-bottom: 8px; }

.status-hint {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 16px;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}
.timeline li {
  flex: 1;
  position: relative;
  text-align: center;
  padding-top: 22px;
  font-size: 13px;
  color: var(--muted);
}
/* соединительная линия между этапами */
.timeline li::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--line);
}
.timeline li:first-child::before { display: none; }

.timeline .dot {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--line);
}

.timeline li.done { color: var(--ink); }
.timeline li.done::before { background: var(--accent); }
.timeline li.done .dot { background: var(--accent); border-color: var(--accent); }

.timeline li.current { color: var(--accent); font-weight: 600; }
.timeline li.current::before { background: var(--accent); }
.timeline li.current .dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(43, 87, 255, 0.15);
}


/* --- Администрирование --- */

.admin-tiles {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 16px;
}
.admin-tile {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: var(--ink);
}
.admin-tile:hover { border-color: var(--accent); }
.admin-tile-title {
  display: block;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.staff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.staff-table th,
.staff-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.staff-table th {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.staff-table tr:last-child td { border-bottom: none; }

.rule-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
}


/* --- Подсказка маршрутизации --- */

.suggestion {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin: 6px 0 4px;
}


/* --- Аналитика --- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}

.analytics-cols {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  font-size: 14px;
}
.bar-label { flex: 0 0 40%; overflow-wrap: anywhere; }
.bar {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}
.bar-num { flex: 0 0 auto; color: var(--muted); min-width: 24px; text-align: right; }
