/* Цвета сайта — светлая тема (тёмная ниже, включается переключателем в меню) */
:root {
  --ink: #2b2b2b;
  --card: #fff;
  --bg: #f5f1ea;
  --line-soft: #eee;
  --line-soft2: #e5e5e5;
  --line: #ccc;
  --line-2: #ddd5c6;
  --btn: #ebe5da;
  --btn-2: #f0ebe2;
  --hover: #444;
  --mut-1: #555;
  --mut-2: #666;
  --mut-3: #777;
  --mut-4: #888;
  --mut-5: #999;
  --mut-6: #aaa;
  --sand-1: #e2d9c9;
  --sand-2: #e6dfd3;
  --sand-3: #ece5d8;
  --sand-4: #d6cdbd;
  --sand-5: #efeae1;
  --sand-6: #e4dccd;
  --sand-7: #faf8f4;
  --tint-yellow: #fffbe6;
  --tint-yellow2: #fff7d6;
  --tint-orange: #fff3d6;
  --tint-red: #fdecea;
  --tint-red2: #f6d5d2;
  --tint-green: #e6f4ea;
  --tint-green2: #eef6ee;
  --tint-green3: #d6e6d6;
  --tint-blue: #eef3ff;
  --tint-peach: #fdf3e7;
  --tint-yellow3: #f0e2a8;
  --red: #b3261e;
  --green: #1e7b34;
  --brown: #9a6200;
  --brown2: #7a5200;
  --blue: #3b5bdb;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #ece6dc;
  --card: #23211e;
  --bg: #171614;
  --line-soft: #34312c;
  --line-soft2: #34312c;
  --line: #4a463f;
  --line-2: #4a453d;
  --btn: #34302a;
  --btn-2: #2e2b26;
  --hover: #cfc8bc;
  --mut-1: #c4bdb1;
  --mut-2: #b3ab9f;
  --mut-3: #a39b8f;
  --mut-4: #948c80;
  --mut-5: #857e73;
  --mut-6: #766f65;
  --sand-1: #3d3933;
  --sand-2: #3a362f;
  --sand-3: #36322c;
  --sand-4: #4d483f;
  --sand-5: #2f2c27;
  --sand-6: #3f3a33;
  --sand-7: #1f1d1a;
  --tint-yellow: #3a3420;
  --tint-yellow2: #3a3420;
  --tint-orange: #3d3220;
  --tint-red: #3d2422;
  --tint-red2: #4a2a28;
  --tint-green: #1f3326;
  --tint-green2: #213024;
  --tint-green3: #2f4232;
  --tint-blue: #222a3d;
  --tint-peach: #3a2e22;
  --tint-yellow3: #5a4e2a;
  --red: #ff8a80;
  --green: #6fcf87;
  --brown: #f0b04a;
  --brown2: #e0a640;
  --blue: #8aa4ff;
}
/* Лист документа (и PDF) всегда белый */
html[data-theme="dark"] .sheet {
  color-scheme: light;
  color: var(--ink);
  --ink: #2b2b2b;
  --card: #fff;
  --bg: #f5f1ea;
  --line-soft: #eee;
  --line-soft2: #e5e5e5;
  --line: #ccc;
  --line-2: #ddd5c6;
  --btn: #ebe5da;
  --btn-2: #f0ebe2;
  --hover: #444;
  --mut-1: #555;
  --mut-2: #666;
  --mut-3: #777;
  --mut-4: #888;
  --mut-5: #999;
  --mut-6: #aaa;
  --sand-1: #e2d9c9;
  --sand-2: #e6dfd3;
  --sand-3: #ece5d8;
  --sand-4: #d6cdbd;
  --sand-5: #efeae1;
  --sand-6: #e4dccd;
  --sand-7: #faf8f4;
  --tint-yellow: #fffbe6;
  --tint-yellow2: #fff7d6;
  --tint-orange: #fff3d6;
  --tint-red: #fdecea;
  --tint-red2: #f6d5d2;
  --tint-green: #e6f4ea;
  --tint-green2: #eef6ee;
  --tint-green3: #d6e6d6;
  --tint-blue: #eef3ff;
  --tint-peach: #fdf3e7;
  --tint-yellow3: #f0e2a8;
  --red: #b3261e;
  --green: #1e7b34;
  --brown: #9a6200;
  --brown2: #7a5200;
  --blue: #3b5bdb;
}

/* Боковое меню — общее для всех страниц */
body {
  margin: 0;
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 220px;
  flex-shrink: 0;
  box-sizing: border-box;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: 24px 12px;
  background: var(--card);
  border-right: 1px solid var(--sand-2);
}
.sidebar .brand {
  padding: 0 12px 20px;
  font-size: 18px;
  font-weight: 700;
}
.sidebar a {
  display: block;
  margin-bottom: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
.sidebar a:hover { background: var(--bg); }
/* Блоки меню: «Сделки» и «Учёт» */
.sidebar .nav-group {
  margin: 16px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a39a8b;
}
.sidebar .nav-group:first-child { margin-top: 0; }
.sidebar a.active { background: var(--ink); color: var(--card); }
/* Счётчик новых уведомлений у пункта меню */
.sidebar .nav-badge { float: right; min-width: 20px; padding: 1px 6px; box-sizing: border-box; font-size: 12px; font-weight: 700; line-height: 18px; text-align: center; color: #fff; background: var(--red); border-radius: 10px; }
main {
  flex: 1;
  min-width: 0;
  padding: 40px 24px;
}

/* На узком экране меню становится полоской сверху */
@media (max-width: 700px) {
  body { flex-direction: column; }
  .sidebar {
    width: auto;
    height: auto;
    position: static;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-right: none;
    border-bottom: 1px solid var(--sand-2);
  }
  .sidebar .brand { padding: 0 8px 0 0; }
  .sidebar .nav-group { margin: 0 0 0 8px; }
  .sidebar a { margin: 0; }
  main { padding: 24px 16px; }
}

/* Низ бокового меню: переключатель темы */
.sidebar { display: flex; flex-direction: column; }
.sidebar-foot { margin-top: auto; padding: 12px 4px 0; }
.theme-switch { display: flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.theme-switch button {
  flex: 1; padding: 7px 4px; font-size: 12px; background: var(--card); color: var(--ink);
  border: none; cursor: pointer;
}
.theme-switch button + button { border-left: 1px solid var(--line-2); }
.theme-switch button.active { background: var(--ink); color: var(--card); }
body { background: var(--bg); color: var(--ink); }
.sidebar { background: var(--card); border-color: var(--sand-2); }
@media (max-width: 700px) {
  .sidebar { flex-direction: row; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; }
}

/* Язык и тема — в одну строку внизу меню */
.sidebar-foot { display: flex; gap: 6px; }
.sidebar-foot .theme-switch { flex: 1; }
.theme-switch button { font-size: 13px; }

/* Кто вошёл — внизу меню, над языком и темой */
.sidebar-user { margin-top: auto; padding: 10px 12px; font-size: 13px; border-top: 1px solid var(--sand-2); }
.sidebar-user strong { display: block; font-size: 14px; }
.sidebar-user span { display: block; color: var(--mut-3); font-size: 12px; margin-bottom: 6px; }
.sidebar-user button { padding: 4px 10px; font-size: 12px; background: var(--btn); color: var(--ink); border: none; border-radius: 6px; cursor: pointer; }
.sidebar-user button:hover { background: var(--line-2); }
.sidebar-user + .sidebar-foot { margin-top: 0; }
@media (max-width: 700px) { .sidebar-user { margin-top: 0; border-top: none; } }

/* «← Назад» — вверху страницы, если пришли по ссылке с другой страницы системы */
.back-nav { display: inline-block; margin: -16px 0 14px; padding: 6px 12px; font-size: 14px; font-weight: 600; color: var(--ink); background: var(--card); border: 1px solid var(--line-2); border-radius: 8px; text-decoration: none; }
.back-nav:hover { border-color: var(--ink); }
@media print { .back-nav { display: none; } }
