/* ═══════════════════════════════════════════════════════════════════
   CRM — Premium Dark Theme
   Inspired by SalesDrive UI · Built with Vanilla CSS
═══════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand:        #4f8ef7;
  --brand-dark:   #2563eb;
  --brand-glow:   rgba(79, 142, 247, 0.25);

  /* Background layers */
  --bg-root:      #0f1117;
  --bg-sidebar:   #13161f;
  --bg-panel:     #181c27;
  --bg-card:      #1e2436;
  --bg-hover:     #242a3a;
  --bg-input:     #1a1f2e;

  /* Borders */
  --border:       rgba(255,255,255,0.07);
  --border-focus: rgba(79, 142, 247, 0.6);

  /* Text */
  --text-primary:   #e8ecf5;
  --text-secondary: #8892a9;
  --text-muted:     #505870;
  --text-link:      #60a5fa;

  /* Status colors */
  --status-new:       #f87171; /* soft red */
  --status-new-bg:    rgba(248, 113, 113, 0.08);
  --status-proc:      #fbbf24; /* soft yellow */
  --status-proc-bg:   rgba(251, 191, 36, 0.08);
  --status-toship:    #0ea5e9; /* sky blue */
  --status-toship-bg: rgba(14, 165, 233, 0.08);
  --status-ship:      #4ade80; /* soft green */
  --status-ship-bg:   rgba(74, 222, 128, 0.08);
  --status-delivered: #818cf8; /* soft indigo */
  --status-delivered-bg: rgba(129, 140, 248, 0.08);
  --status-issued:    #34d399; /* soft dark green */
  --status-issued-bg: rgba(52, 211, 153, 0.08);
  --status-done:      #ffffff; /* white */
  --status-done-bg:   rgba(255, 255, 255, 0.08);
  --status-refused:   #9ca3af; /* grey */
  --status-refused-bg: rgba(156, 163, 175, 0.08);
  --status-returned:  #c084fc; /* soft purple */
  --status-returned-bg: rgba(192, 132, 252, 0.08);
  --status-seccancel: #c084fc; /* soft purple */
  --status-seccancel-bg: rgba(192, 132, 252, 0.08);
  --status-deleted:   #4b5563; /* black/dark grey */
  --status-deleted-bg: rgba(75, 85, 99, 0.08);
  --status-cancel:    #ef4444;

  /* Source badge colors */
  --src-prom:     #8b5cf6;
  --src-rozetka:  #16a34a;
  --src-opencart: #0284c7;
  --src-maudau:   #9c27b0;
  --src-epicentr: #4caf50;
  --src-manual:   #607d8b;
  --src-olx:      #a16207;
  --src-bigl:     #c084fc;

  /* Spacing */
  --sidebar-w:    72px;
  --sidebar-w-sm: 48px;
  --topbar-h:     56px;

  /* Radius */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  16px;

  /* Transitions */
  --t-fast: 0.15s ease;
  --t-med:  0.25s ease;
}

/* ── Светлая тема ───────────────────────────────────────────────── */
[data-theme="light"] {
  --brand:        #2563eb;
  --brand-dark:   #1d4ed8;
  --brand-glow:   rgba(37, 99, 235, 0.15);

  --bg-root:      #f0f2f7;
  --bg-sidebar:   #ffffff;
  --bg-panel:     #ffffff;
  --bg-card:      #f8f9fc;
  --bg-hover:     #eef1f8;
  --bg-input:     #f4f6fb;

  --border:       rgba(0,0,0,0.08);
  --border-focus: rgba(37, 99, 235, 0.5);

  --text-primary:   #1a202c;
  --text-secondary: #4a5568;
  --text-muted:     #a0aec0;
  --text-link:      #2563eb;

  --status-new:       #f87171;
  --status-new-bg:    rgba(248, 113, 113, 0.15);
  --status-proc:      #fbbf24;
  --status-proc-bg:   rgba(251, 191, 36, 0.15);
  --status-toship:    #0ea5e9;
  --status-toship-bg: rgba(14, 165, 233, 0.15);
  --status-ship:      #4ade80;
  --status-ship-bg:   rgba(74, 222, 128, 0.15);
  --status-delivered: #818cf8;
  --status-delivered-bg: rgba(129, 140, 248, 0.15);
  --status-issued:    #34d399;
  --status-issued-bg: rgba(52, 211, 153, 0.15);
  --status-done:      #1a202c;
  --status-done-bg:   #ffffff;
  --status-refused:   #9ca3af;
  --status-refused-bg: rgba(156, 163, 175, 0.15);
  --status-returned:  #c084fc;
  --status-returned-bg: rgba(192, 132, 252, 0.15);
  --status-seccancel: #c084fc;
  --status-seccancel-bg: rgba(192, 132, 252, 0.15);
  --status-deleted:   #4b5563;
  --status-deleted-bg: rgba(75, 85, 99, 0.15);
}


/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}
a { color: var(--text-link); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 13px; }

/* Числовые поля — только ручной ввод, без стрелок spinner */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
::placeholder { color: var(--text-muted); }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-root); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/* ═══════════════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--t-med);
  position: relative;
  z-index: 100;
}

.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.logo-icon { font-size: 20px; flex-shrink: 0; line-height: 1; }
.logo-text {
  font-size: 10px;
  font-weight: 700;
  background: linear-gradient(135deg, #4f8ef7, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
  line-height: 1;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 2px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  transition: all var(--t-fast);
  text-align: center;
  line-height: 1.15;
}
.nav-item:hover  { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--brand-glow); color: var(--brand); border: 1px solid rgba(79, 142, 247, 0.2); }
.nav-icon  { font-size: 18px; flex-shrink: 0; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 500; max-width: 100%; word-break: break-word; hyphens: auto; }
.nav-separator { height: 1px; background: var(--border); margin: 8px 4px; }

.sidebar-footer {
  padding: 8px 4px;
  border-top: 1px solid var(--border);
}
.sidebar-sync {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.btn-sidebar-sync {
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  padding: 6px 2px;
  text-align: center;
  line-height: 1.15;
}
.btn-sidebar-sync .nav-icon {
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}
.nav-label-sync {
  font-size: 9px;
  font-weight: 500;
  max-width: 100%;
  word-break: break-word;
}
.btn-sidebar-sync-stop:not(:disabled) {
  color: var(--status-new);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-sidebar-sync-stop:not(:disabled):hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--status-cancel);
}
.btn-sidebar-sync.is-running {
  opacity: 0.7;
  cursor: wait;
}
.sidebar.collapsed .nav-label-sync { display: none; }
.sidebar.collapsed .btn-sidebar-sync { padding: 6px 2px; }

/* Collapsed sidebar */
.sidebar.collapsed { width: var(--sidebar-w-sm); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label { display: none; }

/* ═══════════════════════════════════════════════════════════════════
   MAIN WRAP
═══════════════════════════════════════════════════════════════════ */
.main-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  gap: 12px;
}
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.btn-theme-toggle {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: rotate(20deg);
}

.btn-sidebar-toggle {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
}
.btn-sidebar-toggle:hover { background: var(--brand-glow); color: var(--brand); }

.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px; }
.bc-sep { opacity: 0.4; }
.bc-active { color: var(--text-primary); font-weight: 500; }

.topbar-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
}
.stat-new   { background: var(--status-new-bg);    color: var(--status-new);    border-color: rgba(245,158,11,.2); }
.stat-proc  { background: var(--status-proc-bg);   color: var(--status-proc);   border-color: rgba(59,130,246,.2); }
.stat-done  { background: var(--status-done-bg);   color: var(--status-done);   border-color: rgba(34,197,94,.2); }
.stat-money { background: rgba(168,85,247,.12);    color: #c084fc;              border-color: rgba(168,85,247,.2); }

/* ── Action Bar ─────────────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.action-bar-left  { display: flex; gap: 8px; align-items: center; }
.action-bar-right { display: flex; gap: 8px; align-items: center; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  gap: 4px;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 0 var(--brand-glow);
}
.btn-primary:hover {
  background: var(--brand-dark);
  box-shadow: 0 0 14px var(--brand-glow);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: rgba(255,255,255,.15); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--status-cancel); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.25); }

/* ── Search ─────────────────────────────────────────────────────── */
.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 10px;
  gap: 6px;
  transition: border-color var(--t-fast);
}
.search-box:focus-within { border-color: var(--border-focus); }
.search-icon { color: var(--text-muted); font-size: 13px; }
.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  width: 260px;
  height: 34px;
}

/* ── Filter Bar ─────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 2px; }
.filter-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.filter-select, .filter-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  padding: 5px 8px;
  height: 30px;
  outline: none;
  transition: border-color var(--t-fast);
}
.filter-select:focus, .filter-input:focus { border-color: var(--border-focus); }
.filter-info { margin-left: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── Bulk Bar ───────────────────────────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(79, 142, 247, 0.08);
  border-bottom: 1px solid rgba(79, 142, 247, 0.2);
  flex-shrink: 0;
  animation: slideDown 0.2s ease;
}
.bulk-info { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.bulk-info strong { color: var(--brand); }
.bulk-select { min-width: 160px; max-width: 220px; font-size: 12px; height: 30px; }
.bulk-secondary { min-width: 140px; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════════════════════ */
.table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

/* ВЫНЕСЕНО В ОТДЕЛЬНЫЕ ФАЙЛЫ: tables.css, badges.css, orders-table.css */


/* ── Action buttons ─────────────────────────────────────────────── */
.row-actions { display: flex; gap: 4px; justify-content: center; }
.btn-row {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: all var(--t-fast);
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-row:hover { background: var(--bg-hover); color: var(--text-primary); transform: scale(1.1); }
.btn-row-edit:hover  { border-color: var(--brand); color: var(--brand); }
.btn-row-del:hover   { border-color: var(--status-cancel); color: var(--status-cancel); }

/* ── Loading / Empty ────────────────────────────────────────────── */
.loading-row, .empty-row {
  text-align: center;
  padding: 60px !important;
  color: var(--text-muted);
  font-size: 15px;
}
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════════
   PAGINATION
═══════════════════════════════════════════════════════════════════ */
.pagination-dock {
  flex-shrink: 0;
  width: 100%;
  height: 0;
  min-height: 0;
  overflow: visible;
  pointer-events: none;
}

.pagination-float {
  pointer-events: auto;
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 46;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-end;
}

.pagination-dock--collapsed:not(.pagination-dock--hover-open):not(.pagination-dock--pinned) .pagination-float {
  left: auto;
  width: auto;
  min-height: 0;
  background: transparent;
  border: none;
}

.pagination-dock--hover-open .pagination-float,
.pagination-dock--pinned .pagination-float {
  left: 0;
  width: 100%;
  min-height: 52px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}

.pagination-panel {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.28s ease, opacity 0.2s ease;
}

.pagination-dock--hover-open .pagination-panel,
.pagination-dock--pinned .pagination-panel {
  flex: 1;
  max-height: 52px;
  opacity: 1;
}

.pagination-dock--collapsed:not(.pagination-dock--hover-open):not(.pagination-dock--pinned) .pagination-panel {
  flex: 0 0 0;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.pagination-tab {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 72px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  transition: background var(--t-fast), color var(--t-fast);
}

.pagination-dock--hover-open .pagination-tab,
.pagination-dock--pinned .pagination-tab {
  height: 52px;
  border-radius: 0;
  border-bottom: none;
  border-top: none;
  border-left: 1px solid var(--border);
  border-right: none;
  box-shadow: none;
}

.pagination-tab:hover,
.pagination-dock--hover-open .pagination-tab,
.pagination-dock--pinned .pagination-tab {
  background: var(--brand-glow);
  color: var(--brand);
}

.pagination-dock--collapsed:not(.pagination-dock--hover-open):not(.pagination-dock--pinned) .pagination-tab-icon {
  transform: rotate(180deg);
}

.pagination-dock--hover-open .pagination-tab-icon,
.pagination-dock--pinned .pagination-tab-icon {
  transform: none;
}

.pagination-tab-icon {
  display: block;
  font-size: 11px;
  transition: transform var(--t-fast);
}

.pagination-tab-label {
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.pagination-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: var(--bg-panel);
  box-sizing: border-box;
  white-space: nowrap;
}

.bottom-bulk-container,
.pagination-buttons,
.pagination-info {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
  gap: 8px;
}

.pagination-buttons {
  gap: 4px;
}

.pagination-info {
  font-size: 12px;
  color: var(--text-secondary);
}

.pagination-info-text {
  white-space: nowrap;
}

.bottom-bulk-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.bottom-bulk-select,
.pagination-limit-select {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--t-fast);
  cursor: pointer;
}
.page-btn:hover    { background: var(--bg-hover); color: var(--text-primary); }
.page-btn.active   { background: var(--brand, #337ab7); border-color: var(--brand, #337ab7); color: #fff; }
.page-btn:disabled { opacity: .3; cursor: default; }

/* ═══════════════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 95%;
  max-width: 1400px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Page View Layout & Height Scroll Fixes */
.page-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

/* Light Theme Done Status — цвета из палитры (applyStatusColors), без жёсткого фона */
[data-theme="light"] .badge-done {
  color: var(--status-done);
  border-color: var(--status-done);
  background-color: var(--status-done-bg);
}
[data-theme="light"] .stat-done {
  color: var(--status-done);
  background-color: var(--status-done-bg);
  border-color: var(--status-done);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all var(--t-fast);
}
.modal-close:hover { background: rgba(239,68,68,.2); color: var(--status-cancel); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}
.form-section-full { grid-column: 1 / -1; }
.form-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 12px;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  padding: 7px 10px;
  outline: none;
  transition: border-color var(--t-fast);
  resize: vertical;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--brand-glow); }
.form-group select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23505870'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

/* ── Checkboxes ─────────────────────────────────────────────────── */
input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10050;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  min-width: 240px;
  max-width: 360px;
  animation: toastIn .25s ease;
  pointer-events: auto;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.toast-success {
  background: rgba(15, 35, 22, 0.94);
  border-color: rgba(34, 197, 94, 0.45);
  color: #bbf7d0;
  box-shadow: 0 10px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(34,197,94,.2);
}
.toast.toast-error {
  background: rgba(45, 15, 18, 0.94);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fecaca;
  box-shadow: 0 10px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(239,68,68,.25);
}
.toast.toast-info {
  background: rgba(15, 25, 45, 0.94);
  border-color: rgba(79, 142, 247, 0.45);
  color: #bfdbfe;
  box-shadow: 0 10px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(79,142,247,.2);
}
[data-theme="light"] .toast.toast-success {
  background: rgba(220, 252, 231, 0.95);
  border-color: rgba(22, 163, 74, 0.35);
  color: #14532d;
  box-shadow: 0 10px 40px rgba(0,0,0,.12), 0 0 0 1px rgba(22,163,74,.15);
}
[data-theme="light"] .toast.toast-error {
  background: rgba(254, 226, 226, 0.95);
  border-color: rgba(220, 38, 38, 0.35);
  color: #7f1d1d;
  box-shadow: 0 10px 40px rgba(0,0,0,.12), 0 0 0 1px rgba(220,38,38,.15);
}
[data-theme="light"] .toast.toast-info {
  background: rgba(219, 234, 254, 0.95);
  border-color: rgba(37, 99, 235, 0.35);
  color: #1e3a8a;
  box-shadow: 0 10px 40px rgba(0,0,0,.12), 0 0 0 1px rgba(37,99,235,.15);
}
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg  { flex: 1; color: inherit; }
.toast-close { color: inherit; opacity: .65; font-size: 12px; cursor: pointer; }
.toast-close:hover { opacity: 1; }
/* ═══════════════════════════════════════════════════════════════════
   CUSTOMER CARD (в форме заявки)
═══════════════════════════════════════════════════════════════════ */
.customer-card {
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-top: 8px;
  font-size: 12px;
  animation: toastIn .2s ease;
  border: 1px solid;
}
.customer-card.returning {
  background: rgba(79, 142, 247, 0.07);
  border-color: rgba(79, 142, 247, 0.25);
}
.customer-card.new-client {
  background: rgba(34, 197, 94, 0.07);
  border-color: rgba(34, 197, 94, 0.2);
}
.customer-card.blacklist {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.35);
}
.ccard-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ccard-icon { font-size: 18px; }
.ccard-title { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.ccard-tier {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,0.07);
}
.ccard-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.ccard-stat { display: flex; flex-direction: column; gap: 1px; }
.ccard-stat-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .4px; }
.ccard-stat-value { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.ccard-discount {
  margin-top: 8px;
  padding: 5px 10px;
  background: rgba(245,158,11,.12);
  border: 1px solid rgba(245,158,11,.2);
  border-radius: var(--r-sm);
  color: #f59e0b;
  font-size: 12px;
  font-weight: 600;
}
.ccard-recent {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.ccard-recent strong { color: var(--text-secondary); }

/* ── Resizable columns handle ───────────────────────────────────── */
.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 15;
  transition: background var(--t-fast);
}
.resize-handle:hover, .resize-handle:active {
  background: var(--brand);
}

/* ── Floating Column Filters ────────────────────────────────────── */
.th-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  width: 100%;
  overflow: hidden;
}
.th-content > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex-grow: 1;
  text-align: center;
}
.orders-table th, .orders-table thead th {
  overflow: visible !important; /* Allow floating dropdowns to escape the th */
}
.filter-toggle-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  font-size: 11px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.filter-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.filter-toggle-btn.active {
  color: var(--brand);
  background: var(--brand-glow);
  box-shadow: 0 0 5px var(--brand);
}

.filter-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  z-index: 1000;
  display: none;
  min-width: 160px;
  text-align: left;
}
.filter-dropdown.open {
  display: block;
}

.filter-input-field {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: border-color var(--t-fast);
}
.filter-input-field:focus {
  border-color: var(--border-focus);
}

.filter-range-group {
  margin-bottom: 6px;
}
.filter-range-group:last-child {
  margin-bottom: 0;
}
.filter-range-group label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 600;
}

.editable-cell {
  position: relative;
  cursor: pointer;
}
.editable-cell:hover {
  background: rgba(79, 142, 247, 0.08) !important;
}
.editable-cell::after {
  content: "✏️";
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
}
.editable-cell:hover::after {
  opacity: 0.6;
}

/* Inline editing form */
.inline-edit-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 4px;
  box-sizing: border-box;
}
.inline-edit-input {
  width: 100%;
  padding: 3px 5px;
  font-size: 11px;
  background: var(--bg-input);
  border: 1px solid var(--border-focus);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
}
.inline-edit-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.inline-comment-input {
  width: 100%;
  min-width: 180px;
  min-height: 1.6em;
  max-height: 50vh;
  padding: 4px 6px;
  font-size: 11px;
  line-height: 1.35;
  background: var(--bg-input);
  border: 1px solid var(--border-focus);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
  resize: none;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
td.col-comment.editing {
  position: relative;
  z-index: 25;
  overflow: visible;
  min-width: 200px;
  vertical-align: top;
  background: var(--bg-panel) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
td.col-comment.editing .inline-edit-form {
  min-width: 190px;
}
td.col-delivery-addr.editing {
  position: relative;
  z-index: 25;
  overflow: visible;
  min-width: 180px;
  vertical-align: top;
  background: var(--bg-panel) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
td.col-delivery-addr.editing .inline-edit-form {
  min-width: 170px;
}
td.col-delivery-cost.editing {
  position: relative;
  z-index: 25;
  overflow: visible;
  min-width: 90px;
  vertical-align: top;
  background: var(--bg-panel) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
td.col-delivery-cost.editing .inline-edit-input {
  text-align: right;
}
.btn-inline-action {
  padding: 1px 4px;
  font-size: 10px;
  border: none;
  background: var(--bg-card);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-primary);
}
.btn-inline-save {
  background: var(--brand-dark);
}
.phone-edit-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.btn-phone-del {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  padding: 2px;
}
.btn-phone-add {
  align-self: flex-start;
  padding: 1px 6px;
  font-size: 9px;
  border: 1px dashed var(--border);
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-secondary);
}

/* Extended Excel-style Pagination Container */
.pagination-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  align-items: flex-start;
  width: 100%;
}
.pagination-buttons {
  display: flex;
  gap: 4px;
}
.pagination-info {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.limit-select {
  padding: 3px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}
.pagination-actions {
  margin-top: 4px;
}
.pagination-actions .btn {
  background: #5cb85c;
  color: white;
  border: none;
}
.pagination-actions .btn:hover {
  background: #4cae4c;
}

/* ═══════════════════════════════════════════════════════════════════
   PRODUCT CARD (FULL SCREEN VIEW) STYLING
   ═══════════════════════════════════════════════════════════════════ */
#view-product-card {
  background: var(--bg-root);
  animation: fadeIn 0.25s ease-out;
}

.product-toolbar {
  border-bottom: 1px solid var(--border);
}

.product-card-grid {
  margin-top: 10px;
}

.product-fields-col label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.product-fields-col input,
.product-fields-col select,
.product-fields-col datalist {
  outline: none;
  transition: border-color var(--fast);
}

.product-fields-col input:focus,
.product-fields-col select:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 2px var(--brand-glow);
}

.history-list-wrap::-webkit-scrollbar {
  width: 4px;
}

.history-item {
  border: 1px solid var(--border);
  transition: transform 0.15s ease;
}

.history-item:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 142, 247, 0.2);
}

.product-link {
  color: var(--brand);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

.product-link:hover {
  color: var(--brand-dark);
}

.wysiwyg-toolbar button {
  border-radius: var(--r-sm);
  color: var(--text-secondary);
}

.wysiwyg-toolbar button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

/* ── Products Catalog Custom CSS ── */
.products-tabs .btn {
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
}

.products-tabs .btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.category-header-row:hover {
  background: var(--bg-hover) !important;
  opacity: 0.95;
}

.category-tree-row {
  background: rgba(79, 142, 247, 0.07);
  cursor: pointer;
  user-select: none;
}

.category-tree-row td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}

.tree-row-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tree-category-inner {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.tree-toggle {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.tree-toggle:hover {
  color: var(--brand);
}

.tree-folder-icon,
.tree-file-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.tree-category-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-category-count {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  flex-shrink: 0;
}

.tree-product-inner {
  min-width: 0;
}

.tree-connector {
  color: var(--text-muted);
  font-family: monospace;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  width: 12px;
}

.tree-muted {
  color: var(--text-muted);
}

.product-tree-row td {
  background: var(--bg-root);
}

.product-tree-row:hover td {
  background: rgba(79, 142, 247, 0.04);
}

.product-catalog-row:hover {
  background: rgba(79, 142, 247, 0.04) !important;
}

.product-catalog-row td {
  padding: 8px 10px;
}

#btnActiveProductsFilter.active,
#btnDeletedProductsFilter.active {
  font-weight: 600;
}

.products-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.products-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.products-toolbar-right {
  flex-shrink: 0;
}

.products-catalog-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.products-catalog-table-wrap .orders-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
}

/* Custom header select filter dropdowns */
.th-content.flex-column {
  flex-direction: column !important;
  align-items: stretch !important;
  overflow: visible !important;
  gap: 4px !important;
}

.custom-select-container {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: inherit;
  cursor: pointer;
  height: 26px;
  box-sizing: border-box;
}

.custom-select-trigger span.trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 90%;
}

.filter-dropdown-search {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 12px;
  margin-bottom: 8px;
  outline: none;
  box-sizing: border-box;
}

.filter-dropdown-search:focus {
  border-color: var(--brand);
}

.filter-dropdown-options {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.filter-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  user-select: none;
  transition: background 0.15s, color 0.15s;
  text-align: left;
}

.filter-dropdown-option:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-dropdown-option.selected {
  background: var(--brand-glow);
  color: var(--brand);
  font-weight: 500;
}

.filter-radio-circle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

.filter-dropdown-option.selected .filter-radio-circle {
  border-color: var(--brand);
}

.filter-radio-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  display: none;
}

.filter-dropdown-option.selected .filter-radio-dot {
  display: block;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  z-index: 1000;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.autocomplete-item:last-child {
  border-bottom: none;
}
.autocomplete-item:hover {
  background: var(--bg-hover);
}
.autocomplete-item-name {
  font-weight: 500;
  color: var(--text-primary);
}
.np-city-item {
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.np-city-name {
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}
.np-city-area {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}
.autocomplete-item-sku {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}
.autocomplete-item-price {
  font-weight: 600;
  color: var(--brand);
}
.item-row-input {
  width: 100%;
  background: transparent !important;
  border: none !important;
  color: var(--text-primary) !important;
  padding: 4px !important;
}
.item-row-input:focus {
  background: var(--bg-input) !important;
  border: 1px solid var(--border-focus) !important;
  box-shadow: none !important;
}

/* Phone action buttons in orders table */
.phone-line-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-bottom: 4px;
}
.phone-line-wrap:last-child {
  margin-bottom: 0;
}
.phone-num {
  font-size: 11px;
  white-space: nowrap;
}
.phone-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.phone-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  transition: all var(--t-fast);
}
.phone-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}
.phone-action-btn.btn-rcs {
  background: #38a5e4;
  border-color: #2794d3;
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
}
.phone-action-btn.btn-prom-chat {
  background: var(--src-prom);
  border-color: var(--src-prom);
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
}
.phone-action-btn.btn-prom-chat:hover {
  background: #d81b60;
  border-color: #d81b60;
  color: #fff;
  transform: scale(1.05);
}
.phone-action-btn.btn-rcs:hover {
  background: #2794d3;
  border-color: #2794d3;
  color: #fff;
  transform: scale(1.05);
}
.phone-action-btn.btn-rcs.btn-rcs-ok {
  background: #4caf50;
  border-color: #4caf50;
}
.phone-action-btn.btn-rcs:disabled {
  opacity: 0.6;
  cursor: wait;
}
.phone-action-btn.btn-viber:hover { color: #7360f2; }
.phone-action-btn.btn-telegram:hover { color: #29a9eb; }
.phone-action-btn.btn-sms:hover { color: #34c759; }
.phone-action-btn.btn-templates:hover { color: var(--brand); }

.phone-templates-popup {
  position: fixed;
  z-index: 2000;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  min-width: 220px;
  max-width: 320px;
  max-height: 360px;
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.phone-templates-popup.open {
  display: flex;
}
.phone-templates-popup-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.phone-templates-popup-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}
.phone-templates-popup-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.phone-templates-popup-item:hover {
  background: var(--bg-hover);
}
.phone-templates-popup-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.phone-templates-popup-footer a {
  font-size: 11px;
  color: var(--brand);
  text-decoration: none;
}
.phone-templates-popup-footer a:hover {
  text-decoration: underline;
}

/* Order items editor modal (orders table) */
.order-items-editor-modal {
  max-width: 1280px;
  width: 98%;
}
.order-items-editor-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.order-items-editor-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.order-items-editor-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.order-items-editor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.order-items-editor-table th,
.order-items-editor-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.order-items-editor-table thead th {
  background: var(--bg-card);
  font-weight: 600;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}
.order-items-editor-table .col-action {
  width: 28px;
  text-align: center;
}
.order-items-editor-table .col-name {
  min-width: 220px;
}
.order-items-editor-table .col-num {
  min-width: 76px;
  width: 76px;
  text-align: right;
  white-space: nowrap;
}
.order-items-editor-table .col-num-wide {
  min-width: 84px;
  width: 84px;
}
.order-items-editor-table .col-sum {
  background: rgba(51, 122, 183, 0.08);
}
.order-items-editor-table tfoot td {
  background: var(--bg-card);
  font-weight: 600;
}
.oie-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.oie-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.oie-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--bg-card);
}
.oie-name {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--text-primary);
  padding: 2px 0;
}
.oie-name-clickable {
  cursor: pointer;
  color: var(--brand);
  text-decoration: underline;
  text-decoration-style: dotted;
}
.btn-oie-open-product {
  border: none;
  background: none;
  color: var(--brand);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}
.btn-oie-open-product:hover {
  color: var(--text-link);
}
.oie-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  text-align: right;
}
.order-items-editor-table .oie-line-sum,
.order-items-editor-table .oie-line-cost,
.order-items-editor-table .oie-line-profit,
.order-items-editor-table tfoot .col-num {
  white-space: nowrap;
  padding-left: 6px;
  padding-right: 8px;
}
.oie-stock {
  color: var(--text-muted);
  text-align: center;
}
.btn-oie-delete,
.btn-oie-commit-draft,
.btn-oie-clear-draft {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
}
.btn-oie-delete { color: var(--status-cancel); }
.btn-oie-commit-draft { color: var(--status-done); }
.btn-oie-clear-draft { color: var(--status-cancel); }
.order-items-editor-add-row {
  display: grid;
  grid-template-columns: 28px minmax(160px, 1fr) 52px 76px 76px 68px 68px 40px 28px;
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.order-items-editor-search-wrap {
  position: relative;
  min-width: 0;
}
.order-items-editor-search {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  color: var(--text-primary);
}
.order-items-editor-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}
.oie-draft-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  text-align: right;
}
.oie-draft-stock {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-items-editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.order-items-editor-footer-actions {
  display: flex;
  gap: 8px;
}

.items-cell-wrap {
  position: relative;
  padding-bottom: 18px;
  min-height: 100%;
}
.items-cell-wrap .items-cell {
  padding-right: 0;
}
.btn-edit-order-items {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--brand);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.items-cell-wrap:hover .btn-edit-order-items {
  opacity: 1;
}
.btn-edit-order-items:hover {
  background: var(--brand-glow);
  border-color: var(--brand);
}

.chat-templates-section {
  min-width: 0;
}

/* ── Settings page layout ─────────────────────────────────────────── */
.settings-page-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1400px;
}
.settings-row--primary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 24px;
  align-items: start;
}
.settings-row--secondary {
  max-width: 1200px;
}
.settings-dictionaries-section {
  min-width: 0;
}
.settings-dict-items-list {
  max-height: min(70vh, 800px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
  background: rgba(0, 0, 0, 0.15);
  flex: 1;
  min-height: 200px;
}
@media (max-width: 960px) {
  .settings-row--primary {
    grid-template-columns: 1fr;
  }
}

.chat-templates-list {
  max-height: 600px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
  background: rgba(0, 0, 0, 0.15);
}
.chat-template-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.chat-template-add .btn {
  align-self: flex-start;
  padding: 8px 16px;
  font-size: 13px;
}
.chat-template-meta {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-template-meta .chat-tpl-name,
.chat-template-add input[type="text"] {
  flex: 1;
  min-width: 0;
}
.chat-template-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  gap: 12px;
}
.chat-template-item:last-child {
  margin-bottom: 0;
}
.chat-template-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.chat-template-fields input,
.chat-template-fields textarea,
.chat-template-add input,
.chat-template-add textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}
.chat-template-fields textarea,
.chat-template-add textarea {
  min-height: 96px;
  line-height: 1.45;
  resize: vertical;
}
.chat-template-sort {
  flex: 0 0 64px;
  width: 64px !important;
}

/* ── Dictionary items (settings) ─────────────────────────────────── */
.dict-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
}
.dict-item-reorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.dict-item-reorder .btn-dict-move-up,
.dict-item-reorder .btn-dict-move-down {
  padding: 0 6px;
  min-width: 28px;
  height: 22px;
  line-height: 1;
  font-size: 12px;
  color: var(--text-secondary);
}
.dict-item-reorder .btn-dict-move-up:disabled,
.dict-item-reorder .btn-dict-move-down:disabled {
  opacity: 0.25;
  cursor: default;
}
.dict-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.dict-item-id {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: monospace;
}
.dict-item-name-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  padding: 2px 0;
  width: 100%;
}
.dict-item-skip-payment-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.dict-item-skip-payment-label input {
  margin: 0;
  cursor: pointer;
}
.dict-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.dict-item-actions .btn-save-dict-item {
  color: var(--brand);
  padding: 4px 8px;
}
html.layout-top-menu body {
  flex-direction: column;
}

html.layout-top-menu .sidebar {
  width: 100%;
  min-height: var(--topbar-h);
  height: var(--topbar-h);
  border-right: none;
  border-bottom: 1px solid var(--border);
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  transition: none;
}

html.layout-top-menu .sidebar.collapsed {
  width: 100%;
}

html.layout-top-menu .sidebar.collapsed .logo-text,
html.layout-top-menu .sidebar.collapsed .nav-label,
html.layout-top-menu .sidebar.collapsed .nav-label-sync {
  display: inline !important;
}

html.layout-top-menu .sidebar-logo {
  height: 100%;
  border-bottom: none;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 8px;
}

html.layout-top-menu .logo-icon {
  font-size: 20px;
}

html.layout-top-menu .logo-text {
  font-size: 16px;
  font-weight: 700;
  display: inline !important;
}

html.layout-top-menu .sidebar-nav {
  flex: 1;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 0;
  overflow-y: visible;
  overflow-x: auto;
  margin-left: 24px;
  margin-right: 24px;
  height: 100%;
  scrollbar-width: none; /* Hide scrollbar for Firefox */
}

html.layout-top-menu .sidebar-nav::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome/Safari */
}

html.layout-top-menu .nav-item {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  height: 38px;
  text-align: left;
  white-space: nowrap;
}

html.layout-top-menu .nav-icon {
  font-size: 16px;
}

html.layout-top-menu .nav-label {
  font-size: 13px;
  font-weight: 500;
  display: inline !important;
}

html.layout-top-menu .nav-separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 8px;
}

html.layout-top-menu .sidebar-footer {
  border-top: none;
  padding: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  height: 100%;
}

html.layout-top-menu .sidebar-sync {
  flex-direction: row;
  gap: 8px;
  margin-bottom: 0;
  align-items: center;
}

html.layout-top-menu .btn-sidebar-sync {
  width: auto;
  flex-direction: row;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  height: 34px;
}

html.layout-top-menu .btn-sidebar-sync .nav-icon {
  font-size: 12px;
}

html.layout-top-menu .nav-label-sync {
  font-size: 11px;
  display: inline !important;
}

html.layout-top-menu .main-wrap {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: calc(100vh - var(--topbar-h));
}

html.layout-top-menu .page-view {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  max-height: 100%;
}

html.layout-top-menu .btn-sidebar-toggle {
  display: none !important;
}

/* ── Layout Toggle Button ────────────────────────────────────────── */
.btn-layout-toggle {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-layout-toggle:hover {
  background: var(--brand-glow);
  border-color: var(--brand);
  color: var(--brand);
}


/* ── Column Settings Dropdown ─────────────────────────────────────── */
.column-settings-container {
  position: relative;
  display: inline-block;
}

.column-settings-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: none;
  flex-direction: column;
  padding: 12px;
  color: var(--text-primary);
}

.column-settings-dropdown.open {
  display: flex;
}

.column-settings-header {
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.column-settings-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.column-settings-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 4px;
}

.column-settings-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-body);
  border: 1px solid var(--border);
  margin-bottom: 4px;
  cursor: grab;
  user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.column-settings-item:hover {
  background: var(--bg-hover);
  border-color: var(--brand-glow);
}

.column-settings-item.dragging {
  opacity: 0.5;
  border: 1px dashed var(--brand);
}

.column-settings-item-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  margin-right: 8px;
  font-size: 14px;
}

.column-settings-item input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
}

.column-settings-item span {
  font-size: 13px;
  flex-grow: 1;
}

.column-settings-item-actions {
  display: flex;
  gap: 2px;
}

.column-settings-item-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
  border-radius: var(--r-xs);
  transition: background var(--t-fast), color var(--t-fast);
}

.column-settings-item-btn:hover {
  background: var(--bg-hover);
  color: var(--brand);
}

.column-settings-footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}

/* Drag & Drop and Drag Handle Styling for Table Headers */
.orders-table thead th {
  position: relative;
  padding-top: 18px !important; /* Make room for drag handle */
}

.th-drag-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 14px;
  background: rgba(99, 102, 241, 0.05);
  color: var(--text-muted);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  border-bottom: 1px dashed var(--border);
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: 20;
}

.orders-table thead th:hover .th-drag-handle {
  opacity: 1;
}

.th-drag-handle:active {
  cursor: grabbing;
}

.orders-table thead th.drag-over {
  border-left: 2px dashed var(--brand) !important;
  background: var(--brand-glow) !important;
}

.orders-table thead th.dragging {
  opacity: 0.4;
  background: var(--bg-hover) !important;
}

/* Nova Poshta Delivery UI Styles */
/* Nova Poshta Delivery UI Styles */
.delivery-addr-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}
.delivery-address-text {
  color: var(--text-primary);
  word-break: break-word;
}
.np-ttn-link-wrap {
  display: inline-flex;
  align-items: center;
  font-family: monospace;
}
.np-ttn-link-wrap a {
  color: var(--text-link);
  text-decoration: underline;
  font-weight: 600;
  font-size: 12px;
}
.np-ttn-link-wrap a:hover {
  color: var(--brand);
}
.btn-np-action {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
  transition: all var(--t-fast);
  margin-top: 2px;
}
.btn-np-action:hover {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--bg-hover);
}
.np-delivery-status-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-weight: 500;
}
.btn-np-icon-action {
  transition: background var(--t-fast);
}
.btn-np-icon-action:hover {
  background: var(--bg-hover) !important;
}
.btn-row-np-update {
  opacity: 0.7;
}
.btn-row-np-update:hover {
  opacity: 1;
}

/* Настройки шапки каталога товаров: 2 строки и узкие колонки цен */
.products-catalog-table-wrap .orders-table thead th {
  white-space: normal !important;
  vertical-align: bottom !important;
  font-size: 10px !important;
  line-height: 1.2 !important;
  padding: 6px 4px !important;
  text-transform: none !important;
}

.products-catalog-table-wrap .orders-table td {
  padding: 6px 4px !important;
  font-size: 11px !important;
}

/* HTML Визуальный редактор (WYSIWYG) описаний товаров */
.rich-editor-container {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-input);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.rich-editor-toolbar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.rich-editor-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  font-weight: 500;
  transition: all var(--t-fast);
  gap: 4px;
}

.rich-editor-btn:hover {
  background: var(--bg-hover);
  color: var(--brand);
  border-color: var(--border);
}

.rich-editor-btn.active {
  background: var(--brand-glow);
  color: var(--brand);
  border-color: rgba(79, 142, 247, 0.2);
  font-weight: 600;
}

.rich-editor-content {
  min-height: 220px;
  max-height: 480px;
  overflow-y: auto;
  padding: 12px;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  background: transparent;
}

.rich-editor-content p {
  margin-bottom: 10px;
}

.rich-editor-container textarea {
  display: none;
  border: none !important;
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  resize: vertical;
  min-height: 220px;
  padding: 12px !important;
  margin: 0 !important;
  outline: none !important;
  font-family: monospace !important;
  font-size: 12px !important;
  line-height: 1.4 !important;
}




