/* ===== Токены ===== */
:root {
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.79rem + 0.15vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.92rem + 0.1vw, 1rem);
  --text-lg: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);
  --text-xl: clamp(1.375rem, 1.2rem + 0.8vw, 1.875rem);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;

  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Светлая тема: холодный графит + янтарный акцент */
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --surface-3: #eef0f3;
  --border: #e2e5ea;
  --border-strong: #cfd4db;
  --text: #15191f;
  --text-2: #4a525e;
  --text-3: #7a828e;
  --accent: #c2630a;
  --accent-ink: #ffffff;
  --accent-soft: #fdf0e3;
  --own: #1f5f8b;       /* наши авто */
  --priv: #d08a2c;      /* частники */
  --good: #23824f;
  --good-soft: #e3f3ea;
  --warn: #a86a00;
  --warn-soft: #fbf1db;
  --bad: #b8322a;
  --bad-soft: #f9e3e1;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --sidebar: #12161c;
  --sidebar-text: #c9ced6;
  --sidebar-active: #1f252e;
  --key-bg: color-mix(in srgb, var(--warn-soft) 70%, var(--surface));
  --key-total: color-mix(in srgb, var(--warn-soft) 70%, var(--surface-2));
  --key-ink: var(--text);
  --total-bg: color-mix(in srgb, var(--own) 10%, var(--surface-2));
  --mark: var(--accent); --mark-ink: #fff; --scale: var(--accent); --rev: var(--accent);
}
[data-theme='dark'] {
  --bg: #0d1015;
  --surface: #151a21;
  --surface-2: #1a2029;
  --surface-3: #212833;
  --border: #262e3a;
  --border-strong: #354050;
  --text: #e8ebf0;
  --text-2: #b0b8c4;
  --text-3: #7f8896;
  --accent: #f0913a;
  --accent-ink: #1a1007;
  --accent-soft: #2d2014;
  --own: #5ea8dc;
  --priv: #e8a74e;
  --good: #4cc282;
  --good-soft: #15291f;
  --warn: #e3b14a;
  --warn-soft: #2b2414;
  --bad: #ef6b62;
  --bad-soft: #2f1817;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --sidebar: #0a0d11;
  --sidebar-text: #aeb6c2;
  --sidebar-active: #18202a;
}

/* ===== База ===== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
svg { flex-shrink: 0; }
.muted { color: var(--text-3); font-size: var(--text-sm); }
.num, td.n, th.n { font-variant-numeric: tabular-nums lining-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ===== Каркас ===== */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100dvh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: var(--s5) var(--s3);
  position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) var(--s6); }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--mark); color: var(--mark-ink); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: var(--text-base); }
.brand-text span { font-size: var(--text-xs); color: #8a93a0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s3); border-radius: var(--r-md);
  color: var(--sidebar-text); text-decoration: none; font-size: var(--text-sm); font-weight: 600;
  transition: background .15s, color .15s;
}
.nav a svg, .ghost-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--sidebar-active); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--mark); }
.sidebar-foot { margin-top: auto; }
.ghost-btn { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 10px var(--s3); background: none; border: 0; border-radius: var(--r-md); color: var(--sidebar-text); cursor: pointer; font-size: var(--text-sm); font-weight: 600; }
.ghost-btn:hover { background: var(--sidebar-active); color: #fff; }

.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap;
  padding: var(--s4) var(--s8); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: var(--text-xl); }
.topbar-controls { display: flex; gap: var(--s3); flex-wrap: wrap; }
.field-inline { display: flex; align-items: center; gap: var(--s2); font-size: var(--text-xs); color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
select, input[type='text'], input[type='number'], input[type='password'] {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 7px 10px; font-size: var(--text-sm); min-height: 36px;
}
.field-inline select { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text); min-width: 140px; }
.main { padding: var(--s6) var(--s8) var(--s10); display: flex; flex-direction: column; gap: var(--s5); max-width: 1480px; width: 100%; }

/* ===== Карточки ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5) 0; flex-wrap: wrap; }
.card-head h2 { font-size: var(--text-base); }
.card-head .muted { font-size: var(--text-xs); }
.card-body { padding: var(--s4) var(--s5) var(--s5); }
.grid { display: grid; gap: var(--s5); }
.g-kpi { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1640px) { .g-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); } .g-kpi > .kpi { grid-column: span 2; } .g-kpi > .kpi:nth-child(n+4) { grid-column: span 3; } }
@media (max-width: 1180px) { .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-kpi > .kpi, .g-kpi > .kpi:nth-child(n+4) { grid-column: auto; } .g-kpi .kpi-shifts { grid-column: span 2; } }
@media (max-width: 520px) { .g-kpi { grid-template-columns: 1fr; } .g-kpi > .kpi, .g-kpi .kpi-shifts { grid-column: auto; } }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-half { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* KPI */
.kpi { padding: var(--s4) var(--s5) var(--s5); display: flex; flex-direction: column; gap: var(--s2); }
.kpi-label { font-size: var(--text-xs); font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; display: flex; justify-content: space-between; gap: var(--s2); }
.kpi-value { font-size: var(--text-xl); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-sub { font-size: var(--text-sm); color: var(--text-2); display: flex; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.kpi-sub b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: var(--s1); }
.bar > i { display: block; height: 100%; background: var(--scale); border-radius: inherit; transition: width .5s ease; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: var(--text-xs); font-weight: 700; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.neutral { background: var(--surface-3); color: var(--text-2); }

.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 220px; }

/* Таблицы */
.table-wrap { overflow-x: auto; overscroll-behavior: contain; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th { text-align: left; font-size: var(--text-xs); font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.n, th.n { text-align: right; }
tr.total td { font-weight: 800; border-top: 2px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
tr.sub td:first-child { padding-left: 24px; color: var(--text-2); }
tr.strong td { font-weight: 700; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.own { background: var(--own); }
.dot.priv { background: var(--priv); }
.daily-table th { position: sticky; top: 0; z-index: 2; }
.daily-table thead tr.groups th { text-align: center; color: var(--text-2); border-bottom: 0; padding-bottom: 0; }
.daily-table .wd-weekend { color: var(--accent); font-weight: 700; }
.inline-input { width: 100px; text-align: right; padding: 4px 8px; min-height: 30px; font-variant-numeric: tabular-nums; }

/* Метрики */
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.metric { padding: var(--s3) 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: var(--s3); font-size: var(--text-sm); }
.metric:nth-child(odd) { padding-right: var(--s4); }
.metric:nth-child(even) { padding-left: var(--s4); border-left: 1px solid var(--border); }
.metric span { color: var(--text-2); }
.metric b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Наш vs частник */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.split-col { border-radius: var(--r-md); padding: var(--s4); background: var(--surface-2); border: 1px solid var(--border); }
.split-col h3 { font-size: var(--text-sm); margin-bottom: var(--s3); display: flex; align-items: center; }
.split-col dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px var(--s3); font-size: var(--text-sm); }
.split-col dt { color: var(--text-2); }
.split-col dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.share-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin: var(--s2) 0 var(--s4); background: var(--surface-3); }
.share-bar i { display: block; height: 100%; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); padding: 8px 14px; min-height: 36px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--text-sm); font-weight: 700; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 4px; font-size: var(--text-xs); font-weight: 700; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* Telegram */
.tg { white-space: pre-wrap; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: var(--text-xs); line-height: 1.6; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s4); max-height: 360px; overflow: auto; overscroll-behavior: contain; margin: 0; }

/* Загрузка */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: var(--s10) var(--s6);
  display: flex; flex-direction: column; align-items: center; gap: var(--s3); text-align: center;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 40px; height: 40px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dropzone strong { font-size: var(--text-lg); }
.dropzone input { display: none; }
.result { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.result div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s3) var(--s4); }
.result span { display: block; font-size: var(--text-xs); color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.result b { font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md); font-size: var(--text-sm); }
.alert.warn { background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.alert.bad { background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); }
.alert.good { background: var(--good-soft); border: 1px solid color-mix(in srgb, var(--good) 30%, transparent); }
.alert svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; margin-top: 2px; }
.alert a { color: inherit; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); font-weight: 700; color: var(--text-2); }
.field input, .field select { font-weight: 500; color: var(--text); }
.field small { font-weight: 500; color: var(--text-3); }
.form-actions { display: flex; gap: var(--s3); justify-content: flex-end; margin-top: var(--s4); flex-wrap: wrap; }
.drv-input { width: 84px; text-align: right; padding: 4px 8px; min-height: 32px; }
.drv-select { padding: 4px 8px; min-height: 32px; }
.drv-ip { width: 260px; padding: 4px 8px; min-height: 32px; }
tr.need td { background: var(--warn-soft); }

/* Пустое состояние / скелетон */
.empty { padding: var(--s10) var(--s6); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s3); }
.empty svg { width: 44px; height: 44px; fill: none; stroke: var(--text-3); stroke-width: 1.5; }
.empty h2 { font-size: var(--text-lg); }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r-lg); }
@keyframes sk { to { background-position: -200% 0; } }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 13, 18, .45); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--surface); z-index: 50; transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); padding: var(--s5); border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: var(--text-lg); }
.drawer-body { overflow: auto; overscroll-behavior: contain; padding: var(--s4) var(--s5) var(--s8); display: flex; flex-direction: column; gap: var(--s4); }
.route-group { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.route-head { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s3); background: var(--surface-2); font-size: var(--text-sm); flex-wrap: wrap; }
.route-head b { font-variant-numeric: tabular-nums; }
.status { font-size: var(--text-xs); font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.status.ok { background: var(--good-soft); color: var(--good); }
.status.part { background: var(--warn-soft); color: var(--warn); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.status.none { background: var(--surface-3); color: var(--text-3); }

/* Логин / тост */
.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 60; padding: var(--s4); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s8); width: min(380px, 100%); display: flex; flex-direction: column; gap: var(--s4); box-shadow: var(--shadow); }
.error { color: var(--bad); font-size: var(--text-sm); }
.toast { position: fixed; bottom: var(--s6); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: var(--r-md); font-size: var(--text-sm); font-weight: 600; z-index: 70; box-shadow: 0 8px 24px rgba(0,0,0,.2); }

.row-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.legend { display: flex; gap: var(--s4); font-size: var(--text-xs); color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ===== Адаптив ===== */
@media (max-width: 1180px) {
  .g-main, .g-half { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; padding: var(--s2) var(--s3); z-index: 30; gap: var(--s2); }
  .brand { padding: 0; }
  .brand-text { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: center; }
  .nav a { padding: 8px 10px; }
  .nav a span { display: none; }
  .nav a.active { box-shadow: inset 0 -3px 0 var(--mark); }
  .sidebar-foot { margin: 0; }
  .ghost-btn span { display: none; }
  .ghost-btn { width: auto; }
  .topbar { position: static; padding: var(--s4); }
  .main { padding: var(--s4) var(--s4) var(--s8); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .result { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .metrics { grid-template-columns: 1fr; }
  .metric:nth-child(even) { padding-left: 0; border-left: 0; }
  .metric:nth-child(odd) { padding-right: 0; }
  .split { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field-inline select { min-width: 0; }
  .topbar-controls { width: 100%; }
  .field-inline { flex: 1; }
  .field-inline select { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.drawer-body > * { flex-shrink: 0; }
.split-col dt { white-space: nowrap; }
.drawer { width: min(880px, 100vw); }
.seg { flex-wrap: wrap; max-width: 100%; }
@media (max-width: 520px) { .chart-box { height: 260px; } .seg button { padding: 5px 9px; } }
a.btn { text-decoration: none; color: var(--text); }
a.btn.primary { color: var(--accent-ink); }
.split-col dd { white-space: nowrap; }
.split-col dl { grid-template-columns: minmax(0, 1fr) auto; }
.split-col { padding: var(--s3); }

.kpi-label > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kpi-sub { flex-wrap: nowrap; }
.kpi-sub > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kpi-sub b { white-space: nowrap; }
.kpi .bar { margin-top: auto; }

/* ===== Список объектов в боковой панели ===== */
.obj-block { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid #232a34; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.obj-title { font-size: var(--text-xs); font-weight: 700; color: #7f8896; text-transform: uppercase; letter-spacing: .05em; padding: 0 var(--s3) var(--s2); }
.obj-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overscroll-behavior: contain; max-height: 40vh; }
.obj-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left; padding: 8px var(--s3); border: 0; border-radius: var(--r-md); background: none; color: var(--sidebar-text); cursor: pointer; font-size: var(--text-sm); font-weight: 600; }
.obj-item small { font-size: var(--text-xs); font-weight: 500; color: #7f8896; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-item:hover { background: var(--sidebar-active); color: #fff; }
.obj-item.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--own); }
.obj-item .obj-name { display: flex; align-items: center; gap: 8px; max-width: 100%; }
.obj-item .obj-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.obj-add { font-size: var(--text-xs); color: #8a93a0; text-decoration: none; padding: 6px var(--s3); font-weight: 600; }
.obj-add:hover { color: #fff; }

/* ===== Общие данные ===== */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--text-sm); font-weight: 600; cursor: pointer; user-select: none; }
.chip input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.chip.off { opacity: .55; }
.chip small { color: var(--text-3); font-weight: 500; }
.obj-cell { display: flex; align-items: center; gap: 8px; }
.share-mini { display: inline-block; width: 60px; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; vertical-align: middle; margin-right: 6px; }
.share-mini i { display: block; height: 100%; }
tr.off td { opacity: .5; }

@media (max-width: 860px) {
  .obj-block { display: none; }
}
.upload-target { margin-top: var(--s4); max-width: 520px; }

/* Telegram: текст заполняет карточку целиком, без внутренней прокрутки */
.tg-card { display: flex; flex-direction: column; }
.tg-card > .card-body { flex: 1; display: flex; flex-direction: column; }
.tg-card .tg { flex: 1; max-height: none; overflow: visible; font-size: var(--text-sm); }

/* ===== График водителей ===== */
.sch-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s5); font-size: var(--text-sm); color: var(--text-2); }
.sch-legend > span { display: inline-flex; align-items: center; }
.sch-legend .muted { flex-basis: 100%; font-size: var(--text-xs); }
i.k { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; padding: 0 6px; margin-right: 8px; border-radius: var(--r-sm); font-style: normal; font-weight: 800; font-size: var(--text-sm); background: var(--surface-3); color: var(--text); }
.sch-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--text-xs); color: var(--text-3); font-weight: 600; }
.sch-tools > span { margin-right: var(--s2); }
.sch-tools input[type='number'] { width: 72px; }
.sch-tools .btn { min-height: 32px; padding: 6px 12px; }
.sch-tools .chip { padding: 5px 10px; }

table.sch { width: auto; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.sch th, .sch td { padding: 0; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
.sch thead th { background: var(--head-bg, var(--sidebar)); color: #fff; text-transform: none; letter-spacing: 0; font-size: var(--text-xs); font-weight: 700; padding: 6px 4px; border-bottom: 0; line-height: 1.25; }
.sch thead th.we { background: var(--sidebar-active); }
.sch thead th.today { box-shadow: inset 0 -3px 0 var(--accent); }
.sch th.sch-day { min-width: 46px; }
.sch th.sch-day small { display: block; color: var(--sidebar-text); font-weight: 600; }
.sch .sch-no { position: sticky; left: 0; z-index: 2; width: 40px; min-width: 40px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sch .sch-name { position: sticky; left: 40px; z-index: 2; min-width: 236px; max-width: 236px; text-align: left; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.sch .sch-name small { margin-left: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.sch .sch-name small.own { color: var(--own); }
.sch .sch-name small.priv { color: var(--priv); }
.sch .sch-fact { position: sticky; left: 276px; z-index: 2; min-width: 58px; font-weight: 800; font-variant-numeric: tabular-nums; border-right: 2px solid var(--border-strong); }
.sch tbody .sch-no, .sch tbody .sch-name, .sch tbody .sch-fact { background: var(--surface); }
.sch thead .sch-no, .sch thead .sch-name, .sch thead .sch-fact { z-index: 3; background: var(--head-bg, var(--sidebar)); }
.sch thead .sch-name { padding: 6px 10px; }
.sch tbody tr:hover .sch-no, .sch tbody tr:hover .sch-name, .sch tbody tr:hover .sch-fact { background: var(--surface-2); }
.sch td.sch-c { height: 32px; cursor: pointer; font-weight: 700; color: var(--text-2); }
.sch td.we { background: var(--surface-3); }
.sch td.sch-c:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.sch td.sch-c:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0; }
.sch td.st-a { color: var(--text); }
.sch td.st-an { color: var(--own); }
.sch td.st-cds { color: var(--accent); }
.sch td.st-n, i.k.st-n { background: var(--bad-soft); color: var(--bad); }
.sch td.st-p, i.k.st-p { background: var(--warn-soft); color: var(--warn); }
.sch td.st-r, i.k.st-r { background: var(--good-soft); color: var(--good); }
i.k.st-an { color: var(--own); }
i.k.st-cds { color: var(--accent); }
.sch td.sch-empty { padding: var(--s5); color: var(--text-3); text-align: left; }
.sch tfoot th { position: sticky; left: 0; z-index: 2; text-align: right; padding: 0 12px; font-size: var(--text-sm); font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--text-2); background: var(--surface-2); border-right: 2px solid var(--border-strong); }
.sch tfoot td { height: 30px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface-2); }
.sch tfoot tr.sch-plan th, .sch tfoot tr.sch-plan td { background: var(--warn-soft); }
.sch tfoot tr.sch-plan th { color: var(--warn); }
.sch tfoot input { width: 42px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; text-align: center; font-weight: 800; -moz-appearance: textfield; }
.sch tfoot input::-webkit-outer-spin-button, .sch tfoot input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sch tfoot input:hover, .sch tfoot input:focus { border-color: var(--border-strong); background: var(--surface); }
.sch tfoot input::placeholder { color: var(--text-3); font-weight: 600; }
.sch tfoot tr.sch-def td.bad { background: var(--bad-soft); color: var(--bad); }
.sch tfoot tr.sch-def th, .sch tfoot tr.sch-def td { border-bottom: 0; }

.sch-menu { position: fixed; z-index: 60; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(16, 24, 40, .18); display: flex; flex-direction: column; gap: 2px; }
.sch-menu-head { padding: 4px 8px 6px; font-size: var(--text-xs); color: var(--text-3); font-weight: 700; }
.sch-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
.sch-menu button { display: flex; align-items: center; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; font-size: var(--text-sm); font-weight: 600; cursor: pointer; }
.sch-menu button:hover, .sch-menu button:focus-visible { background: var(--surface-2); outline: none; }
.sch-menu button.cur { background: var(--accent-soft); }

/* ===== Сотрудники ===== */
.g-emp { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.g-emp .kpi-label > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-emp .kpi-sub .neg { color: var(--bad); font-weight: 700; }
.g-emp .kpi-sub .pos { color: var(--good); font-weight: 700; }
.g-emp .kpi-sub a { color: var(--accent); font-weight: 700; text-decoration: none; }
.emp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.emp-tools input[type='search'] { width: 240px; max-width: 100%; }
input[type='search'], input[type='date'], input[type='tel'], textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 7px 10px; font: inherit; font-size: var(--text-sm); min-height: 36px; color: var(--text);
}
textarea { resize: vertical; min-height: 72px; }
table.emp td { vertical-align: middle; }
.emp-row { cursor: pointer; }
.emp-row:hover td { background: var(--surface-2); }
.emp-row.fired td { color: var(--text-3); }
.emp-row.fired b { text-decoration: line-through; text-decoration-color: var(--text-3); }
.emp-phone { display: block; color: var(--text-3); font-size: var(--text-xs); }
.sched { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
.emp-empty { padding: var(--s6) 0; max-width: 60ch; }
.emp-empty h3 { margin: 0 0 var(--s2); font-size: var(--text-lg); }
.drawer.narrow { width: min(560px, 100vw); }
.emp-form { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.emp-form .span2 { grid-column: 1 / -1; }
.emp-form .field textarea, .emp-form .field input, .emp-form .field select { width: 100%; font-weight: 500; color: var(--text); }
.emp-form .form-actions { margin-top: 0; }
.emp-form .grow { flex: 1; }
.emp-form .error { margin: 0; color: var(--bad); font-weight: 600; font-size: var(--text-sm); }
.emp-form .muted { margin: 0; font-size: var(--text-sm); }
.sched-pick { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.sched-pick .chip { padding: 6px 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sched-pick .chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sched-pick input { flex: 1 1 180px; min-width: 0; }
@media (max-width: 520px) { .emp-form { grid-template-columns: 1fr; } }

/* ===== Календарь рабочих дней ===== */
.cal-head { align-items: flex-end; }
.cal-head h2 + .muted { margin: 4px 0 0; font-size: var(--text-sm); }
.cal-total { font-size: var(--text-sm); color: var(--text-2); }
.cal-total b { color: var(--text); font-variant-numeric: tabular-nums; }
.cal-total b.pos { color: var(--good); } .cal-total b.neg { color: var(--bad); }
.cal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; }
.cal-day {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 14px 16px 12px; border-radius: var(--r-md); cursor: pointer; color: var(--text);
  border: 1px solid color-mix(in srgb, var(--own) calc(var(--heat) + 8%), var(--border));
  background: color-mix(in srgb, var(--own) var(--heat), var(--surface));
  transition: transform .12s ease, box-shadow .12s ease;
}
.cal-day:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.cal-day.sel { box-shadow: 0 0 0 2px var(--own); border-color: var(--own); }
.cal-day.idle { background: var(--surface-2); color: var(--text-3); }
.cal-wd { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.cal-day.we .cal-wd { color: var(--accent); }
.cal-date { font-size: var(--text-lg); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin-bottom: 6px; }
.cal-trips { font-size: var(--text-xs); color: var(--text-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.cal-rev { font-size: var(--text-sm); font-weight: 800; font-variant-numeric: tabular-nums; }
.cal-profit { font-size: var(--text-xs); font-weight: 700; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .cal-day { transition: none; } .cal-day:hover { transform: none; } }

.cal-body { display: flex; flex-direction: column; gap: var(--s4); }
#calSlot:empty { display: none; }
.cal-detail { border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); padding: var(--s5); display: flex; flex-direction: column; gap: var(--s5); min-width: 0; }
.cal-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); flex-wrap: wrap; }
.cal-detail-head h3 { margin: 0; font-size: var(--text-lg); }
.cal-detail-head .muted { margin: 4px 0 0; font-size: var(--text-sm); }
.cal-detail .row-actions { display: flex; gap: var(--s2); align-items: center; }
.day-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s4); }
.day-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.day-group h4, .cal-routes h4 { margin: 0; font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.dm { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px var(--s3); font-size: var(--text-sm); }
.dm > span { color: var(--text-2); }
.dm > b { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.dm > small { grid-column: 1 / -1; font-size: var(--text-xs); color: var(--text-3); }
.dm > small.pos { color: var(--good); } .dm > small.neg { color: var(--bad); }
.dm.big > b { font-size: var(--text-lg); font-weight: 800; }
.dm .inline-input { justify-self: end; }
.cal-routes { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.cal-routes table { background: var(--surface); }
.cal-routes .muted { margin: 0; font-size: var(--text-xs); }

/* ===== Меню «Сотрудники» ===== */
.nav-group { display: flex; flex-direction: column; position: relative; }
.nav-parent { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 10px var(--s3); border: 0; border-radius: var(--r-md); background: none; color: var(--sidebar-text); font-size: var(--text-sm); font-weight: 600; cursor: pointer; text-align: left; transition: background .15s, color .15s; }
.nav-parent svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-parent span { flex: 1; }
.nav-parent .chev { width: 16px; height: 16px; transition: transform .2s ease; opacity: .7; }
.nav-group.open .nav-parent .chev { transform: rotate(180deg); }
.nav-parent:hover, .nav-parent.active { background: var(--sidebar-active); color: #fff; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; overflow: hidden; max-height: 0; transition: max-height .22s ease; }
.nav-sub > a:first-child { margin-top: 2px; }
.nav-group.open .nav-sub { max-height: 480px; }
.nav-group:not(.open) .nav-sub a { visibility: hidden; }
.nav .nav-sub a { padding: 8px var(--s2) 8px 14px; font-size: var(--text-sm); white-space: nowrap; }
@media (max-width: 860px) {
  .nav-group { position: relative; }
  .nav-parent { width: auto; padding: 8px 10px; }
  .nav-parent span, .nav-parent .chev { display: none; }
  .nav-parent.active { box-shadow: inset 0 -3px 0 var(--mark); }
  .nav-sub { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); min-width: 200px; max-height: none; background: var(--sidebar); border: 1px solid var(--sidebar-active); border-radius: var(--r-md); padding: 6px; box-shadow: 0 12px 28px rgba(0, 0, 0, .35); z-index: 40; display: none; }
  .nav-group.open .nav-sub { display: flex; max-height: none; }
  .nav-group:not(.open) .nav-sub a { visibility: visible; }
  .nav .nav-sub a { padding: 8px 10px; }
  .nav .nav-sub a span { display: inline; }
  .nav .nav-sub a.active { box-shadow: none; }
}

/* ===== Водители ===== */
.drv-note { margin: 0 0 var(--s4); font-size: var(--text-xs); max-width: 90ch; }
table.drv td { vertical-align: top; padding-top: 12px; padding-bottom: 12px; white-space: normal; }
table.drv td:first-child { white-space: nowrap; }
.drv-sub { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--text-3); font-weight: 500; }
small.cat { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-left: 4px; }
small.cat.own { color: var(--own); } small.cat.priv { color: var(--priv); }
.plate { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; margin: 0 6px 6px 0; border: 1.5px solid var(--text); border-radius: 5px; font-weight: 800; font-size: var(--text-sm); letter-spacing: .04em; font-variant-numeric: tabular-nums; background: var(--surface); white-space: nowrap; }
.plate small { font-weight: 700; color: var(--text-3); letter-spacing: 0; }
.plate.minor { border-color: var(--border-strong); color: var(--text-2); font-weight: 700; }
.drv-chip { display: inline-flex; gap: 6px; align-items: center; padding: 3px 10px; margin: 0 6px 6px 0; border-radius: 99px; background: var(--surface-3); font-size: var(--text-sm); font-weight: 700; white-space: nowrap; }
.drv-chip small { color: var(--text-3); }
.drv-chip.minor { font-weight: 600; color: var(--text-2); }
.drv-sub.nowrap { white-space: nowrap; }
.drv-shifts { font-size: var(--text-lg); font-weight: 800; }
.drv-obj-h { min-width: 260px; }
.drv-obj { min-width: 260px; }
.obj-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.obj-bar i { display: block; height: 100%; }
.obj-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: var(--text-xs); color: var(--text-2); }
.obj-legend b { color: var(--text); }
.obj-legend small { color: var(--text-3); }

/* ===== Рейтинг водителей ===== */
.g-rt { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.kpi-sub b.neg { color: var(--bad); }
.st-bar { display: flex; gap: 2px; height: 14px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.st-bar i { display: block; min-width: 3px; }
.st-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: var(--text-sm); color: var(--text-2); }
.st-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.st-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.st-legend small { color: var(--text-3); }
table.rt td { vertical-align: top; white-space: normal; }
table.rt td.n { white-space: nowrap; }
.rt-row { cursor: pointer; }
.rt-row:hover td { background: var(--surface-2); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable.on { color: var(--text); }
.score { display: inline-grid; place-items: center; min-width: 42px; height: 28px; padding: 0 8px; border-radius: 8px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score.good { background: var(--good-soft); color: var(--good); }
.score.warn { background: var(--warn-soft); color: var(--warn); }
.score.bad { background: var(--bad-soft); color: var(--bad); }
.score.neutral { background: var(--surface-3); color: var(--text-3); }
.warn-t { color: var(--warn); font-weight: 700; }
.rt-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--s3); }
.rt-sum > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s3); display: flex; flex-direction: column; gap: 4px; }
.rt-sum span { font-size: var(--text-xs); color: var(--text-3); font-weight: 700; }
.rt-sum b { font-size: var(--text-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.rt-block { display: flex; flex-direction: column; gap: var(--s2); }
.rt-block h4 { margin: 0; font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.rt-block .muted { margin: 0; font-size: var(--text-sm); }
.rt-moves { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rt-moves li { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-left: 3px solid var(--warn); background: var(--surface-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: var(--text-sm); }
.rt-moves li span { color: var(--text-2); }

/* ===== Реестр счетов ===== */
.inv-help { margin: 4px 0 0; font-size: var(--text-xs); max-width: 70ch; }
.inv-rates { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--text-xs); color: var(--text-3); font-weight: 700; }
.inv-rates input { width: 78px; }
.inv-rates label + input { margin-right: var(--s3); }
table.inv { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
table.inv th, table.inv td { border-bottom: 1px solid var(--border); padding: 0; }
table.inv thead th { padding: 8px 10px; background: var(--head-bg, var(--sidebar)); color: #fff; text-transform: none; letter-spacing: 0; font-size: var(--text-xs); border-bottom: 0; }
table.inv thead tr.inv-mrow th { background: none; padding: 0; }
table.inv thead tr.inv-mrow th.inv-month { background: var(--head-bg, var(--sidebar)); color: #fff; text-align: center; padding: 6px 10px; border-radius: 6px 6px 0 0; font-size: var(--text-sm); }
table.inv thead th.inv-gap { background: none; }
table.inv thead th.inv-com-h { background: color-mix(in srgb, var(--accent) 80%, #000); }
table.inv thead th.inv-hl { background: color-mix(in srgb, var(--head-bg, var(--sidebar)) 70%, #000); }
table.inv td.inv-code, table.inv td.inv-name { padding: 8px 12px; text-align: center; background: var(--surface-2); white-space: nowrap; }
table.inv td.inv-name { font-weight: 600; }
table.inv td.inv-period { padding: 8px 12px; white-space: nowrap; text-align: center; font-weight: 600; }
.inv-note { display: block; font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.inv-note.open { color: var(--warn); }
table.inv td.inv-hl { background: var(--key-bg); color: var(--key-ink); font-weight: 800; }
table.inv .inv-in { width: 100%; min-width: 72px; height: 36px; min-height: 0; padding: 0 6px; border: 1px solid transparent; border-radius: 0; background: transparent; text-align: right; font: inherit; font-size: var(--text-sm); font-variant-numeric: tabular-nums; color: var(--text); }
table.inv .inv-in.strong { font-weight: 800; }
.inv-in.calc { color: var(--text); }
.inv-in.zero { color: var(--text-3); }
table.inv .inv-in:hover { border-color: var(--border-strong); }
table.inv .inv-in:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent); }
table.inv .inv-in.ov, table.inv .inv-date.ov { background: color-mix(in srgb, var(--own) 12%, transparent); box-shadow: inset 3px 0 0 var(--own); }
.inv-date { border: 1px solid transparent; background: transparent; height: 36px; padding: 0 10px; font: inherit; font-size: var(--text-sm); color: var(--text); }
.inv-date:hover { border-color: var(--border-strong); }
table.inv tfoot td { padding: 10px 7px; font-weight: 800; background: var(--total-bg); text-align: right; white-space: nowrap; border-bottom: 0; }
table.inv tfoot td:first-child { text-align: left; }
table.inv tfoot td.inv-hl { background: var(--key-total); color: var(--key-ink); }
table.inv-total { min-width: 640px; }
.g-inv { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.g-inv .kpi-value { font-size: var(--text-xl); white-space: nowrap; }
table.inv td.inv-code { padding: 8px; }
table.inv td.inv-name { white-space: normal; min-width: 80px; max-width: 120px; line-height: 1.3; }
table.inv td.inv-code, table.inv td.inv-name { border-right: 1px solid var(--border); }
table.inv td.inv-period { padding: 8px 10px; }
table.inv { width: 100%; }
table.inv thead th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
table.inv thead tr.inv-mrow th { white-space: nowrap; }
table.inv td.inv-code { min-width: 0; width: 96px; max-width: 110px; white-space: normal; border-right: 1px solid var(--border); }
table.inv td.inv-code b { display: block; font-size: var(--text-lg); font-weight: 800; }
table.inv td.inv-code small { display: block; font-size: var(--text-xs); color: var(--text-2); font-weight: 600; line-height: 1.3; }

/* ===== ФОТ труда ===== */
.pay-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.pay-hint { font-size: var(--text-xs); flex: 1 1 320px; }
.kpi-value.neg { color: var(--bad); }
table.pay { font-variant-numeric: tabular-nums; }
table.pay td, table.pay th { white-space: nowrap; }
.pay-ip { cursor: pointer; }
.pay-ip:hover td { background: var(--surface-2); }
.pay-ip.open td { background: var(--surface-2); border-bottom-color: transparent; }
.pay-ip.noip b { color: var(--bad); }
.pay-chev { width: 28px; padding-right: 0 !important; }
.pay-chev svg { width: 16px; height: 16px; fill: none; stroke: var(--text-3); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s ease; display: block; }
.pay-ip.open .pay-chev svg { transform: rotate(90deg); stroke: var(--accent); }
td.pay-hl, th.pay-hl { background: var(--key-bg); color: var(--key-ink); }
td.pay-hl b, td.pay-hl { font-weight: 800; }
.pay-ip.open td.pay-hl { background: var(--key-bg); }
table.pay tfoot td { font-weight: 800; background: var(--total-bg); border-bottom: 0; padding: 10px; }
table.pay tfoot td.pay-hl { background: var(--key-total); color: var(--key-ink); }
.pay-detail-box { width: 0; min-width: 100%; }
tr.pay-detail > td { background: var(--surface-2); padding: 4px 10px 16px; border-bottom: 2px solid var(--border-strong); }
table.pay-drv { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
table.pay-drv td { white-space: nowrap; }
table.pay-drv th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
table.pay-drv td:first-child { white-space: normal; min-width: 180px; }
table.pay-drv td { vertical-align: top; }
table.pay-drv th small { color: var(--text-3); }
.pay-items { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--text-sm); color: var(--text-2); }
.pay-items li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kind { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: var(--text-xs); font-weight: 800; background: var(--surface-3); color: var(--text-2); }
.kind.k-fuel { background: var(--warn-soft); color: var(--warn); }
.kind.k-claims { background: var(--bad-soft); color: var(--bad); }
.kind.k-bonus { background: var(--good-soft); color: var(--good); }
.kind.k-branding, .kind.k-uniform { background: color-mix(in srgb, var(--own) 14%, var(--surface)); color: var(--own); }
table.pay-ded td { vertical-align: top; }
table.pay-ded .pay-comment { white-space: normal; min-width: 160px; color: var(--text-2); }
table.pay-ded .btn { min-height: 30px; padding: 4px 10px; font-size: var(--text-xs); }
.card-head .row-actions { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }

.sp-calc { font-size: var(--text-lg); font-weight: 800; padding: 6px 0; font-variant-numeric: tabular-nums; }
table.sp td { white-space: nowrap; }
table.sp td:nth-child(3) { white-space: normal; }

/* ===== ИПешники ===== */
.nav-portal { display: none !important; }
body.ip-mode .nav > a, body.ip-mode .nav > .nav-group, body.ip-mode .obj-block, body.ip-mode #objectField { display: none !important; }
body.ip-mode .nav > a.nav-portal { display: flex !important; }
.g-portal { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.g-portal .kpi-value { font-size: var(--text-xl); white-space: nowrap; }
.g-portal .drv-sub.pos { color: var(--good); } .g-portal .drv-sub.neg { color: var(--bad); }
table.portal td { white-space: nowrap; }
table.portal td:nth-child(2) { white-space: normal; min-width: 200px; }
.portal-mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--s2); margin: 6px 0 10px; }
.portal-mini > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.portal-mini span { font-size: var(--text-xs); color: var(--text-3); font-weight: 700; }
.portal-mini b { font-variant-numeric: tabular-nums; }
.portal-late { margin: 8px 0 0; font-size: var(--text-sm); color: var(--text-2); }
.portal-detail .muted { margin: 4px 0 0; font-size: var(--text-sm); }
.ip-row { cursor: pointer; }
.ip-row:hover td { background: var(--surface-2); }
.ip-row.sel td { background: var(--accent-soft); }
.ip-row.sel td.pay-hl { background: var(--key-total); }
table.ip-list td { vertical-align: top; }
table.ip-list td:nth-child(2) { white-space: normal; min-width: 220px; }
table.ip-list .drv-chip { margin: 0 4px 4px 0; font-size: var(--text-xs); }
.ip-portal-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s2); }
.ip-portal-head h2 { margin: 0; font-size: var(--text-lg); }
.ip-portal-head:empty { display: none; }
.ip-portal { display: flex; flex-direction: column; gap: var(--s5); }
table.ipset td { vertical-align: top; }
table.ipset select { min-width: 260px; max-width: 100%; }
table.ipset select.manual { border-color: var(--own); box-shadow: inset 3px 0 0 var(--own); }
.ip-add { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s4); }
.ip-add input { flex: 1 1 320px; }
.ip-comment { width: 100%; min-width: 160px; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.user-actions .btn { min-height: 30px; padding: 4px 10px; font-size: var(--text-xs); }
.cred-box { display: grid; gap: var(--s2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s4); }
.cred-box > div { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.cred-box span { color: var(--text-3); font-size: var(--text-sm); }
.cred-box b { font-variant-numeric: tabular-nums; word-break: break-all; }
.cred-pass { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-lg); letter-spacing: .04em; }
#credText { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
table.ip-list td:nth-child(2) { min-width: 180px; max-width: 320px; }
table.ip-list td:nth-child(2) .drv-chip { display: inline-flex; }
table.ip-list th small { font-weight: 600; text-transform: none; letter-spacing: 0; }
@media (max-width: 520px) {
  .sidebar { gap: 2px; padding: var(--s2); }
  .sidebar .brand { display: none; }
  .nav { gap: 0; justify-content: space-between; }
  .nav a, .nav-parent { padding: 8px 6px; }
  .ghost-btn { padding: 8px 6px; }
  .nav-sub { left: auto; right: -40px; transform: none; }
}
body.ip-mode .sidebar .brand { display: flex; }
table.ipset select { width: 100%; min-width: 220px; }

/* ===== Ключевые цифры ===== */
.kpi-value { color: var(--key-ink); }
td.n, th.n, .n { font-variant-numeric: tabular-nums; }
table.inv td.inv-hl .inv-in, table.inv td.inv-hl .calc { color: var(--key-ink); }

/* ===== Расходы по выпискам ===== */
.exp-bar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.exp-upload { cursor: pointer; }
.exp-hint { font-size: var(--text-xs); flex: 1 1 260px; }
#bankResult .alert { margin: 0 var(--s4) var(--s4); }
.exp-empty h2 { margin-bottom: var(--s2); font-size: var(--text-lg); }
.exp-empty p { max-width: 70ch; }
.exp-split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s5); }
@media (max-width: 1100px) { .exp-split { grid-template-columns: 1fr; } }
.exp-cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.exp-cats button { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 4px var(--s3); align-items: center; text-align: left; background: none; border: 0; border-radius: var(--r-sm); padding: 8px 10px; cursor: pointer; color: var(--text); font: inherit; }
.exp-cats button:hover { background: var(--surface-2); }
.exp-cats button.on { background: var(--accent-soft); }
.exp-cats button.personal { color: var(--text-3); }
.exp-cat-name { font-size: var(--text-sm); font-weight: 600; }
.exp-cat-name small { margin-left: 6px; color: var(--text-3); font-weight: 600; font-size: var(--text-xs); }
.exp-cats b { font-variant-numeric: tabular-nums; font-size: var(--text-sm); }
.exp-cat-bar { grid-column: 1 / -1; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.exp-cat-bar i { display: block; height: 100%; background: var(--scale); }
.exp-objs { list-style: none; margin: 0 0 var(--s3); padding: 0; }
.exp-objs li { display: flex; justify-content: space-between; gap: var(--s3); padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--text-sm); }
.exp-objs li span { display: inline-flex; align-items: center; gap: 6px; }
.exp-objs b { font-variant-numeric: tabular-nums; }
.exp-accts { display: grid; gap: 6px; margin-top: var(--s3); }
.exp-accts > div { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); font-size: var(--text-xs); background: var(--surface-2); border-radius: var(--r-sm); padding: 6px 8px; }
.exp-accts small { display: block; color: var(--text-3); word-break: break-all; }
.exp-accts .btn { min-height: 28px; padding: 3px 8px; font-size: var(--text-xs); flex-shrink: 0; }
.exp-remember { display: flex; gap: 8px; align-items: flex-start; font-size: var(--text-xs); color: var(--text-2); margin-bottom: var(--s3); }
.exp-remember input { margin-top: 2px; accent-color: var(--accent); }
table.exp-ops td { vertical-align: top; }
table.exp-ops .exp-date { white-space: nowrap; }
table.exp-ops .exp-cp { min-width: 260px; max-width: 520px; white-space: normal; }
.exp-purpose { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--text-3); line-height: 1.35; }
table.exp-ops select { max-width: 230px; font-size: var(--text-xs); }
table.exp-ops select.set { box-shadow: inset 3px 0 0 var(--own); }
table.exp-ops tr.is-personal td { color: var(--text-3); }
table.exp-ops tr.is-personal b.neg { color: var(--text-3); text-decoration: line-through; }
table.exp-ops tfoot td { font-weight: 800; background: var(--total-bg); padding: 10px; }
#expMore { margin-top: var(--s3); }
#bankResult .alert:not(.warn):not(.bad):not(.good) { background: var(--surface-2); }
.exp-root, #expBody { display: flex; flex-direction: column; gap: var(--s5); }
.exp-kpis .kpi-sub, .exp-kpis .kpi-sub span { white-space: normal; overflow: visible; text-overflow: clip; }
.exp-cats button { padding: 6px 10px; }

/* =====================================================================
   Тема «Лес»: лесной зелёный, шалфей, крафт; фон из листьев, мягкий объём
   ===================================================================== */
:root:not([data-theme='dark']) {
  --bg: #e6ebe3; --surface: #fbfaf6; --surface-2: #f3f1ea; --surface-3: #e8e5da;
  --border: #ddd8cb; --border-strong: #c7c0ad;
  --text: #1b2a22; --text-2: #4a5a50; --text-3: #75837a;
  --accent: #2f6b4f; --accent-ink: #fff; --accent-soft: #e1ece3;
  --mark: #d9b48f; --mark-ink: #1f3a2e; --scale: #3f7d5c; --rev: #1f4a3d;
  --own: #2f6b4f; --priv: #c08a55; --obj-1: #2f6b4f; --obj-2: #c08a55;
  --good: #2e7d4f; --good-soft: #e0efe3; --warn: #a2702a; --warn-soft: #f5ead4; --bad: #b4483a; --bad-soft: #f7e3de;
  --key-bg: #f3e6d4; --key-total: #e9d4b8; --key-ink: #5c3a22; --total-bg: #e8e5d8;
  --sidebar: #183a2e; --sidebar-text: #d3ded6; --sidebar-active: rgba(255, 255, 255, .13);
  --kpi-ink: #1f4a3d;
  --veil: rgba(231, 237, 228, .86); --veil-2: rgba(222, 230, 219, .93);
  --lift: inset 0 1px 0 rgba(255, 255, 255, .85), 0 1px 2px rgba(24, 58, 46, .08), 0 14px 30px -16px rgba(24, 58, 46, .38);
  --lift-hi: inset 0 1px 0 rgba(255, 255, 255, .9), 0 2px 4px rgba(24, 58, 46, .1), 0 20px 36px -16px rgba(24, 58, 46, .45);
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --shadow: var(--lift);
}
:root[data-theme='dark'] {
  --bg: #0e1a15; --surface: #15241d; --surface-2: #1a2c23; --surface-3: #22362b;
  --border: #284131; --border-strong: #36533f;
  --text: #e6eee8; --text-2: #b0c1b6; --text-3: #7f9488;
  --accent: #5fae82; --accent-ink: #0c1a13; --accent-soft: #1d3529;
  --mark: #d9b48f; --mark-ink: #1b2a22; --scale: #6fbf8f; --rev: #d3e6d9;
  --own: #6fbf8f; --priv: #d9a877; --obj-1: #6fbf8f; --obj-2: #d9a877;
  --good: #6cc48d; --good-soft: #183325; --warn: #e0b565; --warn-soft: #2e2615; --bad: #ee8a7a; --bad-soft: #3a1f1a;
  --key-bg: #2e2418; --key-total: #3d2f1e; --key-ink: #f0d2ae; --total-bg: #1f3127;
  --sidebar: #0f241b; --sidebar-text: #c3d2c8; --sidebar-active: rgba(255, 255, 255, .1);
  --kpi-ink: #ecdcc4;
  --veil: rgba(10, 22, 16, .86); --veil-2: rgba(8, 18, 13, .93);
  --lift: inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .35), 0 16px 32px -18px rgba(0, 0, 0, .7);
  --lift-hi: inset 0 1px 0 rgba(255, 255, 255, .08), 0 2px 4px rgba(0, 0, 0, .4), 0 22px 40px -18px rgba(0, 0, 0, .8);
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --shadow: var(--lift);
}

/* Фон: размытые листья под светлой (или тёмной) вуалью */
body { background: linear-gradient(180deg, var(--veil), var(--veil-2)), url('img/leaves-bg.jpg') center / cover fixed, var(--bg); }

/* Меню: тёмно-зелёное с листьями */
.sidebar {
  background: linear-gradient(180deg, rgba(20, 52, 40, .78) 0%, rgba(16, 40, 31, .9) 45%, rgba(12, 30, 23, .96) 100%), url('img/leaves-side.jpg') top center / cover, var(--sidebar);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .06), 8px 0 30px -18px rgba(0, 0, 0, .55);
}
.brand-text span, .obj-title, .obj-item small, .obj-add { color: rgba(211, 222, 214, .62); }
.obj-block { border-top-color: rgba(255, 255, 255, .1); }
.brand-mark { border-radius: 12px; background: linear-gradient(145deg, #ecd3b6, #c99c70); color: #1f3a2e; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 6px 14px -6px rgba(0, 0, 0, .6); }
.nav a, .nav-parent { border-radius: 12px; }
.nav a.active, .nav-parent.active {
  background: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .08)); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 8px 16px -10px rgba(0, 0, 0, .6);
}
.nav .nav-sub a.active { box-shadow: none; background: rgba(255, 255, 255, .1); }
.obj-item.active { background: rgba(255, 255, 255, .12); box-shadow: inset 3px 0 0 var(--mark); }

/* Шапка: полоса с листьями */
.topbar {
  background: linear-gradient(100deg, rgba(18, 48, 36, .94) 0%, rgba(24, 62, 46, .82) 50%, rgba(24, 62, 46, .55) 100%), url('img/leaves-band.jpg') center 40% / cover;
  border-bottom: 0; box-shadow: 0 10px 30px -18px rgba(10, 30, 22, .7); color: #f4f1ea;
}
.topbar h1 { color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .25); }
.topbar .muted, .topbar #periodLine { color: rgba(240, 236, 226, .78); }
.topbar .field-inline { color: rgba(240, 236, 226, .75); }
.topbar .field-inline select { background: rgba(251, 250, 246, .95); color: #1b2a22; border-color: transparent; box-shadow: inset 0 1px 0 #fff, 0 4px 10px -6px rgba(0, 0, 0, .5); }
.topbar .demo-note { background: rgba(233, 212, 184, .92); color: #5c3a22; }

/* Карточки: светлый «картон» с мягким объёмом */
.card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 100%, #fff 0%), color-mix(in srgb, var(--surface) 92%, var(--surface-3)));
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: var(--lift);
}
.kpi { position: relative; overflow: hidden; isolation: isolate; }
.kpi::after {
  content: ''; position: absolute; right: -50px; bottom: -62px; width: 118px; height: 118px; border-radius: 50%; z-index: -1; pointer-events: none;
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .55), transparent 42%), radial-gradient(circle at 50% 50%, var(--kpi-dot, #9cc0a6) 0 60%, transparent 61%);
  box-shadow: inset -8px -10px 18px rgba(0, 0, 0, .12); opacity: .3;
}
.grid > .kpi:nth-child(4n+2) { --kpi-dot: #d9b48f; }
.grid > .kpi:nth-child(4n+3) { --kpi-dot: #2f6b4f; }
.grid > .kpi:nth-child(4n+4) { --kpi-dot: #b9a387; }
[data-theme='dark'] .kpi::after { opacity: .22; }
.kpi-value { color: var(--kpi-ink); text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }
[data-theme='dark'] .kpi-value { text-shadow: none; }

/* Кнопки: объёмные */
.btn { border-radius: 10px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 1px 2px rgba(24, 58, 46, .12); transition: transform .12s, box-shadow .12s, background .15s; }
.btn:active { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12); }
.btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, #fff), var(--accent)); border-color: color-mix(in srgb, var(--accent) 80%, #000);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 8px 16px -8px color-mix(in srgb, var(--accent) 70%, #000); }
[data-theme='dark'] .btn { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .4); }
.seg { border-radius: 12px; padding: 4px; box-shadow: inset 0 1px 3px rgba(24, 58, 46, .14); }
.seg button { border-radius: 9px; }
.seg button.on { background: linear-gradient(180deg, #fff, var(--surface)); color: var(--text); box-shadow: inset 0 1px 0 #fff, 0 3px 8px -3px rgba(24, 58, 46, .35); }
[data-theme='dark'] .seg button.on { background: linear-gradient(180deg, var(--surface-3), var(--surface-2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 3px 8px -3px rgba(0, 0, 0, .6); }

/* Поля ввода */
select, input[type='text'], input[type='number'], input[type='password'], input[type='search'], input[type='date'] { border-radius: 10px; box-shadow: inset 0 1px 2px rgba(24, 58, 46, .08); }

/* Шкалы и метки */
.bar, .exp-cat-bar { box-shadow: inset 0 1px 2px rgba(24, 58, 46, .15); }
.bar > i, .exp-cat-bar i { background: linear-gradient(90deg, color-mix(in srgb, var(--scale) 75%, #fff), var(--scale)); }
.badge, .score, .kind { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5); }

/* Таблицы: тёмно-зелёная шапка там, где она тёмная (реестр, график) — со светлым бликом */
table.inv thead th, .sch thead th { background: linear-gradient(180deg, #24513f, #183a2e); }
table.inv thead th.inv-com-h { background: linear-gradient(180deg, #8a5a36, #6b4227); }
td.pay-hl, th.pay-hl, table.inv td.inv-hl { background: linear-gradient(180deg, color-mix(in srgb, var(--key-bg) 70%, #fff), var(--key-bg)); }
[data-theme='dark'] td.pay-hl, [data-theme='dark'] th.pay-hl, [data-theme='dark'] table.inv td.inv-hl { background: var(--key-bg); }

/* Вход */
.login { background: linear-gradient(180deg, rgba(14, 36, 27, .55), rgba(10, 26, 19, .8)), url('img/leaves-bg.jpg') center / cover; }
.login-card { border-radius: 20px; box-shadow: var(--lift-hi); }

@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
@media (max-width: 860px) {
  body { background-attachment: scroll; }
  .sidebar { background: linear-gradient(90deg, rgba(16, 42, 32, .92), rgba(16, 42, 32, .82)), url('img/leaves-side.jpg') center / cover, var(--sidebar); }
}
.kpi-value.neg { color: var(--bad); }

/* ===== Нижняя панель меню и настройки ===== */
.foot-row { display: flex; gap: 4px; }
.foot-row .ghost-btn { flex: 1 1 0; min-width: 0; }
@media (max-width: 860px) { .foot-row { gap: 0; } .foot-row .ghost-btn { flex: 0 0 auto; } }
.set-sec { display: flex; flex-direction: column; gap: var(--s3); }
.set-sec h3 { font-size: var(--text-sm); color: var(--text-2); }
.design-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s3); }
.design-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: var(--s3); border-radius: 14px; border: 2px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.design-card:hover { border-color: var(--border-strong); }
.design-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.design-card small { color: var(--text-3); font-size: var(--text-xs); line-height: 1.35; }
.design-prev { display: flex; width: 100%; height: 56px; border-radius: 10px; overflow: hidden; margin-bottom: 4px; }
.design-prev i { flex: 1; }
.design-prev-forest { background: url('img/leaves-side.jpg') center / cover; padding: 8px; gap: 6px; }
.design-prev-forest i { border-radius: 6px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 4px 8px -4px rgba(0, 0, 0, .6); }
.design-prev-soft { background: #efeae3; padding: 10px; gap: 10px; }
.design-prev-soft i { border-radius: 50%; flex: 0 0 34px; height: 34px; box-shadow: 4px 4px 8px rgba(166, 152, 132, .45), -4px -4px 8px rgba(255, 255, 255, .9); }

/* =====================================================================
   Оформление «Мягкий»: слоновая кость, терракота, выпуклые элементы (soft UI)
   ===================================================================== */
:root[data-design='soft']:not([data-theme='dark']) {
  --bg: #efeae3; --surface: #f3efe9; --surface-2: #ebe6de; --surface-3: #e2dcd2;
  --border: #e0d9ce; --border-strong: #cec5b7;
  --text: #26303a; --text-2: #59616a; --text-3: #8a8e91;
  --accent: #c0654a; --accent-ink: #fff; --accent-soft: #f3e1d9;
  --mark: #c0654a; --mark-ink: #fff; --scale: #c0654a; --rev: #26303a;
  --own: #2f5a46; --priv: #d49a6a; --obj-1: #2f5a46; --obj-2: #c0654a;
  --good: #2f7a52; --good-soft: #e2ede4; --warn: #a8762c; --warn-soft: #f3e7d1; --bad: #b8432e; --bad-soft: #f6e0d9;
  --key-bg: #f4e2d9; --key-total: #ecd0c3; --key-ink: #8e3f28; --total-bg: #e7e1d7; --kpi-ink: #26303a;
  --sidebar: #efeae3; --sidebar-text: #59616a; --sidebar-active: transparent; --head-bg: #2f3a44;
  --neu: 9px 9px 20px rgba(166, 150, 128, .34), -9px -9px 20px rgba(255, 255, 255, .9);
  --neu-sm: 4px 4px 10px rgba(166, 150, 128, .32), -4px -4px 10px rgba(255, 255, 255, .9);
  --neu-in: inset 4px 4px 9px rgba(166, 150, 128, .3), inset -4px -4px 9px rgba(255, 255, 255, .85);
  --neu-acc: 6px 6px 14px rgba(192, 101, 74, .32), -5px -5px 12px rgba(255, 255, 255, .85);
  --r-sm: 10px; --r-md: 14px; --r-lg: 22px; --shadow: var(--neu);
}
:root[data-design='soft'][data-theme='dark'] {
  --bg: #262d34; --surface: #29313a; --surface-2: #2e373f; --surface-3: #343e47;
  --border: #343e47; --border-strong: #46525c;
  --text: #ede7de; --text-2: #bab4ab; --text-3: #8b8f92;
  --accent: #e0866a; --accent-ink: #1d1410; --accent-soft: #3d2c26;
  --mark: #e0866a; --mark-ink: #1d1410; --scale: #e0866a; --rev: #ede7de;
  --own: #8fc1a4; --priv: #e0a77a; --obj-1: #8fc1a4; --obj-2: #e0866a;
  --good: #7cc59a; --good-soft: #1f3329; --warn: #e2b664; --warn-soft: #3a3020; --bad: #f08d78; --bad-soft: #402520;
  --key-bg: #3a2b25; --key-total: #4a342a; --key-ink: #f3bca6; --total-bg: #2f3840; --kpi-ink: #f5efe6;
  --sidebar: #262d34; --sidebar-text: #bab4ab; --sidebar-active: transparent; --head-bg: #1c2228;
  --neu: 9px 9px 20px rgba(0, 0, 0, .42), -8px -8px 18px rgba(255, 255, 255, .045);
  --neu-sm: 4px 4px 10px rgba(0, 0, 0, .4), -4px -4px 10px rgba(255, 255, 255, .045);
  --neu-in: inset 4px 4px 9px rgba(0, 0, 0, .4), inset -4px -4px 9px rgba(255, 255, 255, .04);
  --neu-acc: 6px 6px 14px rgba(0, 0, 0, .45), -4px -4px 10px rgba(255, 255, 255, .04);
  --r-sm: 10px; --r-md: 14px; --r-lg: 22px; --shadow: var(--neu);
}
html[data-design='soft'] body { background: radial-gradient(1200px 600px at 70% -10%, color-mix(in srgb, var(--surface) 90%, #fff 10%), transparent 70%), var(--bg); }
html[data-design='soft'] .sidebar { background: var(--bg); box-shadow: 8px 0 24px -16px rgba(120, 104, 84, .45); }
html[data-design='soft'][data-theme='dark'] .sidebar { box-shadow: 8px 0 24px -14px rgba(0, 0, 0, .7); }
html[data-design='soft'] .brand-text strong { color: var(--text); }
html[data-design='soft'] .brand-text span, html[data-design='soft'] .obj-title, html[data-design='soft'] .obj-item small, html[data-design='soft'] .obj-add { color: var(--text-3); }
html[data-design='soft'] .brand-mark { background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 85%, #fff), var(--accent)); color: #fff; border-radius: 14px; box-shadow: var(--neu-acc); }
html[data-design='soft'] .obj-block { border-top-color: var(--border); }
html[data-design='soft'] .nav a, html[data-design='soft'] .nav-parent, html[data-design='soft'] .ghost-btn, html[data-design='soft'] .obj-item { color: var(--sidebar-text); border-radius: 14px; }
html[data-design='soft'] .nav a:hover, html[data-design='soft'] .nav-parent:hover, html[data-design='soft'] .ghost-btn:hover, html[data-design='soft'] .obj-item:hover { background: var(--bg); color: var(--text); box-shadow: var(--neu-sm); }
html[data-design='soft'] .nav a.active, html[data-design='soft'] .nav-parent.active, html[data-design='soft'] .obj-item.active { background: var(--bg); color: var(--accent); box-shadow: var(--neu-in); }
html[data-design='soft'] .nav .nav-sub a.active { background: transparent; box-shadow: none; color: var(--accent); }
html[data-design='soft'] .topbar { background: color-mix(in srgb, var(--bg) 90%, transparent); box-shadow: none; border-bottom: 1px solid var(--border); color: var(--text); }
html[data-design='soft'] .topbar h1 { color: var(--text); text-shadow: none; font-weight: 600; letter-spacing: .01em; }
html[data-design='soft'] .topbar .muted, html[data-design='soft'] .topbar #periodLine, html[data-design='soft'] .topbar .field-inline { color: var(--text-3); }
html[data-design='soft'] .topbar .field-inline select { background: var(--bg); color: var(--text); box-shadow: var(--neu-in); }
html[data-design='soft'] .topbar .demo-note { background: var(--accent-soft); color: var(--key-ink); }
html[data-design='soft'] .card { background: var(--bg); border: 0; box-shadow: var(--neu); }
html[data-design='soft'] th { background: var(--bg); }
html[data-design='soft'] .kpi-label { letter-spacing: .12em; font-weight: 600; }
html[data-design='soft'] .kpi-value { font-weight: 600; text-shadow: none; letter-spacing: -0.01em; }
html[data-design='soft'] .kpi::after {
  right: -40px; bottom: -76px; width: 108px; height: 108px; opacity: .5; box-shadow: none;
  background: none; border: 9px solid var(--surface-3); border-top-color: var(--accent); border-right-color: var(--accent); transform: rotate(18deg);
}
html[data-design='soft'] .grid > .kpi:nth-child(4n+2)::after { border-top-color: var(--own); border-right-color: var(--own); }
html[data-design='soft'] .grid > .kpi:nth-child(4n+3)::after { border-top-color: var(--priv); border-right-color: transparent; }
html[data-design='soft'] .btn { background: var(--bg); border: 0; border-radius: 999px; box-shadow: var(--neu-sm); padding-inline: 18px; }
html[data-design='soft'] .btn:hover { color: var(--accent); background: var(--bg); }
html[data-design='soft'] .btn:active { box-shadow: var(--neu-in); transform: none; }
html[data-design='soft'] .btn.primary { background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent)); color: var(--accent-ink); box-shadow: var(--neu-acc); }
html[data-design='soft'] .btn.primary:hover { color: var(--accent-ink); }
html[data-design='soft'] .btn.danger { color: var(--bad); }
html[data-design='soft'] .seg { background: var(--bg); box-shadow: var(--neu-in); border-radius: 999px; padding: 5px; }
html[data-design='soft'] .seg button { border-radius: 999px; }
html[data-design='soft'] .seg button.on { background: var(--bg); color: var(--accent); box-shadow: var(--neu-sm); }
html[data-design='soft'] :is(select, input[type='text'], input[type='number'], input[type='password'], input[type='search'], input[type='date'], textarea):not(.inv-in):not(.inv-date) { background: var(--bg); border-color: transparent; border-radius: 14px; box-shadow: var(--neu-in); }
html[data-design='soft'] .bar, html[data-design='soft'] .exp-cat-bar { background: var(--bg); box-shadow: var(--neu-in); height: 8px; }
html[data-design='soft'] .bar > i, html[data-design='soft'] .exp-cat-bar i { background: var(--scale); border-radius: 99px; }
html[data-design='soft'] table.inv thead th, html[data-design='soft'] .sch thead th { background: linear-gradient(180deg, #3a4651, #26303a); }
html[data-design='soft'] table.inv thead th.inv-com-h { background: linear-gradient(180deg, #c97a60, #a8533a); }
html[data-design='soft'] td.pay-hl, html[data-design='soft'] th.pay-hl, html[data-design='soft'] table.inv td.inv-hl { background: var(--key-bg); }
html[data-design='soft'] .badge, html[data-design='soft'] .score, html[data-design='soft'] .kind { box-shadow: none; }
html[data-design='soft'] .drawer { background: var(--bg); }
html[data-design='soft'] .design-card { background: var(--bg); border-color: transparent; box-shadow: var(--neu-sm); }
html[data-design='soft'] .design-card.on { box-shadow: var(--neu-in); border-color: var(--accent); }
html[data-design='soft'] .login { background: var(--bg); }
html[data-design='soft'] .login-card { background: var(--bg); border: 0; box-shadow: var(--neu); }
html[data-design='soft'] .pay-detail-box, html[data-design='soft'] .portal-mini > div { background: var(--bg); }
@media (max-width: 860px) { html[data-design='soft'] .sidebar { background: var(--bg); box-shadow: 0 8px 20px -14px rgba(120, 104, 84, .5); } }
.foot-row .ghost-btn { padding: 10px 8px; gap: 8px; }
.set-sec .seg { align-self: flex-start; }
.foot-row .settings-btn { flex: 0 0 auto; width: auto; padding: 10px 12px; }


/* =====================================================================
   Левая панель: выдвижная (значки → при наведении названия), иконки-«капли»
   ===================================================================== */
:root { --blob-1: rgba(233, 212, 184, .2); --blob-2: rgba(181, 210, 190, .2); --blob-3: rgba(255, 255, 255, .12); --blob-ink: #eef3ee; --blob-act: #e9d4b8; --blob-act-ink: #1f3a2e; --rail: 84px; --rail-open: 260px; }
:root[data-design='soft']:not([data-theme='dark']) { --blob-1: #ecdcd2; --blob-2: #d9dacd; --blob-3: #ddd0c4; --blob-ink: #4a4540; --blob-act: #c0654a; --blob-act-ink: #fff; }
:root[data-design='soft'][data-theme='dark'] { --blob-1: #3e3530; --blob-2: #353c37; --blob-3: #3c3732; --blob-ink: #ddd6cc; --blob-act: #e0866a; --blob-act-ink: #1d1410; }

.ico { display: inline-grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; background: var(--blob-1); border-radius: 58% 42% 52% 48% / 46% 56% 44% 54%; transition: background .2s, transform .2s, border-radius .4s; }
.ico.b2 { background: var(--blob-2); border-radius: 44% 56% 40% 60% / 58% 42% 58% 42%; }
.ico.b3 { background: var(--blob-3); border-radius: 52% 48% 62% 38% / 42% 52% 48% 58%; }
.ico svg, .nav .ico svg, .ghost-btn .ico svg { width: 21px; height: 21px; fill: none; stroke: var(--blob-ink); stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 30px; height: 30px; }
.ico.sm svg, .nav .ico.sm svg { width: 17px; height: 17px; }
.nav a:hover .ico, .nav-parent:hover .ico, .ghost-btn:hover .ico { transform: rotate(-6deg) scale(1.04); }
.nav a.active .ico, .nav-parent.active .ico { background: var(--blob-act); box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .6); }
.nav a.active .ico svg, .nav-parent.active .ico svg { stroke: var(--blob-act-ink); stroke-width: 1.7; }
.nav a, .nav-parent, .ghost-btn { gap: 12px; }
.nav a > span, .nav-parent > span, .ghost-btn > span { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .ico { transition: none; } .nav a:hover .ico, .nav-parent:hover .ico, .ghost-btn:hover .ico { transform: none; } }

@media (min-width: 861px) {
  .app { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .main-wrap { grid-column: 2; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100dvh; width: var(--rail); z-index: 45;
    padding: var(--s5) 12px; overflow: hidden; transition: width .24s cubic-bezier(.2, .7, .2, 1), box-shadow .24s;
  }
  .sidebar:hover, .sidebar:focus-within { width: var(--rail-open); box-shadow: 18px 0 40px -16px rgba(10, 30, 22, .55); overflow-y: auto; }
  .brand { padding: 0 0 var(--s5) 11px; flex-wrap: nowrap; }
  .brand-mark { width: 38px; height: 38px; flex-shrink: 0; }
  .brand-text { white-space: nowrap; }
  .nav { gap: 2px; }
  .nav a, .nav-parent { padding: 5px 11px; min-height: 48px; width: 100%; }
  .nav .nav-sub a { padding: 4px 11px 4px 26px; min-height: 40px; }
  .nav-parent .chev { margin-left: auto; }
  .sidebar-foot { display: flex; flex-direction: column; gap: 2px; }
  .ghost-btn { padding: 5px 11px; min-height: 48px; }
  .foot-row { flex-direction: row; }
  .foot-row .settings-btn { padding: 5px 11px; }
  /* свёрнуто: только значки */
  .sidebar:not(:hover):not(:focus-within) :is(.brand-text, .nav a > span, .nav-parent > span, .nav-parent .chev, .ghost-btn > span, .obj-block) { opacity: 0; pointer-events: none; }
  .sidebar:not(:hover):not(:focus-within) .nav-group .nav-sub { max-height: 0; }
  .sidebar:not(:hover):not(:focus-within) .nav-group .nav-sub a { visibility: hidden; }
  .sidebar:not(:hover):not(:focus-within) .foot-row { flex-direction: column; }
  .sidebar:not(:hover):not(:focus-within) .obj-block { max-height: 0; overflow: hidden; margin: 0; padding: 0; border: 0; }
  :is(.brand-text, .nav a > span, .nav-parent > span, .nav-parent .chev, .ghost-btn > span, .obj-block) { transition: opacity .18s ease .06s; }
}
@media (max-width: 860px) {
  .ico { width: 34px; height: 34px; }
  .ico svg, .nav .ico svg { width: 19px; height: 19px; }
  .nav a, .nav-parent { padding: 4px; }
}
@media (max-width: 520px) {
  .ico { width: 29px; height: 29px; }
  .ico svg, .nav .ico svg, .ghost-btn .ico svg { width: 17px; height: 17px; }
  .nav a, .nav-parent, .ghost-btn, .foot-row .settings-btn { padding: 3px; }
  .sidebar-foot { display: flex; }
}

/* =====================================================================
   Чат: правая выдвижная панель (в стиле левой)
   ===================================================================== */
:root { --chat-rail: 76px; --chat-open: 380px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.chat {
  position: fixed; right: 0; top: 0; bottom: 0; width: var(--chat-rail); z-index: 44; display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-text); overflow: hidden;
  transition: width .24s cubic-bezier(.2, .7, .2, 1), box-shadow .24s;
}
:root:not([data-design='soft']) .chat { background: linear-gradient(180deg, rgba(20, 52, 40, .8), rgba(12, 30, 23, .96)), url('img/leaves-side.jpg') top right / cover, var(--sidebar); box-shadow: inset 1px 0 0 rgba(255, 255, 255, .06); }
html[data-design='soft'] .chat { background: var(--bg); box-shadow: -8px 0 24px -16px rgba(120, 104, 84, .45); }
.chat:hover, .chat:focus-within, .chat.open { width: var(--chat-open); box-shadow: -18px 0 40px -16px rgba(10, 30, 22, .55); }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s5) 14px var(--s3); gap: var(--s2); }
.chat-title { position: relative; background: none; border: 0; color: inherit; font: 800 var(--text-lg)/1 var(--font); letter-spacing: .06em; cursor: pointer; padding: 8px 6px; white-space: nowrap; }
:root:not([data-design='soft']) .chat-title { color: #fff; }
.chat-badge { position: absolute; top: -4px; right: -10px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--blob-act); color: var(--blob-act-ink); font-size: 11px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 4px 10px -4px rgba(0, 0, 0, .6); letter-spacing: 0; }
.chat-x, .chat-back { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--blob-3); color: inherit; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.chat-x svg, .chat-back svg, .chat-search svg, .chat-attach svg, .chat-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-search { position: relative; margin: 0 14px var(--s3); display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 999px; background: var(--blob-3); min-height: 42px; }
.chat-search input { flex: 1; min-width: 0; background: transparent !important; border: 0 !important; box-shadow: none !important; color: inherit; padding: 8px 0; outline: none; }
.chat-search input::placeholder { color: inherit; opacity: .6; }
html[data-design='soft'] .chat-search, html[data-design='soft'] .chat-x, html[data-design='soft'] .chat-back { background: var(--bg); box-shadow: var(--neu-in); }
html[data-design='soft'] .chat-x, html[data-design='soft'] .chat-back { box-shadow: var(--neu-sm); }
.chat-sugg { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5; background: var(--surface); color: var(--text); border-radius: 16px; padding: 6px; box-shadow: var(--lift-hi, 0 14px 30px -10px rgba(0, 0, 0, .4)); max-height: 320px; overflow-y: auto; }
.chat-sugg button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-radius: 12px; padding: 6px 8px; cursor: pointer; color: inherit; font: inherit; }
.chat-sugg button:hover, .chat-sugg button.hl { background: var(--surface-2); }
.chat-sugg b { display: block; font-size: var(--text-sm); }
.chat-sugg small { color: var(--text-3); font-size: var(--text-xs); }
.ico.av { font-style: normal; font-weight: 800; font-size: 13px; color: var(--blob-ink); letter-spacing: .02em; }
.chat-sugg .ico.av { --blob-ink: var(--text); background: var(--surface-3); }
.ico.av.sm { width: 32px; height: 32px; font-size: 11px; }
.chat-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 10px var(--s4); display: flex; flex-direction: column; gap: 2px; }
.chat-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-radius: 14px; padding: 6px 8px; cursor: pointer; color: inherit; font: inherit; min-height: 54px; }
.chat-item:hover, .chat-item.on { background: rgba(255, 255, 255, .1); }
html[data-design='soft'] .chat-item:hover, html[data-design='soft'] .chat-item.on { background: var(--bg); box-shadow: var(--neu-sm); }
.chat-item .ico.av { width: 40px; height: 40px; }
.chat-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-item-text b { font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root:not([data-design='soft']) .chat-item-text b { color: #fff; }
.chat-item-text small { font-size: var(--text-xs); opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread .chat-item-text small { opacity: 1; font-weight: 700; }
.chat-item time { font-size: 11px; opacity: .6; align-self: flex-start; margin-top: 6px; }
.chat-dot { position: absolute; left: 38px; top: 4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; background: var(--blob-act); color: var(--blob-act-ink); font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.chat-empty { font-size: var(--text-xs); opacity: .7; padding: 8px 6px; line-height: 1.45; }
.chat-conv { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-conv-head { display: flex; align-items: center; gap: 10px; padding: 0 14px var(--s3); border-bottom: 1px solid rgba(255, 255, 255, .1); }
html[data-design='soft'] .chat-conv-head { border-bottom-color: var(--border); }
.chat-with { min-width: 0; display: flex; flex-direction: column; }
.chat-with b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--text-sm); }
:root:not([data-design='soft']) .chat-with b { color: #fff; }
.chat-with small { font-size: var(--text-xs); opacity: .65; }
.chat-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s3) 14px; display: flex; flex-direction: column; gap: 6px; background: color-mix(in srgb, var(--bg) 92%, transparent); color: var(--text); }
:root:not([data-design='soft']) .chat-msgs { background: rgba(240, 244, 238, .95); }
:root[data-theme='dark']:not([data-design='soft']) .chat-msgs { background: rgba(12, 26, 19, .92); }
.chat-day { align-self: center; font-size: 11px; color: var(--text-3); background: var(--surface-2); border-radius: 99px; padding: 2px 10px; margin: 6px 0; }
.msg { align-self: flex-start; max-width: 82%; background: var(--surface); border-radius: 16px 16px 16px 6px; padding: 7px 11px 5px; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.msg.mine { align-self: flex-end; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-radius: 16px 16px 6px 16px; }
html[data-design='soft'] .msg { box-shadow: var(--neu-sm); background: var(--bg); }
html[data-design='soft'] .msg.mine { background: var(--accent-soft); }
.msg p { margin: 0; font-size: var(--text-sm); line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }
.msg time { display: flex; justify-content: flex-end; gap: 4px; font-size: 10px; color: var(--text-3); margin-top: 2px; }
.msg-read.on { color: var(--accent); font-weight: 800; }
.msg-img { display: block; border: 0; padding: 0; background: none; cursor: zoom-in; margin: 2px 0 4px; border-radius: 12px; overflow: hidden; }
.msg-img img { display: block; max-width: 240px; max-height: 240px; border-radius: 12px; }
.msg-img .skeleton { display: block; width: 200px; height: 140px; }
.chat-full { max-width: 100%; border-radius: 12px; }
.chat-preview { position: relative; padding: 8px 14px 0; background: color-mix(in srgb, var(--bg) 92%, transparent); }
.chat-preview img { max-height: 90px; border-radius: 10px; display: block; }
.chat-preview button { position: absolute; top: 2px; left: 110px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; cursor: pointer; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 14px; background: color-mix(in srgb, var(--bg) 92%, transparent); }
:root:not([data-design='soft']) .chat-form, :root:not([data-design='soft']) .chat-preview { background: rgba(240, 244, 238, .95); }
:root[data-theme='dark']:not([data-design='soft']) .chat-form, :root[data-theme='dark']:not([data-design='soft']) .chat-preview { background: rgba(12, 26, 19, .92); }
.chat-form textarea { flex: 1; min-width: 0; resize: none; max-height: 140px; border-radius: 18px; padding: 9px 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm); line-height: 1.4; }
.chat-attach, .chat-send { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; border: 0; }
.chat-attach { background: var(--surface-3); color: var(--text-2); }
.chat-send { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--accent) 80%, #000); }
.chat-send:disabled { opacity: .5; }
html[data-design='soft'] .chat-attach { background: var(--bg); box-shadow: var(--neu-sm); }
html[data-design='soft'] .chat-send { box-shadow: var(--neu-acc); }
/* свёрнуто: «Чат» и кружки собеседников */
.chat:not(:hover):not(:focus-within):not(.open) :is(.chat-x, .chat-search, .chat-item-text, .chat-item time, .chat-empty) { opacity: 0; pointer-events: none; }
.chat:not(:hover):not(:focus-within):not(.open) .chat-search { max-height: 0; min-height: 0; margin: 0; overflow: hidden; }
.chat:not(:hover):not(:focus-within):not(.open) .chat-head { justify-content: center; padding-inline: 4px; }
.chat:not(:hover):not(:focus-within):not(.open) .chat-x { display: none; }
.chat:not(:hover):not(:focus-within):not(.open) .chat-conv { display: none; }
.chat:not(:hover):not(:focus-within):not(.open) .chat-list { display: flex !important; }
.chat:not(:hover):not(:focus-within):not(.open) .chat-item { padding-inline: 8px; }
@media (min-width: 861px) {
  body.has-chat .app { grid-template-columns: var(--rail) minmax(0, 1fr) var(--chat-rail); }
}
@media (max-width: 860px) {
  .chat { top: auto; bottom: 16px; right: 16px; width: 60px; height: 60px; border-radius: 50%; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .6); }
  .chat .chat-head { padding: 0; height: 60px; justify-content: center; }
  .chat .chat-title { font-size: var(--text-sm); }
  .chat:not(.open) :is(.chat-search, .chat-list, .chat-conv, .chat-x) { display: none !important; }
  .chat:hover, .chat:focus-within { width: 60px; }
  .chat.open { inset: 0; width: auto; height: auto; border-radius: 0; }
  .chat.open .chat-head { height: auto; padding: var(--s4) 14px var(--s3); justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) { .chat { transition: none; } }
.chat-form textarea { height: 40px; min-height: 40px; }

/* ===== Настройки: сотрудники и доступы ===== */
.set-tabs { align-self: flex-start; margin-bottom: var(--s2); }
#drawerBody > .set-tabs { margin-bottom: var(--s4); }
.staff-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s4); }
.staff-top p { max-width: 60ch; }
.staff-list { display: flex; flex-direction: column; gap: var(--s3); }
.staff-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px var(--s3); align-items: start; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
html[data-design='soft'] .staff-card { background: var(--bg); border: 0; box-shadow: var(--neu-sm); }
.staff-card.off { opacity: .6; }
.staff-card .ico.av { --blob-ink: var(--text); width: 44px; height: 44px; grid-row: span 2; background: var(--surface-3); }
.staff-main b { font-size: var(--text-base); }
.staff-main small { display: block; color: var(--text-3); font-size: var(--text-xs); margin-top: 2px; }
.staff-main small b { font-size: inherit; color: var(--text-2); }
.staff-card .user-actions { grid-column: 2; }
.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.perm-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); }
.perm-chip.edit { background: var(--accent-soft); color: var(--accent); }
.staff-empty { padding: var(--s6); border: 1px dashed var(--border-strong); border-radius: var(--r-md); color: var(--text-2); }
.staff-form .perm-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s2); }
.staff-form .perm-head h3 { font-size: var(--text-base); }
.perm-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.perm-quick .btn { min-height: 30px; padding: 4px 10px; font-size: var(--text-xs); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: var(--s3); }
.perm-group { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s2) var(--s3) var(--s3); margin: 0; min-width: 0; }
html[data-design='soft'] .perm-group { border: 0; box-shadow: var(--neu-in); }
.perm-group legend { font-size: var(--text-xs); font-weight: 800; color: var(--text-3); padding: 0 6px; letter-spacing: .04em; }
.perm-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.perm-row:last-child { border-bottom: 0; }
.perm-row > span { font-size: var(--text-sm); font-weight: 600; }
.perm-row .seg button { padding: 4px 10px; }
.perm-row .seg button[data-pv='view'].on { color: var(--own); }
.perm-row .seg button[data-pv='edit'].on { color: var(--accent); }
.ro-badge { vertical-align: middle; font-size: var(--text-xs); margin-left: 8px; letter-spacing: 0; text-shadow: none; }
.perm-row .seg button[data-pv='none'].on { color: var(--text-2); }
.drawer.xwide { width: min(1120px, 100vw); }
.linkish { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.ip-subtabs { align-self: flex-start; margin-bottom: var(--s4); }
.ip-tab-box { display: flex; flex-direction: column; gap: var(--s4); }
.ip-tab-note { margin: 0; }
.ip-tab-box .card { box-shadow: none; }

/* Большие мониторы: содержимое по центру, шапка выровнена по тем же краям */
.main { margin-inline: auto; }
.topbar { padding-inline: max(var(--s8), calc((100% - 1480px) / 2 + var(--s8))); }
@media (max-width: 860px) { .topbar { padding-inline: var(--s4); } }
