/* ============================================================
   Диспетчерская Ecosin — дизайн-система (Claude-inspired)
   ============================================================ */

:root {
  --font-body: "Onest", system-ui, -apple-system, sans-serif;

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-pill: 999px;

  --sb-w:     240px;
  --sb-w-col: 60px;

  /* === СВЕТЛАЯ ТЕМА === */
  --bg:           #ffffff;
  --bg-soft:      #f9f9f7;
  --surface:      #ffffff;
  --surface-2:    #f4f4f1;
  --border:       rgba(0,0,0,0.08);
  --border-strong:rgba(0,0,0,0.15);

  --sidebar-bg:     #f7f7f5;
  --sidebar-hover:  #ededea;
  --sidebar-active: #e5e5e1;

  --text:       #1a1a18;
  --text-soft:  #4a4a46;
  --text-muted: #8a8a84;

  --accent:      #1f4a2c;
  --accent-deep: #0f2c1a;
  --accent-soft: #2f6b3e;
  --on-accent:   #ffffff;

  --ok-bg:  #e8f2ec; --ok-fg:  #1a5232;
  --err-bg: #fce8e2; --err-fg: #8a2a1a;

  --msg-in-bg:  #f2f2ef;
  --msg-in-fg:  #1a1a18;
  --msg-out-bg: #1f4a2c;
  --msg-out-fg: #ffffff;

  --badge-alert: #c0392b;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);

  --focus-ring: 0 0 0 3px rgba(31,74,44,0.2);
}

[data-theme="dark"] {
  --bg:           #1c1c1a;
  --bg-soft:      #232321;
  --surface:      #252523;
  --surface-2:    #2c2c2a;
  --border:       rgba(255,255,255,0.08);
  --border-strong:rgba(255,255,255,0.14);

  --sidebar-bg:     #161614;
  --sidebar-hover:  #222220;
  --sidebar-active: #2a2a28;

  --text:       #e8e8e4;
  --text-soft:  #b0b0aa;
  --text-muted: #6a6a64;

  --accent:      #6f9a78;
  --accent-deep: #4a7a55;
  --accent-soft: #8db595;
  --on-accent:   #ffffff;

  --ok-bg:  #1a3322; --ok-fg:  #8db595;
  --err-bg: #2e1810; --err-fg: #e3a784;

  --msg-in-bg:  #2a2a28;
  --msg-in-fg:  #e8e8e4;
  --msg-out-bg: #2f5d3b;
  --msg-out-fg: #f0ece4;

  --badge-alert: #e74c3c;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45);

  --focus-ring: 0 0 0 3px rgba(111,154,120,0.3);
}

/* ============================================================
   Base Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

p  { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* ============================================================
   App Shell (sidebar + main)
   ============================================================ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: var(--bg);
}

/* Стандартный враппер страниц с отступами */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 28px;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sb-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.22s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
  z-index: 20;
}
.sidebar.is-collapsed { width: var(--sb-w-col); }

/* --- Header --- */
.sb-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 56px;
}
.sb-logo {
  width: 28px; height: 28px; flex-shrink: 0;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 13px; font-weight: 700;
}
.sb-brand {
  flex: 1; min-width: 0;
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden;
  transition: opacity 0.15s;
}
.sidebar.is-collapsed .sb-brand { display: none; }

.sb-toggle {
  flex-shrink: 0; width: 26px; height: 26px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s;
}
.sb-toggle:hover { background: var(--sidebar-hover); color: var(--text); }
/* В свёрнутом виде кнопка-стрелка прячется (не влезает в 60px) — разворачивает
   меню клик по логотипу. */
.sidebar.is-collapsed .sb-toggle { display: none; }
.sidebar.is-collapsed .sb-logo { margin: 0 auto; cursor: pointer; }
.sidebar.is-collapsed .sb-header { padding: 14px 0; justify-content: center; }

/* --- Nav --- */
.sb-nav {
  flex: 1;
  overflow-y: auto; overflow-x: hidden;
  padding: 8px;
  display: flex; flex-direction: column; gap: 1px;
  scrollbar-width: none;
}
.sb-nav::-webkit-scrollbar { display: none; }

.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-soft); text-decoration: none;
  font-size: 13.5px; line-height: 1;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
  cursor: pointer; border: 0; background: transparent;
  width: 100%; text-align: left; min-height: 36px;
  position: relative;
}
.sb-item:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
.sb-item.is-active { background: var(--sidebar-active); color: var(--text); }
.sb-item.is-active .sb-icon { opacity: 1; }
.sb-item.is-locked { opacity: .45; cursor: not-allowed; pointer-events: none; }

.sb-icon {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.65;
}
.sb-item:hover .sb-icon { opacity: 1; }

.sb-label {
  flex: 1;
  transition: opacity 0.12s;
}
.sidebar.is-collapsed .sb-label { opacity: 0; width: 0; overflow: hidden; }

.sb-badge {
  font-size: 11px; font-weight: 700;
  background: var(--badge-alert); color: white;
  border-radius: var(--radius-pill);
  padding: 1px 6px; min-width: 18px; text-align: center;
  line-height: 16px; flex-shrink: 0;
}
.sb-badge[hidden] { display: none; }
.sidebar.is-collapsed .sb-badge {
  position: absolute; top: 4px; right: 4px;
  font-size: 9px; padding: 1px 4px; min-width: auto;
}

.sb-divider {
  height: 1px; background: var(--border);
  margin: 5px 4px; flex-shrink: 0;
}

/* Collapsible groups */
.sb-group { display: flex; flex-direction: column; gap: 1px; }
.sb-group > summary { list-style: none; }
.sb-group > summary::-webkit-details-marker { display: none; }

.sb-chevron {
  width: 14px; height: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.sb-group[open] > summary .sb-chevron { transform: rotate(90deg); }
.sidebar.is-collapsed .sb-chevron { display: none; }
.sidebar.is-collapsed .sb-group-items { display: none; }

.sb-group-items {
  padding-left: 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.sb-sub { font-size: 13px; color: var(--text-muted); }
.sb-sub:hover { color: var(--text); }
.sb-sub.is-active { color: var(--text); }

/* --- Footer --- */
.sb-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
}

.sb-user {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; min-height: 44px;
}
.sb-avatar {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--accent); color: white;
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.sb-user-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  transition: opacity 0.12s;
}
.sb-user-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-user-role { font-size: 11px; color: var(--text-muted); }
.sidebar.is-collapsed .sb-user-info { opacity: 0; width: 0; overflow: hidden; pointer-events: none; }

.sb-logout {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
}
.sb-logout:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
.sidebar.is-collapsed .sb-logout { display: none; }

/* Theme toggle в сайдбаре */
.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px; min-height: 36px;
  border-radius: var(--radius-sm); border: 0;
  background: transparent; color: var(--text-soft);
  font-size: 13.5px; font-family: inherit;
  cursor: pointer; width: 100%; text-align: left;
  transition: background 0.1s;
}
.theme-toggle:hover { background: var(--sidebar-hover); color: var(--text); }

/* Мобильная панель (скрыта на десктопе) */
.sb-mobile-bar {
  display: none;
  align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
  flex-shrink: 0; position: sticky; top: 0; z-index: 5;
}
.sb-mobile-toggle {
  width: 32px; height: 32px;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sb-mobile-brand { font-size: 15px; font-weight: 600; color: var(--text); }
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,0.35);
}

/* ============================================================
   Auth (страница логина)
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  width: 40px; height: 40px;
  background: var(--accent); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px; font-weight: 700;
  margin-bottom: 20px;
}
.auth-theme {
  position: fixed; top: 16px; right: 16px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 14px; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block;
  padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  background: var(--surface-2); color: var(--text-soft);
  border: 1px solid var(--border);
}
.badge-expert  { background: var(--accent); color: white; border-color: transparent; }
.badge-manager { background: var(--surface-2); color: var(--text-soft); }
.badge-src     { background: var(--surface-2); color: var(--accent); }

/* ============================================================
   Forms & Buttons
   ============================================================ */
label {
  display: block; margin: 12px 0 5px;
  font-size: 13px; font-weight: 500; color: var(--text-soft);
}
input[type=text], input[type=password], input[type=search],
input:not([type]), textarea, select {
  width: 100%; padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus-ring);
}
input::placeholder { color: var(--text-muted); }

.btn, button[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; margin-top: 14px;
  border: 0; border-radius: var(--radius-md);
  background: var(--accent); color: white;
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: background .12s;
}
.btn:hover, button[type=submit]:hover { background: var(--accent-deep); }

.btn-ghost {
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; margin: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text-soft);
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: background .1s;
}
.btn-sm:hover { background: var(--surface-2); color: var(--text); }
.btn-sm[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-xs {
  padding: 3px 8px; margin: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
  font-size: 12px; font-family: inherit; cursor: pointer;
}
.btn-xs:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: #c0392b; border-color: rgba(192,57,43,0.3); }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: 10px 14px; border-radius: var(--radius-md);
  margin-bottom: 14px; font-size: 13px;
  border: 1px solid transparent;
}
.alert.ok    { background: var(--ok-bg);  color: var(--ok-fg); }
.alert.error { background: var(--err-bg); color: var(--err-fg); }

/* ============================================================
   Tables
   ============================================================ */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; padding: 10px 12px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  letter-spacing: 0.04em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.tbl td { padding: 12px 12px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: 0; }

/* ============================================================
   Permissions list
   ============================================================ */
.perms { list-style: none; padding: 0; margin: 0; }
.perms li {
  padding: 4px 0; font-size: 14px; color: var(--text-soft);
  display: flex; align-items: center; gap: 8px;
}
.perms li::before { content: "✓"; color: var(--accent); font-weight: 700; }

/* ============================================================
   Inbox — двухколоночный (список + переписка)
   ============================================================ */
.main-content.inbox-main {
  overflow: hidden;
  display: flex; flex-direction: column;
}

.inbox {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  overflow: hidden;
}

/* Левая колонка: список диалогов */
.dialog-list {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg-soft);
}
.list-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  letter-spacing: 0.05em; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.dialog-list-scroll { flex: 1; overflow-y: auto; }

.dialog-item {
  display: block; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: var(--text);
  transition: background 0.1s;
}
.dialog-item:hover { background: var(--sidebar-hover); text-decoration: none; }
.dialog-item.active { background: var(--sidebar-active); }

.di-top {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 6px; margin-bottom: 2px;
}
.di-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.di-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.di-src  { font-size: 11px; color: var(--accent); margin-bottom: 3px; }
.di-row2 { display: flex; align-items: center; gap: 6px; }
.di-last { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.unread  {
  background: var(--accent); color: white;
  font-size: 10px; font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 1px 6px; min-width: 18px; text-align: center;
  flex-shrink: 0;
}
.empty { padding: 24px 16px; font-size: 13px; color: var(--text-muted); }

/* Правая колонка: переписка */
.conversation {
  display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg);
}
.conv-head {
  padding: 14px 20px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface);
}
.conv-head-name { font-size: 15px; font-weight: 600; }
.conv-head-sub  { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.conv-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.conv-head-actions form { margin: 0; }

.conv-body {
  flex: 1; overflow-y: auto;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 8px;
}
.msg {
  max-width: 68%;
  padding: 10px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.5;
}
.msg-text { word-break: break-word; }
.msg-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.msg-in  {
  align-self: flex-start;
  background: var(--msg-in-bg); color: var(--msg-in-fg);
  border-bottom-left-radius: 4px;
}
.msg-out {
  align-self: flex-end;
  background: var(--msg-out-bg); color: var(--msg-out-fg);
  border-bottom-right-radius: 4px;
}
.msg-out .msg-time { color: rgba(255,255,255,0.5); }

.conv-reply {
  flex-shrink: 0; padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.reply-form { display: flex; gap: 8px; align-items: center; }
.reply-form input { flex: 1; margin: 0; }
.btn-send {
  width: 36px; height: 36px; padding: 0; margin: 0;
  border-radius: var(--radius-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: white; border: 0; cursor: pointer;
  transition: background 0.12s;
}
.btn-send:hover { background: var(--accent-deep); }
.reply-error { margin: 8px 0 0; font-size: 13px; color: var(--err-fg); }

.conv-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px;
  color: var(--text-muted); font-size: 14px;
}

/* ============================================================
   Monitoring
   ============================================================ */
.mon-grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.mon-add-form { display: flex; gap: 8px; }
.mon-add-form input { flex: 1; }
.mon-channels-head { display: flex; justify-content: space-between; align-items: center; }
.mon-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  padding: 3px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-pill); font-size: 12px;
  color: var(--text-soft); background: var(--surface-2); text-decoration: none;
}
.chip:hover { background: var(--sidebar-hover); text-decoration: none; }
.chip-on { background: var(--accent); color: white; border-color: transparent; }

.mon-channel-list { list-style: none; margin: 0; padding: 0; }
.mon-channel { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.mon-channel.is-off { opacity: 0.5; }
.mc-title { font-weight: 600; color: var(--text); text-decoration: none; display: block; }
.mc-title:hover { color: var(--accent); }
.mc-err { color: #c0392b; font-size: 12px; margin-top: 2px; }
.mc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.mon-posts { display: flex; flex-direction: column; gap: 10px; }
.mon-post { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.mon-post.is-guide { border-left: 3px solid var(--accent-soft); }
.mon-feed-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mon-feed-filter input[type="search"] { flex: 1; min-width: 160px; }
.mon-check { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-soft); white-space: nowrap; }
.mon-check input { width: auto; margin: 0; }
.mp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.mp-channel { font-weight: 600; color: var(--accent); }
.mp-date { margin-left: auto; font-size: 13px; color: var(--text-muted); }
.mp-text { white-space: pre-wrap; word-break: break-word; color: var(--text); line-height: 1.5; }
.mp-foot { margin-top: 8px; }
.badge-guide { background: var(--accent-soft); color: white; border-color: transparent; }

/* ============================================================
   Integrations
   ============================================================ */
.integ-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.integ-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.ok-dot { color: #27ae60; }
.off-dot { color: var(--text-muted); }
@media (max-width: 780px) { .integ-grid { grid-template-columns: 1fr; } }

/* ============================================================
   Products (Ш-2)
   ============================================================ */
.product-form .pf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.product-form label { display: block; font-size: 0.85rem; color: var(--text-soft); }
.product-form input, .product-form select, .product-form textarea { width: 100%; margin-top: 4px; }
.prod-thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; display: block; }
.prod-thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.row-off { opacity: 0.55; }
.prod-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.img-upload { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }

/* Управление категориями (раздел «Товары») */
.cat-add-form { display: flex; gap: 8px; align-items: center; margin: 10px 0 16px; }
.cat-add-form input { flex: 1; max-width: 320px; }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--border);
}
.cat-rename { display: flex; gap: 6px; align-items: center; margin: 0; flex: 1; }
.cat-rename input { flex: 1; max-width: 260px; }
.cat-slug { flex-shrink: 0; }

/* Чекбокс «в наличии» в формах товара */
.pf-check { display: flex; align-items: center; gap: 8px; margin: 12px 0; font-size: 14px; color: var(--text); }
.pf-check input { width: auto; margin: 0; }

/* Индикатор-пилюля наличия (кликабельный переключатель) */
.stock-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.stock-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.stock-pill.in  { background: var(--ok-bg);  color: var(--ok-fg); }
.stock-pill.in::before  { background: #27ae60; }
.stock-pill.out { background: var(--err-bg); color: var(--err-fg); }
.stock-pill.out::before { background: #c0392b; }
.prod-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.pg-item { position: relative; margin: 0; border-radius: 14px; overflow: hidden; border: 2px solid transparent; background: var(--surface-2); }
.pg-item.is-cover { border-color: var(--accent); }
.pg-item img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; }
.pg-cover-label { position: absolute; top: 8px; left: 8px; background: var(--accent); color: white; font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.pg-actions { position: absolute; bottom: 0; left: 0; right: 0; display: flex; gap: 6px; justify-content: center; padding: 6px; background: linear-gradient(transparent, rgba(0,0,0,0.5)); }

/* ============================================================
   Orders (Ш-3)
   ============================================================ */
.orders-list { display: flex; flex-direction: column; gap: 12px; }
.order-card { border-left: 3px solid var(--border-strong); }
.order-card.order-placed    { border-left-color: #e67e22; }
.order-card.order-confirmed { border-left-color: #27ae60; }
.order-card.order-paid      { border-left-color: var(--accent); }
.order-card.order-shipped   { border-left-color: var(--accent-deep); }
.order-card.order-cancelled { border-left-color: var(--text-muted); opacity: 0.7; }
.order-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.order-id { font-weight: 600; }
.order-badge { background: var(--surface-2); color: var(--text-soft); }
.order-date { margin-left: auto; font-size: 13px; color: var(--text-muted); }
.order-customer { margin: 8px 0; }
.order-items { list-style: none; padding: 0; margin: 8px 0; }
.order-items li { display: flex; align-items: baseline; gap: 6px; padding: 2px 0; font-size: 14px; }
.order-item-sum { margin-left: auto; color: var(--text-soft); white-space: nowrap; }
.order-total { margin: 6px 0 10px; }
.order-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.order-status-form { display: flex; gap: 6px; align-items: center; margin: 0; flex-wrap: wrap; }
.status-silent { display: inline-flex; align-items: center; gap: 4px;
                 font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.order-comment-form { display: flex; gap: 8px; align-items: center; }
.order-comment-form input { flex: 1; }
.order-hist-plashka { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--accent); border: 1px solid var(--border); }
button.order-hist-plashka { cursor: pointer; }
button.order-hist-plashka:hover { background: var(--sidebar-hover); }
.order-hist-static { cursor: default; }

/* Dialog modal (Orders) */
.dlg-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.4); opacity: 0; transition: opacity .2s; }
.dlg-overlay.show { opacity: 1; }
.dlg-modal { position: fixed; z-index: 301; left: 50%; top: 50%; transform: translate(-50%,-48%) scale(.98); width: min(560px, calc(100vw - 32px)); max-height: min(80vh,640px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); opacity: 0; transition: opacity .2s, transform .2s; }
.dlg-modal.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-soft); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.dlg-head strong { font-size: 16px; font-weight: 600; }
.dlg-close { width: 30px; height: 30px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--text-soft); cursor: pointer; font-size: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.dlg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.dlg-body .msg { max-width: 85%; }
.dlg-reply { display: flex; gap: 8px; flex-shrink: 0; padding: 12px 18px; border-top: 1px solid var(--border); }
.dlg-reply input { flex: 1; margin: 0; }
.dlg-reply button { margin: 0; }
.dlg-collapse { border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--text-soft); font-size: 12px; padding: 4px 10px; cursor: pointer; }
.dlg-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dlg-history { flex-shrink: 0; max-height: 32%; overflow-y: auto; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.dlg-hist-title { font-size: 12px; font-weight: 700; color: var(--text-soft); margin-bottom: 6px; }
.dlg-hist-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; color: var(--text-soft); }
.dlg-hist-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-hist-sum { white-space: nowrap; font-weight: 600; color: var(--text); }
body.modal-open { overflow: hidden; }

/* ============================================================
   Bot settings
   ============================================================ */
.bb-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.bb-row .bb-label { flex: 2; min-width: 0; }
.bb-row .bb-value { flex: 3; min-width: 0; }
.bb-row .btn-kind { flex: 0 0 120px; }
.bb-row .bb-value[readonly] { background: var(--cream, #f5ede0); color: var(--text-muted); }
.bb-head { display: flex; gap: 6px; margin-bottom: 4px; font-size: 12px;
           font-weight: 600; color: var(--text-muted); }
.bb-head .h-kind  { flex: 0 0 120px; }
.bb-head .h-label { flex: 2; }
.bb-head .h-value { flex: 3; }
.bb-head .h-tail  { flex: 0 0 92px; }

/* ============================================================
   Mobile / Responsive
   ============================================================ */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sb-w) !important;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(.4,0,.2,1);
    z-index: 100; box-shadow: var(--shadow-md);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }

  .sb-mobile-bar { display: flex; }

  .inbox { grid-template-columns: 1fr; }
  .dialog-list { max-height: 300px; border-right: 0; border-bottom: 1px solid var(--border); }
  .conversation { height: calc(100vh - 400px); min-height: 300px; }

  .mon-grid { grid-template-columns: 1fr; }
  .page { padding: 20px 16px; }
}

@media (max-width: 560px) {
  .card { padding: 16px; }
  .msg { max-width: 88%; }
  .bb-row { flex-wrap: wrap; }
  .bb-row .bb-label, .bb-row .bb-value { flex: 1 1 100%; }
  .bb-head { display: none; }   /* строки в столбик — заголовки колонок не нужны */
  .dlg-modal { width: 100vw; max-height: 92dvh; left: 0; right: 0; bottom: 0; top: auto; transform: translateY(100%); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .dlg-modal.show { transform: translateY(0); }
  .order-comment-form { flex-wrap: wrap; }
  .reply-form input { flex: 1 1 100%; }
}
