/* ============================================================================
   MarketFlow — design system
   Minimal operational SaaS. Light + dark via semantic tokens.
   Single source of truth: everything below is token-driven so dark mode is
   automatic. No per-component hardcoded colors.
   ============================================================================ */

/* ---------- Fonts ---------- */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

/* ---------- Tokens: light (default) ---------- */
:root {
  color-scheme: light;

  /* surfaces */
  --bg: #f5f7fb;
  --bg-tint-a: rgba(47, 107, 255, 0.05);
  --bg-tint-b: rgba(16, 185, 129, 0.045);
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --surface-inset: #f3f6fb;
  --elevated: #ffffff;

  /* text */
  --text: #0f172a;
  --text-2: #475569;
  --text-muted: #687385;
  --text-faint: #94a3b8;
  --on-primary: #ffffff;

  /* lines */
  --border: #e6eaf1;
  --border-2: #dde3ec;
  --border-strong: #cbd3e0;

  /* brand + semantic */
  --primary: #2f6bff;
  --primary-hover: #1f57e6;
  --primary-press: #1a4ccc;
  --primary-soft: #eaf1ff;
  --primary-soft-border: #cfe0ff;
  --accent: #b9740a;

  --success: #0f8a52;
  --success-soft: #e7f6ee;
  --success-border: #b9e6cd;
  --warn: #9a6608;
  --warn-soft: #fbf2dd;
  --warn-border: #f0dca6;
  --danger: #cf3a3a;
  --danger-hover: #b62f2f;
  --danger-soft: #fdecec;
  --danger-border: #f4c9c9;

  --ring: rgba(47, 107, 255, 0.32);

  /* elevation */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.16);

  /* radii */
  --r-xs: 7px;
  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, monospace;

  --z-sticky: 30;
  --z-nav: 40;
  --z-modal: 100;
}

/* ---------- Tokens: dark ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0e16;
  --bg-tint-a: rgba(75, 134, 255, 0.10);
  --bg-tint-b: rgba(45, 212, 191, 0.06);
  --surface: #121826;
  --surface-2: #0f1420;
  --surface-3: #1b2332;
  --surface-inset: #0d121d;
  --elevated: #161d2c;

  --text: #e8edf6;
  --text-2: #aab6c8;
  --text-muted: #8593a8;
  --text-faint: #5d6a80;
  --on-primary: #ffffff;

  --border: #232c3d;
  --border-2: #2a3447;
  --border-strong: #36425a;

  --primary: #5089ff;
  --primary-hover: #6a9bff;
  --primary-press: #7ba8ff;
  --primary-soft: rgba(80, 137, 255, 0.16);
  --primary-soft-border: rgba(80, 137, 255, 0.34);
  --accent: #f0a83c;

  --success: #41c98a;
  --success-soft: rgba(34, 197, 94, 0.14);
  --success-border: rgba(34, 197, 94, 0.30);
  --warn: #f0b84a;
  --warn-soft: rgba(245, 158, 11, 0.13);
  --warn-border: rgba(245, 158, 11, 0.28);
  --danger: #f5736e;
  --danger-hover: #ff8a85;
  --danger-soft: rgba(244, 63, 94, 0.14);
  --danger-border: rgba(244, 63, 94, 0.30);

  --ring: rgba(80, 137, 255, 0.42);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

/* ============================================================================
   Base
   ============================================================================ */
* {
  box-sizing: border-box;
}

/* the [hidden] attribute must always win over component display rules */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 8% -8%, var(--bg-tint-a), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, var(--bg-tint-b), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* legacy decorative blobs — retired in favor of token gradients */
.glow {
  display: none !important;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--text);
  letter-spacing: -0.02em;
  font-weight: 700;
}

h1 {
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 800;
}

h2 {
  font-size: clamp(17px, 1.5vw, 20px);
}

h3 {
  font-size: 16px;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

strong {
  font-weight: 700;
}

::selection {
  background: var(--primary-soft);
  color: var(--text);
}

/* number columns / metrics use tabular figures */
.metric strong,
.orders-row-title,
.orders-row-code,
.analytics-product-title,
td,
.code-pill,
.sales-num,
.sales-kpi strong,
.order-summary-item input {
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
   App layout
   ============================================================================ */
.app {
  position: relative;
  width: min(100%, 1640px);
  margin: 0 auto;
  padding: 18px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 12px;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}

.topbar h1 {
  line-height: 1.1;
}

.brand-kicker {
  margin: 0 0 1px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.market-switch {
  display: flex;
  gap: 6px;
}

.market-switch .chip[disabled] {
  display: none;
}

/* chips */
.chip {
  border: 1px solid var(--border-2);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip-active {
  border-color: var(--primary-soft-border);
  background: var(--primary-soft);
  color: var(--primary);
}

/* session card */
.session-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 8px 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.session-copy {
  display: grid;
  gap: 1px;
  line-height: 1.25;
}

.session-copy strong {
  font-size: 13px;
}

.session-kicker {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.session-roles {
  font-size: 12px;
  color: var(--text-muted);
}

/* theme toggle */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ============================================================================
   Workspace: sidebar + content
   ============================================================================ */
.workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.sidebar::before {
  content: "Рабочие зоны";
  padding: 4px 10px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--text-faint);
  transition: color 0.15s ease;
}

.nav-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.nav-btn:hover svg {
  color: var(--text-2);
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.nav-btn.active svg {
  color: var(--primary);
}

.sidebar-status {
  margin-top: 8px;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.content {
  min-width: 0;
}

/* ---------- Tabs ---------- */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: rise 0.22s ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================================
   Surfaces: panels, cards, sections
   ============================================================================ */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.panel-lite {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.section {
  display: grid;
  gap: 18px;
  padding: clamp(16px, 2vw, 22px);
}

.section-head h2 {
  margin: 0;
}

.section-head p,
.subhead {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  max-width: 760px;
}

.compact-head h2 {
  font-size: 17px;
}

.compact-head p {
  font-size: 12.5px;
}

/* ---------- Metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 92px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.metric span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metric strong {
  font-size: clamp(19px, 1.6vw, 24px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* ============================================================================
   Controls: buttons, inputs, fields
   ============================================================================ */
.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field.small {
  width: 150px;
}

.field.grow {
  flex: 1;
  min-width: 180px;
}

.field-wide {
  grid-column: span 2;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

input,
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--border-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

input[readonly],
textarea[readonly] {
  background: var(--surface-2);
  color: var(--text-2);
  cursor: default;
}

input[type="checkbox"] {
  width: auto;
  padding: 0;
  border: 0;
  box-shadow: none;
  accent-color: var(--primary);
}

input[type="date"],
input[type="number"] {
  font-variant-numeric: tabular-nums;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 500;
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease, transform 0.1s ease;
}

.btn:hover:enabled {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.btn:active:enabled {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  color: var(--on-primary);
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 28%, transparent);
}

.btn-primary:hover:enabled {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.btn-danger:hover:enabled {
  color: var(--on-primary);
  background: var(--danger);
  border-color: var(--danger);
}

.small-btn,
.btn.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12.5px;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ============================================================================
   Tables
   ============================================================================ */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 13px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 13px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.13s ease;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================================
   Tags & status pills
   ============================================================================ */
.tag,
.status-pill,
.code-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-2);
}

.tag-ok,
.status-pill.status-good {
  color: var(--success);
  background: var(--success-soft);
  border-color: var(--success-border);
}

.tag-warn,
.status-pill.status-warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: var(--warn-border);
}

.status-pill.status-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.code-pill {
  font-family: var(--font-mono);
  color: var(--primary);
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
}

/* ============================================================================
   Disclosure (details / advanced panels)
   ============================================================================ */
.advanced-panel,
details.panel-lite {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  overflow: hidden;
}

.advanced-panel > summary,
details.panel-lite > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  user-select: none;
}

.advanced-panel > summary::-webkit-details-marker,
details.panel-lite > summary::-webkit-details-marker {
  display: none;
}

.advanced-panel > summary,
details.panel-lite > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.advanced-panel > summary:hover,
details.panel-lite > summary:hover {
  background: var(--surface-3);
  color: var(--text);
}

.advanced-panel > summary::after,
details.panel-lite > summary::after {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.advanced-panel[open] > summary::after,
details.panel-lite[open] > summary::after {
  transform: rotate(-135deg);
}

.advanced-panel-body {
  padding: 4px 14px 14px;
}

/* ============================================================================
   Modals / detail panels (orders, etc.)
   ============================================================================ */
.modal-shell {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, 0.55);
  backdrop-filter: blur(3px);
}

.modal-dialog {
  position: relative;
  width: min(100%, 920px);
  max-height: 90dvh;
  display: flex;
}

.modal-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 90dvh;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--elevated);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-scroll {
  padding: 18px;
  overflow: auto;
}

/* ============================================================================
   ORDERS
   ============================================================================ */
.orders-section {
  gap: 16px;
}

.orders-page-head,
.analytics-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.orders-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.orders-searchbar .field input {
  min-height: 44px;
  font-size: 14px;
}

.orders-board {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.orders-queue {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.orders-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.orders-list-head strong {
  font-size: 15px;
}

.orders-list-hint {
  color: var(--text-muted);
  font-size: 12px;
  text-align: right;
  max-width: 260px;
}

/* queue rendered as stacked cards (table-stack) */
.orders-table-modern {
  width: 100%;
}

.orders-table-modern thead {
  display: none;
}

.orders-table-modern tbody {
  display: grid;
  gap: 10px;
}

.orders-table-modern tr {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.1s ease;
}

.orders-table-modern tr:hover {
  border-color: var(--primary-soft-border);
  box-shadow: var(--shadow-sm);
}

.orders-table-modern td {
  border: 0;
  padding: 0;
}

.orders-row-active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--ring) !important;
}

.orders-row-title {
  font-size: 14px;
  font-weight: 700;
}

.orders-row-meta,
.orders-row-code,
.analytics-row-meta {
  color: var(--text-muted);
  font-size: 12.5px;
}

.orders-row-critical .orders-row-title {
  color: var(--danger);
}

.open-order-btn {
  width: 100%;
  justify-content: center;
}

/* order detail: inline master-detail (not an overlay) */
.orders-board:has(#orderModal:not([hidden])) {
  grid-template-columns: minmax(0, 1fr) minmax(400px, 1.05fr);
  align-items: start;
}

.orders-detail-panel {
  position: static;
  display: block;
  inset: auto;
  padding: 0;
  z-index: auto;
}

.orders-detail-panel .modal-backdrop {
  display: none;
}

.orders-detail-panel .modal-dialog {
  width: 100%;
  max-height: none;
  display: block;
}

.orders-detail-panel .modal-panel {
  position: sticky;
  top: 92px;
  max-height: calc(100dvh - 108px);
  background: var(--surface-2);
}

@media (max-width: 1040px) {
  .orders-board:has(#orderModal:not([hidden])) {
    grid-template-columns: 1fr;
  }

  .orders-detail-panel .modal-panel {
    position: static;
    max-height: none;
  }
}

.order-detail-view {
  display: grid;
  gap: 14px;
}

.order-detail-hero,
.order-action-card,
.order-chat-card,
.order-details-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 16px;
}

.order-action-card {
  border-color: var(--primary-soft-border);
}

.order-detail-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.order-detail-summary,
.order-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.order-summary-item {
  display: grid;
  gap: 5px;
}

.order-summary-item span,
.order-message-field span,
.order-chat-status-field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.order-summary-product {
  grid-column: 1 / -1;
}

.order-card-head,
.order-card-head-between {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.order-card-head-between {
  justify-content: space-between;
}

.order-card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.order-step {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 800;
}

.order-message-field,
.order-chat-status-field {
  display: grid;
  gap: 6px;
}

#selectedOrderCodeMessageInput {
  min-height: 260px;
  font-size: 14px;
  line-height: 1.55;
}

.order-submit-btn {
  min-height: 48px;
  font-size: 15px;
  width: 100%;
}

.order-primary-actions {
  display: grid;
  gap: 10px;
}

.order-workflow-hint,
.orders-quick-guide {
  color: var(--text-muted);
  font-size: 12.5px;
}

.order-items-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

/* ============================================================================
   ANALYTICS
   ============================================================================ */
.analytics-section {
  gap: 16px;
}

.analytics-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.analytics-hint {
  padding: 12px 14px;
  border: 1px solid var(--primary-soft-border);
  border-radius: var(--r-md);
  background: var(--primary-soft);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.5;
}

.analytics-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.analytics-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.analytics-table-wrap,
.analytics-products-wrap {
  max-height: 70dvh;
  overflow: auto;
  border-radius: var(--r-sm);
}

.analytics-product-title {
  font-weight: 700;
  color: var(--text);
}

.analytics-money-input {
  width: 116px;
  padding: 6px 9px;
  font-size: 12.5px;
  background: var(--surface-2);
}

.analytics-profit-positive {
  color: var(--success);
  font-weight: 700;
}

.analytics-profit-negative {
  color: var(--danger);
  font-weight: 700;
}

.analytics-metric-wide {
  grid-column: span 2;
}

/* ============================================================================
   CHATS
   ============================================================================ */
.chat-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.chat-list-panel,
.chat-detail-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.chat-list {
  display: grid;
  gap: 8px;
  max-height: 72dvh;
  overflow: auto;
}

.chat-list-item {
  display: grid;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.chat-list-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.chat-list-item-active {
  border-color: var(--primary) !important;
  background: var(--primary-soft) !important;
}

.chat-list-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-list-item-top strong {
  font-size: 13px;
}

.chat-list-item-customer {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.chat-list-item-context,
.chat-list-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-list-item-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* history container — generous, scrollable (fixes "cut off" clipping) */
.chat-history {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 240px;
  max-height: min(72dvh, 720px);
  overflow-y: auto;
  padding: 4px;
}

.order-chat-history {
  max-height: min(48dvh, 460px);
}

.chat-message {
  max-width: min(90%, 720px);
  display: grid;
  gap: 7px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.chat-message-service {
  background: var(--surface-2);
  justify-self: start;
}

.chat-message-customer {
  justify-self: start;
  border-color: var(--border);
}

.chat-message-partner,
.chat-message-self {
  justify-self: end;
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
}

.chat-message-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.chat-message-meta strong {
  font-size: 12px;
  color: var(--text-2);
}

.chat-message-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* attachments — inline images + file chips */
.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-attachment-image {
  display: block;
  max-width: 220px;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.chat-attachment-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: cover;
}

.chat-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* full-height conversation: the message history fills available space */
#tab-chats .metrics {
  display: none;
}

.chat-layout {
  align-items: stretch;
  min-height: calc(100dvh - 230px);
}

.chat-list {
  max-height: none;
  flex: 1;
  min-height: 0;
}

.chat-list-panel {
  display: flex;
  flex-direction: column;
}

.chat-detail-panel {
  display: flex;
  flex-direction: column;
}

.chat-detail-panel .chat-history {
  flex: 1;
  min-height: 200px;
  max-height: none;
}

.chat-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.chat-summary-wide {
  grid-column: 1 / -1;
}

.chat-lookup-panel {
  display: grid;
  gap: 10px;
}

/* ============================================================================
   SALES / ECONOMICS  (new section)
   ============================================================================ */
.sales-section {
  gap: 16px;
}

.sales-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.sales-kpi {
  display: grid;
  gap: 6px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.sales-kpi span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sales-kpi strong {
  font-size: clamp(18px, 1.5vw, 23px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sales-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.sales-board.has-detail {
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
}

.sales-list-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.sales-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sales-list {
  display: grid;
  gap: 9px;
  max-height: 72dvh;
  overflow: auto;
  padding: 2px;
}

.sales-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.sales-row:hover {
  border-color: var(--primary-soft-border);
  box-shadow: var(--shadow-sm);
}

.sales-row-active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--ring) !important;
}

.sales-row-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.sales-row-meta {
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: var(--text-muted);
}

.sales-row-figures {
  display: grid;
  justify-items: end;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.sales-row-revenue {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.sales-row-profit {
  font-size: 12.5px;
  font-weight: 700;
}

.sales-profit-positive {
  color: var(--success);
}

.sales-profit-negative {
  color: var(--danger);
}

/* detail */
.sales-detail-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  position: sticky;
  top: 92px;
}

.sales-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sales-detail-econ {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sales-econ-cell {
  display: grid;
  gap: 3px;
}

.sales-econ-cell span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sales-econ-cell strong {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sales-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.sales-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sales-group-head h4 {
  font-size: 13px;
  font-weight: 700;
}

.sales-line {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.sales-line-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sales-line-row input {
  background: var(--surface);
}

.sales-line .sales-amount {
  width: 120px;
  flex: 0 0 auto;
}

.sales-line-remove {
  flex: 0 0 auto;
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--danger);
}

.sales-empty-line {
  color: var(--text-muted);
  font-size: 12.5px;
  padding: 4px 2px;
}

.sales-detail-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.sales-placeholder {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 260px;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.sales-placeholder svg {
  width: 34px;
  height: 34px;
  color: var(--text-faint);
}

/* ============================================================================
   PRODUCTS / CATEGORIES / misc feature blocks
   ============================================================================ */
.product-form,
.product-advanced-grid,
.product-editor-details,
.category-grid,
.vault-layout,
.vault-editor-grid,
.delivery-workspace,
.digital-layout,
.price-tools {
  display: grid;
  gap: 14px;
}

.product-advanced-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.category-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}

.category-tree-wrap {
  max-height: 60dvh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: 8px;
}

.category-tree {
  display: grid;
  gap: 2px;
}

.category-btn,
.category-node {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.category-btn:hover,
.category-node:hover {
  background: var(--surface-3);
  color: var(--text);
}

.category-selected {
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
  border-color: var(--primary-soft-border) !important;
  font-weight: 600;
}

.leaf-mark {
  color: var(--text-faint);
  font-size: 11px;
}

.advanced-panel-body .product-template-panel,
.product-global-template-details,
.product-template-panel {
  display: grid;
  gap: 12px;
}

/* photos */
.photo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.photo-item {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-photo-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(8, 12, 20, 0.7);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}

/* draft action buttons */
.edit-draft,
.delete-draft,
.push-draft,
.edit-market,
.select-store-btn {
  font-size: 12.5px;
}

/* vault list */
.vault-list-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.vault-list-title {
  font-weight: 700;
}

.vault-list-meta,
.vault-list-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.order-code-message {
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.order-code-substatus {
  font-size: 12px;
  color: var(--text-muted);
}

.cards-health,
.details-summary,
.details-body {
  display: grid;
  gap: 10px;
}

/* ============================================================================
   Marketplace switcher (YM / WB) + per-marketplace visibility
   ============================================================================ */
.mp-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.mp-pill {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.mp-pill:hover {
  color: var(--text);
}

.mp-pill-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

#mpWb.mp-pill-active {
  color: #8b3bd6;
}

:root[data-theme="dark"] #mpWb.mp-pill-active {
  color: #c084fc;
}

/* show only the active marketplace's nav, tabs and header bits */
:root:not([data-marketplace="wb"]) [data-mp="wb"] {
  display: none !important;
}

:root[data-marketplace="wb"] [data-mp="ym"] {
  display: none !important;
}

.cabinet-static {
  cursor: default;
}

.cabinet-static #wbSellerLabel {
  font-weight: 700;
  color: var(--text);
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* WB price/feedback helpers reuse table + list components */
.wb-num {
  font-variant-numeric: tabular-nums;
}

.wb-price-old {
  color: var(--text-faint);
  text-decoration: line-through;
}

.wb-price-final {
  font-weight: 700;
  color: var(--success);
}

.wb-discount {
  color: var(--accent);
  font-weight: 700;
}

.wb-rating {
  font-weight: 700;
}

.wb-rating-low {
  color: var(--danger);
}

.wb-rating-high {
  color: var(--success);
}

.wb-fb-item {
  display: grid;
  gap: 6px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.wb-fb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wb-fb-product {
  font-size: 12.5px;
  color: var(--text-muted);
}

.wb-fb-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
}

.wb-fb-answer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 2px;
}

.wb-fb-answer textarea {
  flex: 1;
  min-height: 38px;
}

.wb-price-input {
  width: 110px;
  padding: 6px 9px;
  font-variant-numeric: tabular-nums;
}

.wb-price-input-sm {
  width: 64px;
}

/* ============================================================================
   Header cabinet picker + session
   ============================================================================ */
.cabinet-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
}

.cabinet-picker svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.cabinet-picker select {
  border: 0;
  background: transparent;
  padding: 0;
  min-width: 150px;
  max-width: 240px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.cabinet-picker select:focus {
  box-shadow: none;
}

.session-panel {
  gap: 10px;
  padding: 6px 8px 6px 12px;
}

.session-user {
  font-size: 13px;
  font-weight: 700;
}

/* ============================================================================
   Sidebar: grouped nav + Каталог disclosure
   ============================================================================ */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-catalog {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

.nav-catalog > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  user-select: none;
}

.nav-catalog > summary::-webkit-details-marker {
  display: none;
}

.nav-catalog-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.nav-catalog[open] .nav-catalog-chevron {
  transform: rotate(180deg);
}

/* ============================================================================
   Shared page header pattern
   ============================================================================ */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

/* the active cabinet now lives in the header — hide the per-screen copies */
.field:has(> #ordersStoreInput),
.field:has(> #analyticsStoreInput),
.field:has(> #salesStoreInput),
.field:has(> #orderCodesStoreInput),
.field:has(> #chatsStoreInput),
.field:has(> #activeStoreInput) {
  display: none;
}

/* ============================================================================
   Dashboard (Обзор)
   ============================================================================ */
.overview-section {
  gap: 18px;
}

.overview-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.metric-accent {
  border-color: var(--primary-soft-border);
  background: var(--primary-soft);
}

.metric-accent strong {
  color: var(--primary);
}

.metric-warn {
  border-color: var(--warn-border);
  background: var(--warn-soft);
}

.metric-warn strong {
  color: var(--warn);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

.overview-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.overview-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.overview-panel-head h3 {
  font-size: 14px;
}

.overview-list {
  display: grid;
  gap: 8px;
  max-height: 56dvh;
  overflow: auto;
}

.overview-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.overview-item:hover {
  border-color: var(--primary-soft-border);
  background: var(--surface-2);
}

.overview-item-title {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.overview-item-meta {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-muted);
}

.overview-item-figure {
  display: grid;
  justify-items: end;
  gap: 1px;
  font-variant-numeric: tabular-nums;
}

.overview-item-revenue {
  font-size: 13px;
  font-weight: 700;
}

.overview-item-profit {
  font-size: 12px;
  font-weight: 700;
}

/* ============================================================================
   Accessibility: focus
   ============================================================================ */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.nav-btn:focus-visible,
.btn:focus-visible,
.chip:focus-visible,
.theme-toggle:focus-visible,
.sales-row:focus-visible,
.chat-list-item:focus-visible {
  outline-offset: 3px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
   Auth screen (login)
   ============================================================================ */
.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 400px);
  display: grid;
  gap: 16px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-copy {
  display: grid;
  gap: 4px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-status {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface-2);
}

.auth-status.is-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.auth-status.is-success {
  color: var(--success);
  background: var(--success-soft);
  border-color: var(--success-border);
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 8px;
    z-index: var(--z-nav);
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
  }

  .sidebar::before {
    display: none;
  }

  .nav-btn {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .sidebar-status {
    display: none;
  }

  .analytics-layout,
  .chat-layout,
  .sales-board.has-detail {
    grid-template-columns: 1fr;
  }

  .sales-detail-panel {
    position: static;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 11px;
  }

  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .topbar-meta {
    justify-content: space-between;
  }

  .session-panel {
    flex: 1;
  }

  .section {
    padding: 15px;
  }

  .orders-page-head,
  .analytics-page-head,
  .orders-head-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .orders-head-actions .btn,
  .analytics-page-head .btn {
    width: 100%;
  }

  .order-detail-summary,
  .order-details-grid,
  .sales-detail-econ {
    grid-template-columns: 1fr;
  }

  .sales-detail-econ {
    grid-template-columns: repeat(3, 1fr);
  }

  .chat-message {
    max-width: 100%;
  }

  .modal-shell {
    padding: 0;
  }

  .modal-dialog {
    max-height: 100dvh;
  }

  .modal-panel {
    border-radius: 0;
    max-height: 100dvh;
  }
}

/* ===================== Publish (cross-marketplace publishing) ===================== */
/* Reuses existing tokens/classes (panel-lite, sales-board, field, btn, tag…).
   These few rules cover only what the publish editor adds. */
.publish-target {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}
.publish-target label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.publish-charc {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.publish-charc > * {
  flex: 1 1 160px;
}
.publish-charcs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.publish-wb-results {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.publish-results {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
}
.publish-req {
  color: var(--danger, #d33);
  font-weight: 700;
}

/* ===================== Сводка (cross-marketplace summary) ===================== */
/* Reuses overview-kpis/overview-grid/overview-panel/metric; only the bars are new. */
.summary-grid {
  margin-bottom: 16px;
}
.summary-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.summary-bar-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 12px;
}
.summary-bar-label {
  font-size: 13px;
  color: var(--text-muted, #6b7280);
}
.summary-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--panel-2, rgba(127, 127, 127, 0.15));
  overflow: hidden;
}
.summary-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent, #4f7cff);
  transition: width 0.3s ease;
}
.summary-bar-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ============================================================================
   Прайс-лист (price list / minimum prices)
   ========================================================================== */
.pl-tag-wb {
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.12);
  border-color: rgba(124, 58, 237, 0.35);
}
.pl-tag-ym {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.35);
}
.pl-name {
  font-weight: 600;
}
.pl-id {
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.pl-min-input {
  width: 96px;
}
