/* ============ Neurosel — design tokens & base ============ */
:root {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --sidebar: #FAFBFD;
  --accent: #5B7CF6;
  --accent-weak: #EEF2FE;
  --accent-weak-2: #E5EBFD;
  --accent-ink: #3A57C9;
  --border: #E4E8EE;
  --border-strong: #D6DCE6;
  --text: #1A1F2E;
  --text-2: #5A6275;
  --text-3: #8990A3;

  --green: #1F9E6E;
  --green-weak: #E6F6EF;
  --amber: #C98A1E;
  --amber-weak: #FBF1DE;
  --violet: #8B5CF6;
  --violet-weak: #F1ECFE;
  --rose: #D6536A;
  --rose-weak: #FCECEF;

  --radius: 12px;
  --radius-sm: 9px;
  --radius-xs: 7px;

  --shadow-xs: 0 1px 2px rgba(20, 28, 48, 0.04);
  --shadow-sm: 0 1px 2px rgba(20, 28, 48, 0.05), 0 1px 1px rgba(20, 28, 48, 0.03);
  --shadow-md: 0 6px 16px -6px rgba(20, 28, 48, 0.12), 0 2px 6px -2px rgba(20, 28, 48, 0.06);
  --shadow-pop: 0 16px 40px -12px rgba(20, 28, 48, 0.22), 0 4px 12px -4px rgba(20, 28, 48, 0.10);

  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* numeric token: interface sans + tabular-nums for money & percents;
     --mono stays reserved for SKU / codes / kbd */
  --num: var(--sans);
  --tnum: "tnum";
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}
#root { height: 100%; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
::selection { background: var(--accent-weak-2); }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #D9DEE8; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #C3CAD8; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============ App frame ============ */
.app {
  display: grid !important;
  grid-template-columns: 244px 1fr;
  height: 100vh;
  overflow: hidden;
}

html { height: 100%; }
body { height: 100%; margin: 0; }
#root { height: 100%; display: block; }

/* ============ Sidebar ============ */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
}
.sb-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 19px 20px 16px;
}
.sb-logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(150deg, #6E8CF8, #5B7CF6 55%, #4B6CEA);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 2px 6px -1px rgba(91, 124, 246, 0.45), inset 0 1px 0 rgba(255,255,255,0.25);
  flex: none;
}
.sb-brand-name { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.sb-brand-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; letter-spacing: 0.01em; white-space: nowrap; }

.sb-scroll { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.sb-section-label {
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3); padding: 14px 10px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--radius-xs);
  font-size: 13.5px; color: var(--text-2); width: 100%;
  position: relative; transition: background .14s, color .14s;
  letter-spacing: -0.005em;
}
.nav-item:hover { background: #EFF2F7; color: var(--text); }
.nav-item.active { background: var(--accent-weak); color: var(--accent-ink); font-weight: 500; }
.nav-item.active .nav-ic { color: var(--accent); }
.nav-ic { color: var(--text-3); flex: none; transition: color .14s; }
.nav-item:hover .nav-ic { color: var(--text-2); }
.nav-label { flex: 1; text-align: left; white-space: nowrap; }
.nav-badge {
  font-size: 11px; font-weight: 500; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 6px; display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.nav-badge.live {
  background: var(--green-weak); color: var(--green);
  display: inline-flex; gap: 5px; align-items: center; padding: 0 7px 0 6px;
}
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.sb-foot { border-top: 1px solid var(--border); padding: 10px 12px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-xs); }
.sb-user:hover { background: #EFF2F7; }
.avatar {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 500; color: #fff;
}
.sb-user-name { font-size: 13px; font-weight: 500; line-height: 1.2; }
.sb-user-mail { font-size: 11px; color: var(--text-3); line-height: 1.3; }

/* ============ Main column ============ */
.main { display: flex; flex-direction: column; height: 100%; overflow: hidden; min-width: 0; }

/* Глобальный бейдж «Тестовый режим» (read-only) */
.readonly-bar {
  flex: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 30px; padding: 0 16px;
  background: var(--amber-weak); color: var(--amber);
  border-bottom: 1px solid rgba(201, 138, 30, 0.28);
  font-size: 12.5px; font-weight: 500; letter-spacing: -0.005em;
  z-index: 6;
}
.readonly-bar svg { flex: none; }

/* Боевой режим (TASK_67): магазин вооружён — реальные изменения в Маркете. */
.live-bar {
  flex: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 30px; padding: 0 16px;
  background: var(--rose-weak, #FCE9ED); color: var(--rose);
  border-bottom: 1px solid rgba(214, 83, 106, 0.32);
  font-size: 12.5px; font-weight: 600; letter-spacing: -0.005em;
  z-index: 6;
}
.live-bar svg { flex: none; }

/* Top bar */
.topbar {
  height: 60px; flex: none; background: rgba(255,255,255,0.82);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 22px; z-index: 5;
}
.tb-title { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.tb-crumb { color: var(--text-3); font-size: 13px; }
.tb-spacer { flex: 1; }

.store-select {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 11px 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  box-shadow: var(--shadow-xs); transition: border-color .14s, box-shadow .14s;
}
.store-select:hover { border-color: var(--border-strong); }
.store-flag { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 500; flex: none; }
.store-select .ss-name { font-size: 13px; font-weight: 500; }
.store-select .ss-meta { font-size: 11px; color: var(--text-3); }

.tb-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; color: var(--text-2);
  box-shadow: var(--shadow-xs); transition: border-color .14s, color .14s, background .14s; position: relative;
}
.tb-btn:hover { border-color: var(--border-strong); color: var(--text); }
.tb-btn .ping { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }

.tb-search {
  display: flex; align-items: center; gap: 9px; height: 38px; width: 260px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text-3); box-shadow: var(--shadow-xs); transition: border-color .14s, box-shadow .14s;
}
.tb-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.tb-search input { border: none; outline: none; background: none; flex: 1; font-size: 13px; color: var(--text); }
.tb-search input::placeholder { color: var(--text-3); }
.kbd { font-size: 11px; font-family: var(--mono); color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }

/* scroll body */
.scroll { flex: 1; overflow-y: auto; }
.page { padding: 26px 28px 60px; max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-h1 { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.page-sub { font-size: 13.5px; color: var(--text-2); margin-top: 4px; }

/* ============ Shared bits ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.row { display: flex; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; white-space: nowrap;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; letter-spacing: -0.005em;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs); transition: border-color .14s, background .14s, transform .06s, box-shadow .14s;
}
.btn:hover { border-color: var(--border-strong); background: #FBFCFE; }
.btn:active { transform: translateY(0.5px); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 1px 2px rgba(91,124,246,0.4), inset 0 1px 0 rgba(255,255,255,0.18); }
.btn.primary:hover { background: #506FE8; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: #EFF2F7; color: var(--text); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn.green { background: var(--green); border-color: transparent; color: #fff; box-shadow: 0 1px 2px rgba(31,158,110,0.35); }
.btn.green:hover { background: #198a5f; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 7px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); white-space: nowrap;
}

.badge { display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500; letter-spacing: 0.01em; white-space: nowrap; }
.badge.best { background: var(--accent); color: #fff; }
.badge.super { background: linear-gradient(120deg, #9466F7, #7C53EE); color: #fff; }
.badge.green { background: var(--green-weak); color: var(--green); }
.badge.amber { background: var(--amber-weak); color: var(--amber); }
.badge.rose { background: var(--rose-weak); color: var(--rose); }
.badge.gray { background: #EEF1F6; color: var(--text-2); }
.badge.indigo { background: var(--accent-weak); color: var(--accent-ink); }
.badge.violet { background: var(--violet-weak); color: #7C53EE; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-green { background: var(--green); box-shadow: 0 0 0 3px var(--green-weak); }
.dot-amber { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-weak); }
.dot-gray { background: #B5BDCC; box-shadow: 0 0 0 3px #EEF1F6; }

/* toggle */
.toggle { width: 38px; height: 22px; border-radius: 999px; background: #D4DAE4; position: relative; transition: background .18s; flex: none; }
.toggle.on { background: var(--accent); }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform .18s; }
.toggle.on::after { transform: translateX(16px); }

/* table */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl thead th {
  text-align: left; font-weight: 500; color: var(--text-3); font-size: 11.5px; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: #FCFCFE;
}
.tbl tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #FAFBFD; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; font-feature-settings: var(--tnum); font-size: 12.5px; letter-spacing: -0.005em; white-space: nowrap; }
.col-price { min-width: 104px; white-space: nowrap; }
.col-cost { min-width: 104px; white-space: nowrap; }
.col-margin { min-width: 108px; }
.col-stock { min-width: 90px; }
.col-thumb { width: 44px; padding-right: 0 !important; }

.stock-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}
.stock-src-badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  font-family: var(--mono);
}
.stock-src-badge.zero {
  color: var(--text-3);
  opacity: 0.65;
}

/* Product thumbnail */
.prod-thumb { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; border: 1px solid var(--border); background: var(--bg); display: block; }
.prod-thumb-ph { width: 36px; height: 36px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--text-3); flex: none; }

/* Card status badges */
.badge.no-card { background: #F1F4F9; color: var(--text-2); }
.badge.archived-card { background: var(--amber-weak); color: var(--amber); }

/* Listing filter tabs */
.listing-filter-tabs { display: flex; gap: 2px; background: var(--bg); border-radius: 9px; padding: 3px; border: 1px solid var(--border); }
.listing-filter-tab { padding: 4px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--text-2); background: transparent; border: none; cursor: pointer; transition: background .12s, color .12s; white-space: nowrap; }
.listing-filter-tab:hover { background: var(--surface); color: var(--text); }
.listing-filter-tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.07); }

/* Warehouse badges on the Products screen */
.wh-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.wh-badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.wh-badge-sep { color: inherit; opacity: .5; }
.wh-badge-stock { font-variant-numeric: tabular-nums; }
.wh-badge-green  { background: #E7F6EF; color: var(--green); }
.wh-badge-rose   { background: #FDEEF1; color: var(--rose); }
.wh-badge-amber  { background: #FEF3E2; color: var(--amber); }
.wh-badge-gray   { background: var(--bg); color: var(--text-3); border: 1px solid var(--border); }

/* checkbox */
.cbx { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; transition: all .14s; flex: none; color: #fff; }
.cbx.on { background: var(--accent); border-color: var(--accent); }
.cbx svg { opacity: 0; transition: opacity .1s; }
.cbx.on svg { opacity: 1; }

/* AI pulse */
@keyframes pulse-ring { 0% { transform: scale(0.7); opacity: 0.55; } 70%,100% { transform: scale(2.0); opacity: 0; } }
@keyframes soft-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes blink-caret { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes rise { from { transform: translateY(6px); } to { transform: translateY(0); } }
@keyframes dots { 0%,80%,100% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes dash-skel-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.dash-skel { background: linear-gradient(90deg, #EEF1F6 25%, #F6F8FB 37%, #EEF1F6 63%); background-size: 200% 100%; animation: dash-skel-shimmer 1.4s ease-in-out infinite; }
.ai-live { position: relative; }
.ai-live::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent); animation: pulse-ring 2s ease-out infinite; }

.thinking-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; animation: dots 1.2s infinite; }
.caret { display: inline-block; width: 2px; height: 1em; background: var(--accent); margin-left: 1px; vertical-align: text-bottom; animation: blink-caret 1s step-end infinite; }
.rise { animation: rise .32s ease; }

.divider { height: 1px; background: var(--border); }

/* lang toggle */
.lang-toggle {
  height: 38px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow-xs); font-size: 12.5px; font-weight: 500; letter-spacing: 0.02em;
  display: inline-flex; align-items: center; gap: 6px; transition: border-color .14s, color .14s;
}
.lang-toggle:hover { border-color: var(--border-strong); color: var(--text); }

/* KPI strip */
.kpi-grid { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kpi-cell { background: var(--surface); padding: 15px 17px; }
.kpi-cell .kpi-val { font-size: 23px; font-weight: 500; letter-spacing: -0.02em; line-height: 1; }
.kpi-cell .kpi-lbl { font-size: 12px; color: var(--text-2); margin-top: 7px; }

/* segmented tabs / pills */
.seg { display: inline-flex; gap: 3px; background: #EEF1F6; border-radius: 9px; padding: 3px; }
.seg button { height: 30px; padding: 0 13px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--text-2); transition: all .14s; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.seg button:not(.on):hover { color: var(--text); }

.pill-tab { height: 32px; padding: 0 13px; border-radius: 8px; font-size: 12.5px; font-weight: 500; color: var(--text-2); border: 1px solid var(--border); background: var(--surface); display: inline-flex; align-items: center; gap: 6px; transition: all .14s; white-space: nowrap; }
.pill-tab:hover { border-color: var(--border-strong); color: var(--text); }
.pill-tab.on { background: var(--accent-weak); border-color: transparent; color: var(--accent-ink); }
.pill-tab .pill-count { font-size: 11px; background: rgba(0,0,0,0.06); border-radius: 5px; padding: 0 5px; min-width: 16px; text-align: center; }
.pill-tab.on .pill-count { background: rgba(91,124,246,0.18); }

/* supply screen */
.sup-hint { font-size: 12.5px; color: var(--text-2); line-height: 1.55; background: var(--accent-weak); border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; }
.sup-inp { height: 30px; border: 1px solid var(--accent); border-radius: 7px; padding: 0 9px; outline: none; font-size: 12.5px; box-shadow: 0 0 0 3px var(--accent-weak); }
.sup-inp::-webkit-outer-spin-button, .sup-inp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sup-recalc-note { font-size: 12px; color: var(--text-3); margin-top: 12px; padding-left: 2px; }

/* supply: диагностика закупки (TASK_77) */
.sup-diag-funnel { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.sup-diag-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); text-align: left; transition: all .14s; border-left: 3px solid var(--tile-color, var(--border)); }
.sup-diag-tile:not(.static):hover { border-color: var(--border-strong); border-left-color: var(--tile-color, var(--border)); box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.sup-diag-tile.on { background: var(--accent-weak); border-color: transparent; border-left-color: var(--tile-color, var(--accent)); }
.sup-diag-tile.static { cursor: default; }
.sup-diag-tile-n { font-size: 22px; font-weight: 700; color: var(--tile-color, var(--text)); line-height: 1; }
.sup-diag-tile-l { font-size: 12px; color: var(--text-2); }
.sup-diag-coverage { font-size: 12.5px; color: var(--text-2); line-height: 1.6; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; margin-top: 14px; }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,28,48,0.42); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; animation: rise .2s ease; }
.modal { width: 480px; max-width: calc(100vw - 40px); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 24px; animation: rise .26s ease; }

/* stars */
.stars { display: inline-flex; gap: 1px; color: #E5B73B; }
.stars .empty { color: #DDE2EA; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; font-size: 13px; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow-pop); z-index: 200; animation: rise .22s ease; display: flex; align-items: center; gap: 9px; }
/* global toast stack (window.showToast) */
.toast-stack { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast-item { background: var(--text); color: #fff; font-size: 13px; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-pop); animation: rise .22s ease; display: flex; align-items: center; gap: 9px; pointer-events: auto; max-width: 420px; }
.toast-item.success { background: var(--green); }
.toast-item.error { background: var(--rose); }
.toast-item.info { background: var(--text); }
.toast-item.leaving { opacity: 0; transition: opacity .25s ease; }

/* topbar search dropdown */
.search-group-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 14px 4px; }
.search-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 14px; transition: background .12s; }
.search-item:hover { background: #F1F4F9; }

/* loading spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; border-radius: 50%; border: 2.5px solid var(--accent-weak-2); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.screen-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 56px 20px; color: var(--text-3); font-size: 13px; }

/* banner */
.banner { display: flex; align-items: center; gap: 11px; padding: 12px 16px; border-radius: var(--radius); background: var(--accent-weak); color: var(--accent-ink); font-size: 13px; border: 1px solid var(--accent-weak-2); }
.banner .ai-live { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 26px; }
.spark span { width: 4px; border-radius: 2px; background: var(--accent-weak-2); }
.muted { color: var(--text-2); }
.mono { font-family: var(--mono); }

/* ============ Login page ============ */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.login-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.login-bg-blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.45; }
.login-bg-blob-1 { width: 420px; height: 420px; background: #C7D4FD; top: -120px; right: -80px; }
.login-bg-blob-2 { width: 360px; height: 360px; background: #D8F0E8; bottom: -100px; left: -60px; }
.login-card {
  position: relative; width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 32px 28px 24px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-title { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }
.login-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.login-lead { font-size: 13.5px; color: var(--text-2); line-height: 1.55; margin: 0 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.login-input {
  height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #FBFCFE; font-size: 14px; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); background: #fff; }
.login-pass-wrap { position: relative; }
.login-pass-wrap .login-input { width: 100%; padding-right: 40px; }
.login-pass-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; color: var(--text-3);
}
.login-pass-toggle:hover { background: var(--accent-weak); color: var(--text-2); }
.login-error {
  font-size: 13px; color: var(--rose); background: var(--rose-weak);
  border: 1px solid #F5D0D8; border-radius: var(--radius-xs); padding: 9px 11px;
}
.login-submit { width: 100%; height: 40px; margin-top: 4px; font-size: 14px; font-weight: 500; }
.login-foot {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 22px; font-size: 12px; color: var(--text-3);
}
.login-live-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.sb-logout {
  width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center;
  color: var(--text-3); flex: none;
}
.sb-logout:hover { background: var(--rose-weak); color: var(--rose); }

/* ============ Side panel (юнит-экономика) ============ */
.side-panel-overlay { position: fixed; inset: 0; background: rgba(20,28,48,0.35); z-index: 90; animation: rise .2s ease; }
.side-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 440px; max-width: 94vw;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(20,28,48,0.14); z-index: 91;
  display: flex; flex-direction: column; overflow-y: auto;
  animation: slideInRight .25s cubic-bezier(.22,.61,.36,1);
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.sp-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sp-head-ic { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--accent-weak); color: var(--accent); }
.sp-body { padding: 18px 22px 32px; display: flex; flex-direction: column; gap: 20px; }
.sp-line { display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 5px 0; }
.sp-line .lbl { color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.sp-line .val { font-weight: 500; }
.sp-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin-bottom: 8px; }

/* Лесенка цен */
.sp-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sp-price-card { border: 1px solid var(--border); border-radius: 13px; padding: 13px 15px; background: var(--surface); transition: border-color .15s; }
.sp-price-card.full { grid-column: 1 / -1; }
.sp-price-card.accent { border-color: var(--accent); background: linear-gradient(155deg, #FFFFFF, var(--accent-weak)); box-shadow: 0 2px 10px -4px rgba(91,124,246,0.4); }
.sp-price-card .cap { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.sp-price-card .pval { font-size: 20px; font-weight: 600; letter-spacing: -0.025em; margin-top: 5px; line-height: 1; }
.sp-price-card .sub { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }

/* Маржа-полоса */
.sp-margin { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; padding: 15px 16px; }
.sp-margin-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.sp-margin-val { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.sp-margin-track { position: relative; height: 9px; border-radius: 6px; background: #EDF0F5; overflow: visible; }
.sp-margin-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; transition: width .3s; }
.sp-margin-min { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text-2); border-radius: 2px; }
.sp-margin-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 7px; }

/* Маржа: валовая + чистая рядом (TASK_66) */
.sp-margins-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sp-mtile { border: 1px solid var(--border); border-radius: 13px; padding: 12px 14px; background: var(--surface); }
.sp-mtile.accent { border-color: var(--accent); background: linear-gradient(155deg, #FFFFFF, var(--accent-weak)); }
.sp-mtile .cap { font-size: 11.5px; color: var(--text-3); }
.sp-mtile .val { font-size: 22px; font-weight: 600; letter-spacing: -0.025em; line-height: 1; margin-top: 5px; }
.sp-mtile .sub { font-size: 11px; color: var(--text-3); margin-top: 6px; line-height: 1.35; }

/* Полный расход: итог-кнопка + раскрытие (TASK_66) */
.sp-exp-total { width: 100%; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; transition: border-color .12s, background .12s; }
.sp-exp-total:hover { border-color: var(--accent); background: var(--accent-weak); }
.sp-exp-total .lbl { font-size: 13px; font-weight: 600; color: var(--text); }
.sp-exp-total .exp-pct { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.sp-exp-total .exp-rub { font-size: 13px; color: var(--text-2); }
.sp-exp-list { padding: 4px 4px 0; }

/* Источник ставки + разбивка логистики + план/факт + перенять (TASK_68b) */
.sp-src { font-size: 9.5px; font-weight: 600; letter-spacing: 0.02em; border-radius: 5px; padding: 1px 6px; margin-left: 7px; white-space: nowrap; vertical-align: 1px; }
.sp-src.src-manual { color: var(--accent-ink); background: var(--accent-weak); }
.sp-src.src-default { color: var(--amber); background: #FBF1DD; }
.sp-src.src-allin { color: var(--text-2); background: #F1F4F9; }
.sp-src.src-formula { color: var(--green); background: var(--green-weak); }
.sp-src.src-estimate { color: var(--amber); background: #FBF1DD; }
.sp-src.src-report { color: var(--green); background: var(--green-weak); }
.sp-src.src-zero { color: var(--text-3); background: #F1F4F9; }
.sp-src.src-unknown { color: var(--text-3); background: #F1F4F9; }
.sp-incomplete { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--amber); background: #FBF1DD; border-radius: 9px; padding: 7px 11px; margin-top: 8px; line-height: 1.35; }
.sp-log-detail { padding: 0 0 4px 14px; border-left: 2px solid var(--border); margin: 0 0 4px 4px; }
.sp-line.sub { font-size: 12px; padding: 3px 0; }
.sp-line.sub .lbl { color: var(--text-3); }
.sp-planfact { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 8px; }
.sp-commission-note { font-size: 11px; color: var(--text-3); font-style: italic; }
.sp-adopt { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sp-adopt-btn { height: 30px; font-size: 12px; gap: 6px; }

/* Бейдж типа склада у остатка (TASK_66) */
.stock-wt { font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-3); background: #F1F4F9; border-radius: 5px; padding: 1px 5px; }

/* Прибыль */
.sp-profit { display: flex; align-items: center; gap: 13px; padding: 15px 16px; border-radius: 13px; background: var(--green-weak); border: 1px solid #BFE6D5; }
.sp-profit-ic { width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--green); color: #fff; }
.sp-profit .big { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; color: var(--green); }

.sp-drr { display: flex; gap: 8px; flex-wrap: wrap; }
.sp-drr .chip { background: #F1F4F9; border-color: transparent; }

.sp-actions { display: flex; flex-direction: column; gap: 9px; }
.sp-actions .btn { justify-content: center; height: 40px; }

@media (max-width: 480px) {
  .side-panel { width: 100%; max-width: 100%; }
}

/* ============ "Скоро" badge на кнопках ============ */
.coming-wrap { position: relative; display: inline-flex; }
.coming-wrap .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.coming-badge {
  position: absolute; top: -7px; right: -6px; z-index: 2;
  background: var(--text-3); color: #fff; font-size: 9px; font-weight: 600;
  padding: 1px 5px; border-radius: 6px; letter-spacing: 0.02em; pointer-events: none; white-space: nowrap;
}

/* ============ Promo offers panel ============ */
.promo-offers-panel { display: flex; flex-direction: column; }
.promo-offers-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.promo-offers-list { max-height: 520px; overflow-y: auto; }

/* ============ Messages (Сообщения) ============ */
.messages-page { padding-bottom: 0; }
.messages-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - 160px);
  border: 1px solid var(--border);
  border-radius: var(--radius, 10px);
  background: var(--surface);
  overflow: hidden;
}

/* Список чатов — левая колонка */
.messages-list-col {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-list {
  flex: 1;
  overflow-y: auto;
}
.chat-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  text-align: center;
}
.chat-list-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.chat-list-item:hover { background: var(--bg); }
.chat-list-item.active { background: var(--accent-weak); border-left: 3px solid var(--accent); }
.chat-list-item.waiting { border-left: 3px solid var(--rose); }
.chat-list-item.active.waiting { border-left: 3px solid var(--accent); background: var(--accent-weak); }

.chat-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.chat-customer-name { font-size: 13px; font-weight: 600; color: var(--text); }
.chat-customer-name-lg { font-size: 15px; font-weight: 600; color: var(--text); }
.chat-list-time { font-size: 11px; color: var(--text-3); flex-shrink: 0; margin-left: 8px; }
.chat-list-preview { margin-bottom: 4px; }
.chat-preview-text { font-size: 12px; color: var(--text-2); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.chat-context-badge { font-size: 10px; color: var(--text-3); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.chat-order-ref { font-size: 11px; color: var(--text-3); margin-left: 6px; }

/* Правая панель — переписка */
.messages-chat-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}
.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.desktop-placeholder {}

.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.chat-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-panel-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.chat-panel-meta { display: flex; gap: 6px; align-items: center; }

/* Область сообщений */
.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-loading { display: flex; justify-content: center; padding: 20px; }
.chat-empty { color: var(--text-3); font-size: 13px; text-align: center; margin-top: 20px; }
.chat-load-more { text-align: center; margin-bottom: 8px; }

/* Пузыри сообщений */
.msg-bubble-row {
  display: flex;
}
.msg-bubble-row.partner { justify-content: flex-end; }
.msg-bubble-row.customer { justify-content: flex-start; }
.msg-bubble {
  max-width: 72%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}
.msg-bubble.partner {
  background: var(--accent);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}
.msg-bubble.customer {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px 14px 14px 4px;
}
.msg-text { word-break: break-word; white-space: pre-wrap; }
.msg-meta { display: flex; justify-content: flex-end; margin-top: 4px; }
.msg-time { font-size: 10px; opacity: 0.7; }

/* Системные сообщения */
.msg-system {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  padding: 4px 12px;
  background: var(--bg);
  border-radius: 8px;
  align-self: center;
  max-width: 80%;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.msg-system-label { font-weight: 600; }
.msg-system-text { }

/* Вложения */
.msg-attachment-img-link { display: block; margin-top: 6px; }
.msg-attachment-img { max-width: 220px; max-height: 180px; border-radius: 8px; object-fit: cover; }
.msg-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 3px 8px;
  margin-top: 6px;
}
.msg-att-size { color: var(--text-3); }

/* AI-черновик */
.ai-draft-block {
  border-top: 1px solid var(--border);
  background: var(--accent-weak);
  padding: 10px 14px;
  flex-shrink: 0;
}
.ai-draft-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.ai-draft-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.ai-draft-generating { display: flex; align-items: center; }
.ai-draft-empty { display: flex; align-items: center; gap: 6px; }
.ai-draft-body {}
.ai-draft-text {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  line-height: 1.5;
}
.ai-draft-textarea {
  width: 100%;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}
.ai-draft-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Поле ввода */
.chat-compose {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  flex-shrink: 0;
  background: var(--surface);
}
.chat-compose-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 8px;
  outline: none;
  box-sizing: border-box;
}
.chat-compose-input:focus { border-color: var(--accent); background: var(--surface); }
.chat-compose-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Мобильная кнопка назад */
.mobile-back-btn { display: none; }

/* ============ Мобильный адаптив ============ */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr !important; }

  /* Sidebar → нижняя навигация */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    height: 60px; width: 100%; flex-direction: row;
    border-right: none; border-top: 1px solid var(--border);
    background: rgba(255,255,255,0.96); backdrop-filter: blur(8px); z-index: 50;
  }
  .sb-brand, .sb-foot, .sb-section-label { display: none !important; }
  .sb-scroll { flex: 1; display: flex; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 4px 6px; gap: 2px; }
  .nav-item { flex-direction: column; gap: 3px; padding: 6px 12px; min-width: 64px; justify-content: center; flex: none; }
  .nav-label { font-size: 10px; text-align: center; }
  .nav-badge, .nav-badge.live { position: absolute; top: 2px; right: 10px; transform: scale(0.8); }

  /* контент не прячется под нижней навигацией */
  .scroll { padding-bottom: 76px; }
  .agent-screen { padding-bottom: 60px; }
  .page { padding: 18px 16px 76px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* таблицы скроллятся по горизонтали (перекрываем inline overflow:hidden) */
  .card { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 600px; }

  /* топбар: скрыть глобальный поиск, сжать */
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .tb-search { display: none; }
  .store-select { padding: 0 8px; }
  .store-select .ss-meta { display: none; }

  /* дашборд: метрики 2 колонки, скрыть правую колонку */
  .dash-metrics { grid-template-columns: repeat(2, 1fr) !important; }
  .dash-grid { grid-template-columns: 1fr !important; }
  .dash-side { display: none !important; }

  /* Messages — стек вместо сетки */
  .messages-layout {
    grid-template-columns: 1fr;
    height: auto;
    border-radius: 8px;
  }
  .messages-list-col { border-right: none; border-bottom: 1px solid var(--border); max-height: 45vh; }
  .messages-chat-col { min-height: 50vh; }
  .mobile-hidden { display: none !important; }
  .mobile-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--accent);
    cursor: pointer;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
  }
}

@media (max-width: 480px) {
  .dash-metrics { gap: 10px !important; }
  /* модалки — bottom sheet */
  .modal-overlay { align-items: flex-end; }
  .modal { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
}

/* ===== Готовность магазина к расчёту цен (TASK_72) ===== */
.sr-block { padding: 10px 16px 14px 32px; background: var(--bg); border-top: 1px dashed var(--border); }
.sr-status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 8px; margin-bottom: 9px; }
.sr-status.ok { background: var(--green-weak); color: var(--green); }
.sr-status.warn { background: var(--amber-weak); color: var(--amber); }
.sr-lines { display: flex; flex-direction: column; gap: 2px; }
.sr-line { display: flex; align-items: center; gap: 9px; padding: 4px 0; }
