/* ══════════════════════════════════════════════════════════
   Реестр отгрузок — премиальная дизайн-система
   ══════════════════════════════════════════════════════════ */
:root {
  /* палитра */
  --primary: #2563eb;
  --primary-deep: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-light: #3b82f6;
  --ring: rgba(37, 99, 235, .12);
  --ring-strong: rgba(37, 99, 235, .25);
  --topbar-a: #0b1220;
  --topbar-b: #0f172a;
  --topbar-glow-a: rgba(96, 165, 250, .55);
  --topbar-glow-b: rgba(45, 212, 191, .4);
  --logo-grad-a: #3b82f6;
  --logo-grad-b: #0d9488;
  --btn-grad-a: #3b82f6;
  --btn-grad-b: #1d4ed8;
  --btn-shadow: rgba(37, 99, 235, .32);
  --ink: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-soft: #eef2f7;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;

  /* тени */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 2px 6px rgba(15, 23, 42, .06), 0 10px 28px -14px rgba(15, 23, 42, .18);
  --shadow-lg: 0 4px 12px rgba(15, 23, 42, .08), 0 24px 48px -20px rgba(15, 23, 42, .28);
  --shadow-primary: 0 2px 10px rgba(37, 99, 235, .32);

  /* радиусы */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  /* цвета групп */
  --g-sales: linear-gradient(135deg, #059669, #047857);
  --g-quarry: linear-gradient(135deg, #d97706, #b45309);
  --g-carrier: linear-gradient(135deg, #2563eb, #1d4ed8);
  --g-fin: linear-gradient(135deg, #475569, #334155);
  --g-auto: linear-gradient(135deg, #7c3aed, #6d28d9);
  --g-docs: linear-gradient(135deg, #e11d48, #be123c);
  --g-team: linear-gradient(135deg, #0d9488, #0f766e);

  --row-hover: #f8fafc;
  --row-stripe: #fbfcfe;
  --sel: #dbeafe;
  --sel-border: #3b82f6;
}


/* Цветовые темы компаний */
.theme-green {
  --primary: #059669;
  --primary-deep: #047857;
  --primary-soft: #ecfdf5;
  --primary-light: #10b981;
  --ring: rgba(5, 150, 105, .12);
  --ring-strong: rgba(5, 150, 105, .25);
  --topbar-a: #052e16;
  --topbar-b: #064e3b;
  --topbar-glow-a: rgba(52, 211, 153, .5);
  --topbar-glow-b: rgba(16, 185, 129, .35);
  --logo-grad-a: #10b981;
  --logo-grad-b: #0d9488;
  --btn-grad-a: #10b981;
  --btn-grad-b: #047857;
  --btn-shadow: rgba(5, 150, 105, .35);
  --sel: #d1fae5;
  --sel-border: #10b981;
}
.theme-violet {
  --primary: #7c3aed;
  --primary-deep: #6d28d9;
  --primary-soft: #f5f3ff;
  --primary-light: #8b5cf6;
  --ring: rgba(124, 58, 237, .12);
  --ring-strong: rgba(124, 58, 237, .25);
  --topbar-a: #1e1b4b;
  --topbar-b: #2e1065;
  --topbar-glow-a: rgba(167, 139, 250, .5);
  --topbar-glow-b: rgba(232, 121, 249, .35);
  --logo-grad-a: #8b5cf6;
  --logo-grad-b: #d946ef;
  --btn-grad-a: #8b5cf6;
  --btn-grad-b: #6d28d9;
  --btn-shadow: rgba(124, 58, 237, .35);
  --sel: #ede9fe;
  --sel-border: #8b5cf6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 400px at 15% -10%, var(--ring), transparent 60%),
    radial-gradient(1000px 420px at 90% -20%, rgba(13, 148, 136, .06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: #bfdbfe; }

/* ---- Верхняя панель ---- */
.topbar {
  background: linear-gradient(180deg, var(--topbar-a), var(--topbar-b));
  color: #fff;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  box-shadow: 0 6px 24px -12px rgba(2, 6, 23, .6);
  position: relative;
  z-index: 20;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--topbar-glow-a), var(--topbar-glow-b), transparent);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  height: 56px;
}
.brand {
  font-weight: 800;
  font-size: 16.5px;
  letter-spacing: .01em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand .brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--logo-grad-a), var(--logo-grad-b));
  font-size: 16px;
  box-shadow: 0 2px 10px var(--btn-shadow);
}
.nav { display: flex; gap: 6px; flex: 1; }
.nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .18s ease;
}
.nav a:hover { background: rgba(148, 163, 184, .12); color: #fff; }
.nav a.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, .28), rgba(13, 148, 136, .24));
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, .35);
}
.user { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  box-shadow: 0 2px 8px rgba(56, 189, 248, .4);
}
.user-name { font-weight: 600; font-size: 13.5px; }
.user-role {
  font-size: 11px;
  background: rgba(148, 163, 184, .18);
  border: 1px solid rgba(148, 163, 184, .25);
  padding: 3px 10px;
  border-radius: 999px;
  color: #475569;
}
.logout-form { display: inline; margin: 0; }
.btn-link {
  background: none; border: none; color: #94a3b8;
  cursor: pointer; padding: 6px 8px;
  font-size: 12.5px;
  border-radius: 8px;
  transition: all .15s ease;
}
.btn-link:hover { color: #fff; background: rgba(239, 68, 68, .15); }

/* ---- Контент ---- */
.content { padding: 22px 26px 26px; max-width: 100%; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.spacer { flex: 1; }
.search {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  min-width: 300px;
  font-size: 13.5px;
  color: var(--text);
  background: #f8fafc;
  transition: all .18s ease;
}
.search:hover { border-color: #cbd5e1; background: #fff; }
.search:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--ring);
}
.filter-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.filter-label input[type="date"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  background: #f8fafc;
  transition: all .18s ease;
}
.filter-label input[type="date"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }

/* ---- Кнопки ---- */
.btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  transition: all .18s ease;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--btn-grad-a), var(--btn-grad-b));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: var(--btn-shadow), 0 1px 3px rgba(15,23,42,.15);
}
.btn.primary:hover { background: linear-gradient(135deg, var(--primary), var(--primary-deep)); box-shadow: 0 6px 18px var(--btn-shadow); }
.btn.danger { border-color: #fecaca; color: var(--danger); background: #fff; }
.btn.danger:hover { background: var(--danger-soft); border-color: #fca5a5; }
.btn.full { width: 100%; }

/* ---- Итоги ---- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12.5px;
  padding: 0 2px 14px;
  min-height: 52px;
}
#status.saved { color: var(--green); font-weight: 600; }
#status { display: inline-flex; align-items: center; gap: 6px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 16px 8px 12px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 16px;
  flex: none;
}
.stat-icon.i-rows { background: #eff6ff; }
.stat-icon.i-supply { background: #ecfdf5; }
.stat-icon.i-quarry { background: #fffbeb; }
.stat-icon.i-carrier { background: #eef2ff; }
.stat-icon.i-margin { background: linear-gradient(135deg, #ecfdf5, #eff6ff); }
.stat-body { display: flex; flex-direction: column; gap: 1px; }
.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
  font-weight: 600;
}
.stat-value {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
}
.stat-margin { border-color: #d1fae5; background: linear-gradient(180deg, #ffffff, #f0fdf9); }

/* ---- Сетка (стиль Google Таблиц) ---- */
.grid {
  background: #fff;
  border: 1px solid #64748b;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: none;
}

/* Шапка таблицы */
#shipments-table .tabulator-header {
  border-bottom: 1px solid #c6c8ca;
  background: #f8f9fa;
}
#shipments-table .tabulator-header .tabulator-col {
  background: #f8f9fa;
  border-right: 1px solid #64748b;
  border-bottom: 1px solid #c6c8ca;
  padding: 5px 8px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: #202124;
  transition: background .12s ease;
}
#shipments-table .tabulator-header .tabulator-col:hover { background: #f1f3f4; }
#shipments-table .tabulator-header .tabulator-col .tabulator-col-content { padding: 0; line-height: 1.3; }
#shipments-table .tabulator-col-sorter { margin-left: 3px; opacity: .6; }

/* Заголовки групп — как объединённые заголовки в Sheets */
#shipments-table .tabulator-colgroup-row { background: #f1f3f4; }
#shipments-table .tabulator-col-group {
  padding: 3px 8px;
  border-right: 1px solid #64748b;
  border-bottom: 1px solid #c6c8ca;
  background: #f1f3f4;
}
.group-title {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #3c4043;
  white-space: nowrap;
}
.g-sales { background: #e6f4ea; }
.g-quarry { background: #fef7e0; }
.g-carrier { background: #e8f0fe; }
.g-fin { background: #e8eaed; }
.g-auto { background: #f3e8fd; }
.g-docs { background: #fce8e6; }
.g-team { background: #e0f2f1; }

/* Фильтры в шапке */
#shipments-table .tabulator-header-filter input,
#shipments-table .tabulator-header-filter select {
  width: 100%;
  padding: 3px 5px;
  border: 1px solid #64748b;
  border-radius: 3px;
  font-size: 12px;
  background: #fff;
  color: var(--text);
  margin-top: 3px;
  transition: border .12s ease;
}
#shipments-table .tabulator-header-filter input:focus,
#shipments-table .tabulator-header-filter select:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: none;
}

/* Ячейки — ровная сетка */
#shipments-table .tabulator-cell {
  padding: 4px 8px;
  font-size: 13px;
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  transition: none;
}
#shipments-table .tabulator-row .tabulator-cell { background: #fff; }

/* Строка, где ТТН выписан, но оригинал не сдан */
#shipments-table .tabulator-row.row-needs-ttn .tabulator-cell { background: #fff8e1; }
#shipments-table .tabulator-row.row-needs-ttn .tabulator-cell:first-child {
  border-left: 3px solid #f9ab00;
}

/* Замороженные колонки */
#shipments-table .tabulator-cell.tabulator-frozen,
#shipments-table .tabulator-col.tabulator-frozen { z-index: 3; background: #fff; }
#shipments-table .tabulator-cell.tabulator-frozen { box-shadow: 1px 0 0 #e0e0e0; }
#shipments-table .tabulator-cell.col-frozen-last { box-shadow: 6px 0 10px -8px rgba(60, 64, 67, .3); }
#shipments-table .tabulator-col.col-frozen-last { box-shadow: 6px 0 10px -8px rgba(60, 64, 67, .3); }

/* Выделение — как в Google Таблицах */
#shipments-table .tabulator-cell.tabulator-range-selected { background: #e8f0fe !important; }
#shipments-table .tabulator-cell.tabulator-range-only-cell-selected {
  outline: 2px solid #1a73e8;
  outline-offset: -2px;
  background: #fff !important;
}

/* Редактируемая ячейка */
#shipments-table .tabulator-cell.tabulator-editing {
  background: #fff !important;
  padding: 0;
  box-shadow: inset 0 0 0 2px #1a73e8;
  border-radius: 0;
}
#shipments-table .tabulator-cell.tabulator-editing input {
  width: 100%;
  height: 100%;
  border: none;
  padding: 3px 7px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
}
#shipments-table .tabulator-cell.tabulator-editing input:focus { outline: none; }
#shipments-table .tabulator-cell.tabulator-editing input[type="date"] { cursor: pointer; }

/* Числа и номер строки */
#shipments-table .col-money { font-variant-numeric: tabular-nums; }
#shipments-table .col-rownum {
  color: #5f6368;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: #f8f9fa !important;
  text-align: center;
}
#shipments-table .tabulator-col.col-rownum { background: #f8f9fa !important; }
#shipments-table .col-actions { padding: 0; background: #f8f9fa !important; }
#shipments-table .tabulator-col.col-actions { background: #f8f9fa !important; }

/* Маржа */
.margin-pos { color: var(--green); font-weight: 700; }
.margin-neg { color: var(--danger); font-weight: 700; }

/* Дата — сегодня */
.date-today {
  background: #e6f4ea;
  color: #137333;
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 5px;
  display: inline-block;
}

/* Галочки-бейджи */
.bool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
}
.bool-yes { background: #e6f4ea; color: #188038; }
.bool-no { color: #dadce0; }

/* Редактор-галочка */
#shipments-table .tabulator-cell.tabulator-editing input[type="checkbox"],
#shipments-table .tabulator-cell input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #188038;
  cursor: pointer;
  margin: 0;
}

/* Кнопка удаления строки */
#shipments-table .icon-btn {
  border: none;
  background: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 3px 6px;
  font-size: 13px;
  opacity: .35;
  transition: opacity .12s ease, background .12s ease;
}
#shipments-table .icon-btn:hover { opacity: 1; background: #fce8e6; }

/* Скроллбар */
#shipments-table .tabulator-tableholder::-webkit-scrollbar { height: 12px; width: 12px; }
#shipments-table .tabulator-tableholder::-webkit-scrollbar-track { background: #f8f9fa; }
#shipments-table .tabulator-tableholder::-webkit-scrollbar-thumb {
  background: #c1c3c6;
  border-radius: 999px;
  border: 3px solid #f8f9fa;
}
#shipments-table .tabulator-tableholder::-webkit-scrollbar-thumb:hover { background: #9aa0a6; }

/* Плейсхолдер пустой таблицы */
#shipments-table .tabulator-placeholder {
  color: var(--muted);
  font-size: 14px;
  background: #fff;
}

/* Ссылки на контрагентов в таблице */
#shipments-table .partner-link {
  color: #1a73e8;
  text-decoration: none;
  border-bottom: 1px dashed #aecbfa;
  font-weight: 500;
}
#shipments-table .partner-link:hover { color: #174ea6; border-bottom-style: solid; }

/* ---- Табы ---- */
.tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}
.tab {
  border: none; background: none; padding: 8px 18px; border-radius: 999px;
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted);
  transition: all .18s ease;
}
.tab:hover { color: var(--ink); }
.tab.active {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ---- Таблицы-списки ---- */
.pane {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.hidden { display: none; }
.list-table { width: 100%; border-collapse: collapse; }
.list-table th {
  text-align: left; font-size: 10.5px; color: var(--faint); text-transform: uppercase;
  letter-spacing: .07em; padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.list-table td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.list-table tbody tr { transition: background .12s ease; }
.list-table tbody tr:hover { background: #f8fafc; }
.list-table .muted { color: var(--muted); font-size: 12.5px; }
.table-actions { white-space: nowrap; text-align: right; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 9px;
  cursor: pointer;
  padding: 6px 9px;
  margin-left: 5px;
  font-size: 13px;
  text-decoration: none;
  transition: all .15s ease;
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover { background: #f8fafc; border-color: #cbd5e1; transform: translateY(-1px); }
.icon-btn.danger:hover { background: var(--danger-soft); border-color: #fca5a5; color: var(--danger); }

.inline-form { display: flex; gap: 10px; margin-bottom: 14px; }
.inline-form input {
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 260px;
  background: #f8fafc;
  transition: all .18s ease;
}
.inline-form input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--ring); }

/* ---- Карточка контрагента ---- */
.card-page { max-width: 1000px; margin: 0 auto; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  transition: color .15s ease;
}
.back-link:hover { color: var(--primary); }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 6px 0 20px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 26px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.card-head::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #3b82f6, #0d9488, #7c3aed);
}
.card-head h1 { margin: 4px 0 10px; font-size: 23px; font-weight: 800; letter-spacing: -.01em; }
.card-head-info { flex: 1; min-width: 260px; }
.card-head-actions { display: flex; gap: 8px; align-items: center; }
.badges { display: flex; gap: 7px; flex-wrap: wrap; }
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.kind-customer { background: var(--green-soft); color: #047857; box-shadow: inset 0 0 0 1px rgba(5, 150, 105, .2); }
.badge.kind-carrier { background: #eff6ff; color: #1d4ed8; box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .18); }
.badge.kind-supplier { background: var(--amber-soft); color: #b45309; box-shadow: inset 0 0 0 1px rgba(217, 119, 6, .18); }
.badge.vat-with { background: #eef2ff; color: #4338ca; }
.badge.vat-usn { background: #ecfdf5; color: #047857; }
.badge.vat-patent { background: #f5f3ff; color: #6d28d9; }
.badge.vat-none { background: #f1f5f9; color: #64748b; }
.badge-inactive { background: #f1f5f9; color: #64748b; }

.card-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease;
}
.card-section:hover { box-shadow: var(--shadow-md); }
.card-section h3 {
  margin: 0 0 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--faint);
  font-weight: 700;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kv { margin: 0; display: grid; grid-template-columns: 200px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.section-text { margin: 0; font-size: 13.5px; white-space: pre-line; }

/* ---- Форма карточки + автозаполнение ---- */
.partner-card-form { max-width: 1000px; margin: 0 auto; }
.card-form-grid {
  max-height: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dadata-box {
  background: linear-gradient(135deg, var(--primary-soft), #f0fdfa);
  border: 1px solid var(--sel-border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.dadata-row { display: flex; gap: 10px; flex-wrap: wrap; }
.dadata-row input {
  flex: 1;
  min-width: 260px;
  padding: 10px 14px;
  border: 1px solid var(--sel-border);
  border-radius: 999px;
  font-size: 14px;
  background: #fff;
  transition: all .18s ease;
}
.dadata-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.dadata-hint { margin-top: 9px; font-size: 12px; color: var(--muted); }
.dadata-results { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.dadata-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--sel);
  border-radius: var(--r-md);
  padding: 11px 14px;
  cursor: pointer;
  font-size: 13.5px;
  transition: all .15s ease;
  box-shadow: var(--shadow-sm);
}
.dadata-item:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.dadata-item .muted { color: var(--muted); font-size: 12.5px; }
.dadata-item .small { font-size: 12px; }
.dadata-empty { padding: 12px 14px; color: var(--muted); font-size: 13px; background: #fff; border-radius: var(--r-md); }

/* Ссылки на контрагентов в списке */
.partner-name-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.partner-name-link:hover { text-decoration: underline; }

/* ---- Модальное окно (не используется, оставлено на будущее) ---- */
.partner-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(760px, 94vw);
  box-shadow: var(--shadow-lg);
}
.partner-dialog::backdrop { background: rgba(2, 6, 23, .55); backdrop-filter: blur(3px); }
.partner-dialog form { padding: 22px 26px; margin: 0; }
.partner-dialog h3 { margin: 0 0 14px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  max-height: 62vh;
  overflow-y: auto;
  padding-right: 4px;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field.span2 { grid-column: span 2; }
.field input, .field select, .field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text);
  font-family: inherit;
  background: #f8fafc;
  transition: all .18s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--ring);
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---- Вход ---- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 20% 0%, rgba(59, 130, 246, .35), transparent 55%),
    radial-gradient(800px 500px at 90% 100%, rgba(13, 148, 136, .3), transparent 55%),
    linear-gradient(160deg, #0b1220, #10213f 60%, #0b1a33);
}
.login-card {
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 20px;
  padding: 38px 38px 34px;
  width: 392px;
  box-shadow: 0 32px 80px -20px rgba(2, 6, 23, .7);
}
.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border-radius: 16px;
  background: linear-gradient(135deg, #3b82f6, #0d9488);
  box-shadow: 0 10px 24px -6px rgba(59, 130, 246, .55);
}
.login-card h1 { text-align: center; font-size: 21px; font-weight: 800; margin: 14px 0 3px; letter-spacing: -.01em; }
.login-card .sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.login-card .field { margin-bottom: 15px; }
.login-card .field span { font-size: 12.5px; font-weight: 600; color: #475569; }
.login-card .field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  background: #f8fafc;
  transition: all .18s ease;
}
.login-card .field input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(37, 99, 235, .14); }
.alert {
  padding: 11px 14px;
  border-radius: 12px;
  margin-bottom: 15px;
  font-size: 13px;
}
.alert.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }

/* ---- Сотрудники контрагента ---- */
.card-section.wide { grid-column: span 2; }
.contacts-table td a { color: var(--primary); text-decoration: none; }
.contacts-table td a:hover { text-decoration: underline; }
.contacts-edit { margin-top: 14px; }
.contacts-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.contact-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1.2fr 1.5fr 44px;
  gap: 8px;
  align-items: center;
}
.contact-row input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text);
  font-family: inherit;
  background: #f8fafc;
  transition: all .18s ease;
  min-width: 0;
}
.contact-row input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--ring);
}
.contact-row .icon-btn { margin-left: 0; }
@media (max-width: 860px) {
  .contact-row { grid-template-columns: 1fr 1fr; }
  .card-section.wide { grid-column: span 1; }
  .card-sections { grid-template-columns: 1fr; }
}

/* ---- Вкладки карточки контрагента ---- */
.card-tabs { margin-bottom: 14px; display: inline-flex; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.card-tabs .tab { font-size: 13.5px; padding: 9px 20px; }
.meta-block { margin-top: 14px; }
.contacts-edit, .contracts-edit { margin-bottom: 14px; }

/* Строки договоров */
.contracts-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.contract-row {
  display: grid;
  grid-template-columns: 1.2fr 130px 2fr 44px;
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: #fbfcfe;
}
.contract-row .ct-notes { grid-column: 1 / -1; }
.contract-row input, .contract-row textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text);
  font-family: inherit;
  background: #fff;
  transition: all .18s ease;
  min-width: 0;
}
.contract-row input:focus, .contract-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}
.contract-row .icon-btn { margin-left: 0; }
@media (max-width: 860px) {
  .contract-row { grid-template-columns: 1fr 1fr; }
}

/* ---- БИК: кнопка поиска банка ---- */
.bik-row { display: flex; gap: 8px; align-items: center; }
.bik-row input { flex: 1; }
.bik-row .btn { padding: 9px 12px; }
.bik-hint { font-size: 12px; margin-top: 4px; min-height: 16px; }
.bik-hint.loading { color: var(--muted); }
.bik-hint.ok { color: var(--green); font-weight: 600; }
.bik-hint.err { color: var(--danger); }

/* ---- Переключатель компаний ---- */
.company-switch { display: flex; gap: 6px; align-items: center; }
.company-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .1);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, .28);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: all .18s ease;
}
.company-pill:hover { background: rgba(148, 163, 184, .2); color: #fff; }
.company-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.company-pill.theme-blue .company-dot { background: #1d4ed8; }
.company-pill.theme-green .company-dot { background: #34d399; }
.company-pill.theme-violet .company-dot { background: #a78bfa; }
.company-pill.theme-blue.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, .4);
}
.company-pill.theme-green.active {
  background: linear-gradient(135deg, #059669, #047857);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px rgba(5, 150, 105, .4);
}
.company-pill.theme-violet.active {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px rgba(124, 58, 237, .4);
}
.company-pill.active .company-dot { background: rgba(255, 255, 255, .85); }

/* ---- Настройки ---- */
.settings-page { max-width: 1100px; margin: 0 auto; }
.settings-title { font-size: 22px; font-weight: 800; margin: 4px 0 16px; letter-spacing: -.01em; }
.alert.ok {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid #a7f3d0;
}
.settings-company { position: relative; overflow: hidden; }
.settings-company::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
}
.settings-company.theme-green::before { background: linear-gradient(90deg, #059669, #10b981); }
.settings-company.theme-violet::before { background: linear-gradient(90deg, #7c3aed, #8b5cf6); }
.settings-company-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.settings-company-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.settings-company-head .company-dot { width: 12px; height: 12px; }
.settings-company.theme-blue .company-dot { background: #3b82f6; }
.settings-company.theme-green .company-dot { background: #10b981; }
.settings-company.theme-violet .company-dot { background: #8b5cf6; }

.users-list { display: flex; flex-direction: column; gap: 8px; }
.user-row {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1.1fr 1.2fr 1.2fr 70px 60px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: #fff;
  margin: 0;
}
.user-row-head {
  background: #f8fafc;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--faint);
  font-weight: 600;
  border: none;
  padding: 4px 12px;
}
.user-row input, .user-row select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  background: #f8fafc;
  transition: all .18s ease;
  min-width: 0;
}
.user-row input:focus, .user-row select:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--ring);
}
.user-row .u-name { display: flex; gap: 8px; }
.user-row .u-active { text-align: center; }
.user-row .u-active input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
.user-row .u-save { text-align: right; }
@media (max-width: 900px) {
  .user-row, .user-row-head { grid-template-columns: 1fr 1fr; }
}

/* ---- Карточка компании: загрузка файлов ---- */
.upload-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.upload-row input[type="text"] {
  flex: 1;
  min-width: 260px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  background: #f8fafc;
}
.upload-row input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); background: #fff; }
.file-label { cursor: pointer; }
.files-chosen { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.file-chosen {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--sel);
  border-radius: 10px;
  background: var(--primary-soft);
  font-size: 13px;
}
.docs-hint {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

/* ---- Галочка «совпадает с юридическим» ---- */
.same-addr {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.same-addr input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.field input.readonly {
  background: #f1f5f9;
  color: var(--muted);
}

/* ---- Грузополучатели заказчика ---- */
.consignees-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.consignee-row {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 44px;
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #fbfcfe;
}
.consignee-row .cn-notes { grid-column: 1 / -1; }
.consignee-row input, .consignee-row textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text);
  font-family: inherit;
  background: #fff;
  transition: all .18s ease;
  min-width: 0;
}
.consignee-row input:focus, .consignee-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}
.consignee-row .icon-btn { margin-left: 0; }
@media (max-width: 860px) {
  .consignee-row { grid-template-columns: 1fr 1fr; }
}

/* ══════════ Модалка выгрузки заявки ══════════ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: #fff; border-radius: 14px; width: min(760px, 100%);
  max-height: 90vh; overflow: auto; padding: 20px 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-hint { margin: 6px 0 12px; }
.modal textarea {
  width: 100%; min-height: 340px; border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; resize: vertical; background: #fafbfc; color: var(--ink);
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* ══════════ Объекты и заявки ══════════ */
.section-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head-row h3 { margin: 0; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--accent-soft, #eef4ff); }
.badge.req-draft { background: #fff7e6; color: #b45309; border: 1px solid #fcd34d; }
.badge.req-sent { background: #e8f0fe; color: #1a56b5; border: 1px solid #bcd3f5; }
.badge.req-done { background: #e6f4ea; color: #137333; border: 1px solid #a8dab5; }
.file-current { display: block; margin-bottom: 6px; color: var(--muted, #64748b); font-size: 12px; }
.field-hint { display: block; margin-top: 4px; color: var(--muted, #64748b); font-size: 11px; }
.kv-inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px 22px; }
.kv-inline dt { color: var(--muted, #64748b); font-size: 12px; }
.kv-inline dd { margin: 0 0 10px; font-size: 14px; }

/* чекбоксы выбора нескольких грузополучателей */
.checkbox-list { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 0 2px; }
.checkbox-item { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.checkbox-item input { width: 16px; height: 16px; accent-color: var(--accent, #1a73e8); }

/* модалка узкая (быстрое добавление) */
.modal-sm { width: min(520px, 100%); }
.danger-link { color: var(--danger, #d93025); background: none; border: none; cursor: pointer; font-size: 14px; padding: 0 2px; }

/* история цен карьера */
.history-row td { background: #fafbfc; padding: 6px 10px; }
.history-row details summary { cursor: pointer; color: var(--accent, #1a73e8); font-size: 12px; user-select: none; }
.history-row details table { margin-top: 8px; }

/* ══════════════════════════════════════════════════════════
   CRM-редизайн: тёмный сайдбар + светлый контент
   ══════════════════════════════════════════════════════════ */
:root {
  --bg: #eef1f6;
  --border: rgba(148,163,184,.16);
  --border-soft: #eef1f7;
  --card: var(--card-solid);
  --r-lg: 14px;
}

html, body { background: var(--bg); }

.app-layout {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}
.app-layout.sidebar-collapsed { grid-template-columns: 70px minmax(0, 1fr); }

/* ---------- сайдбар ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 14px 16px;
  background: linear-gradient(180deg, #171c31 0%, #10142a 100%);
  color: #dfe4f0;
  border-right: 1px solid rgba(255, 255, 255, .05);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 14px;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
  background: linear-gradient(135deg, var(--logo-grad-a), var(--logo-grad-b));
  box-shadow: 0 4px 14px var(--btn-shadow);
  flex: none;
}
.brand-name {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
}
.brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: #8b93ad;
  margin-top: 2px;
}

.sidebar-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #6d7592;
  padding: 0 10px;
  margin-bottom: 8px;
}

/* переключатель компаний */
.sidebar-company { display: flex; flex-direction: column; gap: 6px; }
.company-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 11px;
  background: rgba(255, 255, 255, .04);
  color: #cdd3e4;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background .15s ease, border-color .15s ease;
}
.company-item:hover { background: rgba(255, 255, 255, .09); }
.company-item.active {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .22);
  color: #fff;
}
.company-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--logo-grad-a, #3b82f6);
  flex: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .1);
}
.company-item.theme-green .company-dot { background: #10b981; }
.company-item.theme-violet .company-dot { background: #8b5cf6; }
.company-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.company-check { color: #137333; font-size: 12px; flex: none; }

/* меню */
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  color: #b6bdd2;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, var(--btn-grad-a), var(--btn-grad-b));
  color: #fff;
  box-shadow: 0 4px 14px var(--btn-shadow);
}
.nav-icon { font-size: 15px; width: 20px; text-align: center; flex: none; }

/* пользователь внизу сайдбара */
.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 2px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--logo-grad-a), var(--logo-grad-b));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role { font-size: 11px; color: #8b93ad; }
.sidebar .btn-link {
  background: none;
  border: none;
  color: #8b93ad;
  font-size: 15px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}
.sidebar .btn-link:hover { color: #fff; background: rgba(255, 255, 255, .1); }

/* ---------- сайдбар свёрнут ---------- */
.app-layout.sidebar-collapsed .sidebar { padding: 20px 10px 16px; gap: 16px; }
.app-layout.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 4px 0 14px;
  width: 100%;
}
.app-layout.sidebar-collapsed .brand-name,
.app-layout.sidebar-collapsed .sidebar-label,
.app-layout.sidebar-collapsed .company-name,
.app-layout.sidebar-collapsed .company-check,
.app-layout.sidebar-collapsed .nav-text,
.app-layout.sidebar-collapsed .user-meta,
.app-layout.sidebar-collapsed .logout-form { display: none; }
.app-layout.sidebar-collapsed .company-item { justify-content: center; padding: 9px 0; }
.app-layout.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.app-layout.sidebar-collapsed .nav-icon { margin: 0; }
.app-layout.sidebar-collapsed .sidebar-user { justify-content: center; padding: 10px 0 2px; }

/* ---------- контент ---------- */
.content { padding: 22px 26px 30px; }

/* ---------- тулбар (реестр) ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}
.toolbar .search {
  min-width: 220px;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  background: #f8fafd;
  transition: border-color .15s, box-shadow .15s;
}
.toolbar .search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); background: #fff; }
.filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.filter-label input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  background: #f8f9fa;
}

/* статусбар со статистикой */
.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.stats { gap: 10px; }
.stat {
  border-radius: 13px;
  padding: 10px 16px 10px 12px;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.stat:hover { transform: translateY(-1px); }
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 18px;
}
.stat-value { font-size: 17px; }
.stat-label { font-size: 10px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: #f6f8fc; border-color: #d5dce8; box-shadow: var(--shadow-sm); transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--btn-grad-a), var(--btn-grad-b));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px var(--btn-shadow);
}
.btn.primary:hover { background: linear-gradient(135deg, var(--btn-grad-a), var(--btn-grad-b)); box-shadow: 0 4px 14px var(--btn-shadow); }
.btn.danger { border-color: #f3c4c4; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: #eda1a1; }
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .35);
  font-size: 10.5px;
  font-weight: 700;
}

/* ---------- таблица реестра (Google-Sheets сетка на светлом фоне) ---------- */
#shipments-table.grid {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
#shipments-table .tabulator-header .tabulator-col {
  background: #f4f6fa;
  border-right: 1px solid #e3e8f0;
  color: #46506a;
  font-weight: 600;
  font-size: 12px;
}
#shipments-table .tabulator-row { background: #fff; }
#shipments-table .tabulator-row.tabulator-row-even { background: #fdfdfe; }
#shipments-table .tabulator-row .tabulator-cell { border-right: 1px solid #e8ebf2; }
#shipments-table .tabulator-row.tabulator-selectable:hover { background: #f7f9fc; }
#shipments-table .tabulator-row .tabulator-selected,
#shipments-table .tabulator-row .tabulator-selected:hover { background: var(--sel); }

/* ---------- вкладки ---------- */
.tabs {
  display: inline-flex;
  gap: 4px;
  background: #e9edf5;
  border-radius: 12px;
  padding: 4px;
  margin: 14px 0 16px;
  flex-wrap: wrap;
}
.tab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}
.tab:hover { color: var(--ink); }
.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ---------- карточки ---------- */
.card-page { max-width: 1000px; margin: 0 auto; }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.card-head::before { display: none; }
.card-head h1 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.card-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-sections { gap: 14px; }
.card-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.card-section:hover { box-shadow: var(--shadow-sm); }
.card-section h3 {
  margin: 0 0 12px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: .01em;
}
.meta-block { margin-top: 14px; }

/* ---------- таблицы-списки ---------- */
.list-table {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.list-table th {
  background: #f6f8fc;
  color: #5d6884;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.list-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
.list-table tbody tr:last-child td { border-bottom: none; }
.list-table tbody tr:hover { background: #f7f9fd; }

/* ---------- таблица строк спецификации ---------- */
#items-table { table-layout: fixed; width: 100%; }
#items-table th:nth-child(1), #items-table td:nth-child(1) { width: 29%; }
#items-table th:nth-child(2), #items-table td:nth-child(2) { width: 14%; }
#items-table th:nth-child(3), #items-table td:nth-child(3) { width: 9%; }
#items-table th:nth-child(4), #items-table td:nth-child(4) { width: 10%; }
#items-table th:nth-child(5), #items-table td:nth-child(5) { width: 8%; }
#items-table th:nth-child(6), #items-table td:nth-child(6) { width: 5%; }
#items-table th:nth-child(7), #items-table td:nth-child(7) { width: 16%; }
#items-table th:nth-child(8), #items-table td:nth-child(8) { width: 5%; }
#items-table input, #items-table select {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  padding: 6px 7px;
}
#items-table input.sub {
  margin-top: 4px;
  padding: 4px 6px;
  font-size: 11.5px;
  color: #cbd5e1;
}
#items-table td { overflow: hidden; text-overflow: ellipsis; }
#items-table th:last-child, #items-table td:last-child {
  width: 52px;
  padding-left: 6px;
  padding-right: 6px;
  overflow: visible;
  text-align: center;
}
#items-table .icon-btn { width: auto; margin-left: 0; padding: 6px 8px; }

/* ---------- чекбоксы грузополучателей в спецификации ---------- */
.checkbox-list { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  cursor: pointer;
}

/* ---------- дерево договоров ---------- */
#contracts-tree .tree-toggle {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  line-height: 1;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
#contracts-tree .tree-toggle:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
#contracts-tree .tree-sign { font-size: 12px; font-weight: 800; }
#contracts-tree .tree-count { font-size: 9.5px; font-weight: 700; color: var(--muted); }
#contracts-tree .tree-toggle:hover .tree-count { color: #fff; }
#contracts-tree th:first-child,
#contracts-tree td:first-child { width: 42px; text-align: center; padding-left: 8px; padding-right: 8px; }
#contracts-tree tr.ctr-row > td:first-child { vertical-align: middle; }
#contracts-tree tr.ctr-spec td {
  background: #f8f9fa;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
#contracts-tree tr.ctr-spec td:nth-child(3) {
  padding-left: 34px;
  position: relative;
}
#contracts-tree tr.ctr-spec td:nth-child(3)::before {
  content: "└";
  position: absolute;
  left: 14px;
  top: 8px;
  color: #b3bdd4;
  font-size: 13px;
  line-height: 1;
}
#contracts-tree tr.ctr-spec:hover td { background: #f2f6fc; }

/* ---------- агрегация по заявкам объекта (3 колонки) ---------- */
.agg-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.2fr;
  gap: 20px;
  margin-top: 4px;
}
.agg-grid.agg-4 { grid-template-columns: 1fr 1.3fr 1.6fr 1fr; }
.agg-grid.agg-4 .agg-items { padding-top: 1px; }
.agg-grid.agg-2 { grid-template-columns: 1fr 1.6fr; }
.agg-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #5d6884;
  margin-bottom: 6px;
}
.agg-items { font-size: 13px; line-height: 1.55; color: var(--text); }
.agg-items > div + div { margin-top: 2px; }

/* ---------- бейджи ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid transparent;
}
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- формы ---------- */
.form-grid { gap: 12px 14px; }
.field span { font-size: 12px; font-weight: 600; color: #4b5568; margin-bottom: 5px; }
.field input,
.field select,
.field textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  background: #f8fafd;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
  background: #fff;
}

/* ---------- модалки ---------- */
.modal { border-radius: 16px; }
.modal-head h3 { font-size: 15.5px; }
.modal-actions { gap: 8px; }

/* ---------- алерты ---------- */
.alert { border-radius: 10px; padding: 11px 14px; font-size: 13px; }

/* ---------- ссылка назад ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 12px;
}
.back-link:hover { color: var(--primary); }

/* ---------- вход ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 20% -10%, rgba(59, 130, 246, .18), transparent 60%),
    radial-gradient(700px 420px at 85% 110%, rgba(13, 148, 136, .16), transparent 55%),
    #f2f5fa;
}
.login-wrap { width: min(400px, 92vw); }
.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px 30px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 26px;
  background: linear-gradient(135deg, var(--logo-grad-a), var(--logo-grad-b));
  box-shadow: 0 8px 20px var(--btn-shadow);
  margin-bottom: 14px;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-card .field { text-align: left; margin-bottom: 12px; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* ---------- панели списков (контрагенты, настройки) ---------- */
.pane {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.inline-form input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  background: #f8f9fa;
  min-width: 200px;
}
.inline-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); background: #fff; }

/* таблица настроек */
.settings-table { margin-top: 12px; }
.settings-table .kv { margin: 0; }

/* секция «поля ввода в ряд» в настройках */
.settings-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.settings-row input,
.settings-row select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  background: #f8f9fa;
}
.settings-row input:focus,
.settings-row select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); background: #fff; }

/* автокомплит-списки Tabulator на светлом фоне */
.tabulator-edit-list {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}
.tabulator-edit-list-item { padding: 7px 12px; font-size: 13px; }
.tabulator-edit-list-item.active { background: var(--primary-soft); color: var(--primary); }

/* адаптив: узкие экраны — сайдбар сверху */
@media (max-width: 900px) {
  .app-layout,
  .app-layout.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
  .sidebar-brand { border-bottom: none; padding: 4px 8px; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-label { display: none; }
  .sidebar-user { margin-top: 0; border-top: none; padding: 0 4px; }
}

/* квадратик-галочка в булевых колонках реестра (клик — поставить/снять) */
.check-square {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 1.6px solid #9aa6bd;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  user-select: none;
  transition: background .12s ease, border-color .12s ease;
  box-sizing: border-box;
}
.check-square.checked {
  background: var(--green, #188038);
  border-color: var(--green, #188038);
}
.check-square:hover { border-color: var(--primary, #2563eb); }
.col-bool .tabulator-cell { cursor: pointer; }

/* редактор даты: ручной ввод + календарь */
.date-editor {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.date-editor input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--sel-border, #3b82f6);
  border-radius: 6px;
  padding: 5px 7px;
  font: inherit;
  font-size: 12.5px;
}
.date-editor input.invalid {
  border-color: var(--danger, #dc2626);
  background: var(--danger-soft, #fef2f2);
}
/* нативный календарь: кнопка 📅 + невидимый input[type=date] поверх неё */
.date-cal-btn {
  flex: none;
  position: relative;
  width: 36px;
  height: 27px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.date-cal-btn:hover { background: var(--primary-soft, #eff6ff); }
.date-cal-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  pointer-events: auto;
}
.date-cal-overlay::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

/* ── Мини-карты (Leaflet / OpenStreetMap) ── */
.mini-map {
  width: 100%;
  height: 280px;
  border-radius: 10px;
  border: 1px solid var(--border, #e2e8f0);
  background: #eef2f7;
  z-index: 0;
}
.mini-map.small { height: 220px; }
.map-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted, #64748b);
  font-size: 13px;
}
.leaflet-container { font: inherit; }
.leaflet-popup-content { margin: 8px 12px; font-size: 12px; }
.leaflet-popup-content-wrapper { border-radius: 8px; }

/* ── Выпадающий статус заявки в шапке ── */
.status-select {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 30px 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235d6884' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.status-select.req-draft { background-color: #fff7e6; color: #b45309; border-color: #fcd34d; }
.status-select.req-sent  { background-color: #e8f0fe; color: #1a56b5; border-color: #bcd3f5; }
.status-select.req-done  { background-color: #e6f4ea; color: #137333; border-color: #a8dab5; }

/* ── Статусы заявки (новые) ── */
.badge.req-logistics    { background: #f3e8ff; color: #6b21a8; border: 1px solid #d8b4fe; }
.badge.req-in_progress  { background: #ecfeff; color: #0e7490; border: 1px solid #a5f3fc; }
.status-select.req-logistics   { background-color: #f3e8ff; color: #6b21a8; border-color: #d8b4fe; }
.status-select.req-in_progress { background-color: #ecfeff; color: #0e7490; border-color: #a5f3fc; }

/* ── Шкала выполнения заявки ── */
.request-progress {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
}
.progress-head { font-size: 13px; margin-bottom: 8px; }
.progress-head b { font-size: 14px; }
.progress-bar {
  height: 14px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #059669, #047857);
  transition: width .4s ease;
}
.progress-meta { margin-top: 8px; font-size: 12px; color: var(--muted, #64748b); }

/* ── Статусы спецификации ── */
.badge.spec-draft       { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge.spec-on_approval { background: #fff7e6; color: #b45309; border: 1px solid #fcd34d; }
.badge.spec-approved    { background: #e8f0fe; color: #1a56b5; border: 1px solid #bcd3f5; }
.badge.spec-protocol   { background: #fff7e6; color: #b45309; border: 1px solid #fcd34d; }
.badge.spec-signed      { background: #e6f4ea; color: #137333; border: 1px solid #a8dab5; }

