/* Панель клининга. Один файл, без сборки. Светлый тёплый фон, один глубокий
   акцент — морская зелень. Manrope, крупные табличные цифры для денег. */

:root {
  --ground: #f4f3ef;
  --paper: #ffffff;
  --ink: #1b2a2a;
  --ink-2: #5f6e6c;
  --ink-3: #93a09d;
  --line: #e2dfd7;
  --line-soft: #eceae4;
  --accent: #0f7a6b;
  --accent-deep: #0b5f53;
  --accent-tint: #e3f0ec;
  --danger: #9b4038;
  --danger-tint: #f8e7e3;

  --status-new: #96610b;        --status-new-bg: #fbefd6;
  --status-confirmed: #0f7a6b;  --status-confirmed-bg: #e3f0ec;
  --status-reschedule: #4058a0; --status-reschedule-bg: #e7ecf9;
  --status-done: #3e5c55;       --status-done-bg: #e4ebe8;
  --status-declined: #9b4038;   --status-declined-bg: #f8e7e3;
  --status-cancelled: #6e6a62;  --status-cancelled-bg: #eeece6;

  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
  --radius-s: 6px;
  --space: 1rem;
  --width: 1100px;
}

*, *::before, *::after { box-sizing: border-box; }
/* Атрибут hidden должен побеждать любой display у класса — иначе скрытое поле формы остаётся flex-элементом. */
[hidden] { display: none !important; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 500 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 0.15em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-s); }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 800; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 0.5rem; }
p { margin: 0; }

/* Числа. Табличные цифры, чтобы суммы выравнивались колонкой. */
.num, input[type="number"], td.num, th.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
td.num, th.num { text-align: right; white-space: nowrap; }
td.num { font-size: 1.05rem; font-weight: 700; }

/* ── Шапка ─────────────────────────────────────────────────────────────── */

header.top {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: var(--width);
  margin: 0 auto;
  padding: 1.1rem var(--space) 0.9rem;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.05rem; color: var(--ink); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; color: var(--accent-deep); }
header.top nav { display: flex; gap: 1.25rem; margin-left: 0.5rem; }
header.top nav a {
  color: var(--ink-2);
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}
header.top nav a:hover { color: var(--ink); text-decoration: none; }
header.top nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
header.top form { margin-left: auto; }
header.top nav svg { display: none; }

/* Красная обводка: «Отмена» и «Удалить заказ» — чтобы рука не спутала с «Подтвердить». */
button.danger-outline { color: var(--danger); border-color: var(--danger); background: var(--paper); }
button.danger-outline:hover { background: var(--danger-tint); border-color: var(--danger); }

main {
  max-width: var(--width);
  margin: 0 auto;
  padding: 1.75rem var(--space) 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* ── Заголовок страницы ─────────────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
}
.page-head .muted { margin-top: 0.35rem; }
.back { display: inline-block; font-size: 0.875rem; color: var(--ink-2); margin-bottom: 0.5rem; }
.back:hover { color: var(--accent-deep); }

/* Перенос визита: свёрнутая деталь отдельной строкой на всю ширину шапки,
   разворачивается вручную или сама — если форма только что вернулась с ошибкой. */
.page-head > details.visit { flex: 1 1 100%; order: 3; margin-top: 0; }
.page-head details.visit summary, .page-head details.edit summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent-deep);
}
.page-head details.visit summary::-webkit-details-marker, .page-head details.edit summary::-webkit-details-marker { display: none; }
.page-head details.visit summary::marker, .page-head details.edit summary::marker { content: ""; }
.visit-form { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.6rem; }
.visit-form input[type="date"], .visit-form select { width: auto; }
.visit-form label.check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--ink-2); font-weight: 500; white-space: nowrap; }

.muted { color: var(--ink-2); }
.empty { color: var(--ink-2); padding: 1.25rem 0; }
.count, .day .c {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  height: 1.5em;
  padding: 0 0.5em;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Статусы: тонкие цветные метки ──────────────────────────────────────── */

.status {
  display: inline-block;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--ink-2);
  background: var(--line-soft);
}
h1 .status { font-size: 0.85rem; vertical-align: middle; }
.status-new        { color: var(--status-new);        background: var(--status-new-bg); }
.status-confirmed  { color: var(--status-confirmed);  background: var(--status-confirmed-bg); }
.status-reschedule { color: var(--status-reschedule); background: var(--status-reschedule-bg); }
.status-done       { color: var(--status-done);       background: var(--status-done-bg); }
.status-declined   { color: var(--status-declined);   background: var(--status-declined-bg); }
.status-cancelled  { color: var(--status-cancelled);  background: var(--status-cancelled-bg); }

.chip {
  display: inline-block;
  padding: 0.1em 0.55em;
  margin: 0 0.25rem 0.15rem 0;
  border-radius: 999px;
  background: var(--ground);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ── Сообщения ──────────────────────────────────────────────────────────── */

.flash, .error {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-s);
  font-weight: 600;
}
.flash { background: var(--accent-tint); color: var(--accent-deep); }
.error { background: var(--danger-tint); color: var(--danger); }
form .error { padding: 0.5rem 0.75rem; font-size: 0.9rem; }

/* ── Карточки и колонки ─────────────────────────────────────────────────── */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.card h2 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  align-items: start;  /* карточки разной высоты не тянутся друг за другом */
}
.card.wide { grid-column: 1 / -1; }
.columns.split { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); }

dl { margin: 0; display: grid; grid-template-columns: 6.5rem 1fr; gap: 0.5rem 1rem; }
dt { color: var(--ink-2); }
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ── Формы ──────────────────────────────────────────────────────────────── */

.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.stack label, .login label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-2);
  font-weight: 600;
}

input, select, textarea, button {
  font: inherit;
  color: inherit;
}
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
}
input:not([type="checkbox"]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
input::placeholder { color: var(--ink-3); }
textarea { resize: vertical; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); margin: 0; }

.filter select { width: auto; padding-right: 2rem; font-weight: 600; cursor: pointer; }

button {
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease;
}
button:hover { border-color: var(--ink-3); background: var(--ground); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
button.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
button.quiet:hover { color: var(--ink); background: var(--line-soft); }
.stack button, .crew button { align-self: flex-start; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.crew { display: flex; flex-direction: column; gap: 0.6rem; }
.crew-row {
  display: grid;
  grid-template-columns: auto 1fr 8.5rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.crew-row:last-of-type { border-bottom: 0; }
.crew-row input[type="number"] { padding: 0.4rem 0.6rem; text-align: right; }

/* ── Таблицы ────────────────────────────────────────────────────────────── */

section { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td { padding: 0.8rem 0.75rem; text-align: left; vertical-align: middle; border-top: 1px solid var(--line-soft); }
thead th {
  border-top: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--ground);
  white-space: nowrap;
}
tbody tr[data-href] { cursor: pointer; }
tbody tr:hover { background: #fbfaf7; }
tr.current td { background: var(--accent-tint); }
td a { font-weight: 700; }
.ellipsis { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* auto-layout позволяет min-content колонок раздвинуть таблицу шире 100% —
   при длинном «Когда» она вылезала за правый край страницы. Fixed-layout
   держит ширину строго в контейнере; узким колонкам хватает места на одну
   строку, «Услуга»/«Адрес» забирают остаток и переносятся. table-wrap —
   подстраховка на случай совсем патологической строки: скролл внутри
   секции, а не расширение страницы. */
.table-wrap { overflow-x: auto; }
table.orders { width: 100%; table-layout: fixed; }
table.orders td { overflow: hidden; }
table.orders th:nth-child(1), table.orders td:nth-child(1) { width: 4.5rem; white-space: nowrap; }
table.orders th:nth-child(2), table.orders td:nth-child(2) { width: 8.5rem; font-weight: 600; }
table.orders td:nth-child(2) .muted { font-weight: 400; font-size: 0.85rem; }
table.orders th:nth-child(3), table.orders td:nth-child(3) { width: 6rem; white-space: nowrap; text-overflow: ellipsis; }
table.orders th:nth-child(6), table.orders td:nth-child(6) { width: 6.5rem; }
table.orders th:nth-child(7), table.orders td:nth-child(7) { width: 9.5rem; }
table.orders td:nth-child(7) .range { display: inline-block; white-space: normal; line-height: 1.3; }
table.orders th:nth-child(8), table.orders td:nth-child(8) { width: 7.5rem; white-space: nowrap; }
td.service { overflow-wrap: anywhere; }
td.service .muted { display: block; font-size: 0.85rem; }
table.finance td.num { font-size: 1rem; }
table.finance th:first-child, table.finance td:first-child { white-space: nowrap; }
table.finance tfoot td, table.finance tr.total td { font-weight: 700; border-top: 2px solid var(--line); }

/* ── Плитки сводки ──────────────────────────────────────────────────────── */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.tile .label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.tile strong, .tile .num { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.tile.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.tile.accent .label { color: rgba(255, 255, 255, 0.8); }
/* Месяц в минусе: плитка «Итог» целиком красная — видно с телефона без чтения цифр; в таблице месяцев — только число. */
.tile.accent.loss { background: var(--danger); border-color: var(--danger); }
td.num.loss { color: var(--danger); font-weight: 700; }

/* Команда: карточка на человека — имя и телефон, чипы специализации,
   внизу «Отпуск» и «Снять». Цвет человека — полоска слева, как в календаре. */
.stack-cards { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.people { display: flex; flex-direction: column; gap: 0.75rem; }
.person {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.85rem 1rem 0.8rem;
  background: var(--ground);
  border: 1px solid var(--line);
  border-left: 4px solid var(--who, var(--ink-3));
  border-radius: var(--radius-s);
}
.person.paused { border-left-color: var(--line); opacity: 0.85; }
.person > header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.25rem 0.75rem; }
.person > header .dot { align-self: center; }
.person .name { font-weight: 700; font-size: 1.05rem; }
.person .tel { font-variant-numeric: tabular-nums; }
.person .specialty { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.person .specialty .chip-toggle { background: var(--paper); }
/* Две кнопки в ряд одной ширины: слева обратимое («Отпуск» / «Вернуть в работу»),
   справа необратимое «Снять» с красной обводкой — как «Удалить заказ». */
.person-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; padding-top: 0.7rem; border-top: 1px solid var(--line-soft); }
.person-actions form { display: contents; }
.person-actions button { min-height: 40px; padding: 0.4rem 0.75rem; font-weight: 700; }
.person-actions button:not(.primary):not(.danger-outline) { border-color: var(--ink-3); }
.person-actions button:not(.primary):not(.danger-outline):hover { border-color: var(--ink-2); }

/* Окно подтверждения: заголовок-вопрос, пояснение, что произойдёт, «Отмена» и действие.
   Класс danger на <dialog> красит кнопку действия в красный. */
dialog.confirm {
  width: min(420px, calc(100vw - 2rem));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 60px -20px rgba(27, 42, 42, 0.5);
}
dialog.confirm::backdrop { background: rgba(27, 42, 42, 0.38); }
dialog.confirm form { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.25rem 1.25rem 1.1rem; }
dialog.confirm h2 { font-size: 1.15rem; line-height: 1.3; }
dialog.confirm p { color: var(--ink-2); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.6rem; }
.confirm-actions button { min-height: 44px; padding: 0 1.1rem; font-weight: 700; }
.confirm-actions [data-ok] { background: var(--accent); border-color: var(--accent); color: #fff; }
.confirm-actions [data-ok]:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
dialog.confirm.danger [data-ok] { background: var(--danger); border-color: var(--danger); }
dialog.confirm.danger [data-ok]:hover { background: #7f342d; border-color: #7f342d; }

.chip-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.1em 0.7em;
  border-radius: 999px;
  background: var(--ground);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}
.chip-toggle input {
  position: absolute;
  opacity: 0;
}
.chip-toggle:has(input:checked) {
  background: var(--accent-tint);
  color: var(--accent-deep);
  border-color: var(--accent);
}
.chip-toggle:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Планировка ─────────────────────────────────────────────────────────── */
/* Единственное место в панели с цветом: у каждого человека свой оттенок
   (--who), он повторяется на плитке зоны, в чипе бригады и в меню выбора.
   Свободная зона — янтарная, как заявка «ждёт решения». */

.dot {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--who, var(--ink-3));
  margin-right: 0.4em;
  vertical-align: 0.05em;
}
.crew-row.muted .dot { opacity: 0.4; }

.plan > .muted { margin-top: -0.5rem; }
.tiles-plan {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-flow: row dense;   /* меню занимает всю строку под тапнутой плиткой, остальные не прыгают */
  gap: 0.6rem;
}
.tile-zone {
  position: relative;
  overflow: hidden;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem 0.7rem 1rem;
  text-align: left;
  white-space: normal;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.tile-zone:hover { background: var(--paper); border-color: var(--ink-3); }
.tile-zone:focus-visible,
.tile-zone:has(+ .zone-menu) {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.tile-zone.free, .tile-zone.free:hover { background: var(--status-new-bg); border-style: dashed; }
.zone-name { font-weight: 700; font-size: 0.95rem; line-height: 1.25; }
.zone-who {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
  max-width: 100%;
}
.zone-who::before {
  content: "";
  flex: none;
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--who, transparent);
  border: 1.5px solid var(--who, currentColor);
}
/* Цветная полоса у левого края плитки. Переменная --who живёт на чипе,
   поэтому полосу рисует его псевдоэлемент, а плитка даёт ему позицию. */
.zone-who::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--who, transparent);
}
.tile-zone.free .zone-who { color: var(--status-new); }

.zone-menu {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: menu-in 120ms ease-out;
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
}
.zone-menu button {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: var(--paper);
}
.zone-menu button:hover { border-color: var(--who, var(--ink-3)); background: var(--paper); }
.zone-menu button.fit { background: var(--accent-tint); border-color: transparent; }
.zone-menu button.fit:hover { border-color: var(--accent); }
.zone-menu button.danger { color: var(--danger); margin-left: auto; }
.zone-menu button.danger:hover { border-color: var(--danger); background: var(--danger-tint); }

.plan-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.plan-actions .primary { margin-left: auto; }
.quiet-select {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.quiet-select select { width: auto; padding-right: 2rem; font-weight: 600; cursor: pointer; }

/* ── График: месяц сеткой, день — карточками ────────────────────────────── */
/* Цвет здесь только у людей: точки под числом — кто работает в этот день.
   Выходные — на тоне подложки, как в бумажном календаре; сегодня — число
   в кольце акцента; выбранный день — залит акцентной подложкой. */

.month-nav { display: inline-flex; align-items: center; gap: 0.5rem; }
.month-nav strong { min-width: 9.5rem; text-align: center; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.month-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink-2);
  font-weight: 700;
}
.month-nav a:hover { text-decoration: none; color: var(--ink); border-color: var(--ink-3); }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.dow {
  padding: 0 0.5rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.day {
  position: relative;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem 0.45rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--ink);
  transition: border-color 120ms ease, background-color 120ms ease;
}
.day:hover { text-decoration: none; color: var(--ink); border-color: var(--ink-3); }
.day.empty { background: transparent; border-color: transparent; padding: 0; }
/* Шесть и семь в каждой семёрке — суббота и воскресенье; ряд подписей
   занимает ровно семь ячеек, поэтому счёт совпадает с колонками. */
.calendar > :nth-child(7n+6), .calendar > :nth-child(7n) { background: var(--ground); }
.calendar > .dow:nth-child(7n+6), .calendar > .dow:nth-child(7n) { background: transparent; color: var(--ink-3); }
.day .n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7em;
  height: 1.7em;
  margin-left: -0.25em;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.day.busy .n { font-weight: 800; color: var(--ink); }
.day.today .n { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent-deep); }
.day.current { background: var(--accent-tint); border-color: var(--accent); }
.day.current:hover { border-color: var(--accent-deep); }
.day .c { position: absolute; top: 0.4rem; right: 0.4rem; }
.day .dots { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 3px; min-height: 7px; }
.day .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--who, var(--ink-3)); }
.day .dots b { font-size: 0.65rem; font-weight: 700; color: var(--ink-2); line-height: 1; }

.day-list { display: flex; flex-direction: column; gap: 0.6rem; }
.day-order { gap: 0.3rem; padding: 0.9rem 1.1rem 1rem; color: var(--ink); transition: border-color 120ms ease; }
.day-order:hover { text-decoration: none; color: var(--ink); border-color: var(--ink-3); }
.day-order .row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.75rem; }
.day-order .row strong { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.day-order .row .status { margin-left: auto; }
.day-order .muted { font-size: 0.9rem; }
.day-order .crew-line { margin-top: 0.3rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.day-order .crew-line .chip { margin: 0; background: var(--paper); }

/* ── Заявка клиента: что он просил, его фото, протокол — свёрнут ────────── */

.request dl { max-width: 70ch; }
.request .wish { white-space: pre-line; }
.request h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.photos { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.photos a { display: block; line-height: 0; border-radius: var(--radius-s); }
.photos img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--ground);
}
.photos a:hover img { border-color: var(--ink-3); }
.protocol-details { margin-top: 1.25rem; }
.protocol-details summary {
  cursor: pointer;
  color: var(--ink-2);
  font-size: 0.9rem;
  user-select: none;
}
.protocol-details summary:hover { color: var(--ink); }
.protocol-details[open] summary { margin-bottom: 0.75rem; }

/* ── Протокол: документ, который видел клиент ───────────────────────────── */

.protocol-text {
  white-space: pre-line;
  max-width: 70ch;
  padding: 1.25rem 1.5rem;
  border-left: 3px solid var(--accent);
  background: var(--ground);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.protocol-text b { font-weight: 700; color: var(--ink); }
.protocol-text i { color: var(--ink-2); }

/* ── Клиенты: список карточек-ссылок ─────────────────────────────────────── */

.page-head .search { width: 20rem; max-width: 100%; }
.page-head .search input { margin: 0; }

.client-list { display: flex; flex-direction: column; gap: 0.6rem; }
.client-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink);
  transition: border-color 120ms ease;
}
.client-row:hover { text-decoration: none; color: var(--ink); border-color: var(--ink-3); }
.client-row .who { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.client-row .who strong { font-size: 1.05rem; }
.client-row .stats { flex-shrink: 0; font-size: 0.9rem; text-align: right; }

/* ── Вход ───────────────────────────────────────────────────────────────── */

.login {
  max-width: 22rem;
  margin: 12vh auto 0;
  padding: 2rem 2rem 2.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.login h1 { font-size: 1.5rem; }
.login .muted { margin-top: -0.75rem; }
.login form { display: flex; flex-direction: column; gap: 0.9rem; }

/* ── Главная: сегодня целиком, остальное сбоку ─────────────────────────── */

.home { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 1.5rem; align-items: start; }
.home-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.home-main h1 .muted { font-weight: 600; font-size: 1rem; }
.home-main h2 { margin-top: 0.5rem; }
.home-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.home-side .card { gap: 0.75rem; padding: 1rem 1.1rem 1.1rem; }

.today-order { gap: 0.35rem; padding: 1rem 1.1rem 1.05rem; border-left: 4px solid var(--accent); }
.today-order .row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.75rem; }
.today-order .time { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.today-order .row .status { margin-left: auto; }
.today-order .who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.9rem; }
.today-order .name { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.today-order .tel { font-variant-numeric: tabular-nums; }
.today-order .addr { overflow-wrap: anywhere; }
.today-order .crew-line { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.2rem; }
.today-order .crew-line .chip { margin: 0; background: var(--paper); }
.today-order .note { padding: 0.5rem 0.75rem; background: var(--ground); border-radius: var(--radius-s); font-size: 0.9rem; }
.today-order .quick { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.quiet-link { font-size: 0.9rem; color: var(--ink-2); }
.today-order .quick .quiet-link { margin-left: auto; }

.brief-list { display: flex; flex-direction: column; }
.brief {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "when who sum" "where where sum";
  column-gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line-soft);
  color: var(--ink);
  line-height: 1.35;
}
.brief:first-child { border-top: 0; padding-top: 0; }
.brief:hover { text-decoration: none; color: var(--accent-deep); }
.brief-when { grid-area: when; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.brief-who { grid-area: who; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brief-where { grid-area: where; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brief-sum, .brief-crew { grid-area: sum; align-self: center; white-space: nowrap; font-weight: 700; }
.brief-crew .dot { margin: 0 0.15rem 0 0; width: 0.7em; height: 0.7em; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week-day {
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  min-height: 52px; padding: 0.4rem 0.2rem;
  background: var(--ground); border: 1px solid var(--line); border-radius: var(--radius-s);
  color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.week-day:hover { text-decoration: none; border-color: var(--ink-3); }
.week-day.busy { background: var(--paper); color: var(--ink); font-weight: 700; }
.week-day.today .n { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 50%; padding: 0 0.2em; }
.week-day.weekend:not(.busy) { opacity: 0.7; }
.week-day .c { font-size: 0.72rem; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 0.45em; line-height: 1.4; }

.tiles.mini { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.tiles.mini .tile { padding: 0.75rem 0.85rem; color: inherit; }
.tiles.mini .tile strong { font-size: 1.15rem; }
.tiles.mini a.tile:hover { text-decoration: none; border-color: var(--ink-3); }

/* ── Финансы: счёт месяца, журнал, сводка ───────────────────────────────── */
/* Устройство как у приложения учёта: сверху «счёт» (одна карта с итогом и
   полосой доходы/расходы), под ним журнал строками — цветная метка
   категории, название, сумма у правого края; сводка — вторая колонка на ПК
   и второй экран на телефоне. Запись — шторка поверх страницы, сумма первой. */

:root {
  --cat-order: #0f7a6b;
  --cat-other_income: #4a9c8c;
  /* Пять цветов расходов проверены валидатором dataviz: соседи на кольце
     (порядок LEDGER_CATEGORIES + замыкание) различимы при дальтонизме, все ≥ 3:1 на бумаге. */
  --cat-supplies: #b9831a;
  --cat-fuel: #3a5fd0;
  --cat-salary: #7d4fb0;
  --cat-rent: #c25a3a;
  --cat-other: #2b8fb0;
}
.cat-order { --cat: var(--cat-order); }
.cat-other_income { --cat: var(--cat-other_income); }
.cat-supplies { --cat: var(--cat-supplies); }
.cat-fuel { --cat: var(--cat-fuel); }
.cat-salary { --cat: var(--cat-salary); }
.cat-rent { --cat: var(--cat-rent); }
.cat-other { --cat: var(--cat-other); }
i.cat { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--cat, var(--ink-3)); flex: none; }

.month-nav .off {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--line);
  font-weight: 700;
}
.fin-head { align-items: center; }
.fin-head h1 { margin-right: auto; }

/* Раскладка: на ПК журнал слева, счёт и сводка справа; переключатель не нужен. */
.fin-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  grid-template-areas: "journal account" "journal summary";
  grid-template-rows: auto 1fr;
  align-items: start;
  gap: 1.25rem 1.75rem;
}
.fin-page .account { grid-area: account; }
.fin-page .fin-switch { display: none; }
.fin-page .fin-journal { grid-area: journal; min-width: 0; }
.fin-page .fin-summary { grid-area: summary; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.fin-summary table.finance .optional { display: none; }  /* узкая колонка: расходы видны в счёте */

/* Счёт месяца. Минус — вся карта кирпичная. */
.account {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.15rem 1.3rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: 0 10px 24px -18px rgba(11, 95, 83, 0.7);
}
.account.loss { background: var(--danger); box-shadow: 0 10px 24px -18px rgba(155, 64, 56, 0.7); }
.account .label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.8; }
.account .balance { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.account .flows { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.5rem; font-size: 0.85rem; opacity: 0.92; }
.account .flows b { font-weight: 700; margin-left: 0.15rem; }
.account .flows i { font-style: normal; font-size: 0.65rem; opacity: 0.8; }
.account .split { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); overflow: hidden; margin-top: 0.2rem; }
.account .split i { display: block; height: 100%; background: #fff; border-radius: 3px; }

/* Фильтр журнала. */
.filters { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.filters .filter { padding: 0.3rem 0.85rem; border-radius: 999px; font-weight: 600; color: var(--ink-2); background: transparent; border-color: transparent; }
.filters .filter:hover { background: var(--line-soft); color: var(--ink); }
.filters .filter[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* День журнала: заголовок с итогом дня, ниже — строки. (.day занят календарём.) */
.jday { margin-bottom: 0.9rem; }
.day-orders, #day-empty { scroll-margin-top: 4.5rem; }  /* липкая шапка на телефоне не накроет заголовок дня */
.jday > header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 0.35rem 0.25rem; }
.jday > header h3 { margin: 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.day-net { font-size: 0.8rem; font-weight: 700; color: var(--accent-deep); }
.day-net.neg { color: var(--ink-2); }
.jrows { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.jrow {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--line-soft);
}
.jrow:first-child { border-top: 0; }
.jrow:hover { background: var(--ground); }
.jrow:first-child:hover { border-radius: var(--radius) var(--radius) 0 0; }
.jrow:last-child:hover { border-radius: 0 0 var(--radius) var(--radius); }
.jrow:only-child:hover { border-radius: var(--radius); }
.jrow-link { position: absolute; inset: 0; border-radius: inherit; }
.jrow-link:focus-visible { outline-offset: -2px; }
.jrow .what { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.jrow .title { font-weight: 700; }
.jrow .detail { color: var(--ink-2); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jrow .detail:empty { display: none; }
.jrow .sum { font-weight: 700; white-space: nowrap; font-size: 1rem; }
.jrow.inc .sum { color: var(--accent-deep); }
.jrow.exp .sum { color: var(--ink); }

/* Шторка записи: summary — кнопка в шапке; тело — панель поверх страницы. */
.sheet { display: contents; }
.sheet > summary { list-style: none; cursor: pointer; }
.sheet > summary::-webkit-details-marker { display: none; }
.sheet > summary::marker { content: ""; }
.sheet-open {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 40px;
  padding: 0 1rem 0 0.8rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-s);
  font-weight: 700;
}
.sheet-open:hover { background: var(--accent-deep); }
.sheet-open .plus { font-size: 1.3rem; line-height: 1; font-weight: 600; }
.sheet[open]::before { content: ""; position: fixed; inset: 0; background: rgba(27, 42, 42, 0.38); z-index: 40; }
.sheet-body {
  position: fixed;
  z-index: 41;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgba(27, 42, 42, 0.5);
}
.entry-form { display: flex; flex-direction: column; gap: 1rem; padding: 1rem 1.25rem 1.25rem; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 1.05rem; }
.sheet-close { width: 36px; height: 36px; padding: 0; font-size: 1rem; border-radius: 50%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Сумма — первое и самое крупное поле. */
.amount-field { position: relative; display: block; }
.amount-field input {
  width: 100%;
  padding: 0.55rem 2.9rem 0.55rem 0.9rem;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.amount-field input::-webkit-outer-spin-button, .amount-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-field .unit { position: absolute; right: 0.9rem; top: 50%; transform: translateY(-50%); font-size: 1.3rem; font-weight: 700; color: var(--ink-3); }

.kind-switch { display: flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.kind-switch label { position: relative; cursor: pointer; flex: 1; }
.kind-switch input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.kind-switch span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--paper);
}
.kind-switch label + label span { border-left: 1px solid var(--line); }
.kind-switch input:checked + span { background: var(--accent-tint); color: var(--accent-deep); }
.kind-switch input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--accent); }

.chips { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips legend { padding: 0; margin-bottom: 0.4rem; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); width: 100%; }
.chips .chip-toggle { min-height: 38px; padding: 0.3rem 0.8rem; gap: 0.4rem; }
.cat-chips .chip-toggle:has(input:checked) { background: color-mix(in srgb, var(--cat) 14%, white); color: var(--ink); border-color: var(--cat); }
.staff-chips .chip-toggle:has(input:checked) { background: var(--accent-tint); color: var(--accent-deep); border-color: var(--accent); }

.small-fields { display: grid; grid-template-columns: 1fr 1.4fr; gap: 0.75rem; }
.small-fields label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
.sheet-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.25rem; }
.sheet-actions .primary { flex: 1; min-height: 44px; font-size: 1rem; }
.sheet-actions .danger:hover { background: var(--danger-tint); }

/* Кольцо расходов: дуги — окружности со штрихом, поворот на −90° ставит начало на 12 часов.
   В центре — сумма расходов месяца. Зазор между дугами задан в шаблоне (1.2% длины). */
.donut { position: relative; width: 168px; margin: 0.25rem auto 0.5rem; }
.donut svg { display: block; width: 100%; height: auto; transform: rotate(-90deg); }
.donut .track { fill: none; stroke: var(--line-soft); stroke-width: 12; }
.donut .arc { fill: none; stroke: var(--cat, var(--ink-3)); stroke-width: 12; transition: stroke-width 120ms ease; cursor: default; }
.donut .arc:hover { stroke-width: 15; }
.donut figcaption {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  pointer-events: none;
}
.donut .label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.donut strong { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; }
ul.shares .pct { font-style: normal; font-size: 0.8rem; color: var(--ink-3); margin-left: 0.15rem; }

/* Доли расходов: тонкая полоса под строкой, длина — доля категории в месяце. */
ul.shares { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
ul.shares li { position: relative; display: flex; justify-content: space-between; gap: 1rem; padding-bottom: 0.45rem; }
ul.shares li > span:first-child { display: inline-flex; align-items: center; gap: 0.5rem; }
ul.shares li .num { font-weight: 700; }
ul.shares li::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line-soft); border-radius: 2px; }
ul.shares li::after { content: ""; position: absolute; left: 0; bottom: 0; width: var(--share, 0%); height: 3px; background: var(--cat, var(--accent)); border-radius: 2px; }

/* ── Раздел «Заказы»: переключатель вида и вкладки списка ───────────────── */

.segments, .tabs { display: inline-flex; gap: 0; }
.segments {
  margin-top: 0.5rem;
  padding: 3px;
  background: var(--line-soft);
  border-radius: var(--radius-s);
}
.segments a {
  padding: 0.35rem 0.9rem;
  border-radius: calc(var(--radius-s) - 2px);
  color: var(--ink-2);
  font-weight: 600;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.segments a:hover { text-decoration: none; color: var(--ink); }
.segments a[aria-current="page"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(27, 42, 42, 0.08); }

.tabs-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.tabs { gap: 1.25rem; border-bottom: 1px solid var(--line); flex: 1 1 auto; }
.tabs a {
  padding: 0.55rem 0;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count.muted-count { background: var(--ink-3); }

/* Правка заявки и удаление на карточке */
.page-head > details.edit { flex: 1 1 100%; order: 4; }
.edit-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; margin-top: 0.75rem; padding: 1rem 1.1rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.edit-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-2); font-weight: 600; }
.edit-form label.wide { grid-column: 1 / -1; }
.edit-form button { justify-self: start; grid-column: 1 / -1; }
.danger-zone { display: flex; justify-content: flex-end; padding-top: 0.5rem; }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-tint); }


/* Ссылка в виде кнопки — для быстрых действий на главной */
.button-link {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--paper); color: var(--ink); font-weight: 600; white-space: nowrap;
}
.button-link:hover { text-decoration: none; border-color: var(--ink-3); background: var(--ground); }
.button-link.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-link.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }


/* ── Бригада чипами, форма закрытия, подсказки, справка ─────────────────── */

.crew-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.crew-chips .chip-toggle { min-height: 36px; padding: 0.3rem 0.8rem; }
.crew-chips .chip-toggle.inactive { opacity: 0.6; }
.crew-chips .chip-toggle .dot { margin-right: 0.35rem; }
.crew-chips .chip-toggle:has(input:checked) { background: var(--accent-tint); color: var(--accent-deep); border-color: var(--accent); }
.crew-card .tiles-plan { margin-top: 0.25rem; }

.page-head > details.close { flex: 1 1 100%; order: 3; }
.request details.edit summary { cursor: pointer; list-style: none; font-size: 0.875rem; font-weight: 600; color: var(--accent-deep); }
.request details.edit summary::-webkit-details-marker { display: none; }
.request details.edit summary::marker { content: ""; }
.request details.edit { margin-top: 0.25rem; }
.request .danger-zone { justify-content: flex-start; padding-top: 0.25rem; }
.page-head details.close summary { cursor: pointer; list-style: none; font-size: 0.875rem; font-weight: 600; color: var(--accent-deep); }
.page-head details.close summary::-webkit-details-marker { display: none; }
.page-head details.close summary::marker { content: ""; }
.close-form { margin-top: 0.6rem; padding: 1rem 1.1rem; background: var(--paper); border: 1px solid var(--accent); border-radius: var(--radius); display: flex; flex-direction: column; gap: 0.75rem; }
.close-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.close-grid label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-2); font-weight: 600; }
.close-grid label.wide { grid-column: 1 / -1; }
.close-form button { align-self: flex-start; }

.warnings { list-style: none; margin: 0; padding: 0.6rem 0.9rem; background: var(--status-new-bg); border-radius: var(--radius-s); display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.92rem; color: var(--status-new); }
.warnings a { color: var(--ink); font-weight: 600; }

.help-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin-left: auto; margin-right: 0.5rem;
  border: 1px solid var(--line); border-radius: 50%;
  color: var(--ink-2); font-weight: 700;
}
.help-link:hover { text-decoration: none; color: var(--ink); border-color: var(--ink-3); }
header.top .help-link + form { margin-left: 0; }

.steps { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: 1rem; counter-reset: step; max-width: 62ch; }
.steps li { padding-left: 0.4rem; }
.steps li::marker { font-weight: 800; color: var(--accent); }
.steps h2 { font-size: 1.05rem; margin-bottom: 0.25rem; }
.steps p { color: var(--ink); }
.tips { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; }


/* «+ Заказ» и форма ручного заказа */
.add-order { white-space: nowrap; }
.home-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.head-side { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.new-order { max-width: 760px; gap: 1.25rem; }
.new-order h2 { margin-top: 0.25rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.form-grid label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-2); font-weight: 600; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid label.check { flex-direction: row; align-items: center; gap: 0.5rem; color: var(--ink); font-weight: 500; }
.new-order > button { align-self: flex-start; }

/* ── Рамки и клики: карточка заказа читается блоками, а не сплошным текстом ─ */
/* Заголовок карточки подчёркнут, факты — линованные строки, вложенные части
   (пожелания, фото, планировка) — в собственной рамке на сером. Адрес —
   кнопка: тап копирует. Карточка на Главной кликается целиком. */

html { scroll-behavior: smooth; }

.card > h2 { padding-bottom: 0.55rem; border-bottom: 1px solid var(--line-soft); }

dl.facts { gap: 0; }
dl.facts dt, dl.facts dd { padding: 0.55rem 0; border-top: 1px solid var(--line-soft); }
dl.facts dt:first-of-type, dl.facts dd:first-of-type { border-top: 0; }
dl.facts dt { padding-right: 0.5rem; }

.subcard {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem 1rem 1rem;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
.subcard h3 { margin: 0; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.subcard .wish { margin: 0; white-space: pre-line; }
.subcard .photos img { background: var(--paper); }
.subcard .tiles-plan { margin-top: 0; }

/* Адрес копируется тапом: выглядит текстом, реагирует как кнопка. */
button.copy {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.4rem 0.15rem 0;
  margin: -0.15rem 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  min-height: 0;
  overflow-wrap: anywhere;
  border-radius: var(--radius-s);
}
button.copy i { font-style: normal; color: var(--ink-3); font-size: 0.95em; flex: none; }
button.copy:hover { background: var(--accent-tint); color: var(--accent-deep); }
button.copy:hover i { color: var(--accent-deep); }
button.copy.copied i { color: var(--accent); }
button.copy.copied::after { content: "скопировано"; font-size: 0.8rem; color: var(--accent-deep); font-weight: 600; }

/* Формы переноса и закрытия открываются кнопками в шапке — их summary не показываем. */
.page-head details.visit > summary, .page-head details.close > summary { display: none; }

/* Карточка на Главной — одна большая ссылка; кнопки и телефон живут над ней. */
.today-order { position: relative; }
.today-order .card-link { position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
.today-order .card-link:focus-visible { outline-offset: -2px; }
.today-order .who, .today-order .addr, .today-order .quick, .today-order .crew-line { position: relative; z-index: 1; }
.today-order .who { pointer-events: none; }
.today-order .who a { pointer-events: auto; }
.today-order .addr { pointer-events: none; }
.today-order .addr button { pointer-events: auto; }
.today-order .crew-line { pointer-events: none; }
.today-order:hover { border-color: var(--ink-3); }
.today-order:has(.card-link:hover) .name { color: var(--accent-deep); }

/* Удаление — в самом низу страницы, отдельно от всего. */
.danger-zone.order-delete {
  justify-content: flex-start;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  padding: 0.9rem 1.1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* Фото клиента: сетка с удалением на каждом, загрузка — одной кнопкой. */
.photos .photo { position: relative; margin: 0; }
.photo-delete {
  position: absolute; top: -6px; right: -6px;
  width: 24px; height: 24px; padding: 0;
  border-radius: 50%;
  font-size: 0.75rem; line-height: 1;
  background: var(--paper); color: var(--ink-2);
  box-shadow: 0 1px 3px rgba(27, 42, 42, 0.25);
}
.photo-delete:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-tint); }
.upload { display: flex; align-items: center; gap: 0.75rem; }
.upload-button { position: relative; overflow: hidden; cursor: pointer; }
.upload-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }


/* ── Установка на телефон и строка «Календарь | Список  + Заказ» ─────────── */
.seg-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.5rem; }
.seg-row .segments { margin-top: 0; }
.install p { margin: 0; }
.install-pick { display: flex; gap: 0.6rem; }
.install-choice {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 52px; font-size: 1rem; font-weight: 700;
}
.install-choice svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.install-choice[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent-deep); border-color: var(--accent); }
.install-how, .install-tg { display: flex; flex-direction: column; gap: 0.75rem; padding: 1rem 1.1rem; background: var(--ground); border: 1px solid var(--line); border-radius: var(--radius-s); }
.install-go { min-height: 48px; font-size: 1rem; align-self: flex-start; }
.install-steps { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.45rem; }
.install-steps li::marker { font-weight: 800; color: var(--accent); }
.install-done { margin: 0; }

/* ── Телефон: одна колонка, таблица складывается в карточки ─────────────── */

@media (max-width: 720px) {
  /* Шапка липнет к верху и остаётся компактной: на телефоне навигация — это
     единственный способ перейти между пятью страницами. Пять пунктов влезают
     в 390px мельче обычного; на совсем узком экране полоса листается внутри
     себя, страница вбок не едет. */
  header.top {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
    gap: 0 1rem;
    padding: 0.55rem var(--space) 0;
    background: var(--ground);
  }
  /* Разделы — полоса иконок внизу экрана, под большим пальцем; шапка остаётся
     только с именем, «?» и выходом. */
  header.top { padding-bottom: 0.55rem; }
  header.top nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    display: flex;
    margin: 0;
    gap: 0;
    padding: 0.3rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px -12px rgba(27, 42, 42, 0.35);
  }
  header.top nav a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-s);
    color: var(--ink-3);
  }
  header.top nav a svg { display: block; width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  header.top nav a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  header.top nav a[aria-current="page"] { color: var(--accent-deep); background: var(--accent-tint); }
  header.top form button { min-height: 44px; }

  main { padding: 1rem var(--space) calc(4.5rem + env(safe-area-inset-bottom)); gap: 1.25rem; }
  h1 { font-size: 1.45rem; }
  .card { padding: 1.1rem 1.1rem 1.25rem; }
  dl { grid-template-columns: 1fr; gap: 0.15rem; }
  dt { font-size: 0.8rem; }
  dd + dt { margin-top: 0.6rem; }
  /* Фото на телефоне — сетка по три, квадратами во всю ширину карточки. */
  .photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
  .photos a { width: 100%; }
  .photos img { width: 100%; height: auto; aspect-ratio: 1; }
  /* История заказов клиента — карточками: № · дата · сумма, услуга, статус. */
  table.history, table.history tbody { display: block; background: none; border: 0; }
  table.history thead { display: none; }
  table.history tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.2rem 0.6rem;
    align-items: center;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.5rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  table.history td { display: block; padding: 0; border: 0; white-space: normal; }
  table.history td:nth-child(1) { grid-column: 1; grid-row: 1; }
  table.history td:nth-child(2) { grid-column: 2; grid-row: 1; color: var(--ink-2); font-size: 0.9rem; }
  table.history td:nth-child(5) { grid-column: 3; grid-row: 1; text-align: right; }
  table.history td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; }
  table.history td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; }
  table.history td .range br { display: none; }
  .ellipsis { max-width: none; white-space: normal; }
  .columns.split { grid-template-columns: 1fr; }

  /* Пальцу нужно 44px; 16px в полях — иначе iPhone приближает страницу при фокусе. */
  input:not([type="checkbox"]), select, textarea { font-size: 16px; }
  button { min-height: 44px; }
  button.quiet { padding: 0.55rem 0.75rem; }
  .filter select { min-height: 44px; }
  .actions { flex-direction: column; width: 100%; }
  .actions button { width: 100%; }
  .page-head .actions { order: 2; }
  .visit-form { flex-direction: column; align-items: stretch; }
  .visit-form input[type="date"], .visit-form select { width: 100%; }
  .visit-form button { width: 100%; }
  .stack button, .crew button { align-self: stretch; }
  .crew-row { grid-template-columns: auto 1fr 6.5rem; min-height: 44px; }
  input[type="checkbox"] { width: 1.35rem; height: 1.35rem; }
  .person-actions button { min-height: 44px; }
  /* Окно подтверждения на телефоне — лист снизу, под большим пальцем */
  dialog.confirm { width: 100%; max-width: none; margin: auto 0 0; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom, 0); }
  .confirm-actions button { flex: 1; }
  .chip-toggle { min-height: 40px; }

  /* Сводка: четыре плитки — сеткой два на два, а не башней */
  .tiles { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .tile { padding: 0.85rem 0.9rem 0.9rem; }
  .tile strong, .tile .num { font-size: 1.25rem; }
  .tile .label { font-size: 0.7rem; }
  /* Планировка: плитки чуть уже, меню — столбик кнопок под палец */
  .tiles-plan { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.5rem; }
  .zone-menu { flex-direction: column; align-items: stretch; padding: 0.6rem; }
  .zone-menu button, .zone-menu button.danger { min-height: 44px; justify-content: flex-start; margin-left: 0; }
  .plan-actions { flex-direction: column; align-items: stretch; }
  .plan-actions .primary { margin-left: 0; }
  .quiet-select select { flex: 1; min-height: 44px; }
  table.finance .optional { display: none; }
  table.finance th:first-child, table.finance td:first-child { white-space: normal; }
  table.finance th, table.finance td { padding: 0.7rem 0.5rem; }
  table.finance td.num { font-size: 0.95rem; }

  table.orders, table.orders tbody { display: block; background: none; border: 0; }
  table.orders thead { display: none; }
  table.orders tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.15rem 0.75rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  table.orders td { display: block; padding: 0; border: 0; width: auto; }
  table.orders td:nth-child(1) { grid-column: 1; grid-row: 1; }
  table.orders td:nth-child(8) { grid-column: 2; grid-row: 1; justify-self: end; }
  table.orders td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
  table.orders td:nth-child(3) { grid-column: 1; grid-row: 3; }
  table.orders td:nth-child(7) { grid-column: 2; grid-row: 3; text-align: right; }
  table.orders td:nth-child(4),
  table.orders td:nth-child(5),
  table.orders td:nth-child(6) { grid-column: 1 / -1; color: var(--ink-2); font-size: 0.9rem; }
  table.orders td:nth-child(6):has(> .muted:only-child) { display: none; }
  /* График: семь колонок должны влезть в 390px — ячейки ниже, без точек,
     счётчик остаётся; стрелки месяца — под палец. */
  .month-nav { width: 100%; justify-content: space-between; }
  .month-nav a { width: 44px; height: 44px; }
  .calendar { gap: 3px; }
  .dow { padding: 0 0.25rem 0.25rem; font-size: 0.62rem; letter-spacing: 0.05em; }
  .day { min-height: 52px; padding: 0.3rem 0.35rem; gap: 0; }
  .day .n { font-size: 0.85rem; width: 1.6em; height: 1.6em; margin-left: -0.2em; }
  .day .c { top: 0.3rem; right: 0.3rem; min-width: 1.3em; height: 1.3em; padding: 0 0.35em; font-size: 0.7rem; }
  .day .dots { display: none; }
  .day-order { padding: 0.85rem 1rem 0.95rem; }
  .login { margin-top: 6vh; padding: 1.5rem 1.25rem 1.75rem; }

  .page-head .search { width: 100%; }
  .client-row { flex-direction: column; align-items: flex-start; gap: 0.35rem; }
  .client-row .stats { text-align: left; }
  .home { grid-template-columns: 1fr; gap: 1rem; }
  .home-main h1 { flex-wrap: wrap; }
  .today-order { padding: 0.9rem 0.95rem 0.95rem; }
  .today-order .quick button { flex: 1 1 45%; }
  .today-order .quick .quiet-link { flex-basis: 100%; margin-left: 0; text-align: right; min-height: 44px; display: inline-flex; align-items: center; justify-content: flex-end; }
  .brief { padding: 0.65rem 0; }
  .week-day { min-height: 48px; }

  /* Финансы: одна колонка — счёт, переключатель «Журнал | Сводка», один из
     экранов; кнопка записи — круглая, внизу справа под палец; шторка снизу. */
  .fin-head h1 { margin-right: 0; }
  .fin-page { grid-template-columns: 1fr; grid-template-areas: "account" "switch" "journal" "summary"; gap: 0.9rem; }
  .fin-page .fin-switch { display: flex; grid-area: switch; margin-top: 0; }
  .fin-page[data-view="journal"] .fin-summary { display: none; }
  .fin-page[data-view="summary"] .fin-journal { display: none; }
  .account .balance { font-size: 1.9rem; }
  .month-nav .off { width: 44px; height: 44px; }
  .filters { overflow-x: auto; padding-bottom: 0.1rem; }
  .filters .filter { min-height: 40px; flex: none; }
  .jrow { padding: 0.75rem 0.9rem; gap: 0.7rem; }
  .jrow .detail { white-space: normal; }
  .sheet-open {
    position: fixed;
    right: 1rem;
    bottom: calc(4.4rem + env(safe-area-inset-bottom));
    z-index: 30;
    width: 56px;
    height: 56px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 10px 24px -8px rgba(11, 95, 83, 0.6);
  }
  .sheet-open .plus { font-size: 2rem; }
  .sheet-open .word { display: none; }
  .sheet[open] .sheet-open { display: none; }
  /* Шторка от верха до низа, а не «снизу вверх»: когда появляется «Кому»,
     поля не должны уезжать из-под пальца. */
  .sheet-body {
    left: 0;
    right: 0;
    top: 2.5rem;
    bottom: 0;
    transform: none;
    width: auto;
    max-height: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .entry-form { padding: 0.9rem 1rem 1.1rem; }
  .chips .chip-toggle { min-height: 44px; }
  .small-fields { grid-template-columns: 1fr; }
  .sheet-actions { flex-direction: column; align-items: stretch; }
  .sheet-actions .danger { min-height: 44px; }
  main:has(.fin-page) { padding-bottom: calc(9rem + env(safe-area-inset-bottom)); }  /* место под круглую кнопку над полосой разделов */

  .segments { display: flex; }
  .segments a { flex: 1; justify-content: center; min-height: 44px; }
  .tabs { width: 100%; gap: 1rem; }
  .tabs a { min-height: 44px; }
  .tabs-row .filter { width: 100%; }
  .tabs-row .filter select { width: 100%; }
  .edit-form { grid-template-columns: 1fr; }
  .edit-form button { justify-self: stretch; }
  .danger-zone { justify-content: stretch; }
  .danger-zone button { width: 100%; }
  dl.facts dd { border-top: 0; padding-top: 0; }  /* подпись и значение — один блок */
  dl.facts dt { padding-bottom: 0.15rem; }
  .danger-zone.order-delete { flex-direction: column; align-items: stretch; text-align: center; }
  .upload { flex-direction: column; align-items: stretch; }
  .upload-button { justify-content: center; min-height: 44px; }
  .photo-delete { width: 32px; height: 32px; font-size: 0.9rem; }

  .today-order .quick .button-link { flex: 1 1 45%; min-height: 44px; }

  .close-grid { grid-template-columns: 1fr; }
  .close-form button { align-self: stretch; }
  .crew-chips .chip-toggle { min-height: 44px; }
  .help-link { width: 36px; height: 36px; }

  .form-grid { grid-template-columns: 1fr; }
  .new-order > button { align-self: stretch; }
  .add-order { min-height: 44px; }
  .head-side { width: 100%; justify-content: space-between; }
  .seg-row { flex-wrap: nowrap; }
  .seg-row .segments { flex: 1; }
  .install-go { align-self: stretch; }

}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
