/* ============================================================
   Bot-Mob-Trade — слой админки поверх токенов Classical.
   Подключать ПОСЛЕ classical.css. Все значения берутся из
   переменных дизайн-системы (var(--color-*), var(--space-*)…).
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--color-bg); color: var(--color-text); font-family: var(--font-body); }
a { color: var(--color-accent-700); }
a:hover { color: var(--color-accent-800); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--color-neutral-300); border-radius: 6px; border: 3px solid var(--color-bg); }

/* ---------- каркас ---------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 256px; flex: none; height: 100%; display: flex; flex-direction: column;
  background: var(--color-neutral-100); border-right: 1px solid var(--color-divider);
}
.sidebar__head { padding: 22px 22px 16px; border-bottom: 1px solid var(--color-divider); display: flex; align-items: center; gap: 11px; }
.sidebar__logo {
  width: 34px; height: 34px; flex: none; border: 1px solid var(--color-accent);
  border-radius: var(--radius-md); display: grid; place-items: center; color: var(--color-accent);
  font-family: var(--font-heading); font-weight: 600; font-size: 19px;
}
.sidebar__brand { font-family: var(--font-heading); font-weight: 600; font-size: 18px; line-height: 1.15; }
.sidebar__brand small { display: block; font-family: var(--font-body); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--color-neutral-600); }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px 24px; }
.nav-group { margin-bottom: 16px; }
.nav-group__label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--color-neutral-600); padding: 0 12px; margin-bottom: 6px; }

.navlink {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px; margin-bottom: 2px;
  border-radius: var(--radius-md); text-decoration: none; color: var(--color-neutral-800);
  font-family: var(--font-heading); font-size: 14px;
}
.navlink:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); color: var(--color-accent-800); }
.navlink.is-active { background: var(--color-accent-100); color: var(--color-accent-800); box-shadow: inset 2px 0 0 var(--color-accent); }
.navlink svg { width: 17px; height: 17px; stroke-width: 1.75; }
.navlink__label { flex: 1; }
.navlink__badge { font-size: 11px; background: var(--color-accent-200); color: var(--color-accent-800); border-radius: 20px; padding: 1px 8px; min-width: 20px; text-align: center; }

.sidebar__foot { padding: 14px 16px; border-top: 1px solid var(--color-divider); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--color-accent-200); color: var(--color-accent-800); display: grid; place-items: center; font-family: var(--font-heading); font-weight: 600; font-size: 14px; }
.sidebar__me { flex: 1; min-width: 0; line-height: 1.2; }
.sidebar__me b { font-family: var(--font-body); font-weight: 400; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__me small { font-size: 11px; color: var(--color-neutral-600); }

.main { flex: 1; height: 100%; display: flex; flex-direction: column; min-width: 0; }
.topbar { flex: none; min-height: 66px; display: flex; align-items: center; gap: 18px; padding: 0 32px; border-bottom: 1px solid var(--color-divider); background: var(--color-bg); }
.topbar__crumb { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--color-neutral-600); }
.topbar__title { font-family: var(--font-heading); font-weight: 600; font-size: 23px; line-height: 1.1; }
.topbar__search { display: flex; align-items: center; gap: 8px; width: 280px; height: 38px; padding: 0 12px; border: 1px solid var(--color-divider); border-radius: var(--radius-md); background: var(--color-neutral-100); }
.topbar__search input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 13px; color: var(--color-text); outline: none; }
.content { flex: 1; overflow-y: auto; padding: 32px; }
.wrap { max-width: 1200px; }

/* ---------- сетки страниц ---------- */
.grid { display: grid; gap: 16px; }
.grid--kpi { grid-template-columns: repeat(4, 1fr); }
.grid--halves { grid-template-columns: 1fr 1fr; }
.grid--thirds { grid-template-columns: repeat(3, 1fr); }
.grid--detail { grid-template-columns: 400px 1fr; align-items: start; }
.grid--aside-l { grid-template-columns: 340px 1fr; align-items: start; }
.grid--aside-r { grid-template-columns: 1fr 360px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- KPI ---------- */
.kpi-num { font-family: var(--font-heading); font-feature-settings: "tnum"; letter-spacing: -.02em; }

/* ---------- статус-бейджи ---------- */
.badge { display: inline-flex; align-items: center; font-size: 11px; letter-spacing: .02em; padding: 3px 10px; border-radius: 3px; border: 1px solid transparent; white-space: nowrap; }
.badge--new    { background: var(--color-accent-100); color: var(--color-accent-800); }
.badge--work   { background: transparent; color: var(--color-accent-700); border-color: var(--color-accent); }
.badge--warn   { background: #f3ecdb; color: #7a5a1f; }
.badge--ok     { background: #e5ede2; color: #3c5a34; }
.badge--bad    { background: #efe0dc; color: #7a3b30; }
.badge--muted  { background: var(--color-neutral-200); color: var(--color-neutral-800); }

/* ---------- вкладки ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-divider); margin-bottom: 18px; }
.tab { padding: 9px 16px; cursor: pointer; font-family: var(--font-heading); font-size: 14px; border: 0; background: transparent; border-bottom: 2px solid transparent; color: var(--color-neutral-600); text-decoration: none; }
.tab.is-active { border-bottom-color: var(--color-accent); color: var(--color-accent-800); }
.tab .count { font-family: var(--font-body); font-size: 12px; color: var(--color-neutral-500); }

/* таблица занимает всю ширину карточки без внутренних отступов карточки */
.card--table { padding: 0; gap: 0; }
.card--table .table { margin: 0; }
tr.is-link { cursor: pointer; }

/* чат */
.chat { flex: 1; overflow-y: auto; padding: 6px 4px; }
.msg-row { display: flex; margin-bottom: 10px; }
.msg-row--in { justify-content: flex-start; }
.msg-row--out { justify-content: flex-end; }
.msg-row--sys, .msg-row--note { justify-content: center; }
.bubble { max-width: 74%; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.bubble small { display: block; font-size: 10px; opacity: .7; margin-bottom: 2px; }
.msg-row--in .bubble  { background: var(--color-neutral-100); }
.msg-row--out .bubble { background: var(--color-accent-100); color: var(--color-accent-900); }
.msg-row--note .bubble, .msg-row--sys .bubble { max-width: 90%; text-align: center; font-style: italic; border: 1px dashed var(--color-divider); }
.msg-row--note .bubble { background: #f3ecdb; color: #7a5a1f; }
.msg-row--sys .bubble  { background: transparent; color: var(--color-neutral-500); }

/* ---------- алерты ---------- */
.alert { padding: var(--space-3); border-radius: var(--radius-md); font-size: 14px; border: 1px solid transparent; margin-bottom: 16px; }
.alert a { color: inherit; }
.alert--warn { background: #f3ecdb; color: #7a5a1f; border-color: color-mix(in srgb, #7a5a1f 25%, transparent); }
.alert--bad  { background: #efe0dc; color: #7a3b30; border-color: color-mix(in srgb, #7a3b30 25%, transparent); }
.alert--ok   { background: #e5ede2; color: #3c5a34; border-color: color-mix(in srgb, #3c5a34 25%, transparent); }

/* ---------- мелочи ---------- */
code { font-size: 12px; background: var(--color-neutral-200); padding: 1px 5px; border-radius: 3px; }
.hint { font-size: 12px; color: var(--color-neutral-600); }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--color-divider); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv > .k { color: var(--color-neutral-600); font-size: 13px; flex: none; }
.kv > .v { text-align: right; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 13px; }

/* ============================================================
   Адаптив
   ============================================================ */
@media (max-width: 1200px) {
  .grid--kpi { grid-template-columns: repeat(2, 1fr); }
  .grid--thirds { grid-template-columns: repeat(2, 1fr); }
  .grid--detail, .grid--aside-l, .grid--aside-r { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .content { padding: 20px; }
  .grid--kpi, .grid--halves, .grid--thirds { grid-template-columns: 1fr; }
  .sidebar { width: 76px; }
  .sidebar__brand, .navlink__label, .navlink__badge, .nav-group__label, .sidebar__me { display: none; }
  .navlink { justify-content: center; padding: 10px 0; }
  .sidebar__foot { justify-content: center; }
  .card { overflow-x: auto; }
  .table { min-width: 620px; }
}
@media (max-width: 640px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--color-divider); }
  .sidebar__head, .sidebar__foot { display: none; }
  .sidebar__nav { display: flex; flex-direction: row; padding: 8px; }
  .nav-group { margin-bottom: 0; display: flex; }
  .topbar { flex-wrap: wrap; padding: 12px 18px; }
  .topbar__search { width: 100%; order: 3; }
}
