/* Оформление кабинета. Один файл, без сборки. Правила — в docs/DESIGN.md.
   Цвета и размеры берутся только из переменных ниже: так страницы одинаковы в светлой и
   тёмной теме. Основа палитры — панель бота (bot/dashboard.py). */

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --ink: #16181d;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #cfd4dc;
  --field-line: #8a93a2;          /* рамка поля ввода: видна на белом (3:1) */
  --toast-ok: #4cc79a; --toast-bad: #f2877e;      /* значки на всплывающем сообщении: оно темнее страницы */
  --accent: #2f6fde;
  --accent-ink: #ffffff;
  --accent-soft: #e4edfc;
  --accent-text: #1f55b5;
  --success: #12805c;
  --success-soft: #e0f5ec;
  --danger: #c0352b;
  --danger-soft: #fce8e6;
  --warn: #b54708;
  --warn-soft: #fdf0dc;
  --shadow-1: 0 1px 2px rgb(16 24 40 / .06);
  --shadow-2: 0 6px 20px rgb(16 24 40 / .10);
  --shadow-3: 0 20px 48px rgb(16 24 40 / .22);
  --chip-s: 75%; --chip-l: 91%; --chip-ink-s: 60%; --chip-ink-l: 28%;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-s: 6px; --r-m: 10px; --r-l: 14px; --r-pill: 999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-s: 13px; --fs: 15px; --fs-l: 17px; --fs-h2: 18px; --fs-h1: 24px;
  --fast: 120ms; --base: 200ms; --slow: 320ms;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --side: 248px;
}

/* Тёмная тема: по настройке системы, если человек не выбрал тему сам. Набор значений
   повторён дважды намеренно — без сборки иначе не выразить «система или выбор». */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115; --surface: #181b21; --surface-2: #20242c; --ink: #eef0f4; --muted: #98a2b3;
    --line: #2a2f39; --line-strong: #3a414e; --field-line: #6f7888; --toast-ok: #12805c; --toast-bad: #c0352b; --accent: #6ea0f5; --accent-ink: #0b1220;
    --accent-soft: #1d2b45; --accent-text: #9dbffa; --success: #4cc79a; --success-soft: #12322a;
    --danger: #f2877e; --danger-soft: #3d1c1a; --warn: #f5a742; --warn-soft: #3a2a12;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 6px 20px rgb(0 0 0 / .45);
    --shadow-3: 0 20px 48px rgb(0 0 0 / .6);
    --chip-s: 38%; --chip-l: 24%; --chip-ink-s: 85%; --chip-ink-l: 86%;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115; --surface: #181b21; --surface-2: #20242c; --ink: #eef0f4; --muted: #98a2b3;
  --line: #2a2f39; --line-strong: #3a414e; --field-line: #6f7888; --toast-ok: #12805c; --toast-bad: #c0352b; --accent: #6ea0f5; --accent-ink: #0b1220;
  --accent-soft: #1d2b45; --accent-text: #9dbffa; --success: #4cc79a; --success-soft: #12322a;
  --danger: #f2877e; --danger-soft: #3d1c1a; --warn: #f5a742; --warn-soft: #3a2a12;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 6px 20px rgb(0 0 0 / .45);
  --shadow-3: 0 20px 48px rgb(0 0 0 / .6);
  --chip-s: 38%; --chip-l: 24%; --chip-ink-s: 85%; --chip-ink-l: 86%;
}

/* ------------------------------------------------------------------ основа */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: var(--fs)/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: var(--fs-h1); font-weight: 680; }
h2 { font-size: var(--fs-h2); font-weight: 650; }
h3 { font-size: var(--fs); font-weight: 650; }
p { margin: 0 0 var(--s3); }
a { color: var(--accent-text); text-underline-offset: 2px; }
small, .muted { color: var(--muted); font-size: var(--fs-s); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-s); }
::selection { background: var(--accent-soft); }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px;
  border-radius: var(--r-s); }
.skip:focus { left: 8px; }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

@view-transition { navigation: auto; }

/* ------------------------------------------------------------------ оболочка */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: var(--s4);
  padding: var(--s4) var(--s3); background: var(--surface); border-right: 1px solid var(--line);
  overflow-y: auto; view-transition-name: side;
}
.brand { display: flex; align-items: center; gap: var(--s3); padding: var(--s2); color: var(--ink); text-decoration: none; }
.logo-mark { width: 38px; height: 34px; flex: none; }
.brand-text { display: grid; line-height: 1.2; min-width: 0; }
.brand-text b { font-weight: 680; font-size: var(--fs-l); letter-spacing: -.01em; }
.brand-text small { color: var(--muted); font-size: 11px; font-weight: 520; }
.brand-guest { display: grid; justify-items: center; gap: var(--s2); margin-bottom: var(--s5); color: var(--ink);
  text-decoration: none; }
.brand-guest span { color: var(--muted); font-size: var(--fs-s); font-weight: 560; letter-spacing: .04em;
  text-transform: uppercase; }
.logo-full { width: 176px; height: 104px; }
.logo-shadow { fill: var(--line); }
.guest .content { text-align: center; }
.guest .head { justify-content: center; }
.guest .content .btn { width: 100%; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--s3); padding: 9px var(--s3); border-radius: var(--r-m);
  color: var(--muted); text-decoration: none; font-weight: 520; position: relative;
  transition: background var(--fast), color var(--fast);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 620; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--accent); }
.nav a.nav-sub { margin-left: 22px; padding-block: 6px; font-size: .93em; }
.nav a.nav-sub::after { content: ""; position: absolute; left: -11px; top: -2px; bottom: 50%; width: 9px;
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0 0 0 6px; }
.nav a.nav-sub .icon { width: 16px; height: 16px; }
.nav a.nav-sub[aria-current="page"]::before { left: -34px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: var(--s3); display: grid; gap: var(--s2); }
.who { padding: 0 var(--s2); min-width: 0; }
.who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 620; }
.who span { color: var(--muted); font-size: var(--fs-s); }
.side-foot .row { flex-wrap: nowrap; }
.side-foot form { flex: 1; margin: 0; }
.side-foot form .btn { width: 100%; }

.topbar { display: none; }
.backdrop { display: none; }
.main { min-width: 0; padding: var(--s6) var(--s6) var(--s7); }
/* Узкая страница (форма, свой расчёт) начинается от того же левого края, что и обычная, а не
   встаёт по центру: заголовок при переходе между разделами не прыгает. */
.content { max-width: var(--w, 1080px); margin: 0 auto 0 max(0px, calc((100% - max(var(--w, 1080px), 1080px)) / 2)); animation: slide var(--slow) var(--ease) both; }
.content > * + * { margin-top: var(--s4); }
.content > h2 { margin-top: var(--s6); }
.content > h2 + p { margin-top: 2px; }
/* Подзаголовок с пояснением или кнопкой справа (`ui.heading`) отделяет группу так же, как простой. */
.content > .head.section { margin-top: var(--s6); }
.content > .head.section + * { margin-top: var(--s3); }

.guest { display: grid; grid-template-columns: 1fr; place-items: center; padding: var(--s4); min-height: 100vh; min-height: 100dvh; }
.guest main { width: 100%; }
.guest .content { margin: 0 auto; width: 100%; max-width: min(var(--w, 440px), 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l); padding: var(--s6); box-shadow: var(--shadow-2); }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .topbar {
    display: flex; align-items: center; gap: var(--s2); position: sticky; top: 0; z-index: 30;
    padding: var(--s2) var(--s3); background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; }
  .topbar .logo-mark { width: 30px; height: 27px; }
  .topbar .brand-text b { font-size: var(--fs); }
  .topbar .brand-text small { display: none; }
  .side {
    position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(86vw, 300px); transform: translateX(-102%);
    transition: transform var(--base) var(--ease), visibility 0s linear var(--base); visibility: hidden;
    box-shadow: var(--shadow-3); view-transition-name: none;
  }
  .side .brand { display: none; }
  .nav-open .side { transform: none; visibility: visible; transition: transform var(--base) var(--ease); }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(10 14 22 / .45); opacity: 0;
    pointer-events: none; transition: opacity var(--base); }
  .nav-open .backdrop { opacity: 1; pointer-events: auto; }
  .nav-open { overflow: hidden; }
  .nav a { padding: 12px var(--s3); }
  .main { padding: var(--s4) var(--s3) var(--s7); }
  .guest .content { padding: var(--s5); }
  .sched-grid .who-cell { min-width: 96px; max-width: 96px; padding: 6px 8px; font-size: 12px; white-space: normal; line-height: 1.25; }
  .toasts { right: var(--s3); bottom: var(--s3); width: calc(100vw - 2 * var(--s3)); }
}

/* ------------------------------------------------------------------ заголовок страницы */
.head { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4); align-items: center; justify-content: space-between; }
.head-text { min-width: 0; }
.head .sub { color: var(--muted); margin: 2px 0 0; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none;
  font-size: var(--fs-s); margin-bottom: 4px; }
.back:hover { color: var(--ink); }
/* «Данные из Мегаплана — на …»: мелкая строка над содержимым страницы. */
.as-of { margin: 0 0 var(--s2); color: var(--muted); font-size: var(--fs-s); text-align: right; }
.as-of a { color: inherit; text-decoration-color: var(--line-strong); }
.as-of.warn { color: var(--warn); }
/* «Скачать таблицы страницы в Excel»: ссылка над содержимым страницы с таблицей, в одной строке с «данные на …». */
.page-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 2px var(--s4);
  margin: 0 0 var(--s2); }
.page-meta > p { margin: 0; }
/* Плашка «вы смотрите кабинет как …» над страницей: собственник в чужом кабинете. */
.viewing { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); padding: var(--s2) var(--s5);
  background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); }
.viewing-who { display: flex; align-items: center; gap: var(--s2); flex: 1 1 320px; min-width: 0; }
.viewing form { display: flex; align-items: center; gap: var(--s2); margin: 0; }
.viewing .input { width: auto; max-width: 280px; }
.export { font-size: var(--fs-s); }
.export a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.export a:hover { color: var(--ink); }
.export .icon { width: 16px; height: 16px; }
@media print { .export { display: none; } }
.back .icon { width: 16px; height: 16px; }
.month { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 3px; box-shadow: var(--shadow-1); }
.month a, .month span.off { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  color: var(--ink); transition: background var(--fast); }
.month a:hover { background: var(--surface-2); }
.month span.off { color: var(--line-strong); }
.month b { min-width: 9.5em; text-align: center; font-weight: 620; padding: 0 var(--s2); }
.month b::first-letter { text-transform: uppercase; }

/* ------------------------------------------------------------------ карточки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-1); }
.card-head { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center; justify-content: space-between;
  padding: var(--s4) var(--s4) 0; }
.card-body { padding: var(--s4); }
.card-body > :last-child { margin-bottom: 0; }
.card.flush .card-body { padding: var(--s3) 0 0; }
.card.flush .table-wrap { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--r-l) var(--r-l); box-shadow: none; }
.card-foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-s); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(var(--min, 260px), 100%), 1fr)); gap: var(--s4); }

a.tile { display: flex; gap: var(--s3); padding: var(--s4); color: var(--ink); text-decoration: none; align-items: flex-start;
  transition: transform var(--base) var(--ease), box-shadow var(--base), border-color var(--base); }
a.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
a.tile:active { transform: translateY(0) scale(.99); }
.tile-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-text); }
/* Цвет значка плитки по группе раздела: деньги, люди и график, настройки. */
.tile[class*="tone-"] .tile-icon { background: hsl(var(--h) var(--chip-s) var(--chip-l)); color: hsl(var(--h) var(--chip-ink-s) var(--chip-ink-l)); }
.tile.tone-money { --h: 152; }
.tile.tone-people { --h: 268; }
.tile.tone-settings .tile-icon { background: var(--surface-2); color: var(--muted); }
.tile b { display: block; font-weight: 640; }
.tile span.t { color: var(--muted); font-size: var(--fs-s); }
.tile .go { margin-left: auto; align-self: center; color: var(--line-strong); transition: transform var(--base) var(--ease), color var(--base); }
a.tile:hover .go { transform: translateX(3px); color: var(--accent); }

.stat { padding: var(--s4); }
.stat b { display: block; font-size: 26px; line-height: 1.15; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: var(--fs-s); }
.stat small { display: block; margin-top: 2px; }

/* ------------------------------------------------------------------ таблицы */
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
  box-shadow: var(--shadow-1); -webkit-overflow-scrolling: touch; }
.table-wrap.sticky { max-height: min(72vh, 720px); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap;
  vertical-align: middle; }
.table td.wrap { white-space: normal; min-width: 180px; }
.table th { position: sticky; top: 0; z-index: 2; background: var(--surface); color: var(--muted); font-weight: 560;
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em; box-shadow: 0 1px 0 var(--line); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
/* Длинный заголовок над короткими значениями (ui.Col(narrow=True)): переносится по словам. */
.table th.narrow { white-space: normal; min-width: 7.5em; line-height: 1.25; }
.table tbody tr { transition: background var(--fast); }
.table tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.group td { background: var(--surface-2); font-weight: 620; }
.table tr.total td { font-weight: 680; border-top: 1px solid var(--line-strong); }
.table tfoot td { font-weight: 680; border-top: 1px solid var(--line-strong); border-bottom: 0; position: sticky; bottom: 0;
  background: var(--surface); }
.table td a { color: inherit; text-decoration-color: var(--line-strong); }
.table td a:hover { color: var(--accent-text); }
.table input.input { padding: 5px 8px; min-height: 32px; }

/* ------------------------------------------------------------------ поля и кнопки */
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: var(--fs-s); font-weight: 560; }
.field small.err { color: var(--danger); }
.input {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--field-line);
  border-radius: var(--r-m); padding: 8px 12px; min-height: 40px; width: 100%; max-width: 100%;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.input:hover { border-color: var(--muted); }
.input:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input[aria-invalid="true"] { border-color: var(--danger); }
/* Значение, внесённое вручную: поле выделено, слева бледно — что было бы без него. */
.hand { display: inline-flex; align-items: center; justify-content: flex-end; gap: var(--s2); white-space: nowrap; }
.hand > small { font-variant-numeric: tabular-nums; }
.input.hand { border-color: var(--warn); background: var(--warn-soft); }
.input.hand:hover { border-color: var(--warn); }
textarea.input { min-height: 84px; resize: vertical; }
.check { display: inline-flex; gap: var(--s2); align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
/* Выбор из готовых вариантов (ui.choices): галочки или переключатель, столбцами. */
.choices { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 2px var(--s3);
  grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); }
.choices.one { grid-template-columns: 1fr; }
.choices legend { padding: 0; margin-bottom: 4px; font-size: var(--fs-s); font-weight: 560; }
.choice { display: flex; gap: var(--s2); align-items: flex-start; padding: 6px var(--s2); border-radius: var(--r-s);
  cursor: pointer; transition: background var(--fast); }
.choice:hover { background: var(--surface-2); }
.choice input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.choice span { min-width: 0; overflow-wrap: anywhere; }
.choice small { display: block; }
.choice:has(input:checked) { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.choice-extra { grid-column: 1 / -1; padding: var(--s1) var(--s2) var(--s2) calc(18px + var(--s2) * 2); max-width: 320px; }
.choice:not(:has(input:checked)) + .choice-extra { display: none; }
/* Строка настройки (ui.setting): пояснение слева, выбор справа. */
.setting { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--s3) var(--s5); padding: var(--s5) 0; }
.setting:first-child { padding-top: var(--s1); }
.setting:last-child { padding-bottom: var(--s1); }
.setting + .setting { border-top: 1px solid var(--line); }
.setting-about p { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-s); }
.setting-control { min-width: 0; display: grid; gap: var(--s4); align-content: start; }
.setting-control ul { margin: 0; padding-left: 1.2em; }
.setting-control p { margin: 0; }
@media (max-width: 720px) { .setting { grid-template-columns: 1fr; padding: var(--s4) 0; } .save-bar { position: static; box-shadow: var(--shadow-1); } }
/* Полоса сохранения длинной формы (ui.save_bar): держится у нижнего края окна. */
.save-bar { position: sticky; bottom: var(--s3); z-index: 5; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4);
  align-items: center; padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l); box-shadow: var(--shadow-2); }
.save-bar small { flex: 1 1 24ch; }
.save-bar:has(.autosave-note) { position: static; box-shadow: var(--shadow-1); }       /* сохраняется сразу: кнопки нет */
.form { display: grid; gap: var(--s4); }
/* Поля строки формы выровнены по верху: подписи на одной линии, поля ввода на одной линии, а
   подсказки разной длины уходят вниз и ничего не сдвигают. Кнопка и галочка в такой строке
   встают на уровень поля ввода, а не подписи. */
.form-row { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); align-items: start; }
.form-row > .btn, .form-row > .check { margin-top: calc(var(--fs-s) * 1.45 + 4px); }
.form-row > .check { min-height: 40px; }
/* Форма в одну строку: подпись, узкое поле, пояснение и кнопки на одной линии. В карточке под
   списком цифр отделена чертой. */
.form-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.form-line > label { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 560; margin-right: var(--s2); }
.form-line > label .input { width: 4.6em; }
.form-line > label .muted { font-weight: 400; font-size: inherit; }
.form:has(> .form-line) { gap: var(--s2); }
.facts + .form { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }
/* Кнопка формы — своей ширины, слева, а не во всю карточку. */
.form > .btn, .form > .row > .btn { justify-self: start; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 40px; padding: 8px 16px;
  font: inherit; font-weight: 600; border-radius: var(--r-m); border: 1px solid transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background var(--fast), border-color var(--fast), box-shadow var(--fast), transform var(--fast);
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-1); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: var(--surface); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 88%, var(--ink)); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: var(--fs-s); border-radius: var(--r-s); }
.btn.square { padding: 0; width: 40px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ------------------------------------------------------------------ значки состояния */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 620; line-height: 1.6; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }

/* ------------------------------------------------------------------ уведомления */
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-m);
  border: 1px solid var(--line); background: var(--surface); animation: slide var(--base) var(--ease) both; }
.alert > div { flex: 1; min-width: 0; }
.alert.success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.alert.error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert.info { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.alert .x { all: unset; cursor: pointer; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; opacity: .7; }
.alert .x:hover { opacity: 1; background: rgb(127 127 127 / .18); }
.alert.out { opacity: 0; transform: translateY(-4px); transition: opacity var(--base), transform var(--base); }
.toasts { position: fixed; z-index: 80; right: var(--s4); bottom: var(--s4); display: grid; gap: var(--s2);
  width: min(380px, calc(100vw - 2 * var(--s4))); pointer-events: none; }
.toasts .alert { pointer-events: auto; box-shadow: var(--shadow-2); animation: toast-in var(--slow) var(--ease) both;
  background: var(--ink); color: var(--bg); border: 0; }
.toasts .alert.success .icon { color: var(--toast-ok); }
.toasts .alert.error .icon { color: var(--toast-bad); }
.toasts .alert .btn { min-height: 28px; padding: 2px 10px; color: inherit; border-color: rgb(127 127 127 / .5); background: transparent; }

/* ------------------------------------------------------------------ окно подтверждения */
.dialog { border: 0; padding: 0; border-radius: var(--r-l); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-3); width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(10 14 22 / .5); backdrop-filter: blur(2px); }
.dialog[open] { animation: pop var(--base) var(--ease) both; }
.dialog[open]::backdrop { animation: fade var(--base) both; }
.dialog-body { padding: var(--s5) var(--s5) var(--s3); }
.dialog-body h2 { margin-bottom: var(--s2); }
.dialog-body p { color: var(--muted); margin: 0; }
.dialog-foot { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s3) var(--s5) var(--s5); flex-wrap: wrap; }

/* ------------------------------------------------------------------ раскрывающийся блок */
:root { interpolate-size: allow-keywords; }
.fold { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-1); }
.fold summary { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); cursor: pointer;
  font-weight: 620; list-style: none; border-radius: var(--r-l); }
.fold summary::-webkit-details-marker { display: none; }
.fold summary .icon { color: var(--muted); transition: transform var(--base) var(--ease); }
.fold[open] summary .icon { transform: rotate(90deg); }
.fold summary { flex-wrap: wrap; }
.fold summary .icon { flex: none; }
.fold summary span { flex: 1 1 0; min-width: 12ch; }      /* длинный заголовок переносится, а не раздвигает страницу */
.fold summary small { margin-left: auto; font-weight: 400; }
.fold-body { padding: 0 var(--s4) var(--s4); }
.fold::details-content { block-size: 0; overflow: clip; transition: block-size var(--base) var(--ease), content-visibility var(--base) allow-discrete; }
.fold[open]::details-content { block-size: auto; }

/* ------------------------------------------------------------------ пустое состояние */
.empty { text-align: center; padding: var(--s6) var(--s4); color: var(--muted); }
.empty .empty-icon { width: 56px; height: 56px; margin: 0 auto var(--s3); border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); }
.empty .empty-icon .icon { width: 26px; height: 26px; }
.empty b { display: block; color: var(--ink); font-size: var(--fs-l); margin-bottom: 4px; }
.empty .btn { margin-top: var(--s3); }

/* ------------------------------------------------------------------ вкладки */
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--r-m); width: fit-content;
  max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { all: unset; cursor: pointer; padding: 7px 14px; border-radius: 8px; color: var(--muted); font-weight: 560;
  white-space: nowrap; transition: background var(--fast), color var(--fast), box-shadow var(--fast); }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.tab-panel { margin-top: var(--s4); animation: rise var(--base) var(--ease) both; }
.tab-panel[hidden] { display: none; }

/* ------------------------------------------------------------------ график работ */
.sched { display: grid; gap: var(--s3); }
.sched-bar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
/* Подсказка над сеткой меняет текст во время работы. Чтобы сетка под ней не сдвигалась, высоту
   строки держит невидимая копия самого длинного текста (в той же ячейке, что и видимый), а
   кнопка «Убрать смену» без выбранной смены не исчезает, а становится невидимой. */
.sched-hint { color: var(--muted); font-size: var(--fs-s); flex: 1 1 220px; display: grid; align-items: start; }
.sched-hint > * { grid-area: 1 / 1; min-width: 0; }
.sched-hint-size { visibility: hidden; }
.sched-bar [data-remove]:disabled { visibility: hidden; }
.chip { --h: 215; font: inherit; font-size: 12px; font-weight: 640; border: 1px solid transparent; cursor: grab;
  border-radius: 8px; padding: 4px 8px; white-space: nowrap; touch-action: manipulation; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none;
  background: hsl(var(--h) var(--chip-s) var(--chip-l)); color: hsl(var(--h) var(--chip-ink-s) var(--chip-ink-l));
  transition: transform var(--fast) var(--ease), box-shadow var(--fast), opacity var(--fast); }
.chip:hover { box-shadow: var(--shadow-1); transform: translateY(-1px); }
.chip.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px hsl(var(--h) 70% 50%); }
.chip.dragging { opacity: .35; }
.chip.lift { position: fixed; z-index: 90; pointer-events: none; margin: 0; cursor: grabbing; box-shadow: var(--shadow-2);
  transform: rotate(-3deg) scale(1.08); transition: none; }
.chip.pop { animation: pop var(--slow) var(--ease); }
.office.chip { padding: 6px 12px; font-size: var(--fs-s); border-radius: var(--r-pill); }
.sched-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface);
  box-shadow: var(--shadow-1); overscroll-behavior-x: contain; }
.sched-grid { border-collapse: separate; border-spacing: 0; font-size: var(--fs-s); }
.sched-grid th, .sched-grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; }
.sched-grid tr:last-child > * { border-bottom: 0; }
.sched-grid thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); color: var(--muted); font-weight: 560;
  padding: 6px 0; min-width: 46px; text-align: center; line-height: 1.2; }
.sched-grid thead th b { display: block; color: var(--ink); font-size: var(--fs); }
.sched-grid .we { background: var(--surface-2); }
.sched-grid thead th.we { background: var(--surface-2); color: var(--danger); }
/* Сегодняшнее число в шапке графика. */
.sched-grid thead th.today b { display: inline-block; min-width: 1.7em; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink); }
.sched-grid .who-cell { position: sticky; left: 0; z-index: 4; background: var(--surface); text-align: left; padding: 6px 12px;
  white-space: nowrap; font-weight: 600; min-width: 132px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 1px 0 0 var(--line); }
.sched-grid thead .who-cell { z-index: 5; color: var(--muted); font-weight: 560; }
.sched-grid .sum { text-align: center; font-variant-numeric: tabular-nums; font-weight: 640; padding: 0 10px; border-right: 0; }
.slot { height: 44px; min-width: 46px; text-align: center; transition: background var(--fast), box-shadow var(--fast); cursor: pointer; }
.slot .chip { padding: 4px 6px; }
/* График офиса: месяц целиком помещается на экране ноутбука — дни делят ширину поровну, а
   прокрутка вбок появляется, только когда на день остаётся меньше 30 пикселей. */
.sched:not(.board) .sched-grid { width: 100%; min-width: calc(150px + 46px + 31 * 30px); table-layout: fixed; }
.sched:not(.board) .sched-grid .who-cell { width: 150px; white-space: normal; line-height: 1.25; overflow-wrap: anywhere; }
.sched:not(.board) .sched-grid .sum { width: 46px; padding: 0 4px; }
.sched:not(.board) .slot { min-width: 0; }
.sched:not(.board) .slot .chip { padding: 4px 3px; max-width: calc(100% - 4px); overflow: hidden; }
.sched:not(.board) .sched-grid thead th { padding-inline: 0; }
@media (max-width: 860px) {       /* на телефоне имя уже: иначе оно занимает почти половину экрана */
  .sched:not(.board) .sched-grid { min-width: calc(96px + 40px + 31 * 30px); }
  .sched:not(.board) .sched-grid .who-cell { width: 96px; }
  .sched:not(.board) .sched-grid .sum { width: 40px; }
}
.picking .slot:hover, .slot.over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.office.over { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px hsl(var(--h) 70% 50%); transform: scale(1.06); }
.dragging-now, .dragging-now * { cursor: grabbing !important; user-select: none; }
.sched-menu { position: fixed; z-index: 70; display: grid; gap: 2px; min-width: 210px; max-width: 300px;
  max-height: min(380px, 72vh); overflow-y: auto; padding: var(--s2); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-3); animation: pop var(--fast) var(--ease) both; }
.sched-menu[hidden] { display: none; }
.sched-menu-title { padding: 4px var(--s2) 6px; color: var(--muted); font-size: var(--fs-s); font-weight: 560; }
.sched-menu button { display: flex; align-items: center; gap: var(--s2); border: 0; background: none; padding: 7px var(--s2);
  border-radius: var(--r-s); font: inherit; font-size: var(--fs-s); color: inherit; text-align: left; cursor: pointer; }
.sched-menu button:hover, .sched-menu button:focus-visible { background: var(--surface-2); outline: none; }
.sched-menu button[aria-current] { background: var(--accent-soft); color: var(--accent-text); font-weight: 620; }
.sched-menu button.danger { color: var(--danger); }
.sched-menu hr { border: 0; border-top: 1px solid var(--line); margin: var(--s1) 0; width: 100%; }
.sched-dot { --h: 215; flex: none; width: 10px; height: 10px; border-radius: 50%; background: hsl(var(--h) 70% 55%); }
.sched-menu .away .sched-dot { background: var(--line-strong); }
.sched-menu button[hidden] { display: none; }
.sched-menu .input { width: 100%; margin-bottom: var(--s1); }
.sched-menu button.more { color: var(--muted); }
.sched-more summary { cursor: pointer; color: var(--muted); font-size: var(--fs-s); width: fit-content; padding: 2px 0; }
.sched-more summary:hover { color: var(--ink); }
.sched-more[open] summary { margin-bottom: var(--s2); }
.sched-add select.input { width: auto; max-width: 100%; }
.sched-add small { color: var(--muted); }
.sched-log { margin: 0; padding-left: 1.4em; color: var(--muted); font-size: var(--fs-s); }
.sched-log li { animation: rise var(--base) var(--ease) both; }
/* Смена в офисе, который человеку не открыт: видна, но не двигается. Сетка только для чтения. */
.chip.locked { background: transparent; color: var(--muted); border: 1px dashed var(--line); cursor: default; }
.chip.locked:hover, .sched.readonly .chip:hover { box-shadow: none; transform: none; }
.sched.readonly .chip, .sched.readonly .slot { cursor: default; }
.sched.busy { cursor: progress; }
/* Отпуск и больничный: отметка дня вместо смены, без цвета офиса. */
.chip.away { background: var(--surface-2); color: var(--muted); border-color: var(--line); font-weight: 560; }
.chip.away[data-mark="sick"] { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.sched.busy .sched-wrap { opacity: .7; }


/* ------------------------------------------------------------------ движение */
/* slide — для того, что есть на странице сразу: без прозрачности, чтобы содержимое было видно,
   даже если браузер придержал анимацию (свёрнутая вкладка). rise — для появляющегося по нажатию. */
@keyframes slide { from { transform: translateY(8px); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.92); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
  @view-transition { navigation: none; }
}

@media print {
  /* Бумага белая: цвета светлой темы, какая бы тема ни стояла на экране. */
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    color-scheme: light;
    --bg: #ffffff; --surface: #ffffff; --surface-2: #f0f2f5; --ink: #16181d; --muted: #4b5563;
    --line: #c9ced6; --line-strong: #9aa1ad; --field-line: #9aa1ad; --accent: #2f6fde; --accent-ink: #ffffff;
    --accent-soft: #e4edfc; --accent-text: #1f55b5; --success: #12805c; --success-soft: #e0f5ec;
    --danger: #c0352b; --danger-soft: #fce8e6; --warn: #b54708; --warn-soft: #fdf0dc;
    --shadow-1: none; --shadow-2: none; --shadow-3: none;
    --chip-s: 75%; --chip-l: 91%; --chip-ink-s: 60%; --chip-ink-l: 28%;
  }
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; }
  /* На бумаге нет того, что нажимают: меню, кнопок, переключателей, поиска и строки сохранения. */
  .side, .topbar, .toasts, .backdrop, .btn, .month a, .month span.off, .filter, .tabs, .save-bar,
  .autosave-note, .row-toggle, .skip { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .card, .table-wrap { box-shadow: none; }
  .table-wrap, .table-wrap.sticky { max-height: none; overflow: visible; }
  /* Таблица целиком: ничего не прилипает, строка не рвётся между листами, шапка повторяется. */
  .table { font-size: 11px; }
  .table th, .table td { position: static !important; padding: 4px 6px; }
  .table thead { display: table-header-group; }
  .table tr { break-inside: avoid; }
  /* Поле ввода печатается как число в ячейке, без рамки и подсказки. */
  .input, .table input.input { border: 0; padding: 0; min-height: 0; background: transparent; box-shadow: none; }
  .input::placeholder { color: transparent; }
  a { color: inherit; text-decoration: none; }
}

/* Телефон. Поле мельче 16 пикселей iPhone приближает при каждом нажатии — страница «прыгает». */
@media (max-width: 860px) {
  .input, .table input.input { font-size: 16px; }
}
/* Палец крупнее курсора: то, что нажимают, — не меньше 40 пикселей. */
@media (pointer: coarse) {
  .btn.small { min-height: 40px; padding-inline: 12px; }
  .table input.input { min-height: 40px; }
  .month a, .month span.off { width: 40px; height: 40px; }
  .alert .x { width: 36px; height: 36px; }
  .row-toggle { padding: 8px; }
}

/* ------------------------------------------------------------------ список «название — значение» */
.facts { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--s4); margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
/* Раздел и его подпункты: из чего сложена сумма. */
.facts .is-head { color: var(--ink); font-weight: 680; }
.facts .is-head:not(:first-child) { margin-top: var(--s2); }
.facts dt.is-head:first-child + dd { margin-top: 0; }
.facts dt.is-sub { padding-left: var(--s4); }
.facts .is-sub { font-size: var(--fs-s); }
.facts dd.is-sub { font-weight: 480; color: var(--muted); }

/* ---------------------------------------------------------------- страницы на компонентах */
/* Широкая таблица внутри формы прокручивается в своей рамке, а не растягивает страницу. */
.form > *, .grid > *, .stack > * { min-width: 0; }
/* Поля ввода в строках таблицы: узкие для счёта дней и звонков, шире для сумм. */
.table .input { width: 4.6em; padding-inline: var(--s2); }
.table .input[size="8"], .table .input[size="9"] { width: 8em; }
.table select.input { width: auto; min-width: 9em; max-width: 16.5em; text-overflow: ellipsis; }
/* Выбор месяца под операцией (бюджет): «сентябрь 2026» помещается целиком. */
.table .form .stack > select.input { min-width: 11.5em; }
.table td form { display: inline; }
.card-body > ul { margin: 0; padding-left: 1.2em; }
.card-body > ul > li + li { margin-top: 4px; }
.card-foot .form { margin-top: var(--s2); color: var(--ink, inherit); }
/* Первый столбец (имя, офис, статья) остаётся на месте, когда широкая таблица прокручена вбок. */
.table td:first-child, .table th:first-child { position: sticky; left: 0; }
.table td:first-child { z-index: 1; background: var(--surface); }
.table th:first-child { z-index: 3; }
.table tr.group td:first-child { background: var(--surface-2); }
.table tbody tr:hover td:first-child { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }

/* Панель подробностей строки (ui.table(details="side")): открывается справа поверх страницы. */
.table tr.opens { cursor: pointer; scroll-margin-top: var(--s7); }
.table tr.opens.on td, .table tbody tr.opens.on:hover td:first-child { background: var(--accent-soft); }
.row-open { color: inherit; text-decoration: none; display: block; }
.row-open:hover, .row-open:focus-visible { color: var(--accent-text); }
.sheet { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(640px, 100vw); max-width: none; height: 100vh; height: 100dvh;
  max-height: none; border: 0; border-left: 1px solid var(--line); padding: 0; background: var(--bg); color: var(--ink);
  box-shadow: var(--shadow-3); overflow: hidden; z-index: 60; }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in var(--base) var(--ease) both; }
.sheet::backdrop { background: rgb(10 14 22 / .35); }
.sheet[open]::backdrop { animation: fade var(--base) both; }
@keyframes sheet-in { from { transform: translateX(32px); } }
.sheet-head { display: flex; align-items: center; gap: var(--s1); padding: var(--s3) var(--s4); background: var(--surface);
  border-bottom: 1px solid var(--line); }
.sheet-head form { margin: 0; }
.sheet-title { flex: 1; min-width: 0; font-weight: 680; font-size: var(--fs-l); white-space: normal; }
.sheet-title .cell-clip { display: grid; max-width: none; }
.sheet-title small { color: var(--muted); font-size: var(--fs-s); font-weight: 480; }
.sheet-body .form-row { align-items: start; }
.sheet-body > *, .sheet-body .stack > * { min-width: 0; }
.sheet-body .facts { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.sheet-body .facts dd { white-space: normal; overflow-wrap: anywhere; }
.sheet-body .facts dt { white-space: normal; }
.sheet-body { flex: 1; overflow-y: auto; padding: var(--s4); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); align-content: start;
  white-space: normal; overscroll-behavior: contain; }
.sheet-body .table td:first-child, .sheet-body .table th:first-child { position: static; }
.sheet-body .field .input { width: 100%; padding: 8px 12px; min-height: 40px; }
.sheet-body .card-body > .form, .sheet-body .card-foot > .form { display: grid; }
/* Панель стоит внутри карточки с таблицей «от края до края»; её собственные карточки — обычные. */
.sheet .card:not(.flush) > .card-body { padding: var(--s4); }

/* Календарь месяца (ui.month_calendar): неделя с понедельника, день закрашен по виду. */
.month-cal table { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.month-cal th { font-size: var(--fs-s); font-weight: 560; color: var(--muted); text-align: center; padding: 2px 0; }
.month-cal th.rest { color: var(--danger); }
.month-cal td { text-align: center; padding: 10px 0; border-radius: var(--r-s, 8px); font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--line); }
.month-cal td:empty { background: none; border-color: transparent; }
.month-cal td.weekend { background: var(--surface-2); color: var(--muted); }
.month-cal td.holiday { background: var(--danger-soft); color: var(--danger); border-color: transparent; font-weight: 620; }
.month-cal td.short { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.month-cal td.moved { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.month-cal td.today { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Календарь с плашками («Мой график»): число дня сверху, под ним офис смены или отметка. */
.month-cal.filled td { padding: 6px 4px 8px; vertical-align: top; height: 68px; }
.month-cal.filled td b { display: block; font-weight: 560; margin-bottom: 5px; }
.month-cal.filled .chip { display: block; cursor: default; padding: 4px 6px; margin: 2px 0 0; font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-cal.filled .chip:hover { box-shadow: none; transform: none; }
.month-cal.filled .chip.away { background: var(--warn-soft); color: var(--warn); }
@media (max-width: 640px) { .month-cal.filled table { border-spacing: 2px; } .month-cal.filled .chip { padding: 3px 2px; font-size: 10px; } }
.month-cal-legend { list-style: none; margin: var(--s3) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4);
  font-size: var(--fs-s); color: var(--muted); }
.month-cal-legend li { display: flex; align-items: center; gap: 6px; }
.month-cal-legend i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); }
.month-cal-legend i.weekend { background: var(--surface-2); }
.month-cal-legend i.holiday { background: var(--danger-soft); border-color: var(--danger); }
.month-cal-legend i.short { background: var(--warn-soft); border-color: var(--warn); }
.month-cal-legend i.moved { background: var(--accent-soft); border-color: var(--accent-text); }

/* Подробности строки (ui.Row(detail=…)): строка раскрывается по нажатию, подробности идут под ней
   во всю ширину таблицы и не уезжают при прокрутке вбок. */
.table tr.expands { cursor: pointer; scroll-margin-top: var(--s7); }   /* не прятаться под липкой шапкой */
.table tr.expands.open td { background: var(--surface-2); border-bottom-color: transparent; }
.row-first { display: inline-flex; align-items: center; gap: var(--s2); max-width: 100%; }
.row-toggle { flex: none; display: inline-flex; padding: 2px; border-radius: var(--r-s); color: var(--muted); }
.row-toggle .icon { transition: transform var(--base) var(--ease); }
.row-toggle[aria-expanded="true"] .icon { transform: rotate(90deg); }
.table tr.detail > td { position: static; padding: 0; white-space: normal; background: var(--surface-2); }
.table tbody tr.detail:hover > td { background: var(--surface-2); }
.detail-body { position: sticky; left: 0; box-sizing: border-box; width: min(100%, 1040px); max-width: 92vw;
  padding: var(--s3) var(--s4) var(--s4); }
.detail-body .table-wrap { box-shadow: none; }
.detail-body .table td:first-child, .detail-body .table th:first-child { position: static; }
/* Формы в подробностях — обычные формы, а не узкие поля строки таблицы. */
.table .detail-body .field .input { width: 100%; padding: 8px 12px; min-height: 40px; }
.table .detail-body .card-body > .form, .table .detail-body .card-foot > .form { display: grid; }

/* Узкая ячейка (ui.clip): на телефоне имя в закреплённом первом столбце переносится по словам,
   чтобы рядом оставалось место для чисел и полей ввода. */
@media (max-width: 640px) {
  .table .cell-clip { display: inline-block; max-width: 8.5rem; white-space: normal; overflow-wrap: break-word;
    vertical-align: middle; line-height: 1.3; }
  .table .cell-clip .badge { margin-top: 2px; }
  /* Столбец с переносом на телефоне уже: при 180px таблица из трёх столбцов («Выплаты» в «Моём
     расчёте») не помещалась в экран, и у суммы справа обрезалась последняя цифра. */
  .table td.wrap { min-width: 7rem; }
}

/* Пометка под именем (ui.clip(..., note=…)): вид контрагента вместо отдельного столбца. */
.table .cell-clip small { display: block; font-weight: 400; line-height: 1.3; }

/* ---------------------------------------------------------------- доходы и расходы */
/* Строка таблицы, по которой можно перейти (ui.row_link). */
.table tbody tr:has(a.row-link) { cursor: pointer; }
.table td a.row-link { font-weight: 600; text-decoration: none; }
.table tbody tr:has(a.row-link):hover a.row-link { color: var(--accent-text); text-decoration: underline; }
/* Таблица с раскрывающимися группами (ui.group_table). */
.table tbody.tgroup.closed tr:not(.group) { display: none; }
.table.filtering tbody.tgroup.closed tr:not(.group):not([hidden]) { display: table-row; }
.table tbody.tgroup tr:last-child td { border-bottom: 1px solid var(--line); }
.table tbody.tgroup tr.group { cursor: pointer; }
.tgroup-toggle { display: inline-flex; align-items: center; gap: var(--s2); max-width: 100%; padding: 0; border: 0;
  background: none; color: inherit; font: inherit; font-weight: inherit; text-align: left; cursor: pointer;
  white-space: normal; border-radius: var(--r-s); }
.tgroup-toggle .icon { flex: none; color: var(--muted); transition: transform var(--base) var(--ease); }
.tgroup-toggle[aria-expanded="true"] .icon { transform: rotate(90deg); }
.tgroup-toggle small { flex: none; color: var(--muted); font-weight: 400; white-space: nowrap; }
.table tbody.tgroup tr:not(.group) td:first-child { padding-left: calc(12px + 18px + var(--s2)); }
/* Значок с подсказкой (ui.tip). */
.card:has(.tip) > .card-head { position: relative; }
.tip { cursor: help; }
.tip-text { position: absolute; z-index: 20; top: calc(100% + 4px); right: var(--s4); width: max-content;
  max-width: min(320px, calc(100% - 2 * var(--s4))); padding: var(--s2) var(--s3); border-radius: var(--r-m);
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2); color: var(--ink);
  font-size: var(--fs-s); font-weight: 400; line-height: 1.4; white-space: normal; text-align: left;
  opacity: 0; visibility: hidden; transition: opacity var(--fast), visibility var(--fast); }
.tip:hover .tip-text, .tip:focus .tip-text { opacity: 1; visibility: visible; }
/* Страницы доходов и расходов на телефоне (financeui.wrap): плотнее, чтобы помещалось больше цифр. */
@media (max-width: 560px) {
  .fin .table th, .fin .table td { padding: 8px; font-size: 13px; }
  .fin .table td.wrap { min-width: 118px; }
  .fin .table tbody.tgroup tr:not(.group) td:first-child { padding-left: 8px; }
  .fin .tgroup-toggle { display: grid; grid-template-columns: auto 1fr; gap: 0 4px; }
  .fin .tgroup-toggle small { grid-column: 2; }
  .fin .grid { gap: var(--s2); }
  .fin .stat { padding: var(--s3); }
  .fin .stat b { font-size: 19px; }
}
.fin > h2 { margin-top: var(--s6); }
.fin > h2 + * { margin-top: var(--s3); }

/* ---------------------------------------------------------------- строки формы: добавить и убрать (ui.row_list) */
.rowlist { display: grid; gap: var(--s2); align-content: start; }
.rowlist-title { font-weight: 600; }
.rowlist-head, .rowlist-row { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)) 32px;
  gap: var(--s2); align-items: center; }
.rowlist-head { font-size: var(--fs-s); color: var(--muted); align-items: end; }
.rowlist-body { display: grid; gap: var(--s2); }
.rowlist-row .btn.square { width: 32px; }
.rowlist > .btn { justify-self: start; }
/* Две вкладки с длинными названиями помещаются на телефоне без прокрутки вбок. */
@media (max-width: 420px) { .tabs a, .tabs button { padding-inline: 8px; } }

/* ---------------------------------------------------------------- сводный график «офисы × дни» (ui.board) */
.board .bslot { min-width: 78px; height: 44px; padding: 3px; vertical-align: top; text-align: center;
  transition: background var(--fast), box-shadow var(--fast); }
.board .bslot.gap { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); }
.board .bslot.over-cell { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.board.picking .bslot { cursor: pointer; }
.board.picking .bslot:hover { background: var(--accent-soft); }
.board .chip.person { display: block; max-width: 72px; margin: 2px auto; padding: 3px 6px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.board span.chip.person { cursor: default; }
.board.picking .bslot.locked { cursor: not-allowed; }
.board.picking .bslot.locked:hover { background: inherit; }
.board .chip.person.over { box-shadow: inset 0 0 0 2px var(--warn, #c98a00); }
.board .board-group th, .board .board-group td { background: var(--surface-2); font-weight: 620; }
.board .board-group td { border-right: 0; }
.board .who-cell a { color: inherit; text-decoration: none; }
.board .who-cell a:hover, .board .who-cell a:focus-visible { color: var(--accent-text); text-decoration: underline; }
.board.busy { opacity: .7; pointer-events: none; }

/* ---------------------------------------------------------------- группы меню, поиск по таблице, полоска доли */
.nav-fold { display: grid; gap: 2px; }
.nav-group { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin: var(--s3) 0 2px;
  padding: 5px var(--s3); border-radius: var(--r-s); color: var(--muted); font-size: 11px; font-weight: 640;
  letter-spacing: .06em; text-transform: uppercase; cursor: pointer; list-style: none; user-select: none;
  transition: background var(--fast), color var(--fast); }
.nav-group::-webkit-details-marker { display: none; }
.nav-group:hover { background: var(--surface-2); color: var(--ink); }
.nav-group .icon { width: 14px; height: 14px; transition: transform var(--base) var(--ease); }
.nav-fold[open] > .nav-group .icon { transform: rotate(90deg); }
.nav-fold::details-content { block-size: 0; overflow: clip; transition: block-size var(--base) var(--ease), content-visibility var(--base) allow-discrete; }
.nav-fold[open]::details-content { block-size: auto; }
.autosave-note { color: var(--muted); font-size: var(--fs-s); font-weight: 560; }
.autosave-note.bad { color: var(--danger); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.filter { display: inline-flex; align-items: center; gap: var(--s2); }
.filter .input { width: 220px; max-width: 60vw; }
/* Строка «когда обновлялись данные» с кнопкой (ui.sync): значок крутится, пока идёт обновление. */
.sync { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s3); padding: var(--s3) var(--s4); }
.sync-mark { flex: none; width: 28px; height: 28px; border-radius: var(--r-pill); display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); }
.sync-mark .icon { width: 16px; height: 16px; }
.sync.ok .sync-mark { background: var(--success-soft); color: var(--success); }
.sync.error .sync-mark { background: var(--danger-soft); color: var(--danger); }
.sync.running .sync-mark { background: var(--accent-soft); color: var(--accent-text); }
.sync.running .sync-mark .icon { animation: spin 1s linear infinite; }
.sync-text { flex: 1; min-width: 0; }
.sync-text a { color: inherit; }
.sync form { margin: 0; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Список дел на главной (ui.todo): значок, текст, кнопка справа. */
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.todo-mark { flex: none; width: 28px; height: 28px; border-radius: var(--r-pill); display: grid; place-items: center;
  background: var(--warn-soft); color: var(--warn); }
.todo-mark .icon { width: 16px; height: 16px; }
.todo-text { flex: 1; min-width: 0; }
.todo .btn { flex: none; }
.todo form { margin: 0; flex: none; display: flex; }
.todo .btn.square { width: 32px; }

/* Показатель сводки на главной (ui.kpi): значок с названием, крупное значение, полоска доли, строки. */
.kpi { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); --kpi: var(--accent); }
.kpi[class*="tone-"] { --kpi: hsl(var(--h) var(--chip-ink-s) 50%); }
.kpi[class*="tone-"] .tile-icon { background: hsl(var(--h) var(--chip-s) var(--chip-l)); color: hsl(var(--h) var(--chip-ink-s) var(--chip-ink-l)); }
.kpi.tone-money { --h: 152; }
.kpi.tone-people { --h: 268; }
.kpi.tone-time { --h: 32; }
.kpi.tone-bot { --h: 198; }
.kpi-head { display: flex; align-items: center; gap: var(--s3); font-weight: 620; }
.kpi-head .tile-icon { width: 34px; height: 34px; border-radius: var(--r-m); }
.kpi-value { margin: 0; display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.kpi-value b { font-size: 32px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-value span { color: var(--muted); font-size: var(--fs-l); }
.kpi-value.good b { color: var(--success); }
.kpi-value.bad b { color: var(--danger); }
.kpi-bar { display: block; height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.kpi-bar i { display: block; width: var(--w, 0%); height: 100%; border-radius: var(--r-pill); background: var(--kpi); }
.kpi-note { margin: 0; color: var(--muted); font-size: var(--fs-s); }
.kpi-rows { margin: auto 0 0; padding-top: var(--s3); border-top: 1px solid var(--line); display: grid; gap: var(--s1); }
.kpi-rows div { display: flex; justify-content: space-between; gap: var(--s3); }
.kpi-rows dt { color: var(--muted); }
.kpi-rows dd { margin: 0; font-weight: 620; font-variant-numeric: tabular-nums; white-space: nowrap; }

.filter small { color: var(--muted); white-space: nowrap; }
.table tr[hidden] { display: none; }
.bar { display: inline-block; width: 120px; max-width: 100%; height: 8px; border-radius: 4px; background: var(--surface-2);
  vertical-align: middle; overflow: hidden; }
.bar i { display: block; width: var(--w, 0%); height: 100%; border-radius: 4px; background: var(--accent); }

/* Диаграмма по периодам (ui.chart): столбики или линии, цвета рядов — из переменных. */
.chart { margin: 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .tick, .chart .label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .label { text-anchor: middle; }
.chart .col { transition: opacity var(--fast) var(--ease); }
.chart .col:hover, .chart .dot:hover { opacity: .75; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .s1 { fill: var(--accent); stroke: var(--accent); }
.chart .s2 { fill: var(--warn); stroke: var(--warn); }
.chart .s3 { fill: var(--success); stroke: var(--success); }
.chart .s4 { fill: var(--danger); stroke: var(--danger); }
.chart .s5 { fill: var(--muted); stroke: var(--muted); }
.chart .s6 { fill: var(--accent-text); stroke: var(--accent-text); }
.chart .line.s1, .chart .line.s2, .chart .line.s3, .chart .line.s4, .chart .line.s5, .chart .line.s6 { fill: none; }
.chart figcaption { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-top: var(--s2); color: var(--muted);
  font-size: var(--fs-s); }
.chart figcaption span { display: inline-flex; align-items: center; gap: 6px; }
.chart figcaption i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.chart figcaption i.s1 { background: var(--accent); } .chart figcaption i.s2 { background: var(--warn); }
.chart figcaption i.s3 { background: var(--success); } .chart figcaption i.s4 { background: var(--danger); }
.chart figcaption i.s5 { background: var(--muted); } .chart figcaption i.s6 { background: var(--accent-text); }


/* Таблица с порядком строк по нажатию на заголовок: ui.table(sortable=True). */
.table th.sorts { cursor: pointer; user-select: none; }
.table th.sorts:hover, .table th.sorts:focus-visible { color: var(--ink); }
.table th.sorts::after { content: "↕"; margin-left: 4px; opacity: .35; }
.table th.sorts[aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--accent); }
.table th.sorts[aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--accent); }

/* Просмотр документов заказа бота: текст перевода и картинка оригинала. */
.doc-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.doc-image { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r-l); }

/* Форма в ячейке таблицы (сумма «К выплате» в расчёте): одно поле, сохраняется сразу. */
.table td > .form { display: inline-flex; margin: 0; }
.table td > .form .autosave-note { display: none; }
.table td > .form .input { width: 8.5em; }

/* ------------------------------------------------------------------ выбор файлов с перетаскиванием (ui.file_drop) */
/* Без скрипта в площадке стоит обычное поле выбора файлов. Скрипт ставит класс `on`: поле становится
   прозрачным и занимает всю площадку (нажатие в любом месте открывает выбор), видна подсказка. */
.drop-zone { position: relative; display: flex; align-items: center; justify-content: center; min-height: 76px;
  padding: var(--s3); border: 1.5px dashed var(--field-line); border-radius: var(--r-m); background: var(--surface);
  color: var(--muted); text-align: center; transition: border-color var(--fast), background var(--fast); }
.drop-zone input { max-width: 100%; font: inherit; color: var(--ink); }
.file-drop.on .drop-zone { cursor: pointer; }
.file-drop.on .drop-zone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop.on .drop-zone:hover { border-color: var(--muted); }
.file-drop.on .drop-zone:focus-within { border-color: var(--accent); border-style: solid;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.file-drop.over .drop-zone { border-color: var(--accent); border-style: solid; background: var(--accent-soft); color: var(--ink); }
.drop-text { display: inline-flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: center; pointer-events: none; }
.drop-text[hidden], .drop-list[hidden] { display: none; }
.drop-text u { color: var(--accent-text); text-underline-offset: 2px; }
.drop-list { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 4px; }
.drop-list li { display: flex; gap: var(--s2); align-items: center; padding: 4px 4px 4px var(--s3); min-width: 0;
  background: var(--surface-2); border-radius: var(--r-s); font-size: var(--fs-s); }
.drop-list .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-list .size { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.drop-list button { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border: 0; border-radius: var(--r-s); background: transparent; color: var(--muted); cursor: pointer; }
.drop-list button:hover { background: var(--line); color: var(--ink); }
.drop-list button .icon { width: 16px; height: 16px; }
/* Уже приложенные файлы записи: имя — ссылка для скачивания, галочка — убрать при сохранении. */
.kept-title { display: block; margin: var(--s3) 0 4px; }
.kept-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: var(--fs-s); }
.kept-files li { display: flex; flex-wrap: wrap; gap: 2px var(--s3); align-items: center; justify-content: space-between;
  padding: 6px var(--s3); background: var(--surface-2); border-radius: var(--r-s); min-width: 0; }
.kept-files a { min-width: 0; overflow-wrap: anywhere; }
.kept-files li:has(input:checked) a { text-decoration: line-through; color: var(--muted); }

/* Плитка-цифра как кнопка отбора (ui.stat с href): вся плитка — ссылка, включённая обведена. */
a.stat { display: block; color: inherit; text-decoration: none; transition: border-color .12s; }
a.stat:hover { border-color: var(--accent); }
a.stat.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
