/* Панель РЕМОТОР — dashboard, built from scratch (not Django admin).
   Same design tokens as the main site (site/static/core/css/style.css):
   near-black + warm off-white, one copper accent, Inter/JetBrains Mono. */

:root {
  --ink: #131210;
  --ink-soft: #201e1a;
  --paper: #faf9f5;
  --paper-dim: #f0eee6;
  --paper-line: rgba(19, 18, 16, 0.1);
  --accent: #d9662b;
  --accent-dark: #b7501e;
  --accent-tint: #f3ded1;
  --muted: #6b675f;
  --muted-on-dark: #b7b2a6;
  --radius: 14px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow-sm: 0 1px 2px rgba(19, 18, 16, 0.05);
  --shadow-md: 0 8px 24px rgba(19, 18, 16, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- Shell layout ---------- */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  flex: 0 0 232px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  text-decoration: none;
  border-bottom: 1px solid rgba(250, 249, 245, 0.08);
}
.sidebar__mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  flex: none;
}
.sidebar__brand-text {
  color: var(--paper);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.sidebar__nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 9px;
  color: var(--muted-on-dark);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.sidebar__link:hover { background: rgba(250, 249, 245, 0.06); color: var(--paper); }
.sidebar__link--active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar__icon { width: 17px; height: 17px; flex: none; }
.sidebar__external { margin-left: auto; opacity: 0.55; font-size: 0.8rem; }
.sidebar__badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
}
.sidebar__link--active .sidebar__badge { background: #fff; color: var(--accent); }

.sidebar__footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(250, 249, 245, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sidebar__user {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--paper);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__logout {
  background: none;
  border: none;
  color: var(--muted-on-dark);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.sidebar__logout:hover { color: var(--accent-tint); }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  border-bottom: 1px solid var(--paper-line);
}
.topbar__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.content { padding: 24px 32px 48px; }

.messages { margin-bottom: 16px; }
.messages__item {
  background: var(--accent-tint);
  border: 1px solid var(--accent);
  color: var(--accent-dark);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn--sm { padding: 7px 14px; font-size: 0.83rem; }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-dark); }
.btn--ghost { background: #fff; color: var(--ink); border-color: var(--paper-line); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-dark); }

/* ---------- Toolbar (list page) ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.toolbar__search {
  display: flex;
  gap: 8px;
}
.toolbar__search input {
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.88rem;
  width: 280px;
  background: #fff;
}
.toolbar__search input:focus { outline: none; border-color: var(--accent); }
.toolbar__filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--paper-line);
  background: #fff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.filter-chip--active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Card / table ---------- */
.card {
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card--form { padding: 24px 28px; max-width: 560px; }

.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--paper-line);
}
.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--paper-line);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--paper-dim); }
.table__link { color: var(--ink); font-weight: 600; text-decoration: none; }
.table__link:hover { color: var(--accent-dark); }

.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state p { margin: 0 0 16px; }

/* ---------- Status badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}
.badge--new { background: var(--paper-dim); color: var(--muted); }
.badge--diagnosing { background: var(--accent-tint); color: var(--accent-dark); }
.badge--in-repair { background: var(--accent); color: #fff; }
.badge--ready { background: var(--ink); color: var(--paper); }
.badge--delivered { background: #e3f3ea; color: #1f7a4d; }
.badge--cancelled { background: #fbeceb; color: #b3261e; }

/* ---------- Forms ---------- */
.form-field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.form-field input,
.form-field select,
.form-field textarea {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 10px 13px;
  border: 1px solid var(--paper-line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-field textarea { resize: vertical; }
.form-field__error { color: #b3261e; font-size: 0.8rem; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* ---------- Login page ---------- */
.login-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(217, 102, 43, 0.18), transparent 45%),
    var(--ink);
  font-family: var(--font-sans);
}
.login-card {
  width: 100%;
  max-width: 360px;
  margin: 20px;
  background: var(--paper);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  padding: 40px 36px;
}
.login-card__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-card__mark {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--ink); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem;
}
.login-card__brand-text { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.login-card__subtitle { color: var(--muted); font-size: 0.85rem; margin: 0 0 28px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.login-field input {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--paper-line); background: #fff;
  font-family: inherit; font-size: 0.95rem; color: var(--ink);
}
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-submit {
  width: 100%; margin-top: 8px; padding: 12px; border: none;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-weight: 600; font-size: 0.95rem; cursor: pointer;
  transition: background 0.15s ease;
}
.login-submit:hover { background: var(--accent-dark); }
.login-error {
  background: #fdecea; border: 1px solid #f3c6c1; color: #b3261e;
  border-radius: 10px; padding: 10px 14px; font-size: 0.85rem; margin-bottom: 16px;
}

/* ---------- Chat (read-only, sourced from bot/) ---------- */
.chat-list { display: flex; flex-direction: column; gap: 10px; }
.chat-list__item {
  display: block;
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.chat-list__item:hover { border-color: var(--accent); }
.chat-list__who { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.chat-list__meta { display: flex; align-items: center; gap: 8px; }
.chat-list__name { font-weight: 600; font-size: 0.95rem; }
.chat-list__id { font-size: 0.75rem; color: var(--muted); }
.chat-list__preview { margin: 0 0 6px; color: var(--muted); font-size: 0.88rem; }
.chat-list__time { font-size: 0.75rem; }

.chat-thread-card { padding: 20px; display: flex; flex-direction: column; }
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  max-height: 60vh;
  overflow-y: auto;
  padding-bottom: 4px;
}
.chat-bubble-row { display: flex; }
.chat-bubble-row--owner { justify-content: flex-end; }
.chat-bubble-row--visitor { justify-content: flex-start; }
.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
}
.chat-bubble p { margin: 0 0 4px; white-space: pre-wrap; word-break: break-word; }
.chat-bubble__time { font-size: 0.7rem; opacity: 0.7; }
.chat-bubble--visitor { background: var(--paper-dim); color: var(--ink); border-bottom-left-radius: 4px; }
.chat-bubble--owner { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-thread-note { text-align: center; font-size: 0.82rem; margin-top: 14px; }

.chat-reply-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 640px;
  width: 100%;
  margin: 16px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--paper-line);
}
.chat-reply-form textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 14px;
  border: 1px solid var(--paper-line);
  border-radius: 14px;
  background: var(--paper-dim);
  color: var(--ink);
}
.chat-reply-form textarea:focus { outline: none; border-color: var(--accent); background: #fff; }

.chat-list__item--unread { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.chat-list__name--unread { font-weight: 700; }
.chat-list__unread-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .sidebar__brand { border-bottom: none; padding: 14px 16px; }
  .sidebar__nav { flex-direction: row; padding: 0 12px 14px; }
  .sidebar__footer { margin-left: auto; border-top: none; padding: 14px 16px; }
  .toolbar__search input { width: 100%; }
}
