/* Оформление в духе Финтабло: светло-сиреневый фон, белые панели, синий акцент */

:root {
    --bg: #eff0f8;
    --panel: #ffffff;
    --border: #e4e6f2;
    --text: #2c2f45;
    --muted: #8b90a8;
    --accent: #4a5bc4;
    --accent-soft: #eceefb;
    --accent-dark: #3b4aa3;
    --income: #1f9d67;
    --outcome: #d9534f;
    --transfer: #7a6ff0;
    --row-hover: #f7f8fd;
    --shadow: 0 1px 3px rgba(44, 47, 69, .06), 0 6px 20px rgba(44, 47, 69, .04);
    --radius: 10px;
    --sidebar: 208px;
}

/* Половина «Люди» живёт на том же скине, но со своим акцентом: по цвету меню
   сразу видно, смотришь ты на деньги по банку или на людей по журналу записей. */
body.section-people {
    --accent: #1f8f6a;
    --accent-soft: #e5f4ee;
    --accent-dark: #17714f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- каркас ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    flex: 0 0 var(--sidebar);
    background: var(--panel);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding-bottom: 24px;
}

/* Граница между меню и содержимым: её можно тянуть мышкой.
   Названия отчётов в разделе «Люди» длинные и переносятся в две строки —
   одной ширины на оба раздела не хватает, поэтому её выбирает человек,
   а выбор запоминается в браузере (см. static/layout.js). */
.sidebar-resizer {
    flex: 0 0 5px;
    position: sticky;
    top: 0;
    height: 100vh;
    cursor: col-resize;
    background: var(--border);
    background-clip: content-box;
    border-left: 2px solid transparent;
    border-right: 2px solid transparent;
    transition: background-color .12s;
    z-index: 25;
}

.sidebar-resizer:hover,
.sidebar-resizer.dragging { background-color: var(--accent); }

/* Пока тянут — курсор не должен превращаться в текстовый над таблицами,
   а выделение текста мешает попасть в нужную ширину. */
body.resizing { cursor: col-resize; user-select: none; }

.logo {
    display: flex; align-items: center; gap: 8px;
    padding: 16px 18px; font-weight: 700; font-size: 17px; color: var(--accent);
}
.logo .mark {
    width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
    color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center;
}

.switch-section {
    display: flex; gap: 4px; margin: 4px 14px 10px; padding: 3px;
    background: #f0f1f8; border-radius: 9px;
}
.switch-section a {
    flex: 1; text-align: center; padding: 6px 0; border-radius: 7px;
    font-size: 13.5px; color: var(--muted); font-weight: 500;
}
.switch-section a:hover { color: var(--text); text-decoration: none; }
.switch-section a.active {
    background: #fff; color: var(--accent); font-weight: 600;
    box-shadow: 0 1px 2px rgba(44, 47, 69, .12);
}

.nav-group { margin-top: 6px; }
.nav-title {
    padding: 9px 18px; color: var(--text); font-weight: 600; font-size: 13px;
    display: flex; align-items: center; gap: 8px;
}
.nav a {
    display: block; padding: 7px 18px 7px 40px; color: var(--text);
    font-size: 13.5px; border-left: 3px solid transparent;
}
.nav a:hover { background: var(--row-hover); text-decoration: none; }
.nav a.active {
    color: var(--accent); background: var(--accent-soft);
    border-left-color: var(--accent); font-weight: 600;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--panel); border-bottom: 1px solid var(--border);
    padding: 11px 24px; display: flex; align-items: center; gap: 20px;
    position: sticky; top: 0; z-index: 20;
}
.topbar .biz { color: var(--muted); font-size: 13px; }
.topbar .money { font-size: 17px; font-weight: 600; margin-left: auto; }
.topbar .money small { color: var(--muted); font-weight: 400; font-size: 12px; display: block; }

.content { padding: 22px 24px 60px; }

h1 { font-size: 25px; margin: 0 0 18px; font-weight: 600; }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 600; }

/* ---------- панели ---------- */

.panel {
    background: var(--panel); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.panel.tight { padding: 12px 16px; }
.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 16px; }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card .label { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.card .value { font-size: 21px; font-weight: 600; }

/* ---------- элементы управления ---------- */

.btn {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    border: 1px solid var(--border); background: var(--panel); color: var(--text);
    padding: 7px 14px; border-radius: 8px; font-size: 13.5px; font-family: inherit;
    text-decoration: none;
}
.btn:hover { background: var(--row-hover); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-income { background: var(--income); border-color: var(--income); color: #fff; }
.btn-outcome { background: var(--outcome); border-color: var(--outcome); color: #fff; }
.btn-transfer { background: var(--transfer); border-color: var(--transfer); color: #fff; }
.btn-income:hover, .btn-outcome:hover, .btn-transfer:hover { opacity: .9; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a {
    padding: 6px 14px; border-radius: 8px; color: var(--text); font-size: 13.5px;
    border: 1px solid transparent;
}
.tabs a:hover { background: var(--row-hover); text-decoration: none; }
.tabs a.active { background: var(--accent); color: #fff; }

input[type=text], input[type=date], input[type=number], input[type=month],
input[type=password], select, textarea {
    border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
    font: inherit; font-size: 13.5px; color: var(--text); background: #fff;
    max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 3px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { display: flex; flex-direction: column; }

/* ---------- таблицы ---------- */

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
    text-align: right; color: var(--muted); font-weight: 500; font-size: 11.5px;
    text-transform: uppercase; letter-spacing: .03em;
    padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.grid th:first-child, table.grid td:first-child { text-align: left; }
table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
table.grid tbody tr:hover { background: var(--row-hover); }
table.grid td.text, table.grid th.text { text-align: left; white-space: normal; }

.num { font-variant-numeric: tabular-nums; }
.income { color: var(--income); }
.outcome { color: var(--outcome); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.badge {
    display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 11.5px;
    background: var(--accent-soft); color: var(--accent-dark);
}
.badge.warn { background: #fdf0e3; color: #b4700f; }
.badge.grey { background: #f0f1f6; color: var(--muted); }

/* важность отклонения: красный — смотреть сразу, жёлтый — при разборе месяца */
.badge.sev-high { background: #fdeaea; color: #b02a2a; }
.badge.sev-medium { background: #fdf0e3; color: #b4700f; }
.badge.sev-low { background: #f0f1f6; color: var(--muted); }

.alert-row td { vertical-align: top; padding-top: 10px; padding-bottom: 10px; }
.alert-row .badge { margin-right: 6px; }

button.mini {
    font: inherit; font-size: 12.5px; padding: 4px 10px; margin-right: 4px;
    border: 1px solid var(--border); border-radius: 7px;
    background: #fff; color: var(--text); cursor: pointer;
}
button.mini:hover { background: var(--accent-soft); border-color: transparent; }

.inline-form { display: inline-flex; gap: 8px; align-items: center; }

/* ---------- отчёты ---------- */

table.report { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.report th {
    position: sticky; top: 0; background: var(--panel); z-index: 2;
    text-align: right; color: var(--muted); font-weight: 500; font-size: 11.5px;
    text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.report th:first-child { text-align: left; left: 0; z-index: 3; min-width: 280px; }
table.report td { padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid #f2f3fa; }
table.report td:first-child {
    text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 1;
}
table.report tr:hover td { background: var(--row-hover); }
table.report tr.group > td { font-weight: 600; }
table.report tr.subtotal > td, table.report tr.total > td {
    background: #f7f8fd; font-weight: 600; border-top: 1px solid var(--border);
}
table.report tr.subtotal td:first-child, table.report tr.total td:first-child { background: #f7f8fd; }
table.report tr.total > td { font-size: 14.5px; }
table.report tr.ratio td { color: var(--muted); font-size: 12.5px; }
table.report tr.ratio td:first-child { padding-left: 26px; }
table.report .lvl1 td:first-child { padding-left: 30px; font-weight: 400; }
table.report .lvl2 td:first-child { padding-left: 48px; font-weight: 400; }
table.report .lvl3 td:first-child { padding-left: 66px; font-weight: 400; }

.zero { color: #c9cbd8; }

/* редактируемая ячейка: выглядит как текст, списком становится по клику */
.cell-edit {
    display: inline-block; border: 1px solid transparent; padding: 2px 6px;
    border-radius: 6px; cursor: pointer; min-width: 90px;
}
.cell-edit:hover { border-color: var(--border); background: #fff; }
.cell-edit.unset { color: #b4700f; background: #fdf6ec; }
.cell-edit.saved { border-color: var(--income); background: #eaf7f0; }
.cell-edit.failed { border-color: var(--outcome); background: #fdecec; }
select.cell-select { max-width: 260px; font-size: 13px; padding: 2px 4px; }

/* ---------- вспомогательное ---------- */

.pagination { display: flex; gap: 6px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 5px 10px; border-radius: 7px; border: 1px solid var(--border);
    background: #fff; font-size: 13px;
}
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

.empty { padding: 40px; text-align: center; color: var(--muted); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13.5px; }
.flash.ok { background: #e8f7ef; color: #1a7a4f; }
.flash.err { background: #fdeceb; color: #a8322e; }

.dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius); padding: 34px;
    text-align: center; color: var(--muted); background: #fbfbfe;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- панель управления отчётом ---------- */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

.period-nav { display: flex; align-items: center; gap: 2px; position: relative; }
.period-nav .step {
    width: 28px; height: 32px; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 8px; color: var(--muted);
    background: #fff; text-decoration: none; font-size: 16px;
}
.period-nav .step:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.period-btn {
    background: var(--accent-soft); border: 1px solid transparent; color: var(--accent-dark);
    font: inherit; font-weight: 600; font-size: 13.5px; padding: 7px 16px;
    border-radius: 8px; cursor: pointer; min-width: 150px;
}
.period-btn:hover { background: #e2e5f9; }

.period-menu {
    display: none; position: absolute; top: 40px; left: 30px; z-index: 40;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 10px 30px rgba(44, 47, 69, .16); min-width: 240px; padding: 6px;
}
.period-menu.open { display: block; }
.period-menu .presets { display: flex; flex-direction: column; }
.period-menu .presets a {
    padding: 7px 12px; border-radius: 7px; color: var(--text); font-size: 13.5px;
}
.period-menu .presets a:hover { background: var(--row-hover); text-decoration: none; }
.period-custom {
    display: flex; align-items: center; gap: 6px; padding: 10px 8px 4px;
    border-top: 1px solid var(--border); margin-top: 6px;
}
.period-custom input[type=date] { width: 130px; }

.icon-btn {
    width: 34px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer;
    color: var(--muted); font-size: 15px; text-decoration: none; position: relative;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.icon-btn sup { color: var(--accent); font-size: 18px; line-height: 0; }

.inline-form { display: inline-flex; }
.inline-check { color: var(--text); font-size: 13px; display: flex; align-items: center; gap: 5px; }

.tabs-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.filters-box {
    background: #fafbfe; border: 1px solid var(--border); border-radius: 10px;
    padding: 12px 14px; margin-bottom: 14px;
}
.filters-box.hidden { display: none; }

/* ---------- модальное окно ---------- */

.modal {
    display: none; position: fixed; inset: 0; z-index: 100;
    background: rgba(44, 47, 69, .35); align-items: center; justify-content: center;
}
.modal.open { display: flex; }
.modal-box {
    background: #fff; border-radius: 12px; padding: 22px 24px; width: min(520px, 92vw);
    box-shadow: 0 20px 60px rgba(44, 47, 69, .25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.modal-foot { margin-top: 18px; display: flex; align-items: center; gap: 12px; }
.check-row {
    display: flex; align-items: center; gap: 9px; padding: 9px 0;
    color: var(--text); font-size: 13.5px; margin: 0; cursor: pointer;
    border-bottom: 1px solid #f2f3fa;
}

/* ---------- сворачивание групп ---------- */

tr.toggler > td:first-child, tr.row-toggler > td:first-child { cursor: pointer; }
.caret {
    display: inline-block; width: 0; height: 0; margin-right: 8px; vertical-align: middle;
    border-left: 5px solid var(--muted); border-top: 4px solid transparent;
    border-bottom: 4px solid transparent; transform: rotate(90deg);
    transition: transform .12s;
}
tr.collapsed .caret { transform: rotate(0deg); }

.pct { display: block; font-size: 11px; color: var(--muted); }

/* сумма-ссылка: открывает операции, из которых она сложилась */
a.drill { color: inherit; text-decoration: none; border-bottom: 1px dashed transparent; }
a.drill:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }

/* ---------- готовность правил зарплаты ---------- */

.rules-readiness {
    margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 12.5px;
}
.rules-readiness.ok { background: #f4f8f4; border: 1px solid #dbe7db; }
.rules-readiness.wait { background: #fdf6ec; border: 1px solid #f0e0c8; }

/* ---------- сверка выручки под ОПиУ ---------- */

/* Плашка стоит под таблицей, а не над ней: сначала цифры прибыли, за которыми
   пришли, потом оговорка о том, сколько из них дошло до счёта. */
.revenue-check {
    margin-top: 14px; padding: 12px 14px; border-radius: 10px;
    font-size: 13px; line-height: 1.5;
}
.revenue-check.ok { background: #f4f8f4; border: 1px solid #dbe7db; }
.revenue-check.alarm { background: #fdeaea; border: 1px solid #f2cdcd; }
.revenue-check.alarm b { color: #b02a2a; }
.revenue-check .muted { font-size: 12px; margin-top: 6px; }
.revenue-check-list { margin: 8px 0 0; padding-left: 20px; }
.revenue-check-list li { margin-bottom: 3px; }
.revenue-check-note { border-top: 1px solid rgba(0, 0, 0, .07); padding-top: 8px; }

/* ---------- тумблер и инструкция ---------- */

.instruction-toggle {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 16px 0 10px; color: var(--text); font-size: 13.5px;
}
.switch {
    width: 40px; height: 22px; border-radius: 20px; border: 0; background: #d3d6e6;
    position: relative; cursor: pointer; padding: 0; transition: background .15s;
}
.switch i {
    position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
    background: #fff; border-radius: 50%; transition: left .15s;
}
.switch.on { background: var(--accent); }
.switch.on i { left: 21px; }

.instruction .lead { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.instruction-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px;
}
.instruction-block h3 { font-size: 14px; margin: 0 0 8px; }
.instruction-block ul { margin: 0; padding-left: 18px; }
.instruction-block li { margin-bottom: 6px; font-size: 13px; color: #4a4e69; }

/* ---------- закрытие месяца ---------- */

.close-progress { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.close-progress .bar {
    width: 180px; height: 8px; border-radius: 6px; background: var(--border); overflow: hidden;
}
.close-progress .bar i { display: block; height: 100%; background: var(--income); }

.task-list { display: flex; flex-direction: column; }
.task {
    display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid #f2f3fa;
    align-items: flex-start;
}
.task:last-child { border-bottom: 0; }
.task-check input { width: 17px; height: 17px; cursor: pointer; margin-top: 2px; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 14px; }
.task-done .task-title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.task-hint { color: #4a4e69; font-size: 12.5px; margin-top: 4px; }
.task-meta {
    display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px;
    font-size: 11.5px; color: var(--muted);
}
.task-auto {
    margin-top: 8px; font-size: 12.5px; padding: 6px 10px; border-radius: 7px;
    display: inline-block;
}
.task-count {
    display: inline-block; min-width: 40px; text-align: center; font-size: 11.5px;
    padding: 2px 6px; border-radius: 20px; background: #f0f1f6; color: var(--muted);
}
.task-count.full { background: #eaf7f0; color: #1a7a4f; }

.direction-marks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.direction-marks .mark {
    display: inline-flex; align-items: center; gap: 5px; margin: 0;
    padding: 3px 10px 3px 7px; border: 1px solid var(--border); border-radius: 20px;
    font-size: 12px; color: var(--text); cursor: pointer; background: #fff;
}
.direction-marks .mark:hover { border-color: var(--accent); }
.direction-marks .mark.on { background: #eaf7f0; border-color: #a8dcc0; color: #1a7a4f; }
.direction-marks input { width: 13px; height: 13px; cursor: pointer; }

.task-auto.ok { background: #eaf7f0; color: #1a7a4f; }
.task-auto.bad { background: #fdf0e3; color: #b4700f; }
.task-auto a { margin-left: 6px; }

/* простая столбчатая диаграмма без внешних библиотек */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-col .bars {
    flex: 1; width: 100%; display: flex; align-items: flex-end;
    justify-content: center; gap: 3px;
}
.chart .bar { width: 44%; max-width: 26px; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .bar-in { background: var(--income); opacity: .85; }
.chart .bar-out { background: var(--outcome); opacity: .75; }
.chart-col:hover .bar { opacity: 1; }
.chart-label { font-size: 11px; color: var(--muted); padding-top: 6px; }
.legend-dot {
    display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px;
}
.legend-dot.in { background: var(--income); }
.legend-dot.out { background: var(--outcome); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* Кто вошёл — правый угол шапки. Имя видно всегда: в журнале действий
   подписывается именно оно, и человек должен понимать, под кем работает. */
.whoami { display: flex; align-items: center; gap: 14px; margin-left: 22px; font-size: 13px; }
.whoami .who { line-height: 1.25; font-weight: 600; }
.whoami .who small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.whoami a { color: var(--muted); }
.whoami a:hover { color: var(--accent); }

/* Кнопка, выглядящая ссылкой: форма нужна ради POST, а рисовать её кнопкой
   в плотной таблице незачем. */
button.link {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--accent); font: inherit; font-size: 12.5px;
}
button.link:hover { text-decoration: underline; }

/* Таблица «свойство — значение» в профиле: заголовки слева и обычным
   текстом, иначе колонка подписей выглядит как шапка отчёта. */
table.grid.props th {
    text-align: left; text-transform: none; letter-spacing: 0;
    font-size: 12.5px; width: 45%; font-weight: 400;
}
table.grid.props td { text-align: left; }

/* Платёжный календарь: дни — колонки, время идёт слева направо.
   Тридцать одна колонка не помещается в экран, поэтому таблица прокручивается
   вбок, а колонка с названием строки остаётся приклеенной — иначе, доехав
   до 25-го числа, не понять, чей это остаток. */
table.calendar-grid { font-size: 12px; white-space: nowrap; }
table.calendar-grid th, table.calendar-grid td { padding: 4px 6px; }
table.calendar-grid .sticky-col {
    position: sticky; left: 0; z-index: 2;
    background: #fff; text-align: left; min-width: 180px;
    box-shadow: 1px 0 0 var(--line);
}
table.calendar-grid thead .sticky-col, table.calendar-grid .group .sticky-col {
    background: var(--head-bg, #f6f7fb);
}
/* сегодняшний день — вертикальная линия, по ней видно границу факта и прогноза */
table.calendar-grid .is-today { box-shadow: inset 2px 0 0 var(--accent); }
table.calendar-grid .is-weekend { background: #fafbfd; }
/* провал: столько на счёте не будет */
table.calendar-grid .short { background: #fdecec; color: #a8323b; font-weight: 600; }

/* ---------- финансовый директор ---------- */

/* Окно ФД: разговор занимает главную колонку, всё вспомогательное — узкую
   боковую. На узком экране колонки складываются в одну, разговор остаётся
   первым: за ним сюда и приходят. */
.fd-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
@media (max-width: 1100px) { .fd-layout { grid-template-columns: 1fr; } }

.fd-chat { display: flex; flex-direction: column; gap: 14px; }
.fd-msg { border-radius: 10px; padding: 12px 14px; }
.fd-user { background: var(--accent-soft); }
.fd-fd { background: var(--row-hover); border: 1px solid var(--border); }
.fd-error { background: #fdecec; color: #a8323b; }
.fd-who {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); margin-bottom: 6px;
}
.fd-who .muted { text-transform: none; letter-spacing: 0; }

.fd-body > *:first-child { margin-top: 0; }
.fd-body > *:last-child { margin-bottom: 0; }
.fd-body p { margin: 8px 0; }
.fd-body h3, .fd-body h4, .fd-body h5 { margin: 14px 0 6px; font-size: 15px; }
.fd-body ul, .fd-body ol { margin: 8px 0; padding-left: 22px; }
.fd-body li { margin: 3px 0; }
.fd-body code { background: #f0f1f6; border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.fd-body pre { background: #f7f8fd; border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.fd-body pre code { background: none; padding: 0; }
.fd-body table { margin: 10px 0; }
/* таблица в ответе не должна распирать страницу вбок */
.fd-body table { display: block; max-width: 100%; overflow-x: auto; }
.fd-report { font-size: 14.5px; }

.fd-ask textarea {
    width: 100%; border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 12px; font: inherit; resize: vertical;
}
.fd-ask textarea:focus { outline: none; border-color: var(--accent); }

.fd-side .panel { margin-bottom: 14px; }
.fd-side h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); margin: 0 0 8px; }
.fd-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.fd-list li { padding: 4px 0; border-top: 1px solid var(--border); }
.fd-list li:first-child { border-top: none; }
.fd-list .muted { font-size: 11.5px; margin-left: 4px; }
.fd-current > a { font-weight: 600; }

/* Кто делает задачу чек-листа: цвет отвечает на вопрос «это навсегда или
   пока». Серое — работа человека по существу, синее — недоделка программы. */
.badge.fd-kind-hands { background: #f0f1f6; color: #5c6178; }
.badge.fd-kind-part { background: #eef6ff; color: #2a6099; }
.badge.fd-kind-auto { background: #e8f7ef; color: #1a7a4f; }
.badge.fd-kind-todo { background: #fdf0e3; color: #b4700f; }
.badge.fd-kind-fd { background: var(--accent-soft); color: var(--accent-dark); }

/* Подпись-кнопка вместо системного поля файла: то показывает «Файл не выбран»
   и не поддаётся оформлению ни в одном браузере. */
.fd-file-btn { display: inline-flex; align-items: center; cursor: pointer; }
.fd-file-name { margin-left: 8px; }

/* Кружок ожидания. Нужен там, где страница честно ждёт ответа минуту-полторы:
   без движения на экране это неотличимо от «кнопка не нажалась». */
.spinner {
    display: inline-block; width: 12px; height: 12px; vertical-align: -1px;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: spin .7s linear infinite; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.fd-wait { display: none; align-items: center; }

/* Ответ после перезагрузки не должен оказываться под шапкой */
#last { scroll-margin-top: 24px; }
