/* Шрифты: Prata (элегантный засечковый) для заголовков, системные — для текста.
   Palитра смягчена: меньше неонового контраста, тёплый тёмный фон вместо чистого чёрного. */
:root {
  --bg: #17181c;
  --bg-alt: #1d1f24;
  --card: #212328;
  --card-border: #2f323a;
  --card-2: #292c33;
  --text: #ece9e3;
  --text-muted: #9a978f;
  --lime: #cda86a;
  --lime-dim: #b3903f;
  --orange: #e2733a;
  --danger: #e05a5a;
  --radius: 14px;
  --font-display: 'Prata', Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

button, input, select, textarea { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}

/* ---------- Сигнатурный элемент: разделитель в стиле насечек штанги ---------- */
.plate-divider {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
  margin: 0 0 28px 0;
  overflow: hidden;
}
.plate-divider span {
  display: block;
  width: 4px;
  background: var(--card-border);
  border-radius: 2px;
}
.plate-divider span:nth-child(4n) { background: var(--lime); height: 18px; }
.plate-divider span:not(:nth-child(4n)) { height: 10px; }

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

/* ---------- Верхняя панель ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(18, 19, 23, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--card-border);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-family: var(--font-display);
  font-size: 25px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand small {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.brand .x { color: var(--lime); }

.nav-actions { display: flex; gap: 10px; align-items: center; }

.badge-admin {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #0d0e10;
  background: var(--lime);
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ---------- Кнопки ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--lime); color: #0d0e10; }
.btn-primary:hover { background: var(--lime-dim); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--card-border); }
.btn-ghost:hover { border-color: var(--lime); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(255,77,77,0.4); }
.btn-small { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Герой ---------- */
.hero {
  padding: 72px 0 40px;
}
.hero-eyebrow {
  font-family: var(--font-mono);
  color: var(--lime);
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1.08;
  margin: 0 0 18px;
  letter-spacing: 0.2px;
}
.hero h1 .accent { color: var(--lime); }
.hero p.lead {
  color: var(--text-muted);
  font-size: 17px;
  max-width: 560px;
  line-height: 1.55;
  margin: 0 0 32px;
}

/* ---------- Карточки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Вкладки авторизации ---------- */
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-alt);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
}
.auth-tab.active { background: var(--card); color: var(--text); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: 9px;
  font-size: 14px;
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--lime);
}

.form-error {
  background: rgba(255, 77, 77, 0.08);
  border: 1px solid rgba(255, 77, 77, 0.35);
  color: #ff9b9b;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.form-error.show { display: block; }

/* ---------- Список фич на лендинге ---------- */
.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-muted);
  font-size: 14px;
}
.feature-list li:last-child { border-bottom: none; }
.feature-list .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--lime);
  margin-top: 7px;
  flex-shrink: 0;
}

footer {
  padding: 40px 0 60px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- Дашборд ---------- */
.dash-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding: 28px 0 60px;
}
@media (max-width: 860px) {
  .dash-layout { grid-template-columns: 1fr; }
}
.profile-card .name { font-family: var(--font-display); font-size: 23px; letter-spacing: 0.2px; }
.profile-card .phone { font-family: var(--font-mono); color: var(--text-muted); font-size: 13px; }

.section-title {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.2px;
  margin: 0 0 16px;
}

.ticket-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.ticket-item:hover { border-color: var(--lime); }
.ticket-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ticket-topic { font-weight: 600; }
.ticket-meta { color: var(--text-muted); font-size: 12px; font-family: var(--font-mono); margin-top: 4px; }
.ticket-preview { color: var(--text-muted); font-size: 13px; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.status-open { background: rgba(205,168,106,0.14); color: var(--lime); }
.status-in_progress { background: rgba(255,90,31,0.16); color: var(--orange); }
.status-closed { background: rgba(139,143,154,0.15); color: var(--text-muted); }

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  padding: 32px 0;
  text-align: center;
  border: 1px dashed var(--card-border);
  border-radius: 12px;
}

/* ---------- Диалог тикета ---------- */
.message-bubble {
  max-width: 80%;
  padding: 12px 15px;
  border-radius: 12px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.5;
}
.message-client { background: var(--bg-alt); border: 1px solid var(--card-border); margin-right: auto; }
.message-admin { background: rgba(205,168,106,0.1); border: 1px solid rgba(205,168,106,0.3); margin-left: auto; }
.message-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-bottom: 5px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }

/* ---------- Таблица пользователей (админ) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--card-border); }
.table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
@media (max-width: 700px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 18px; }
.stat-num { font-family: var(--font-display); font-size: 30px; color: var(--lime); }
.stat-label { color: var(--text-muted); font-size: 12px; }

.tabs-row { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-chip {
  padding: 8px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--card-border); color: var(--text-muted);
}
.tab-chip.active { border-color: var(--lime); color: var(--lime); }

.hidden { display: none !important; }

/* ---------- Админ-панель: инбокс с диалогами ---------- */
.admin-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
}

.search-box {
  position: relative;
  margin-bottom: 14px;
}
.search-box input {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 11px 13px 11px 38px;
  border-radius: 9px;
  font-size: 14px;
}
.search-box input:focus { border-color: var(--lime); }
.search-box::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  box-shadow: 5px 5px 0 -3px var(--text-muted);
}

.thread-list {
  max-height: 640px;
  overflow-y: auto;
  padding-right: 4px;
}
.thread-item {
  display: flex;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 6px;
}
.thread-item:hover { background: var(--card); }
.thread-item.active { background: var(--card); border-color: var(--lime); }
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--card-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--lime);
  flex-shrink: 0;
}
.thread-item-body { min-width: 0; flex: 1; }
.thread-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.thread-item-name { font-weight: 600; font-size: 14px; }
.thread-item-topic { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.thread-item-preview {
  color: var(--text-muted); font-size: 12px; margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-item-time { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); white-space: nowrap; }

.thread-panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 560px;
  max-height: 720px;
}
.thread-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.thread-header-info { display: flex; gap: 12px; align-items: center; }
.thread-header-name { font-weight: 700; font-size: 16px; }
.thread-header-meta { color: var(--text-muted); font-size: 12px; font-family: var(--font-mono); margin-top: 2px; }
.thread-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.manager-select {
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.thread-messages { flex: 1; overflow-y: auto; padding: 22px; }
.thread-reply { padding: 16px 22px; border-top: 1px solid var(--card-border); display: flex; gap: 10px; align-items: flex-end; }
.thread-reply textarea {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: 9px;
  font-size: 14px;
  resize: none;
  min-height: 46px;
  max-height: 140px;
}
.thread-reply textarea:focus { border-color: var(--lime); }

.thread-empty {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px; text-align: center; padding: 40px;
}

/* ---------- Форма добавления менеджера ---------- */
.inline-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 22px;
}
@media (max-width: 900px) { .inline-form { grid-template-columns: 1fr 1fr; } }
.inline-form .field { margin-bottom: 0; }

.role-pill { font-family: var(--font-mono); font-size: 11px; padding: 4px 10px; border-radius: 999px; font-weight: 700; }
.role-admin { background: rgba(255,90,31,0.16); color: var(--orange); }
.role-manager { background: rgba(205,168,106,0.14); color: var(--lime); }
