/* Sillan ERP — каркас Lief ERP, фирменная палитра Sillan (красный + графит + холодный белый) */

:root[data-theme="light"] {
  --paper: #F4F4F2;
  --surface: #FFFFFF;
  --surface-alt: #ECECE8;
  --line: #DDDDD7;
  --line-strong: #C9C9C1;
  --ink: #1D1C1C;
  --ink-soft: #454343;
  --ink-mute: #6E6B6B;
  --brand: #C2121C;
  --brand-deep: #96101A;
  --brand-weak: rgba(194, 18, 28, 0.10);
  --accent: #2F5F8F;
  --accent-weak: rgba(47, 95, 143, 0.12);
  --live: #2D6A4F;
  --live-weak: rgba(45, 106, 79, 0.14);
  --warn: #8F6A14;
  --warn-weak: rgba(143, 106, 20, 0.14);
  --danger: #A63434;
  --danger-weak: rgba(166, 52, 52, 0.12);
  --shadow-card: 0 2px 12px rgba(29, 28, 28, 0.06), 0 1px 4px rgba(29, 28, 28, 0.04);
  --shadow-hover: 0 8px 32px rgba(29, 28, 28, 0.10), 0 2px 8px rgba(29, 28, 28, 0.05);
  --shadow-panel: 0 8px 32px rgba(29, 28, 28, 0.16), 0 2px 8px rgba(29, 28, 28, 0.07);
  --grain-opacity: 0.35;
  --grain-blend: multiply;
}

:root[data-theme="dark"] {
  --paper: #141313;
  --surface: #1E1D1D;
  --surface-alt: #2B2929;
  --line: #343232;
  --line-strong: #454242;
  --ink: #EDEBE8;
  --ink-soft: #B9B6B2;
  --ink-mute: #8D8A86;
  --brand: #E8535B;
  --brand-deep: #F07A80;
  --brand-weak: rgba(232, 83, 91, 0.15);
  --accent: #6E9CC9;
  --accent-weak: rgba(110, 156, 201, 0.15);
  --live: #5DBB7E;
  --live-weak: rgba(93, 187, 126, 0.15);
  --warn: #D9A94E;
  --warn-weak: rgba(217, 169, 78, 0.15);
  --danger: #E06C6C;
  --danger-weak: rgba(224, 108, 108, 0.14);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.35), 0 1px 4px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-panel: 0 8px 32px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  --grain-opacity: 0.22;
  --grain-blend: screen;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-mute); }

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { flex-shrink: 0; }

.muted { color: var(--ink-mute); }
.mono { font-variant-numeric: tabular-nums; }
.ok { color: var(--live); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.hint { font-size: 11.5px; color: var(--ink-mute); margin-bottom: 6px; }
.clickable { cursor: pointer; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ---------- гейт-логин ---------- */

.auth-split { display: flex; min-height: 100vh; }
.auth-left {
  flex: 1.05;
  background: linear-gradient(155deg, #2A1214 0%, #1E0E10 45%, #150A0B 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
  position: relative;
  overflow: hidden;
}
.auth-left::after {
  content: "";
  position: absolute;
  top: -120px;
  right: -80px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 83, 91, 0.16), transparent 70%);
}
.auth-brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #C2121C;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  display: grid;
  place-items: center;
}
.auth-brand b { font-size: 17px; font-weight: 750; letter-spacing: 0.2px; }
.auth-brand span { display: block; font-size: 12px; color: rgba(255, 255, 255, 0.62); }
.auth-left-body { position: relative; z-index: 1; }
.auth-left-body h1 { font-size: 30px; line-height: 1.22; font-weight: 800; margin: 0 0 26px; letter-spacing: -0.4px; }
.auth-bullets { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.auth-bullets li { position: relative; padding-left: 30px; font-size: 15px; color: rgba(255, 255, 255, 0.9); }
.auth-bullets li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: -1px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: rgba(232, 83, 91, 0.2);
  color: #F07A80;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.auth-quote {
  position: relative;
  z-index: 1;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.6);
  border-left: 3px solid #C2121C;
  padding-left: 14px;
  max-width: 460px;
}
.auth-right {
  flex: 1;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 28px;
  position: relative;
}
.auth-form { width: 360px; max-width: 100%; }
.auth-form h2 { font-size: 26px; font-weight: 800; margin: 0 0 6px; letter-spacing: -0.3px; }
.auth-sub { color: var(--ink-mute); font-size: 14px; margin: 0 0 26px; }
.auth-label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 7px; }
.auth-input {
  width: 100%;
  height: 46px;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
  font-family: inherit;
}
.auth-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.auth-pass { position: relative; }
.auth-pass .auth-input { padding-right: 46px; }
.auth-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  color: var(--ink-mute);
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.auth-eye:hover { color: var(--ink); background: var(--surface-alt); }
.auth-error { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 18px; margin: 12px 0 2px; }
.auth-submit {
  width: 100%;
  height: 48px;
  font-size: 15px;
  font-weight: 700;
  margin-top: 8px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
}
.auth-submit:hover { background: var(--brand-deep); }
.auth-submit:disabled { opacity: 0.7; cursor: default; }
.auth-note { color: var(--ink-mute); font-size: 12.5px; text-align: center; margin-top: 22px; line-height: 1.5; }
.auth-footer { position: absolute; bottom: 22px; font-size: 11.5px; color: var(--ink-mute); }

/* ---------- сайдбар ---------- */

.sidebar {
  position: fixed;
  left: 12px;
  top: 12px;
  bottom: 12px;
  width: 248px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
  transition: background 0.4s ease, transform 0.25s ease;
}
.side-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: grid;
  place-items: center;
  letter-spacing: -0.02em;
}
.logo-word { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.logo-mod {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  background: var(--brand-weak);
  padding: 3px 8px;
  border-radius: 999px;
}

.side-nav { flex: 1; overflow-y: auto; padding: 8px 10px; }
.nav-group {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  padding: 10px 10px 5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-mute);
  margin-bottom: 2px;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-alt); color: var(--ink); }
.nav-item.active { background: var(--surface-alt); color: var(--ink); font-weight: 600; }
.nav-item.active .nav-ic { color: var(--brand); }
.nav-ic { display: grid; place-items: center; color: inherit; }
.nav-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-new {
  margin-left: auto;
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--live);
  background: var(--live-weak);
  padding: 2px 6px;
  border-radius: 4px;
}

.side-foot {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.foot-block {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--ink-soft);
  text-align: left;
  transition: background 0.12s;
}
.foot-block:hover { background: var(--brand-weak); }
.foot-block > svg { color: var(--brand); }
.foot-company { display: flex; flex-direction: column; min-width: 0; }
.foot-company b { font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot-company span { font-size: 10.5px; color: var(--ink-mute); }
.foot-row { display: flex; align-items: center; gap: 4px; }
.foot-ic {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink-mute);
  transition: background 0.12s, color 0.12s;
}
.foot-ic:hover { background: var(--surface-alt); color: var(--ink); }
.foot-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
}
.foot-date { margin-left: auto; font-size: 10.5px; color: var(--ink-mute); }

.burger {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 60;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  place-items: center;
}
.side-bd { display: none; }

/* ---------- контент ---------- */

.main { margin-left: 280px; min-height: 100vh; }
.view {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px 70px;
}
.view.fade-in { animation: fadeIn 0.3s ease forwards; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); align-items: start; }
.g-3-2 { grid-template-columns: 2fr 1fr; align-items: start; }
.g-1-2 { grid-template-columns: 1fr 2fr; align-items: start; }
.col { display: flex; flex-direction: column; min-width: 0; gap: 14px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.ph-row { display: flex; align-items: center; gap: 10px; }
.page-head h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.015em; }
.ph-live {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--live);
  background: var(--live-weak);
  padding: 2px 8px;
  border-radius: 4px;
}
.page-sub { font-size: 12px; color: var(--ink-mute); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: background 0.4s ease;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 0;
  flex-wrap: wrap;
}
.card-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.card-title > span:not(.card-ic):not(.card-sub) { font-size: 13px; font-weight: 700; }
.card-ic { color: var(--brand); align-self: center; display: grid; place-items: center; }
.card-sub { font-size: 11px; color: var(--ink-mute); font-weight: 400; }
.card-body { padding: 12px 20px 18px; }
.card-body.nopad { padding: 12px 0 0; }
.card-foot {
  padding: 11px 20px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-mute);
}

/* ---------- KPI-плитки ---------- */

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  min-height: 96px;
}
.stat-ic { position: absolute; top: 14px; right: 14px; color: var(--ink-mute); }
.stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  padding-right: 26px;
}
.stat-val {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-sub { font-size: 11px; color: var(--ink-mute); margin-top: 4px; }
.stat.t-brand .stat-val, .stat.t-brand .stat-ic { color: var(--brand); }
.stat.t-accent .stat-val, .stat.t-accent .stat-ic { color: var(--accent); }
.stat.t-live .stat-val, .stat.t-live .stat-ic { color: var(--live); }
.stat.t-warn .stat-val, .stat.t-warn .stat-ic { color: var(--warn); }
.stat.t-danger .stat-val, .stat.t-danger .stat-ic { color: var(--danger); }

.delta-up { color: var(--live); font-weight: 700; }
.delta-down { color: var(--danger); font-weight: 700; }

/* ---------- кнопки, инпуты, чипы, бейджи ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 11.5px; border-radius: 7px; }

.input, select.input {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 11px;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 200px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-mute);
}
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--ink);
  font-size: 12.5px;
  font-family: inherit;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 2px 20px 12px;
}

.seg { display: inline-flex; background: var(--surface-alt); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; max-width: 100%; }
.seg button {
  height: 28px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-mute);
  transition: background 0.12s, color 0.12s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip-solid { background: var(--brand-weak); color: var(--brand); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.6;
}
.b-live { background: var(--live-weak); color: var(--live); }
.b-brand { background: var(--brand-weak); color: var(--brand); }
.b-accent { background: var(--accent-weak); color: var(--accent); }
.b-warn { background: var(--warn-weak); color: var(--warn); }
.b-danger { background: var(--danger-weak); color: var(--danger); }
.b-soft { background: var(--surface-alt); color: var(--ink-soft); }
.b-mute { background: var(--surface-alt); color: var(--ink-mute); }

/* ---------- таблицы ---------- */

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-alt) 55%, transparent);
  white-space: nowrap;
}
.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background 0.12s; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--surface-alt) 40%, transparent); }
.tbl tr.clickable { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th:last-child, .tbl td:last-child { padding-right: 18px; }
.tbl tr.row-warn { background: color-mix(in srgb, var(--warn) 6%, transparent); }
.tbl tr.row-danger { background: color-mix(in srgb, var(--danger) 6%, transparent); }
.tbl tr.tbl-total td {
  font-weight: 700;
  background: color-mix(in srgb, var(--surface-alt) 55%, transparent);
  border-top: 2px solid var(--line-strong);
  border-bottom: 0;
}
.tbl-sub { font-size: 10.5px; color: var(--ink-mute); margin-top: 1px; white-space: nowrap; }
.tbl-empty { text-align: center; padding: 36px 20px !important; color: var(--ink-mute); }

.tbl td.cell-ok { background: color-mix(in srgb, var(--live) 14%, transparent); color: var(--live); font-weight: 600; }
.tbl td.cell-bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-weight: 700; }

.stat-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.stat-line:last-child { border-bottom: 0; }
.stat-line-l { color: var(--ink-mute); }
.stat-line-v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- прогресс и графики ---------- */

.prog {
  display: inline-block;
  width: 76px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  vertical-align: middle;
}
.prog-fill { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width 0.4s; }
.prog-row { display: inline-flex; align-items: center; gap: 8px; }
.prog-val { font-size: 11px; font-weight: 600; min-width: 32px; text-align: right; }

.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 10px; }
.hbar-meta { display: flex; flex-direction: column; min-width: 0; }
.hbar-label { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-sub { font-size: 10px; color: var(--ink-mute); }
.hbar-track { height: 8px; border-radius: 4px; background: var(--surface-alt); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; background: var(--brand); }
.hbar-val { font-size: 11px; font-weight: 700; min-width: 48px; text-align: right; }

.vbars { display: flex; align-items: stretch; gap: 8px; padding-top: 4px; }
.vbar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}
.vbar-num { font-size: 10.5px; font-weight: 700; color: var(--ink-soft); }
.vbar-fill { width: 100%; max-width: 46px; border-radius: 5px 5px 2px 2px; background: var(--brand); }
.vbar-fill.alt { background: var(--accent); }
.vbar-label { font-size: 10px; color: var(--ink-mute); white-space: nowrap; }

.funnel { display: flex; flex-direction: column; gap: 11px; }
.funnel-meta { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.funnel-meta span { font-weight: 500; }
.funnel-meta b { font-variant-numeric: tabular-nums; }
.funnel-track { height: 20px; border-radius: 6px; background: var(--surface-alt); overflow: hidden; }
.funnel-fill {
  display: flex;
  align-items: center;
  height: 100%;
  border-radius: 6px;
  padding-left: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.linechart { width: 100%; height: auto; display: block; }
.linechart .lc-grid { stroke: var(--line); stroke-width: 1; }
.linechart .lc-label { font-size: 10px; fill: var(--ink-mute); font-family: inherit; }
.linechart .lc-val { font-size: 10px; font-weight: 700; fill: var(--ink-soft); font-family: inherit; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--ink-mute); padding-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- ETL ---------- */

.etl-src {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
}
.etl-src:last-child { margin-bottom: 0; }
.etl-src-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.etl-src-txt { flex: 1; min-width: 0; }
.etl-src-txt b { display: block; font-size: 12.5px; font-weight: 650; }
.etl-src-txt span { font-size: 10.5px; color: var(--ink-mute); }
.etl-pipe { display: flex; gap: 8px; flex-wrap: wrap; }
.etl-stage {
  flex: 1;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.etl-stg-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.etl-stage b { display: block; font-size: 11.5px; font-weight: 650; line-height: 1.3; }
.etl-stage span { font-size: 10px; color: var(--ink-mute); }
.etl-note { font-size: 10.5px; color: var(--danger); margin-top: 4px; }

/* ---------- ИИ-ассистент ---------- */

.ai-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
.ai-chat { display: flex; flex-direction: column; min-height: 560px; }
.ai-log { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 14px; overflow-y: auto; max-height: 60vh; }
.ai-msg { max-width: 88%; border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.ai-msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: var(--surface-alt); border-bottom-left-radius: 4px; }
.ai-msg.err { align-self: flex-start; background: var(--danger-weak); color: var(--danger); }
.ai-typing { align-self: flex-start; color: var(--ink-mute); font-size: 12px; padding: 2px 6px; }
.ai-typing i { animation: aiBlink 1s infinite; font-style: normal; }
@keyframes aiBlink { 50% { opacity: 0.2; } }
.ai-inp { display: flex; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.ai-inp textarea {
  flex: 1;
  min-height: 44px;
  max-height: 130px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  padding: 11px 13px;
  outline: none;
}
.ai-inp textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.ai-hello { color: var(--ink-mute); font-size: 12.5px; padding: 8px 2px; }
.ai-quick { display: flex; flex-direction: column; gap: 7px; }
.ai-quick button {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink-soft);
  transition: border-color 0.12s, background 0.12s;
}
.ai-quick button:hover { border-color: var(--brand); background: var(--brand-weak); }

/* ---------- аватары и персоны ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: hsl(var(--av-h) 30% 42%);
  color: #FFF6F0;
  font-weight: 700;
  flex: 0 0 auto;
}
.av-sm { width: 26px; height: 26px; font-size: 10px; }
.av-md { width: 34px; height: 34px; font-size: 12px; }
.person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.person-txt { display: flex; flex-direction: column; min-width: 0; }
.person-txt b { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 10.5px; color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- канбан задач ---------- */

.kb-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; align-items: start; }
.kb-col {
  background: color-mix(in srgb, var(--surface-alt) 55%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  min-height: 220px;
  transition: border-color 0.15s, background 0.15s;
}
.kb-col.drop-over { border-color: var(--brand); background: var(--brand-weak); }
.kb-col-head { display: flex; align-items: center; gap: 7px; padding: 4px 6px 8px; }
.kb-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kb-col-head span { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-mute); }
.kb-count { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--ink-mute); background: var(--surface); border-radius: 6px; padding: 1px 7px; }
.kb-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kb-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  box-shadow: var(--shadow-card);
  cursor: grab;
  transition: box-shadow 0.12s, opacity 0.12s, transform 0.12s;
}
.kb-card:hover { box-shadow: var(--shadow-hover); }
.kb-card.dragging { opacity: 0.45; transform: rotate(2deg); cursor: grabbing; }
.kb-card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kb-key { font-size: 10px; font-weight: 700; color: var(--ink-mute); background: var(--surface-alt); border-radius: 5px; padding: 1px 6px; }
.kb-pr { font-size: 10px; font-weight: 800; }
.kb-pr.p1 { color: var(--danger); }
.kb-pr.p2 { color: var(--warn); }
.kb-pr.p3 { color: var(--ink-mute); }
.kb-title { font-size: 12px; font-weight: 600; line-height: 1.4; margin-top: 7px; }
.kb-block {
  display: flex;
  gap: 5px;
  margin-top: 7px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--danger);
  background: var(--danger-weak);
  border-radius: 6px;
  padding: 5px 7px;
}
.kb-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 9px; }
.kb-due { font-size: 10.5px; font-weight: 600; color: var(--ink-mute); }
.kb-due.over { color: var(--danger); }
.kb-empty { font-size: 11px; color: var(--ink-mute); text-align: center; padding: 12px 4px; }

/* ---------- согласования ---------- */

.ap-item { margin-bottom: 14px; }
.ap-item.late { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.ap-item.settled { opacity: 0.75; }
.ap-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ap-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ap-doc { font-size: 10px; font-weight: 700; color: var(--ink-mute); background: var(--surface-alt); border-radius: 5px; padding: 2px 7px; }
.ap-title { font-size: 13.5px; font-weight: 700; margin-top: 7px; }
.ap-sub { font-size: 11.5px; color: var(--ink-mute); margin-top: 3px; }
.ap-actions { display: flex; gap: 8px; flex-shrink: 0; }
.ap-chain { display: flex; align-items: flex-start; overflow-x: auto; padding: 12px 0 4px; margin-top: 10px; border-top: 1px dashed var(--line); }
.ap-step { display: flex; flex-direction: column; align-items: center; text-align: center; width: 86px; flex-shrink: 0; }
.ap-link { height: 3px; width: 34px; border-radius: 3px; background: var(--line-strong); margin-top: 15px; flex-shrink: 0; }
.ap-link.done { background: color-mix(in srgb, var(--live) 55%, var(--line)); }
.ap-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 800;
  background: var(--surface-alt);
  color: var(--ink-mute);
  border: 1px solid var(--line);
}
.ap-circle.done { background: var(--live); color: #fff; border-color: var(--live); }
.ap-circle.current { background: var(--warn); color: #fff; border-color: var(--warn); }
.ap-circle.current.late { background: var(--danger); border-color: var(--danger); }
.ap-step b { font-size: 10.5px; font-weight: 650; margin-top: 5px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-step span { font-size: 9.5px; color: var(--ink-mute); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-days { font-size: 9.5px; font-weight: 800; color: var(--warn); margin-top: 2px; }
.ap-days.late { color: var(--danger); }

/* ---------- документы ---------- */

.doc-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
.doc-layout > * { min-width: 0; }
.doc-tree { padding: 8px; }
.doc-folder {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink-mute);
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.doc-folder:hover { background: var(--surface-alt); color: var(--ink); }
.doc-folder.active { background: var(--surface-alt); color: var(--ink); font-weight: 600; }
.doc-folder.active .df-ic { color: var(--brand); }
.df-ic { color: var(--ink-mute); display: grid; place-items: center; }
.df-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.df-count { font-size: 10px; font-weight: 600; color: var(--ink-mute); background: var(--surface-alt); border-radius: 8px; padding: 1px 7px; }
.doc-tree-sec {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  padding: 10px 10px 5px;
}
.doc-crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-mute); margin-right: auto; }
.doc-crumb svg { color: var(--brand); }
.doc-crumb b { color: var(--ink); }
.edoc-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--ink-mute);
}
.edoc-btn:hover { color: var(--brand); border-color: var(--brand); }

/* ---------- трекер заказа (дашборд) ---------- */

.ship-grid { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
.ship-label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.ship-left > .input { width: 100%; margin-bottom: 14px; }
.ship-route { display: flex; flex-direction: column; gap: 6px; }
.ship-loc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 14px;
}
.ship-loc b { font-size: 14px; display: block; letter-spacing: -0.1px; }
.ship-loc span { font-size: 11.5px; color: var(--ink-mute); }
.ship-flag { border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1); flex: 0 0 auto; }
.ship-arrow { display: flex; justify-content: center; color: var(--brand); }
.ship-right { display: flex; flex-direction: column; }
.ship-phead { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--ink-soft); margin-bottom: 24px; flex-wrap: wrap; gap: 6px 16px; }
.ship-phead b { color: var(--ink); font-weight: 800; }
.ship-stepper { position: relative; display: flex; justify-content: space-between; margin: 4px 12px 28px; }
.ship-stepper .ss-line { position: absolute; top: 13px; left: 14px; right: 14px; height: 4px; background: var(--line-strong); border-radius: 3px; z-index: 0; overflow: hidden; }
.ship-stepper .ss-line > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width 0.3s; }
.ss-step { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ss-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: #fff;
  transition: 0.2s;
}
.ss-step.done .ss-dot { background: var(--brand); border-color: var(--brand); }
.ss-step span { font-size: 11.5px; font-weight: 650; color: var(--ink-mute); white-space: nowrap; }
.ss-step.done span { color: var(--ink); }
.ship-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: auto; }
.ship-fact { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 13px 15px; box-shadow: var(--shadow-card); min-width: 0; }
.ship-fact b { font-size: 13.5px; font-weight: 750; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship-fact span { font-size: 11.5px; color: var(--ink-mute); }

/* ---------- списки и лента (дашборд) ---------- */

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 650; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-arrow { font-weight: 800; font-size: 15px; flex-shrink: 0; }
.feed { display: flex; flex-direction: column; gap: 11px; }
.feed-item { display: flex; gap: 9px; align-items: flex-start; }
.feed-text { font-size: 12.5px; line-height: 1.45; }
.feed-time { font-size: 10.5px; color: var(--ink-mute); margin-top: 1px; }

/* ---------- donut ---------- */

.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-svg { position: relative; width: 158px; flex-shrink: 0; }
.donut-svg svg { width: 100%; height: auto; transform: rotate(0deg); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut-center b { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.donut-center span { font-size: 10px; color: var(--ink-mute); }
.donut-leg { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: 7px; }
.donut-leg-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.donut-leg-row i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-leg-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
.donut-leg-row b { font-size: 11px; }
.donut-leg-pct { color: var(--ink-mute); min-width: 32px; text-align: right; }

/* ---------- тосты и модалки ---------- */

#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink);
  color: var(--paper);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 10px;
  padding: 11px 16px;
  box-shadow: var(--shadow-panel);
  max-width: 360px;
  animation: toastIn 0.25s ease;
}
.toast.out { opacity: 0; transition: opacity 0.4s; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(15, 12, 12, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  width: 520px;
  max-width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-panel);
}
.modal-wide { width: 760px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 14px; font-weight: 700; }
.modal-x { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-mute); }
.modal-x:hover { background: var(--surface-alt); color: var(--ink); }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--ink-mute);
  font-size: 12.5px;
}

/* ---------- адаптив ---------- */

@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-3 { grid-template-columns: repeat(2, 1fr); }
  .g-3-2, .g-1-2, .g-2 { grid-template-columns: 1fr; }
  .ai-wrap { grid-template-columns: 1fr; }
  .kb-board { grid-template-columns: repeat(3, 1fr); }
  .doc-layout { grid-template-columns: 1fr; }
  .ship-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .auth-split { flex-direction: column; }
  .auth-left { display: none; }
  .sidebar { transform: translateX(-270px); }
  .sidebar.open { transform: none; }
  .sidebar.open ~ .side-bd { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 12, 12, 0.35); }
  .burger { display: grid; }
  .main { margin-left: 0; }
  .view { padding: 66px 14px 60px; }
}

@media (max-width: 640px) {
  .g-4, .g-3 { grid-template-columns: 1fr; }
  .hbar-row { grid-template-columns: 110px 1fr auto; }
  .auth-input, .input { font-size: 16px; }
  .kb-board { grid-template-columns: 1fr; }
  .kb-col { min-height: 0; }
  .ship-facts { grid-template-columns: repeat(2, 1fr); }
}
