/* Оформление панели. Один файл, без сборки: ни npm, ни шага компиляции —
   поменял и обновил страницу.

   Цвета заданы переменными и в светлой, и в тёмной теме: панель открывают и
   днём на ноутбуке, и вечером с телефона. */

/* Оформление — «клеймморфизм»: мягкие, будто вылепленные из глины формы.
   Выпуклое (карточки, кнопки) несёт наружную тень и светлый блик сверху;
   вдавленное (поля ввода, дорожка переключателя) — внутреннюю тень. Весь
   объём собран в двух переменных, --shadow и --shadow-in: столько мест
   с тенями вручную неизбежно разъехались бы. */
:root {
  --bg: #efe9e0;
  --panel: #faf6f0;
  --ink: #2a2419;
  --muted: #837a6c;
  --line: #e2d8c9;
  --accent: #8a5a34;
  --accent-soft: #eddfce;
  --good: #1a7f5a;
  --warn: #b45309;
  --bad: #b42318;
  --radius: 18px;
  --radius-small: 12px;
  --shadow:
    0 6px 14px rgba(138, 90, 52, .12),
    0 2px 4px rgba(42, 36, 25, .06),
    inset 0 2px 3px rgba(255, 255, 255, .9),
    inset 0 -3px 5px rgba(138, 90, 52, .07);
  --shadow-in:
    inset 0 2px 5px rgba(42, 36, 25, .10),
    inset 0 -1px 2px rgba(255, 255, 255, .8);
}

/* Тёмная тема применяется в двух случаях: её выбрали в профиле, либо выбрано
   «как в системе» и система просит тёмную. Поэтому набор переменных написан
   дважды: без шага сборки повторение — единственный способ, а выбор человека
   обязан перекрывать системный, а не спорить с ним. */
:root[data-theme="dark"] {
  --bg: #14161a;
  --panel: #1c1f25;
  --ink: #e8eaed;
  --muted: #9aa2ae;
  --line: #2b303a;
  --accent: #d3a077;
  --accent-soft: #2a2119;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow:
    0 8px 18px rgba(0, 0, 0, .42),
    inset 0 1px 2px rgba(255, 255, 255, .07),
    inset 0 -3px 5px rgba(0, 0, 0, .32);
  --shadow-in:
    inset 0 2px 5px rgba(0, 0, 0, .45),
    inset 0 -1px 2px rgba(255, 255, 255, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --panel: #1c1f25;
    --ink: #e8eaed;
    --muted: #9aa2ae;
    --line: #2b303a;
    --accent: #d3a077;
    --accent-soft: #2a2119;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --shadow:
      0 8px 18px rgba(0, 0, 0, .42),
      inset 0 1px 2px rgba(255, 255, 255, .07),
      inset 0 -3px 5px rgba(0, 0, 0, .32);
    --shadow-in:
      inset 0 2px 5px rgba(0, 0, 0, .45),
      inset 0 -1px 2px rgba(255, 255, 255, .05);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------ каркас --- */
.shell { display: flex; min-height: 100vh; gap: 6px; }

/* Боковая панель — отдельная глиняная плита, а не стенка во весь экран. */
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 14px 0 14px 14px;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  align-self: flex-start;
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.brand { padding: 0 8px 18px; }
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: -.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav > a, .nav > span, .subnav a, .subnav span {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
/* Открытый раздел «вдавлен» в боковую панель — по нему уже нажали. */
.nav a.on { background: var(--bg); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-in); }
.nav span.off { color: var(--muted); cursor: default; }
.nav span.off::after {
  content: "скоро";
  float: right;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 7px;
  color: var(--muted);
}

/* Дочерние пункты открытого раздела. Линия слева делает вложенность видимой
   без отступа в полэкрана: где ты находишься, читается одним взглядом. */
.subnav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 6px 14px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.subnav a, .subnav span { padding: 6px 10px; font-size: 13px; color: var(--muted); }
.subnav a.on { background: transparent; color: var(--accent); font-weight: 600; }
.subnav a:hover { color: var(--ink); }

.main { flex: 1; min-width: 0; padding: 16px 28px 48px; }

/* --------------------------------------------------- учётная запись --- */
/* Значок в углу, а не строка меню: «мой профиль» — это не раздел работы. */
.topbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }

.account { position: relative; }
.account summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  border-radius: 50%;
}
.account summary::-webkit-details-marker { display: none; }
.account summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  border: 0;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 640;
  font-size: 14px;
  user-select: none;
}
.account[open] .avatar { box-shadow: var(--shadow-in); }

.account-menu {
  position: absolute;
  right: 0;
  top: 44px;
  z-index: 20;
  min-width: 230px;
  background: var(--panel);
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(20, 14, 8, .25), var(--shadow);
  padding: 8px;
}
.account-who {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 8px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  word-break: break-all;
}
.account-menu a {
  display: block;
  padding: 8px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
}
.account-menu a:hover { background: var(--bg); text-decoration: none; }
.account-menu a.on { color: var(--accent); font-weight: 600; }
.account-menu form { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.account-menu button { width: 100%; }

/* Переключатель оформления в меню учётной записи: три значка в ряд.
   Названиями он занимал бы три строки — больше, чем сами пункты меню, ради
   настройки, которую меняют раз в год. Значок читается быстрее слова, а
   название всплывает по наведению (data-tip в base.html). */
.theme-switch .segmented { display: flex; width: 100%; }
.theme-switch .segmented label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}
.theme-switch .ico { width: 17px; height: 17px; display: block; }

/* ------------------------------------------------- меню строки таблицы --- */
/* Три точки вместо ряда кнопок: «Сохранить» и «Удалить» в каждой строке
   притягивают взгляд к тому, что делают раз в полгода, а «Удалить» рядом с
   курсором — это удаление по неосторожности. */
.rowmenu { position: relative; display: inline-block; }
.rowmenu > summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  border: 1px solid transparent;
  user-select: none;
}
.rowmenu > summary::-webkit-details-marker { display: none; }
.rowmenu > summary:hover { background: var(--bg); color: var(--ink); }
.rowmenu[open] > summary { border-color: var(--line); background: var(--bg); }

.menu-list {
  position: absolute;
  right: 0;
  top: 36px;
  z-index: 20;
  min-width: 170px;
  background: var(--panel);
  border: 0;
  border-radius: var(--radius-small);
  box-shadow: 0 14px 34px rgba(20, 14, 8, .25), var(--shadow);
  padding: 6px;
  text-align: left;
}
.menu-list button, .menu-list a {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.menu-list button:hover, .menu-list a:hover { background: var(--bg); filter: none; text-decoration: none; }
.menu-list form { margin: 0; }

/* МЕНЮ СТРОКИ ВЫНЕСЕНО ИЗ-ПОД ОБРЕЗКИ. Панель скруглена и поэтому режет всё,
   что за неё вылезает (.panel overflow: hidden), а широкие таблицы вдобавок
   лежат в полосе прокрутки (.scroll-x). Меню в нижних строках упиралось в этот
   край: «Изменить» видно, «Спрятать» и «Удалить» — уже нет. Кнопки при этом
   есть и нажимаются, их просто не показывают, и понять это по экрану нельзя.
   Убрать обрезку у предков нельзя: она держит и скругление, и прокрутку.
   Поэтому меню становится fixed и уходит из любого обрезающего предка;
   координаты считает base.html по месту самой кнопки — заодно разворачивая
   меню вверх, когда снизу не помещается. */
.menu-list.floating { position: fixed; right: auto; top: auto; }

/* Пункт меню остаётся ПУНКТОМ, даже когда он опасный: красный только у
   текста. Без этой строки сюда протекал сплошной красный фон кнопки ниже —
   красным по красному, то есть надпись не читалась вовсе. */
.menu-list button.danger {
  background: transparent;
  color: var(--bad);
  border: 0;
}
.menu-list button.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }

/* Сплошная красная кнопка — только для подтверждения в окне, где она одна
   и по ней сознательно нажимают. */
button.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
button.danger:hover { filter: brightness(1.08); }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ карточки --- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--panel); border: 0; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 24px; font-weight: 640; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.card .value.good { color: var(--good); }
.card .value.bad { color: var(--bad); }

.panel { background: var(--panel); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.panel h2 { font-size: 14px; margin: 0; padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 620; }
.panel .body { padding: 14px 16px; }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

/* ------------------------------------------------------------ таблицы --- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 550; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; border-bottom: 1px solid var(--line); }
td { padding: 10px 16px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Сортировка по столбцу. Стрелка бледная, пока по столбцу не сортируют, —
   иначе шапка превращается в частокол значков. */
th.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable-th:hover { color: var(--ink); }
th.sortable-th::after {
  content: "↕";
  margin-left: 5px;
  opacity: .35;
  font-size: 11px;
}
th.sortable-th[data-order="asc"]::after { content: "↑"; opacity: 1; color: var(--accent); }
th.sortable-th[data-order="desc"]::after { content: "↓"; opacity: 1; color: var(--accent); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* Листалка под длинным списком. Номер страницы стоит МЕЖДУ кнопками: он
   отвечает на «где я», и искать его глазами в углу не должно быть нужно. */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ------------------------------------------------------------- значки --- */
.tag { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 20px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); box-shadow: inset 0 1px 2px rgba(42, 36, 25, .06); }
.tag.done { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.tag.cancelled { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.tag.debt { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

/* Состояние человека на сегодня. Цвет читается раньше слова: строку с
   прогулом видно, не вчитываясь в неё. */
.tag.state-working { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.tag.state-vacation { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.tag.state-sick { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.tag.state-unpaid { color: var(--muted); }
.tag.state-absence { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.tag.state-dismissed { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.tag.state-not_yet { color: var(--muted); }

/* -------------------------------------------------------------- формы --- */
form.range { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* Перечислять типы по одному нельзя: у <input> без атрибута type тип text,
   но селектор input[type=text] его НЕ ловит — и такое поле оставалось белым
   на тёмной теме, потому что браузер рисовал его своим цветом. Отсюда правило
   от обратного: оформляем всё, кроме тех типов, у которых своя внешность. */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]) {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  /* Поле ввода — вдавленное: в него кладут, и глубина это подсказывает. */
  background: var(--bg);
  box-shadow: var(--shadow-in);
  color: var(--ink);
  min-width: 0;
}
input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }

/* Календарь и стрелки числовых полей в тёмной теме рисуются браузером —
   без этого они остаются чёрными на чёрном и попросту не видны. */
:root[data-theme="dark"] input { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input { color-scheme: dark; } }

button, .button {
  font: inherit;
  font-weight: 550;
  padding: 9px 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  /* Кнопка выпуклая, нажатая — вдавленная: глина под пальцем. */
  box-shadow:
    0 5px 12px color-mix(in srgb, var(--accent) 35%, transparent),
    inset 0 2px 2px rgba(255, 255, 255, .30),
    inset 0 -3px 4px rgba(0, 0, 0, .18);
}
button:active, .button:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, .28),
    inset 0 -1px 2px rgba(255, 255, 255, .12);
}
button.ghost {
  background: var(--panel);
  color: var(--muted);
  border-color: transparent;
  box-shadow: var(--shadow);
}
button.ghost:hover { color: var(--ink); filter: none; }
button.ghost.danger { color: var(--bad); }
button:hover { filter: brightness(1.05); }

/* --------------------------------------------------------------- вход --- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-box { width: 100%; max-width: 360px; background: var(--panel); border: 0; border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 19px; margin-bottom: 4px; }
.login-box .page-sub { margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field input { width: 100%; }
.login-box button { width: 100%; margin-top: 6px; padding: 10px; }
.error { background: color-mix(in srgb, var(--bad) 12%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* Широкая таблица на телефоне не ломает страницу, а прокручивается сама.
   Владелец смотрит панель стоя в цеху: горизонтальная прокрутка ВСЕЙ страницы
   там означает, что первый столбец уезжает и строку не прочитать. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-x table { min-width: 720px; }

/* ------------------------------------------------ записка после формы --- */
/* Ответ на отправленную форму человек ищет наверху страницы. Показывается
   один раз и стирается — «Сохранено», висящее на следующей странице, читается
   как ответ на то, что на самом деле не сохранялось. */
.note {
  padding: 11px 16px;
  border-radius: var(--radius-small);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.note.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: color-mix(in srgb, var(--good) 10%, transparent); }
.note.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.note.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }

/* ------------------------------------------------------ подсказка --- */
/* ОБЪЯСНЕНИЕ ПОЯВЛЯЕТСЯ, КОГДА НА ПРЕДМЕТ СМОТРЯТ.

   Строчка под каждой карточкой и под каждой графой объясняет один раз, а
   занимает место всегда. Десяток таких строк — это уже не помощь: страница
   из пояснений читается тяжелее, чем страница из чисел, и глаз перестаёт
   отличать важное от подписи.
   Поэтому пояснение лежит в data-tip и показывается, если на предмете
   ЗАДЕРЖАЛИСЬ — две секунды. Задержка и есть смысл: мышь ездит по экрану
   сама по себе, и всплывающее мгновенно мельтешит хуже постоянной строки.
   Про ошибки ввода это правило не работает — их показывает .rule сразу и
   на месте: ошибку ищут не наведением.
   Курсор — единственный намёк, что подсказка есть. Он ничего не занимает и
   виден ровно тогда, когда человек уже навёл. */
[data-tip] { cursor: help; }
[data-tip] input, [data-tip] select, [data-tip] textarea { cursor: auto; }

/* fixed и в конце body: внутри панели подсказку срезало бы её скруглением —
   ровно то, из-за чего меню строк пришлось делать плавающим. */
.tip {
  position: fixed;
  z-index: 60;
  /* width: max-content — не украшение, а условие правильного места.
     У fixed-окошка с одним left ширину ограничивает остаток экрана справа:
     у правого края тот же текст переносится на строку больше и становится
     выше. Померив высоту в одном месте, а показав в другом, мы разворачивали
     подсказку вверх по устаревшему числу — и она накрывала собой предмет,
     который объясняет. С max-content ширина задана содержимым и от места не
     зависит, поэтому померенное и показанное — одно и то же. */
  width: max-content;
  max-width: 290px;
  padding: 9px 12px;
  border-radius: var(--radius-small);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(8, 10, 14, .3), var(--shadow);
  font-size: 12.5px;
  line-height: 1.45;
  opacity: 0;
  transition: opacity .12s ease;
  pointer-events: none;  /* иначе окошко ловит мышь и закрывает само себя */
}
.tip.on { opacity: 1; }

/* ------------------------------------------------------- поля и формы --- */
textarea, select {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: var(--bg);
  box-shadow: var(--shadow-in);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; }
select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
.field input:not([type=checkbox]) { width: 100%; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }

.req { color: var(--muted); font-weight: 400; font-size: 11px; text-transform: none; }
.value-line { font-size: 15px; }

/* Правило поля. Молчит, пока введено верное, и говорит, когда нет.
   Постоянная подсказка под каждой графой удлиняет страницу вдвое и всё равно
   не читается: её пробегают глазами один раз и больше не замечают. А вот
   красная строка ровно под тем полем, где ошиблись, — читается всегда.

   :user-invalid, а не :invalid: второе загорается ещё до того, как человек
   что-нибудь ввёл, и пустая форма встречала бы его красным. */
.field .rule { display: none; color: var(--bad); font-size: 12px; margin-top: 4px; }
.field:has(:user-invalid) .rule { display: block; }
.field :user-invalid { border-color: var(--bad); }

/* Выбор из двух-трёх значений: кнопки в ряд, а не выпадающий список. Список
   прячет варианты, которых всего три, — их проще увидеть, чем открыть. */
/* Дорожка переключателя вдавлена, выбранное — выпуклая «таблетка» в ней. */
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: var(--shadow-in);
}
.segmented label {
  margin: 0;
  padding: 7px 15px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 10px;
  white-space: nowrap;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:hover { color: var(--ink); }
.segmented label:has(input:checked) {
  background: var(--panel);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Отбор над таблицей. Отдельной полосой, а не внутри заголовка страницы:
   фильтров бывает четыре-пять, и в заголовке они его разламывают. */
.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--panel);
  border: 0;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.filters label { white-space: nowrap; }
.filters select, .filters input { width: auto; min-width: 130px; }
.filters .check { margin: 0 0 6px; }

/* ------------------------------------------------------------ период --- */
/* Две графы «с» и «по» — это две задачи вместо одной: человек думает не «с
   первого по шестнадцатое», а «за август» или «за последнюю неделю». Поэтому
   на их месте одна кнопка, а в ней два месяца сразу (границы периода почти
   всегда лежат в соседних) и готовые ответы справа.

   .period-plain — те самые две графы. Они остаются в разметке и остаются
   рабочими: скрипт лишь помечает их .replaced и прячет. Не сработал скрипт —
   человек видит обычные поля дат, а не пустое место. */
.period { position: relative; display: flex; gap: 10px; align-items: flex-end; }
.period-plain.replaced { display: none; }

.period-open { white-space: nowrap; }
.period-open::after { content: " ▾"; color: var(--muted); }

.calendar {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  grid-template-columns: auto auto;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(20, 14, 8, .28), var(--shadow);
  padding: 14px;
  gap: 0 14px;
}
.calendar[hidden] { display: none; }
/* Открытый у правого края уезжал бы за экран — тогда его прижимает правым
   краем к кнопке. Считает это скрипт, здесь только сам случай. */
.calendar.to-left { left: auto; right: 0; }

.calendar .months { display: flex; gap: 22px; }
.calendar .month { width: 224px; }
.calendar .month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 620;
  font-size: 14px;
  margin-bottom: 10px;
  min-height: 28px;
}
.calendar .month-head .name { flex: 1; text-align: center; }
.calendar .month-head .year { color: var(--muted); font-weight: 400; }
.calendar .step {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 8px;
  box-shadow: none;
}
.calendar .step:hover { background: var(--bg); color: var(--ink); filter: none; }

.calendar .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar .dow {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  padding-bottom: 4px;
}
.calendar .day {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 6px 0;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
}
.calendar .day:hover { background: var(--accent-soft); filter: none; }
/* Дни соседних месяцев показаны, а не вырезаны: край периода часто приходится
   ровно на них, и «первое» из следующего месяца проще нажать, чем листать. */
.calendar .day.other { color: var(--muted); opacity: .55; }
.calendar .day.today { font-weight: 700; text-decoration: underline; }
.calendar .day.in { background: var(--accent-soft); border-radius: 0; }
.calendar .day.edge {
  background: var(--accent);
  color: var(--panel);
  font-weight: 620;
  opacity: 1;
}
.calendar .day.edge.first { border-radius: 8px 0 0 8px; }
.calendar .day.edge.last { border-radius: 0 8px 8px 0; }
.calendar .day.edge.only { border-radius: 8px; }

.calendar .presets {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 1px solid var(--line);
  padding-left: 14px;
  min-width: 168px;
}
.calendar .presets button {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.calendar .presets button:hover { background: var(--bg); filter: none; }
.calendar .presets button.on { background: var(--accent); color: var(--panel); font-weight: 600; }

.calendar .apply { grid-column: 1; margin-top: 12px; }
.calendar .apply button { width: 100%; }
.calendar .apply button:disabled { opacity: .45; cursor: default; filter: none; }

/* На узком экране два месяца рядом не помещаются: остаётся один, а готовые
   периоды переезжают под него. */
@media (max-width: 760px) {
  .calendar { grid-template-columns: 1fr; }
  .calendar .months .month + .month { display: none; }
  .calendar .month { width: auto; min-width: 232px; }
  .calendar .presets {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px 0 0;
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* --------------------------------------------------------------- окна --- */
/* Смена пароля и почты живут в окне, а не в форме на странице: это редкие
   действия, и три поля под ними висели бы постоянно, удлиняя страницу ради
   того, что делают раз в год. */
dialog {
  border: 0;
  border-radius: 24px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 18px 50px rgba(20, 14, 8, .35), var(--shadow);
}
dialog::backdrop { background: rgba(8, 10, 14, .55); }
dialog .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
dialog .dialog-head h3 { margin: 0; font-size: 15px; font-weight: 620; }
dialog .dialog-body { padding: 16px; }
dialog .close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 6px;
}
dialog .close:hover { background: var(--bg); color: var(--ink); filter: none; }
dialog button[type=submit] { width: 100%; margin-top: 4px; }

.check { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; font-size: 14px; color: var(--ink); flex-wrap: wrap; }
.check input { margin: 0; }

/* Поле, которое появляется по галочке. Без :has() оно просто видно всегда —
   это хуже, но не сломано, и никакого сценария не закрывает. */
.reveals { margin-bottom: 12px; }
.reveals .reveal { display: none; padding-left: 22px; }
.reveals:has(input[type=checkbox]:checked) .reveal { display: block; }

tr.total td { border-top: 1px solid var(--line); }

/* ------------------------------------------------------------- табель --- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.legend b { display: inline-block; width: 18px; text-align: center; border-radius: 4px; margin-right: 4px; }

.timesheet th, .timesheet td { padding: 4px 3px; }
.timesheet th.day { text-align: center; font-size: 11px; padding: 6px 2px; }
.timesheet th.day span { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .6; }
.timesheet .weekend { background: color-mix(in srgb, var(--muted) 8%, transparent); }
.timesheet .sticky { position: sticky; left: 0; background: var(--panel); min-width: 190px; padding-left: 16px; z-index: 1; }
.timesheet .cell { text-align: center; }
.timesheet select.mark {
  width: 30px;
  padding: 3px 0;
  text-align: center;
  text-align-last: center;
  border-radius: 5px;
  font-size: 12px;
  appearance: none;
}
/* Клетка «сколько сделал» — только у сдельщиков, поэтому узкая и без подписи:
   подпись висела бы над каждым из тридцати одного дня. */
.timesheet input.qty {
  width: 30px;
  padding: 2px 0;
  margin-top: 2px;
  text-align: center;
  font-size: 11px;
  border-radius: 5px;
}
.timesheet .row-actions { white-space: nowrap; padding-right: 16px; }
a.button { display: inline-block; text-decoration: none; }
a.button.ghost-link {
  background: var(--panel);
  color: var(--muted);
  border: 0;
  box-shadow: var(--shadow);
}
a.button.ghost-link:hover { color: var(--ink); text-decoration: none; filter: none; }
.timesheet .row-actions button { padding: 5px 10px; font-size: 12px; }
.timesheet tbody tr:hover .sticky { background: var(--bg); }

/* Цвет отметки виден до того, как её прочитали: строка с прогулом должна
   бросаться в глаза, а не находиться перечитыванием букв. */
.mark-work { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--ink); }
.mark-off { background: transparent; color: var(--muted); }
.mark-vacation { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.mark-sick { background: color-mix(in srgb, var(--warn) 20%, transparent); }
.mark-unpaid { background: color-mix(in srgb, var(--muted) 22%, transparent); }
.mark-absence { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); }

/* ------------------------------------------------------------- деньги --- */
/* ВКЛАДКИ ОДНОГО ОКНА. Расход, доход и перевод — это одно и то же действие с
   разным знаком, и три кнопки на странице делали вид, что их три. Вкладки
   переключаются самой формой: <input type=radio> уже несёт kind, который
   уйдёт на сервер, поэтому переключатель и значение поля — одно и то же, и
   разойтись они не могут. */
.kinds { display: flex; gap: 6px; margin-bottom: 14px; }
.kinds input { position: absolute; opacity: 0; width: 0; height: 0; }
.kinds label {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.kinds input:checked + label {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.kinds input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Поля, которые относятся только к одной вкладке. Без :has() видны все —
   форма остаётся рабочей, просто длиннее. */
.moneyform [data-only] { display: none; }
.moneyform:has(.kinds input[value=expense]:checked) [data-only~=expense],
.moneyform:has(.kinds input[value=income]:checked) [data-only~=income],
.moneyform:has(.kinds input[value=transfer]:checked) [data-only~=transfer] {
  display: block;
}
@supports not selector(:has(*)) {
  .moneyform [data-only] { display: block; }
}

/* Подсказка про курс под полями обмена: считается на месте, пока вводят. */
.implied { font-size: 12px; color: var(--muted); margin: -6px 0 12px; min-height: 16px; }
.implied b { color: var(--ink); font-weight: 600; }

/* «Сколько пришло» нужно только при обмене: на вкладке перевода И когда счета
   в РАЗНЫХ валютах. Оба условия стоят в ОДНОМ правиле намеренно. Двумя —
   «вкладка показывает, скрипт прячет» — они спорят, и выигрывает не тот, кто
   прав, а тот, у кого селектор весомее; :has() весит столько же, сколько его
   аргумент, и правило вкладки молча перебивало правило валюты.
   Класс same-currency ставит скрипт; без скрипта его нет, условие :not()
   выполняется, и поле видно на всей вкладке перевода — правильная сторона
   поломки: лишнее поле хуже, чем невозможность записать обмен. */
.moneyform [data-exchange], .moneyform [data-implied] { display: none; }
.moneyform:has(.kinds input[value=transfer]:checked):not(.same-currency) [data-exchange],
.moneyform:has(.kinds input[value=transfer]:checked):not(.same-currency) [data-implied] {
  display: block;
}
@supports not selector(:has(*)) {
  .moneyform [data-exchange], .moneyform [data-implied] { display: block; }
}

/* ИТОГ ПО ВАЛЮТАМ. Крупно — по одному числу на валюту, потому что сумы и
   доллары не складываются. Пересчёт живёт строкой ниже и мельче: он оценка,
   верная до следующего изменения курса. */
.purses { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; }
.purses .purse { font-size: 20px; font-weight: 640; letter-spacing: -.02em; }
.purses .purse.second { font-size: 16px; color: var(--ink); }
.purses .join { color: var(--muted); font-size: 13px; }
.approx { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Строка журнала: дата печатается один раз на день, как в кассовой ленте. */
.daybreak td { padding-top: 14px; }
.daystamp { font-weight: 640; white-space: nowrap; }

@media (max-width: 720px) {
  .shell { flex-direction: column; gap: 0; }
  .sidebar {
    width: auto;
    flex: none;
    position: static;
    max-height: none;
    margin: 10px 10px 0;
  }
  .nav { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav span.off::after { display: none; }
  /* Дочерние уходят на свою строку: линия слева на узком экране только
     съедает ширину, а порядок «раздел, под ним его страницы» и так виден. */
  .subnav {
    flex-direction: row;
    flex-basis: 100%;
    flex-wrap: wrap;
    margin: 0 0 2px;
    padding: 0;
    border-left: 0;
  }
  .main { padding: 12px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .timesheet .sticky { min-width: 130px; padding-left: 8px; }
}
