/* Hotline MVP · P0. Светлая палитра Hotline, без внешних шрифтов и картинок. */

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --fg: #0f1a26;
  --muted: #5b6b7c;
  --border: #e3e8ef;
  --line: #cfd8e3;
  --accent: #1f56d6;
  --accent-soft: #e8eefc;
  --danger: #d0271c;
  --danger-soft: #fdecea;
  --ok: #1c7a4a;
  --ok-soft: #e7f4ee;
  --warn: #8a5a00;
  --warn-soft: #fdf3df;
  --radius: 12px;
  --radius-sm: 8px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 28px;
  --s8: 40px;
  --shadow: 0 1px 2px rgba(15, 26, 38, 0.04);
  --content-max: 1180px;
  --font: "Manrope", "Inter", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; }
/* Длинное название проекта без пробелов не должно растягивать страницу
   по горизонтали (Issue #48): перенос включается только там, где слово
   не помещается. */
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; line-height: 1.15; overflow-wrap: break-word; hyphens: manual; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
p { margin: 0; }

/* ── topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 var(--s5);
  height: 62px; display: flex; align-items: center; gap: var(--s5);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--fg); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: 7px; background: var(--fg); color: #fff; font-size: 15px; font-weight: 700;
}
.brand-name { font-size: 15px; letter-spacing: -0.01em; }
.brand-tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 7px;
}
.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: var(--s4); }
.nav-link {
  padding: 8px 10px; border-radius: var(--radius-sm); color: var(--muted);
  font-size: 13.5px; white-space: nowrap;
}
.nav-link:hover { color: var(--fg); background: var(--bg); text-decoration: none; }
.nav-link.is-current { color: var(--fg); font-weight: 600; background: var(--accent-soft); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }
.user-text { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 10.5px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

/* ── layout ─────────────────────────────────────────────────────────────── */
.wrap { max-width: 1180px; margin: 0 auto; padding: var(--s6) var(--s5) 64px; }
.foot {
  max-width: 1180px; margin: 0 auto; padding: 0 var(--s5) var(--s6);
  display: flex; justify-content: space-between; gap: var(--s3);
  color: var(--muted); font-size: 11.5px; flex-wrap: wrap;
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s5); margin-bottom: var(--s5); flex-wrap: wrap;
}
.page-head .lead { max-width: 70ch; margin-top: 7px; }
.lead { color: var(--muted); font-size: 14px; line-height: 1.55; }
.meta {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
.hint { margin-top: var(--s4); color: var(--muted); font-size: 12.5px; line-height: 1.55; max-width: 80ch; }
.small { font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.muted { color: var(--muted); }
.sub { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.35; margin-top: 2px; }
.empty { padding: var(--s8) var(--s4); text-align: center; color: var(--muted); }
.crumbs { display: flex; gap: 7px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: var(--s3); }
.crumbs a { color: var(--muted); }
.crumbs span:last-child { color: var(--fg); }

.columns { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s5); align-items: start; }
.column-main { min-width: 0; }
.column-rail { display: flex; flex-direction: column; gap: var(--s4); }
.block { margin-top: var(--s5); }
.block:first-child { margin-top: 0; }
.block-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s2);
}

/* ── panels / tables ───────────────────────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel-pad { padding: var(--s4); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: 13px var(--s4); border-bottom: 1px solid var(--border);
}
.panel-body { padding: var(--s3) var(--s4); }
.table { width: 100%; border-collapse: collapse; }
.table th {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; text-align: left; padding: 10px var(--s4);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
/* Перенос внутри ячеек — по словам, а не по буквам (#95, п. 48):
   break-word переносит слово только если оно не помещается целиком, и,
   в отличие от anywhere, не разрешает таблице сжимать колонку до одной
   буквы. Явные длинные URL (.project-report-url, .estimate-link-url,
   .pre-wrap) сохраняют anywhere точечно. */
.table td {
  padding: 12px var(--s4); border-top: 1px solid var(--border);
  vertical-align: middle; overflow-wrap: break-word; hyphens: manual;
}
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover { background: #fbfcfe; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Утилиты выравнивания ячеек (#95, п. 8, 10, 11, 14, 22): таблицы смет и
   карточки должны читаться по центру, а подписи действий — не рваться. */
.table td.cell-center, .table th.cell-center { text-align: center; }
.table td.cell-nowrap { white-space: nowrap; }
.table td.cell-center .chip, .table td.cell-center .btn { vertical-align: middle; }
/* Панели внутри блока не слипаются (#95, п. 23): сводка, формы и таблица
   получают единый вертикальный ритм, не меняя внешние отступы блока. */
.block > .panel + .panel,
.block > .panel + form,
.block > form + .panel { margin-top: var(--s4); }
.strong-link { color: var(--fg); font-weight: 600; }
.strong-link:hover { color: var(--accent); text-decoration: none; }
.access { font-size: 12px; color: var(--muted); }

/* ── chips / badges ─────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 11px; color: var(--muted); white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: #bfe0cf; background: var(--ok-soft); }
.chip.warn { color: var(--warn); border-color: #ecd9a8; background: var(--warn-soft); }
.chip.danger { color: var(--danger); border-color: #f0c2bd; background: var(--danger-soft); }
.chip.muted { color: var(--muted); background: var(--bg); }
.chip.role-owner { color: var(--fg); border-color: var(--line); font-weight: 600; }
.chip.role-employee { color: var(--accent); border-color: #c8d8f8; background: var(--accent-soft); }
.chip.role-executor { color: var(--warn); border-color: #ecd9a8; background: var(--warn-soft); }
.chip.role-external { color: var(--muted); background: var(--bg); }
.chip-link {
  display: inline-flex; padding: 3px 9px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 11.5px; color: var(--fg); background: var(--bg);
}
.chip-link:hover { border-color: var(--line); text-decoration: none; }

/* ── facts ──────────────────────────────────────────────────────────────── */
.fact-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--s4); margin-bottom: var(--s3);
}
.fact-grid > div {
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--s3) var(--s4); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.fact-grid .k {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
}
.fact-grid .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── buttons / forms ────────────────────────────────────────────────────── */
/* Единая высота кнопок во всех разделах (#94, п. 6): раньше .btn был 38 px,
   а .btn-sm — 44 px, из-за чего при переходах между экранами («Документооборот»
   → карточка проекта) кнопки «прыгали» по высоте. Высота 44 px сохранена по
   решению владельца в #48 (цель нажатия), .btn-sm отличается только
   внутренними отступами и размером шрифта. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--fg);
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1a4ab8; }
.btn-secondary { background: var(--surface); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--fg); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { color: var(--fg); background: var(--bg); }
/* Компактная кнопка — высота 44 px по решению владельца (Issue #48):
   30–32 px давали слишком маленькую цель нажатия, а в узкой ячейке
   таблицы подпись кнопки обрезалась до 37 px. min-width не даёт
   сетке/flex сжать её меньше текста; white-space: nowrap у .btn
   сохраняет подпись в одну строку. */
.btn-sm {
  height: 44px; padding: 0 12px; font-size: 12px;
  vertical-align: middle; min-width: max-content;
}

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.input {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); font: inherit; font-size: 13.5px;
}
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; padding-top: 2px; }

/* ── flash ──────────────────────────────────────────────────────────────── */
.flash {
  padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: var(--s4); font-size: 13px;
}
.flash.ok { background: var(--ok-soft); border-color: #bfe0cf; color: var(--ok); }
.flash.error { background: var(--danger-soft); border-color: #f0c2bd; color: var(--danger); }

/* ── timeline / lists ───────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: flex; justify-content: space-between; gap: var(--s4);
  padding: 10px 0; border-top: 1px solid var(--border);
}
.timeline li:first-child { border-top: 0; }
.timeline-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.timeline .sub { margin-top: 0; }
.member-list { list-style: none; margin: 0; padding: 0; }
.member-list li {
  display: flex; justify-content: space-between; gap: var(--s3);
  padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px;
}
.member-list li:first-child { border-top: 0; }
.plain-list { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.source-row {
  display: flex; gap: var(--s3); align-items: baseline;
  padding: 10px 0; border-top: 1px solid var(--border); font-size: 13px;
}
.source-row .k {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted); min-width: 96px;
}
.source-row .sub { display: inline; margin-left: 8px; }
.external { font-weight: 600; }

/* ── auth ───────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: var(--s6) var(--s4);
  background: radial-gradient(circle at 20% 0%, #eef3fd 0%, var(--bg) 55%);
}
.auth-card {
  width: min(480px, 100%); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(15, 26, 38, 0.08); padding: var(--s6);
}
.auth-brand { display: flex; align-items: center; gap: 9px; margin-bottom: var(--s5); }
.auth-card h1 { font-size: 25px; }
.auth-card .lead { margin: 8px 0 var(--s5); }
.auth-form { display: flex; flex-direction: column; gap: var(--s3); }
.auth-form .btn { margin-top: 4px; }
.demo-box {
  margin-top: var(--s5); padding: var(--s4); background: var(--bg);
  border: 1px dashed var(--line); border-radius: var(--radius-sm); font-size: 12px;
}
.demo-title {
  display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.demo-box ul { margin: 8px 0; padding-left: 18px; line-height: 1.7; }
.demo-note { color: var(--muted); }

@media (max-width: 980px) {
  .columns { grid-template-columns: minmax(0, 1fr); }
  .fact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-text { display: none; }
}
@media (max-width: 720px) {
  .topbar-inner { height: auto; padding: var(--s3) var(--s4); flex-wrap: wrap; gap: var(--s2); }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .wrap { padding: var(--s5) var(--s4) 48px; }
  h1 { font-size: 24px; }
  .fact-grid { grid-template-columns: minmax(0, 1fr); }
  .form { grid-template-columns: minmax(0, 1fr); }
  .table th, .table td { padding-left: var(--s3); padding-right: var(--s3); }
  .table th:nth-child(4), .table td:nth-child(4) { display: none; }
}

/* System audit: use the available desktop canvas while keeping the existing
   shell and page logic intact. */
.shell-main .wrap,
.shell-main .foot { max-width: min(1440px, calc(100vw - 236px)); }
.shell-main .wrap { width: 100%; }

@media (max-width: 900px) {
  .shell-main .wrap,
  .shell-main .foot { max-width: none; }
}

:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
