/* Интерфейс CRM.
 *
 * Токены — с g0faq.ru (~/dev/portfolio/css/main.css): бумага, тушь,
 * сигнальный оранжевый, нулевой радиус, жёсткие тени, шрифты Unbounded /
 * Onest / JetBrains Mono.
 *
 * Компоненты — порт из prota (src/components/ui/ui.module.css,
 * ui/form.module.css, shell/Shell.module.css, app/(app)/home.module.css):
 * бейджи, кнопки, поля, таблица на CSS grid, которая на телефоне
 * превращается в карточки, нижняя панель навигации. Палитра заменена на
 * g0faq, приём с data-атрибутами вместо классов состояния сохранён. */

:root {
  /* Единая высота элементов управления: кнопки и поля в одном ряду
     совпадают по верхнему и нижнему краю. */
  --control-h: 40px;
  --control-h-sm: 32px;
  --paper: #eeefe9;
  --paper-2: #e3e5dd;
  --card: #f7f8f4;
  --ink: #101114;
  --ink-2: #464a52;
  --ink-3: #6d727a;
  --line: #c9ccc2;
  --accent: #ff4f0f;
  --accent-deep: #cf3a02;
  --accent-soft: #ffe1d3;
  --ok: #1f8a4c;
  --ok-soft: #dcf0e4;
  --warn: #b26a00;
  --warn-soft: #ffeccc;

  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Unbounded', 'Onest', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-16: 16px;
  --topbar: 54px;
  --mobilebar: 58px;
  --ease: cubic-bezier(0.2, 0.72, 0.2, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-14);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
h1 { font-size: clamp(20px, 3vw, 26px); }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-12); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.label {
  font-family: var(--mono);
  font-size: var(--fs-11);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ── Каркас ──────────────────────────────────────────────────────────────── */

/* Без «отскока» у краёв страницы: на айфоне при отскоке закреплённое
   нижнее меню отстаёт от экрана и повисает посреди содержимого. */
html, body { overscroll-behavior-y: none; }
/* Страница целиком по ширине экрана не листается и не масштабируется:
   вбок прокручиваются только отдельные ленты (вкладки, кнопки ИИ, фильтры).
   Поля ввода — не меньше 16px, иначе айфон приближает их при фокусе. */
html, body { overflow-x: clip; max-width: 100%; touch-action: pan-x pan-y; }
input, select, textarea { font-size: max(16px, 1em); }
.shell { display: flex; flex-direction: column; min-height: calc(100dvh - var(--topbar)); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar);
  padding: 0 16px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}

.brand {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.03em;
  text-decoration: none;
}

/* Логотип — одно слово: «g0faq» с оранжевым нулём, рядом приглушённая
   метка раздела. Без плиток и знаков — на телефоне они читались пятном. */
.brand__zero { color: var(--accent); }
.brand__tag {
  margin-left: 2px;
  padding-left: 8px;
  border-left: 1.5px solid var(--line);
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

.topbar__nav { display: flex; gap: 14px; align-items: center; margin-left: auto; font-family: var(--mono); font-size: var(--fs-12); }
.topbar__nav a { color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.topbar__nav a:hover { color: var(--ink); }
.icon { flex: none; }
.topbar__nav a[data-active='true'] { color: var(--ink); font-weight: 700; }

main.page { flex: 1; width: min(100%, 1180px); margin: 0 auto; padding: 18px 16px 40px; }
.page--narrow { width: min(100%, 720px); }

/* ── Заголовок страницы и вкладки ────────────────────────────────────────── */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 16px; margin-bottom: 14px; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

.tabs { display: flex; gap: 2px; margin: 0 -16px 18px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 9px 12px;
  border-bottom: 3px solid transparent;
  color: var(--ink-3);
  font-size: var(--fs-13);
  text-decoration: none;
  white-space: nowrap;
}
.tabs a[data-active='true'] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

/* ── Карточки и сетки ────────────────────────────────────────────────────── */

.card { border: 2px solid var(--ink); background: var(--card); padding: 16px; }
.card-soft { border: 1px solid var(--line); background: var(--card); padding: 12px; }
.card + .card, .card + .card-soft, .card-soft + .card { margin-top: 12px; }

.grid { display: grid; gap: 12px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stack { display: grid; gap: 10px; }

/* Правило браузера [hidden]{display:none} слабее любого класса с display,
   поэтому скрытая форма пароля всё равно показывалась клиенту. Ставим
   явный приоритет — иначе каждый новый класс с display снова её откроет. */
[hidden] { display: none !important; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.kpi { border: 2px solid var(--ink); display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); }
.kpi > div { padding: 14px; border-right: 1px solid var(--line); }
.kpi > div:last-child { border-right: 0; }
.kpi--3 { grid-template-columns: repeat(3, 1fr); }
/* Число не рвётся на строки («60.000» и «₽» отдельно) — на узком экране
   оно просто становится мельче. */
.kpi__value { font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: -0.03em; }
@media (max-width: 480px) { .kpi__value { font-size: clamp(15px, 5vw, 24px); white-space: nowrap; } }
/* Лента событий. */
.event { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: var(--fs-13); }
.event:first-of-type { border-top: 0; }
.event__who {
  font-family: var(--mono); font-size: var(--fs-11); font-weight: 700; text-transform: uppercase;
  padding: 2px 6px; color: var(--ink-3); border: 1px solid var(--line);
}
.event__what { min-width: 0; overflow-wrap: anywhere; }
.event__what .muted { margin-left: 6px; }
.event__when { font-family: var(--mono); font-size: var(--fs-11); color: var(--ink-3); white-space: nowrap; }

/* ── Таблица: на телефоне превращается в карточки ────────────────────────── */

.table { border: 2px solid var(--ink); background: var(--card); }
.table__head, .table__row {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  grid-template-columns: var(--cols, 2fr 1fr 1fr 1fr);
}
.table__head {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: var(--fs-11);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.table__row { border-top: 1px solid var(--line); font-size: var(--fs-13); text-decoration: none; }
.table__row:hover { background: var(--paper-2); }
.table__title { font-weight: 600; }

/* ── Бейджи, точки, прогресс ─────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: var(--fs-11);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge[data-tone='accent'] { background: var(--ink); color: var(--paper); }
.badge[data-tone='ok'] { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.badge[data-tone='warn'] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.badge[data-tone='muted'] { border-color: var(--line); color: var(--ink-3); }
.badge[data-tone='neutral'] { background: var(--paper-2); }

.bar { height: 8px; border: 1px solid var(--ink); background: var(--paper); overflow: hidden; display: flex; }
.bar__done { background: var(--accent); }
.bar__progress { background: var(--accent-soft); }

.progress-line { display: grid; gap: 4px; }
.progress-line__meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: var(--fs-11); color: var(--ink-3); }

/* ── Кнопки ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-h);
  padding: 0 14px;
  border: 2px solid var(--ink);
  line-height: 1.1;
  vertical-align: middle;
  background: var(--card);
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--fs-12);
  font-weight: 700;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
}
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: 0.45; box-shadow: none; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--small { min-height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-11); box-shadow: 2px 2px 0 var(--ink); }
/* Призрачная кнопка без тени в любом размере: иначе рядом с полем ввода
   она «съезжает» на ширину тени и ряд выглядит кривым. */
.btn--ghost, .btn--ghost.btn--small { border-color: var(--line); box-shadow: none; }
.btn--danger { border-color: var(--accent-deep); color: var(--accent-deep); }

/* Форма-обёртка одной кнопки: flex, а не inline — иначе кнопка встаёт
   по базовой линии текста и прыгает на пару пикселей относительно соседей. */
.inline-form { display: inline-flex; align-items: center; }
/* Поля и списки в одном ряду с маленькими кнопками — той же высоты:
   ряд «поле + кнопка» совпадает по верхнему и нижнему краю. */
:is(.row, .additem, .item__head, .req__actions, .req__inline):has(.btn--small)
  :is(.input, select, input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .pick__button),
.input--small {
  height: var(--control-h-sm); min-height: var(--control-h-sm);
  padding-top: 0; padding-bottom: 0;
}
/* Сетка полей формы: подписи разной длины не сдвигают поля — все поля
   ряда стоят по нижнему краю. */
.form-grid { align-items: end; }

/* ── Формы ───────────────────────────────────────────────────────────────── */

.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-family: var(--mono); font-size: var(--fs-11); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.field input, .field select, .field textarea, .input {
  width: 100%;
  min-height: var(--control-h);
  padding: 7px 10px;
  line-height: 1.4;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-16);
}
.field textarea { min-height: 84px; resize: vertical; }
.field--check { display: flex; align-items: center; gap: 8px; }
.field--check input { width: 18px; min-height: 18px; height: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.notice { padding: 10px 12px; border-left: 3px solid var(--ink); background: var(--paper-2); font-size: var(--fs-13); }
.notice--error { border-left-color: var(--accent-deep); background: var(--accent-soft); }
.notice--ok { border-left-color: var(--ok); background: var(--ok-soft); }
.notice--warn { border-left-color: var(--warn); background: var(--warn-soft); }

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 36px 16px;
  border: 1px dashed var(--line);
  background: var(--card);
  text-align: center;
  color: var(--ink-3);
}

/* Скелет загрузки: используется на экранах, где данные подгружаются. */
.skeleton {
  height: 12px;
  background: linear-gradient(90deg, var(--paper-2) 25%, var(--line) 50%, var(--paper-2) 75%) 0 0 / 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Код доступа ─────────────────────────────────────────────────────────── */

.code-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.3em;
  padding: 10px 14px;
  border: 2px dashed var(--ink);
  background: var(--paper);
  display: inline-block;
}

.code-input { display: flex; gap: 8px; justify-content: center; }
.code-input input {
  width: 46px;
  height: 56px;
  padding: 0;
  border: 2px solid var(--ink);
  background: var(--card);
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  text-align: center;
}

/* Служебный вход: точка в углу, которую замечаешь, только если знаешь. */
/* Ссылка служебного входа: заметна тому, кто её ищет, и не спорит с
   полем кода, ради которого страница и сделана. */
.owner-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--ink-3, #8a8b90);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.owner-link:hover { color: var(--ink, #101114); }

/* Переключатель проектов в кабинете. */
.project-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.project-switch button {
  padding: 6px 12px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  font-family: var(--mono);
  font-size: var(--fs-12);
  cursor: pointer;
}

.project-switch button[data-active='true'] {
  background: var(--ink);
  color: var(--paper);
}

/* ── Списки пунктов ТЗ, запросов, задач ──────────────────────────────────── */

.item {
  display: grid;
  gap: 6px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.item__title { font-weight: 600; }
.item__meta { display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--mono); font-size: var(--fs-11); color: var(--ink-3); }

/* Требует решения: клиент сообщил об оплате — подтвердить или вернуть в работу. */
.item__callout {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--accent, #d9822b);
  border-left-width: 3px;
  background: color-mix(in srgb, var(--accent, #d9822b) 6%, transparent);
  display: grid;
  gap: 10px;
}
.item__callout p { margin: 0; }

.task { display: flex; align-items: center; gap: 8px; font-size: var(--fs-13); }
.task[data-done='1'] { color: var(--ink-3); text-decoration: line-through; }

.waiting-banner {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
}

/* ── Нижняя панель на телефоне (порт из prota/shell) ─────────────────────── */

.mobilebar { display: none; }

@media (max-width: 860px) {
  main.page { padding-bottom: calc(var(--mobilebar) + env(safe-area-inset-bottom, 0px) + 20px); }

  .topbar__nav { display: none; }

  .mobilebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: flex;
    height: calc(var(--mobilebar) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
    border-top: 2px solid var(--ink);
    background: var(--paper);
  }
  .mobilebar a {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink-3);
  }
  .mobilebar a[data-active='true'] { color: var(--ink); font-weight: 700; }

  /* Иконка крупнее подписи: на ходу читают именно её, а подпись служит
     подсказкой. Активный раздел отмечается полосой сверху, чтобы не
     двигать содержимое кнопки. */
  .mobilebar a[data-active='true']::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 26px;
    height: 3px;
    background: var(--accent);
  }
  .mobilebar a { position: relative; }
  .mobilebar__icon { position: relative; display: block; line-height: 0; }

  .mobilebar__badge {
    position: absolute;
    top: -6px;
    right: -9px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    line-height: 1;
  }

  .kpi, .kpi--3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kpi > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .kpi--3 > div:last-child { grid-column: 1 / -1; }

  /* Строка таблицы складывается в карточку: приём из prota/home.module.css */
  .table__head { display: none; }
  .table__row { grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; }
  .table__row > *:nth-child(1) { grid-column: 1; grid-row: 1; }
  .table__row > *:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; }
  .table__row > *:nth-child(3) { grid-column: 1; grid-row: 2; }
  .table__row > *:nth-child(4) { grid-column: 2; grid-row: 2; text-align: right; }
  .table__row > *:nth-child(5) { grid-column: 1 / -1; grid-row: 3; }

  .card { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .code-input input { width: 40px; height: 50px; font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Центр уведомлений ───────────────────────────────────────────────────── */

.event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.event {
  border: 1px solid var(--line);
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  background: var(--surface);
}

/* Непрочитанное помечается полосой слева, а не цветом текста: так карточка
   остаётся читаемой и после того, как её открыли. */
.event--unread { border-left: 3px solid var(--accent); }
.event--high .event__title { font-weight: 600; }
.event__title { margin: 0; }

.bell { position: relative; display: inline-flex; align-items: center; gap: 6px; }

.bell__count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
}

/* ── Таймлайн ────────────────────────────────────────────────────────────── */

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 1px solid var(--line); display: grid; gap: 14px; }

.timeline__item { position: relative; }

.timeline__item::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 6px;
  width: 9px;
  height: 9px;
  background: var(--ink);
}

/* Пауза и возобновление — единственные события, которые стоит различать
   взглядом: по ним читается, почему срок уехал. */
.timeline__item--pause::before { background: var(--accent); }
.timeline__item--resume::before { background: transparent; border: 1px solid var(--ink); }
.timeline__item--money::before { transform: rotate(45deg); }
.timeline__title { margin: 2px 0 0; }

/* ── Поле даты ───────────────────────────────────────────────────────────── */

.datefield { position: relative; }
.datefield__row { display: flex; gap: 0; align-items: stretch; }
.datefield__text { flex: 1; min-width: 0; }

.datefield__open {
  width: 38px;
  border: 1px solid var(--line);
  border-left: 0;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.datefield__open:hover { color: var(--accent); }

.datefield__pop {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  margin-top: 4px;
  width: 256px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}

.calendar__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.calendar__title { font: 600 13px/1 var(--font-ui, inherit); }

.calendar__nav {
  border: 1px solid var(--line);
  background: var(--surface);
  width: 26px;
  height: 26px;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.calendar__nav:hover { border-color: var(--ink); }
.calendar__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.calendar__dow {
  font: 500 10px/1 var(--mono, monospace);
  color: var(--ink-3);
  text-align: center;
  padding: 4px 0;
}

.calendar__day {
  border: 1px solid transparent;
  background: none;
  font: inherit;
  font-size: 12px;
  padding: 6px 0;
  cursor: pointer;
}

.calendar__day:hover { border-color: var(--ink); }
.calendar__day[data-muted] { color: var(--ink-3); }
.calendar__day[data-today] { font-weight: 700; color: var(--accent); }
.calendar__day[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.calendar__foot { display: flex; justify-content: space-between; margin-top: 8px; }

.calendar__link {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.calendar__link:hover { color: var(--accent); }

/* Свой выпадающий список: системный на телефоне открывается колесом,
   которое не имеет ничего общего с остальным интерфейсом. */
.pick { position: relative; min-width: 0; max-width: 100%; }
/* Длинный вариант в списке режется многоточием, а не распирает форму. */
.field { grid-template-columns: minmax(0, 1fr); }
.field > span { overflow-wrap: anywhere; }

.pick__button {
  width: 100%;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  height: var(--control-h);
  padding: 0 28px 0 10px;
  font: inherit;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.pick__button::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1px solid var(--ink-2);
  border-bottom: 1px solid var(--ink-2);
  transform: translateY(-70%) rotate(45deg);
}

.pick__button:hover { border-color: var(--ink); }

.pick__list {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  max-height: 240px;
  overflow: auto;
}

.pick__option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  font: inherit;
  padding: 8px 10px;
  cursor: pointer;
}

.pick__option:hover { background: var(--surface); }
.pick__option[aria-selected="true"] { background: var(--ink); color: var(--paper); }

/* ── График ──────────────────────────────────────────────────────────────── */

.chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; }
.chart__col { display: grid; gap: 6px; justify-items: center; }

.chart__stack {
  --stack: 160px;
  width: 100%;
  max-width: 54px;
  height: var(--stack);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-bottom: 1px solid var(--ink);
}

/* Высота столбика считается от высоты стакана, а не процентами: процент
   внутри flex-колонки резолвится непредсказуемо и столбики схлопывались
   в линию. Доля приходит в --v как число от 0 до 1. */
.chart__bar {
  width: 100%;
  flex: none;
  height: calc(var(--v, 0) * var(--stack));
  min-height: 1px;
}
.chart__bar--earned { background: var(--ink); }

/* Ожидаемое — штриховкой: это ещё не деньги, и выглядеть как деньги оно
   не должно. */
.chart__bar--expected {
  background: repeating-linear-gradient(45deg, var(--accent) 0 2px, transparent 2px 5px);
  border-top: 1px solid var(--accent);
}

.chart__value { font-size: 11px; }
.chart__label { font-size: 11px; color: var(--ink-3); }
.chart__key { display: inline-block; width: 10px; height: 10px; vertical-align: -1px; }
.chart__key--earned { background: var(--ink); }
.chart__key--expected { background: repeating-linear-gradient(45deg, var(--accent) 0 2px, transparent 2px 5px); border: 1px solid var(--accent); }

@media (max-width: 600px) {
  .chart__stack { --stack: 120px; }
  .chart__value { display: none; }
}

/* ── Таблица пунктов запроса ─────────────────────────────────────────────── */

.itemtable { width: 100%; border-collapse: collapse; margin-top: 6px; }

.itemtable th {
  text-align: left;
  font: 500 10px/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 8px 6px 0;
}

.itemtable td { padding: 0 8px 8px 0; vertical-align: middle; }
/* Строка пунктов: поле, список и кнопка удаления одной высоты. */
.itemtable :is(.input, .pick__button, select) {
  height: var(--control-h-sm); min-height: var(--control-h-sm); padding-top: 0; padding-bottom: 0;
}
.itemtable .btn--small { width: var(--control-h-sm); padding: 0; }
.itemtable td:last-child, .itemtable th:last-child { padding-right: 0; }
.itemtable__check { text-align: center; }

/* Свой переключатель: системный флажок на каждой платформе свой и всегда
   синий, что спорит с оранжевым акцентом. */
.switch { display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch__box {
  width: 18px;
  height: 18px;
  border: 1px solid var(--ink);
  background: var(--surface);
  display: grid;
  place-items: center;
}

.switch__box::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg) scale(0);
  transform-origin: center;
}

.switch input:checked + .switch__box::after { transform: rotate(-45deg) scale(1); }
.switch input:focus-visible + .switch__box { outline: 2px solid var(--accent); outline-offset: 2px; }

.itemtable__req { display: none; }

@media (max-width: 700px) {
  /* На телефоне строка — компактная карточка: название во всю ширину, под
     ним в одну линию тип, «обязательно» и удаление. Раньше каждый элемент
     вставал отдельной строкой без подписи, и строка занимала пол-экрана. */
  .itemtable, .itemtable tbody { display: block; width: 100%; }
  .itemtable thead { display: none; }

  .itemtable__row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
  }

  .itemtable td { display: block; padding: 0; width: auto !important; }
  .itemtable td:first-child { grid-column: 1 / -1; }
  .itemtable__check { text-align: left; }
  .itemtable__req { display: inline; font: 500 11px/1 var(--mono); color: var(--ink-2); }
  .switch { align-items: center; gap: 6px; }
}

/* ── Поле файла ──────────────────────────────────────────────────────────── */

/* Системная кнопка выбора файла подписана на языке браузера и выглядит
   инородно. Сам input остаётся на месте — он и принимает файл, — но
   скрыт, а видна своя кнопка с именем выбранного файла. */
.filefield { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* Общее правило полей растягивает input на всю ширину, и скрытое поле
   файла выпирало за экран на телефоне — появлялась горизонтальная
   прокрутка. Поэтому размеры заданы с приоритетом, а поле обрезано. */
.filefield { position: relative; }
.filefield__input {
  position: absolute !important;
  left: 0;
  top: 0;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0;
  overflow: hidden;
  clip-path: inset(50%);
  pointer-events: none;
}

.filefield__button {
  border: 1px solid var(--ink);
  background: var(--surface);
  padding: 9px 14px;
  font: inherit;
  font-size: var(--fs-12);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
}

.filefield__button:hover { background: var(--ink); color: var(--paper); }
.filefield__name { font-size: var(--fs-13); color: var(--ink-2); overflow-wrap: anywhere; }


/* ── Колокольчик в шапке ─────────────────────────────────────────────────── */

.topbell {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: 6px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  flex: none;
}

.topbell:hover, .topbell[data-active='true'] { border-color: var(--ink); }

/* «Домой» из проекта — рядом с колокольчиком, того же размера. На
   компьютере не нужна: там есть шапка и «← Все проекты» в боковом меню. */
.tophome {
  display: none; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; flex: none;
}
.tophome:hover { border-color: var(--ink); }

.topbell__count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font: 700 10px/1 var(--mono);
}

/* Выход переехал в настройки: в шапке телефона ему не место, а на
   десктопе он был самой частой случайной кнопкой. */
@media (max-width: 860px) {
  .topbar { justify-content: space-between; }
  .topbell { margin-left: auto; }
  .tophome { display: grid; margin-left: auto; }

  /* Листается оболочка, а не документ: у документа на айфоне при прокрутке
     прячется и выезжает панель Safari, и закреплённое меню дёргается
     вместе с ней. Шапка стоит над оболочкой, а не внутри прокрутки: иначе
     iOS размывает верхний край прокручиваемой области вместе с шапкой. */
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--topbar) + env(safe-area-inset-top, 0px));
  }
  .shell {
    position: fixed;
    top: calc(var(--topbar) + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: clip;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
  .tophome + .topbell { margin-left: 6px; }
  .topbell + .topsettings { margin-left: 6px; }
  .topbell ~ .topsettings { display: grid; margin-left: 6px; }
  .tophome[data-active='true'] { border-color: var(--ink); }
}


/* ── Полоса ИИ ───────────────────────────────────────────────────────────── */

.aibar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--paper));
}

.aibar__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 700 11px/1 var(--mono);
  letter-spacing: .06em;
  color: var(--accent-deep, var(--accent));
  margin-right: 4px;
}

/* ── Строка настройки ────────────────────────────────────────────────────── */

.setting {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.setting:first-child { border-top: 0; }
.setting > span:last-child { display: grid; gap: 2px; }

/* ── Приглашение ─────────────────────────────────────────────────────────── */

/* Холст рисуется в 1080×1350 — размер для мессенджеров, — а на странице
   ужимается по ширине колонки. */
.invite-canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  background: var(--paper);
}


/* ── Слой уведомлений ────────────────────────────────────────────────────── */

.bellpanel {
  position: absolute;
  top: calc(100% + 6px);
  right: 12px;
  z-index: 50;
  width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}

.bellpanel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.bellpanel__list { overflow-y: auto; overscroll-behavior: contain; }

.bellitem {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.bellitem:hover { background: var(--surface); }
.bellitem--unread { border-left: 3px solid var(--accent); }
.bellitem__title { font-weight: 600; font-size: var(--fs-13, 13px); }
.bellitem__text { font-size: 12px; color: var(--ink-2); }
.bellitem__time { font: 11px/1 var(--mono); color: var(--ink-3); }
.bellitem__go { font-size: 12px; color: var(--accent-deep, var(--accent)); }
.bellpanel__empty { padding: 18px 12px; }

/* ── Раздел ИИ ───────────────────────────────────────────────────────────── */

.aigrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }

.aitile {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  text-align: left;
  font: inherit;
}

.aitile:hover { border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.aitile .icon { color: var(--accent); }
.aitile .btn { justify-self: start; margin-top: 4px; }
.aitile--button { cursor: pointer; }
.aitile--button:disabled { opacity: .6; cursor: wait; }


/* ── Оплата у клиента ────────────────────────────────────────────────────── */

.paydetails {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--line);
}

.paydetails p { margin: 2px 0 6px; overflow-wrap: anywhere; }

/* Кнопки-раскрывашки платежа: summary выглядит как кнопка, форма под ней. */
.stage-edit { width: 100%; }
/* Раскрытая форма занимает всю строку, свёрнутая — только место кнопки. */
.payment-send[open], .payment-edit[open] { flex-basis: 100%; order: 10; }
.payment-send > summary, .payment-edit > summary { display: inline-flex; list-style: none; }
.payment-send > summary::-webkit-details-marker, .payment-edit > summary::-webkit-details-marker { display: none; }
.payment-send[open], .payment-edit[open] { padding: 10px; border: 1px solid var(--line); }
.stage-edit { margin-top: 10px; }


/* Выбор способа создания проекта: две крупные плитки, на телефоне — одна
   под другой. */
.choice { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.choice__tile { padding: 22px; gap: 10px; min-height: 170px; }
.choice__tile strong { font-size: 18px; }

/* ── Список проектов ─────────────────────────────────────────────────────── */

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  padding: 7px 12px;
  border: 1px solid var(--line);
  font: 500 12px/1 var(--mono);
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}

.chip[data-active='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.projectlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.projectcard { display: grid; gap: 8px; color: inherit; text-decoration: none; }
.projectcard:hover { box-shadow: 4px 4px 0 var(--ink); }


/* Сброс системного вида кнопок: на iOS без него текст кнопки синий, а
   углы скруглены — это и было «синее» в выпадающих списках. */
button { color: inherit; -webkit-appearance: none; appearance: none; border-radius: 0; }
.pick__option { color: var(--ink); }
.datefield__open, .calendar__day, .calendar__nav, .calendar__link { color: var(--ink); }


/* Добавление пункта в существующий запрос: поле, тип и кнопка в одну
   строку на десктопе; на телефоне поле сверху, тип и кнопка под ним. */
.additem { display: grid; grid-template-columns: 1fr 160px auto; gap: 8px; margin-top: 10px; align-items: center; }
.additem > * { min-width: 0; }

@media (max-width: 700px) {
  .additem { grid-template-columns: 1fr auto; }
  .additem > .input:first-child { grid-column: 1 / -1; }
}


/* ── ТЗ: компактный список ───────────────────────────────────────────────── */

.spec__group { border-top: 1px solid var(--line); }
.spec__group:first-of-type { border-top: 0; }

.spec__grouphead, .spec__summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
}

.spec__grouphead::-webkit-details-marker, .spec__summary::-webkit-details-marker,
.req__line::-webkit-details-marker { display: none; }
.spec__grouptitle, .spec__summary { font-weight: 600; }
.spec__grouphead::before, .spec__summary::before { content: "▸"; color: var(--ink-3); margin-right: 6px; }
details[open] > .spec__grouphead::before, details[open] > .spec__summary::before { content: "▾"; }
.spec__grouptitle { flex: 1; }
.spec__summary { justify-content: flex-start; padding: 0; }

/* Пункт: отметка слева, формулировка в одну-две строки, мета справа. */
.req { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; padding: 7px 0; border-top: 1px dashed var(--line); }
.req__check { margin: 0; }

.req__box {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  background: var(--surface);
  color: var(--accent);
  font: 700 14px/1 var(--mono);
  cursor: pointer;
  padding: 0;
}

.req[data-done='true'] .req__box { background: var(--ink); color: var(--paper); }
.req[data-done='true'] .req__title { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line); }

.req__line { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; cursor: pointer; list-style: none; }
.req__title { font-size: 14px; line-height: 1.35; }
.req__meta { display: inline-flex; gap: 6px; align-items: center; flex: none; }
.req__more { display: grid; gap: 8px; padding: 8px 0 4px; }
.req__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.req__inline { display: flex; gap: 6px; align-items: center; margin: 0; }
.req__inline .input, .req__inline .pick { min-width: 150px; }

@media (max-width: 700px) {
  .req__title { font-size: 13px; }
  .req__actions { display: grid; grid-template-columns: 1fr; }
  .req__inline { width: 100%; }
  .req__inline .input, .req__inline .pick { flex: 1; min-width: 0; }
  /* Полоса ИИ на телефоне — одна строка с прокруткой, а не стопка кнопок. */
  .aibar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .aibar::-webkit-scrollbar { display: none; }
  .aibar .btn { white-space: nowrap; }
}


/* Плашка новой версии: над нижним меню на телефоне, внизу справа на
   десктопе. Не закрывает контент целиком и не уходит сама. */
.updatebar {
  position: fixed;
  z-index: 60;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 13px;
}

@media (max-width: 860px) {
  .updatebar {
    left: 12px;
    right: 12px;
    bottom: calc(var(--mobilebar) + env(safe-area-inset-bottom, 0px) + 10px);
    justify-content: space-between;
  }
}


/* ── Обзор проекта: таймер и шапка ───────────────────────────────────────── */

.timer__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.timer__state { display: grid; justify-items: end; gap: 6px; text-align: right; }
.timer__owner { margin: 0; }
.timer__action { margin: 0; max-width: 280px; }
.page-head__settings { display: inline-flex; gap: 6px; align-items: center; }

@media (max-width: 700px) {
  /* Шапка проекта: название мельче, «Настройки» — квадратной иконкой в
     строке с названием, а не отдельной строкой на полэкрана. */
  .page-head--project { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 10px; }
  /* Широкий шрифт заголовков на телефоне превращал длинное название в
     пять строк: мельче и не больше трёх строк, полное — в подсказке. */
  .page-head--project h1 {
    font-size: 17px;
    line-height: 1.2;
    letter-spacing: -0.02em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .page-head--project .page-head__actions { margin: 0; }
  .page-head__settings { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .page-head__settings span { display: none; }

  /* Вкладки дублируют нижнее меню, поэтому на телефоне — мелкой строкой. */
  .tabs a { font-size: 13px; padding: 8px 10px; }

  /* Таймер: всё выровнено влево и идёт сверху вниз, статусы — в строку. */
  .timer__top { display: grid; gap: 10px; }
  .timer__value { font-size: 26px; }
  .timer__state { display: flex; flex-wrap: wrap; justify-items: start; justify-content: flex-start; align-items: center; text-align: left; }
  .timer__action { max-width: none; flex-basis: 100%; }
  .aibar { margin-bottom: 10px; padding: 8px 10px; }
}

/* ── Таблица отчёта ──────────────────────────────────────────────────────── */

.rtable { display: grid; }
.rtable__head, .rtable__row { display: grid; grid-template-columns: 1.4fr 120px 1.4fr 1.4fr; gap: 12px; }

.rtable__head {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ink);
  font: 500 10px/1.2 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.rtable__stage { padding: 14px 0 6px; font-weight: 600; border-bottom: 1px solid var(--line); }
.rtable__row { padding: 10px 0; border-bottom: 1px dashed var(--line); align-items: start; }
.rtable__title { font-size: 14px; line-height: 1.35; }
/* Длинные слова и ссылки переносятся, а не раздвигают строку. */
.rtable__row > * { min-width: 0; overflow-wrap: anywhere; }
.rtable__row textarea { min-height: 44px; font-size: 13px; }
.rtable__label { display: none; }

@media (max-width: 800px) {
  /* На телефоне строка — карточка: пункт и статус сверху, комментарии
     под ними, у заказчика с подписью. */
  .rtable__head { display: none; }
  .rtable__row { grid-template-columns: 1fr; gap: 8px; }
  .rtable__status { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
  .rtable__owner, .rtable__client { grid-column: 1 / -1; }
  .rtable__label { display: block; font: 500 10px/1 var(--mono); color: var(--ink-3); text-transform: uppercase; margin-bottom: 4px; }
}


/* ── Форма запроса: компактнее на телефоне ───────────────────────────────── */

.reqform__more > summary { cursor: pointer; color: var(--ink-2); list-style: none; }
.reqform__more > summary::-webkit-details-marker { display: none; }
.itemtable__options { margin-top: 6px; }

@media (max-width: 700px) {
  /* Тип, этап, срок и «что блокирует» — по два в строке, подписи мельче. */
  .reqform { grid-template-columns: 1fr 1fr; gap: 8px; }
  .reqform > .field:first-child, .reqform > .reqform__more, .reqform > .field:last-child { grid-column: 1 / -1; }
  .reqform .field > span { font-size: 9px; }
  .reqform .pick__button, .reqform .input { padding: 8px; font-size: 13px; }
  .reqform .datefield__text { font-size: 13px; }
  .itemtable__row { padding: 8px; gap: 6px; }
}

/* Выбор у клиента: варианты кнопками, а не полем ввода. */
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-opt { position: relative; }
.choice-opt input { position: absolute; opacity: 0; width: 0; height: 0; }

.choice-opt span {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--ink);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
}

.choice-opt input:checked + span { background: var(--ink); color: var(--paper); }
.choice-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Встроенный опрос: занимает всё место между шапкой и нижним меню. */
.briefframe { border: 1px solid var(--ink); background: var(--paper); }
.briefframe iframe {
  display: block;
  width: 100%;
  height: calc(100dvh - var(--topbar) - 170px);
  min-height: 520px;
  border: 0;
}

@media (max-width: 860px) {
  .briefframe { margin: 0 -16px; border-left: 0; border-right: 0; }
  .briefframe iframe { height: calc(100dvh - var(--topbar) - var(--mobilebar) - env(safe-area-inset-bottom, 0px) - 120px); }
}

.rtable__answer { margin: 6px 0 0; padding-left: 8px; border-left: 2px solid var(--line); font-size: 12px; color: var(--ink-2); white-space: pre-line; }
.rtable__status { display: grid; gap: 6px; justify-items: start; }
.rsum { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.rsteps { display: grid; gap: 14px; }
.rsteps ol { margin: 6px 0 0 18px; display: grid; gap: 4px; font-size: 13px; }

.briefnote { margin: 4px 0 2px; color: var(--ink-2); }


/* ── Боковое меню проекта ────────────────────────────────────────────────── */

.withside { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 0; width: min(100%, 1400px); margin: 0 auto; flex: 1; }
.page--side { width: 100%; max-width: none; margin: 0; }

.sidebar {
  position: sticky;
  top: var(--topbar);
  align-self: start;
  height: calc(100dvh - var(--topbar));
  overflow-y: auto;
  padding: 18px 12px 24px 16px;
  border-right: 1px solid var(--line);
}

.sidebar__back { font: 500 11px/1 var(--mono); color: var(--ink-3); text-decoration: none; }
.sidebar__back:hover { color: var(--ink); }

.sidebar__title {
  margin: 12px 0 14px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar__nav { display: grid; gap: 2px; }

.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  color: var(--ink-2);
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: 14px;
}

.sidebar__nav a:hover { background: var(--surface); color: var(--ink); }
.sidebar__nav a[data-active='true'] { color: var(--ink); font-weight: 600; background: var(--surface); border-left-color: var(--accent); }

/* На компьютере вкладки проекта заменяет боковое меню. */
@media (min-width: 861px) {
  .withside .tabs { display: none; }
}

/* На телефоне бока нет: разделы — в нижнем меню и строке вкладок. */
@media (max-width: 860px) {
  .withside { display: block; }
  .sidebar { display: none; }
}


/* ── Расходы на ИИ по дням ───────────────────────────────────────────────── */
.aicost { display: grid; gap: 4px; }
.aicost__row { display: grid; grid-template-columns: 46px 1fr 90px 120px; gap: 10px; align-items: center; }
.aicost__bar { --w: 100%; display: flex; height: 10px; background: var(--surface); }
.aicost__bar i { display: block; height: 100%; width: calc(var(--v, 0) * 100%); }
.aicost__site, .aicost__keysite { background: var(--ink); }
.aicost__crm, .aicost__keycrm { background: repeating-linear-gradient(45deg, var(--accent) 0 2px, transparent 2px 5px); border-top: 1px solid var(--accent); }
.aicost__sum { text-align: right; }
@media (max-width: 600px) {
  .aicost__row { grid-template-columns: 40px 1fr 76px; }
  .aicost__calls { display: none; }
}


/* Кнопка-раскрывашка «Создать запрос». */
.newreq > summary { list-style: none; display: inline-flex; }
.newreq > summary::-webkit-details-marker { display: none; }
.newreq[open] > summary { box-shadow: 1px 1px 0 var(--ink); transform: translate(2px, 2px); }

/* Кейсы портфолио в настройках. */
.casecard { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: start; }
.casecard[data-hidden='true'] { opacity: 0.6; }
.casecard__image { aspect-ratio: 16 / 10; border: 1px solid var(--line); background: var(--paper-2); overflow: hidden; }
.casecard__image img, .casecard__preview { width: 100%; height: 100%; object-fit: cover; display: block; }
.casecard__preview { max-width: 320px; height: auto; border: 1px solid var(--line); margin-bottom: 6px; }
@media (max-width: 480px) { .casecard { grid-template-columns: 84px minmax(0, 1fr); gap: 10px; } }

/* ── ИИ-помощник ─────────────────────────────────────────────────────────── */
.tabcount {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  background: var(--accent); color: #fff; font: 700 10px/1 var(--mono);
}
.rowform { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rowform > .input, .rowform > .pick { flex: 1 1 180px; min-width: 0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.quote { padding: 8px 10px; border-left: 3px solid var(--line); background: var(--paper); }
.list { margin: 6px 0 0 18px; display: grid; gap: 3px; font-size: var(--fs-13); }
.toggle-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.toggle-row input { margin-top: 3px; }
.inboxitem + .inboxitem { border-top: 1px solid var(--line); }
.ballbadge[data-ball='OWNER'] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }
.ballbadge[data-ball='CLIENT'] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.ballbadge[data-ball='NONE'] { color: var(--ink-3); }

.previewbar {
  position: sticky; top: 0; z-index: 25; padding: 6px 16px; background: var(--ink); color: var(--paper);
  font: 500 var(--fs-12)/1.4 var(--mono); text-align: center;
}
.previewbar a { color: var(--accent-soft); }
@media (max-width: 860px) { .previewbar { position: fixed; left: 0; right: 0; top: calc(var(--topbar) + env(safe-area-inset-top, 0px)); z-index: 26; } }

/* Сводка в кабинете: четыре колонки, на телефоне — две. */
.summary4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) { .summary4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.roadarrow { text-align: center; color: var(--ink-3); margin: -4px 0 8px; font-family: var(--mono); }
.roadstep[data-status='completed'] { opacity: 0.75; }
.roadstep[data-status='in_progress'], .roadstep[data-status='review'] { border-color: var(--accent); }
@media (max-width: 860px) {
  .previewbar { height: 34px; display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; }
  .previewbar + .shell { top: calc(var(--topbar) + 34px + env(safe-area-inset-top, 0px)); }
}
.task[data-done='1'] .btn { text-decoration: none; }
