:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1d2330; --muted: #6b7384; --line: #e2e5eb;
  --accent: #2455d6; --accent-soft: #e8eefc; --ok: #1f8a4c; --ok-soft: #e3f4ea;
  --warn: #b36b00; --warn-soft: #fdf1dc; --bad: #c0392b; --bad-soft: #fbe6e3;
  --radius: 8px; font-size: 14px;
}
* { box-sizing: border-box; }
/* атрибут hidden скрывает всегда: иначе .bar, .grid и другие правила с display его перекрывают */
[hidden] { display: none !important; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.side { width: 230px; background: #1b2233; color: #c9cfdb; padding: 16px 0; flex-shrink: 0; }
.side .brand { color: #fff; font-weight: 600; font-size: 16px; padding: 0 20px 4px; }
.side .sub { font-size: 12px; color: #8b93a7; padding: 0 20px 16px; border-bottom: 1px solid #2c3550; margin-bottom: 8px; }
.side .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6f7892; padding: 14px 20px 6px; }
.side a { display: block; color: #c9cfdb; padding: 7px 20px; }
.side a:hover { background: #242d44; text-decoration: none; color: #fff; }
.side a.on { background: #2b3552; color: #fff; border-left: 3px solid #5b8cff; padding-left: 17px; }
.main { flex: 1; padding: 14px 22px 32px; min-width: 0; }
h1 { font-size: 20px; margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 15.5px; margin: 0 0 8px; font-weight: 600; }
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.bar .grow { flex: 1; }
/* шапка раздела: название, период и фильтры — одной строкой (замечания 10, 12); «?» — справка раздела (И5) */
.bar > h1 { font-size: 19px; margin: 0; }
.bar:has(> form) > h1, .bar:has(> form) > h1.grow { flex: 0 1 auto; white-space: nowrap; }
.bar > form { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 0; }
.bar:has(> h1) > form { flex: 1 1 auto; }
.bar select { width: auto; max-width: 280px; }
.bar input[type=date], .bar input[type=month] { width: auto; }
.bar > form input:not([type=checkbox]):not([type=radio]), .bar > form select { padding: 5px 7px; }
.bar > form label { display: inline-flex; align-items: center; gap: 4px; margin: 0; color: var(--text); font-size: 12.5px; white-space: nowrap; }
.bar > form .btn { padding: 5px 12px; }
label.radio-line { display: flex; gap: 8px; align-items: center; margin: 4px 0; color: var(--text); font-size: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; align-items: start; }
.grid2 > * { min-width: 0; }
.grid2 label > .bar { display: flex; }
.grid2 label > .bar > input { flex: 1; min-width: 0; width: 100%; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 20px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
table.t { width: 100%; border-collapse: collapse; background: var(--panel); }
table.t th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; background: #fafbfc; }
table.t td { border-bottom: 1px solid var(--line); padding: 5px 8px; vertical-align: top; }
table.t tr:hover td { background: #fafbff; }
table.t .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tfoot td { font-weight: 600; background: #fafbfc; }
.wrap-table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.wrap-table table.t { border: 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 6px; padding: 5px 12px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { background: #f1f3f7; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1c46b8; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eef0f4; color: var(--muted); white-space: nowrap; }
.badge.paid { background: var(--ok-soft); color: var(--ok); }
.badge.partial, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.issued { background: var(--accent-soft); color: var(--accent); }
.badge.cancelled, .badge.bad { background: var(--bad-soft); color: var(--bad); }
form.f { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 8px 14px; }
form.f .full, .full { grid-column: 1 / -1; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { width: 100%; max-width: 100%; font: inherit; padding: 5px 8px; border: 1px solid #cfd4dd; border-radius: 6px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; flex: 0 0 auto; }
fieldset { min-width: 0; }
textarea { min-height: 60px; }
.items input, .items select { padding: 5px 7px; }
.items td { padding: 4px 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.alert { border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; }
.alert.warn { background: var(--warn-soft); color: #6d4300; }
.alert.ok { background: var(--ok-soft); color: #145c33; }
.alert.info { background: var(--accent-soft); color: #173a91; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs a { padding: 4px 11px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tabs a .n { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 3px; border-radius: 9px; background: var(--bg, #f1f3f6); color: var(--muted); font-size: 12px; text-align: center; }
.tabs a.on .n { background: rgba(255,255,255,.22); color: #fff; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
.progress { height: 8px; background: #eef0f4; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; background: var(--accent); }
.progress.warn div { background: var(--warn); }
.progress.bad div { background: var(--bad); }
iframe.preview { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.imgprev { max-height: 90px; border: 1px dashed var(--line); padding: 4px; background: #fff; border-radius: 6px; }
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .side { width: 100%; padding: 10px 0 0; }
  .side > :not(.brand) { display: none; }
  .side.open > :not(.brand) { display: block; }
  .side .menu-btn { display: inline-block; }
  .main { padding: 12px; }
  .two { grid-template-columns: minmax(0, 1fr); }
}

.chat .msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; }
.chat .msg.user { background: var(--accent-soft); margin-left: 15%; }
.chat .msg.assistant { background: #f6f7f9; margin-right: 10%; }
.chat .who { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.chat .body { white-space: pre-wrap; }
.chat .body.formatted { white-space: normal; line-height: 1.6; overflow-wrap: anywhere; }
.chat .formatted > :first-child { margin-top: 0; }
.chat .formatted > :last-child { margin-bottom: 12px; }
.chat .formatted p { margin: 0 0 10px; }
.chat .formatted h1, .chat .formatted h2, .chat .formatted h3,
.chat .formatted h4, .chat .formatted h5, .chat .formatted h6 { font-size: 1.08em; line-height: 1.4; margin: 18px 0 8px; }
.chat .formatted ul, .chat .formatted ol { padding-left: 24px; margin: 6px 0 12px; }
.chat .formatted li { margin: 4px 0; }
.chat .formatted li > p { margin: 4px 0; }
.chat .formatted blockquote { border-left: 3px solid var(--accent); margin: 12px 0; padding: 2px 12px; color: var(--muted); }
.chat .formatted code { background: #e8edf2; border-radius: 4px; padding: 1px 4px; font-size: .9em; }
.chat .formatted pre { max-width: 100%; overflow-x: auto; padding: 12px; border-radius: 8px; background: #e8edf2; white-space: pre; }
.chat .formatted pre code { padding: 0; background: none; }
.chat .chat-table { max-width: 100%; overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: 8px; }
.chat .chat-table:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat .chat-table table { border-collapse: collapse; width: 100%; font-size: .95em; }
.chat .chat-table th, .chat .chat-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; min-width: 100px; }
.chat .chat-table th { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.chat .chat-table tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 600px) { .chat .msg.assistant { margin-right: 0; } .chat .msg.user { margin-left: 6%; } }
.offer { border-left: 3px solid var(--accent); }
.side .soon { display: block; color: #5d6680; padding: 5px 20px; font-size: 13px; }
.side .soon::after { content: " · скоро"; font-size: 11px; }
/* ---- v2: юрлица, меню, авторизация ---- */
.entity-switch { padding: 0 14px 10px; border-bottom: 1px solid #2c3550; margin-bottom: 4px; }
.entity-switch select { background: #242d44; color: #fff; border-color: #36405e; font-size: 13px; }
.nbadge { background: #e5484d; color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.nbadge.err { background: transparent; color: #e5484d; border: 1.5px solid #e5484d; font-weight: 700; }   /* проверка не выполнилась */
.linkbtn { background: none; border: 0; color: #9fb5ff; padding: 0; cursor: pointer; font: inherit; margin-top: 4px; }
main .linkbtn { color: var(--accent); }
main .linkbtn:hover { text-decoration: underline; }
.auth { max-width: 380px; margin: 10vh auto; }
.auth h1 { text-align: center; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.mt { margin-top: 12px; }
table.t.matrix td, table.t.matrix th { white-space: nowrap; }
table.t tr.sec td { background: #eef2fb; font-weight: 600; }
table.t tr.sub td { font-weight: 600; }
table.t tr.tot td { background: #fafbfc; font-weight: 700; border-top: 2px solid var(--line); }
table.t tr.group-row td { background: #f4f6fb; border-top: 1px solid var(--line); }
table.t td.lvl1 { padding-left: 24px; } table.t td.lvl2 { padding-left: 40px; } table.t td.lvl3 { padding-left: 56px; } table.t td.lvl4 { padding-left: 72px; }
.chip { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #eef0f4; color: var(--muted); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.review select { padding: 4px 6px; font-size: 13px; }
.bars { display: flex; gap: 14px; align-items: flex-end; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 130px; }
.bars .pair div { width: 16px; border-radius: 3px 3px 0 0; }
.bars .inc { background: #2f9e62; } .bars .exp { background: #d9534f; }
.token { font-family: Consolas, monospace; background: #fff8e1; padding: 10px; border-radius: 6px; word-break: break-all; }
code { background: #f1f3f7; padding: 1px 5px; border-radius: 4px; }
pre.code { font-family: Consolas, monospace; font-size: 12px; background: #f4f5f7; padding: 10px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 6px 0; }

/* дополнительные поля */
fieldset.cf { border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 14px 0; min-width: 0; }
fieldset.cf legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.cf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 8px 14px; }
.cf-check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); margin-top: 18px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }

/* аудит */
.audit-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 18px; }
.audit-item { border-bottom: 1px solid var(--line); }
.audit-item:last-child { border-bottom: 0; }
.audit-item summary { display: grid; grid-template-columns: 26px minmax(180px, 1fr) 2fr; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; list-style: none; }
.audit-item summary::-webkit-details-marker { display: none; }
.audit-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.audit-item.ok .audit-dot { background: var(--ok-soft); color: var(--ok); }
.audit-item.warn .audit-dot { background: var(--warn-soft); color: var(--warn); }
.audit-item.fail .audit-dot { background: var(--bad-soft); color: var(--bad); }
.audit-title { font-weight: 600; }
.audit-sum { color: var(--muted); font-size: 13px; }
.audit-item.fail .audit-sum { color: var(--bad); }
.audit-body { padding: 0 14px 12px 50px; }
.audit-body ul { margin: 6px 0; padding-left: 18px; }
@media (max-width: 700px) { .audit-item summary { grid-template-columns: 26px 1fr; } .audit-sum { grid-column: 2; } }

/* меню: разделы раскрываются по нажатию */
.side .brand { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; }
.menu-btn { display: none; background: #242d44; color: #fff; border: 1px solid #36405e; border-radius: 6px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.ng-top { padding: 6px 0; border-bottom: 1px solid #2c3550; margin-bottom: 4px; }
.side details.ng > summary { list-style: none; cursor: pointer; padding: 9px 20px; color: #e3e7ef; font-weight: 600; font-size: 13.5px;
  display: flex; align-items: center; gap: 6px; user-select: none; }
.side details.ng > summary::-webkit-details-marker { display: none; }
.side details.ng > summary::after { content: "›"; margin-left: auto; color: #6f7892; transition: transform .15s; font-size: 16px; }
.side details.ng[open] > summary::after { transform: rotate(90deg); }
.side details.ng > summary:hover { background: #242d44; }
.side details.ng[open] > summary .nbadge { display: none; }
.side .ng-body { padding-bottom: 6px; }
.side .ng-body a { padding: 6px 20px 6px 32px; font-size: 13.5px; }
.side .ng-body a.on { padding-left: 29px; }

/* дашборд: что сделать */
.todo { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin-bottom: 12px; }
.todo-title { width: 100%; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.todo-item { display: flex; gap: 10px; align-items: center; padding: 7px 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); color: var(--text); text-decoration: none; }
.todo-item:hover { text-decoration: none; border-color: var(--accent); }
.todo-item b { font-size: 20px; }
.todo-item.warn b { color: var(--warn); }
.todo-item.bad b { color: var(--bad); }

/* пояснения на страницах — свёрнуты, раскрываются по нажатию */
details.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
details.hint > summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--accent); list-style: none; }
details.hint > summary::-webkit-details-marker { display: none; }
details.hint > summary::before { content: "i"; width: 16px; height: 16px; border-radius: 50%; border: 1px solid currentColor;
  display: inline-grid; place-items: center; font: 600 10px/1 Georgia, serif; }
details.hint[open] > div { margin-top: 6px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); line-height: 1.5; max-width: 900px; }

/* готовая настройка агента после выпуска токена — заметная панель, а не строка текста */
details.agent-setup { margin-top: 12px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent-soft); }
details.agent-setup > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 4px 8px; padding: 10px 14px; color: var(--text); }
details.agent-setup > summary::-webkit-details-marker { display: none; }
details.agent-setup > summary::before { content: "▸"; color: var(--accent); font-size: 14px; transition: transform .15s; }
details.agent-setup > summary:hover { background: #dbe6fc; }
details.agent-setup > summary .as-sub { font-weight: 400; font-size: 12.5px; color: var(--muted); }
details.agent-setup[open] > summary::before { transform: rotate(90deg); }
details.agent-setup[open] > summary { border-bottom: 1px solid #c8d6f6; }
details.agent-setup > .as-body { padding: 10px 14px 12px; background: var(--panel); border-radius: 0 0 var(--radius) var(--radius); }

/* архив отозванных токенов — спокойная сворачиваемая панель под таблицей */
details.arch { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fafbfc; }
details.arch > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; color: var(--muted); font-size: 13px; }
details.arch > summary::-webkit-details-marker { display: none; }
details.arch > summary::before { content: "▸"; font-size: 12px; transition: transform .15s; }
details.arch[open] > summary::before { transform: rotate(90deg); }
details.arch > summary b { color: var(--text); font-weight: 600; }
details.arch > summary .arch-n { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: #eef0f4; color: var(--muted); font-size: 12px; text-align: center; }
details.arch > .arch-body { padding: 0 10px 10px; }

/* широкие отчёты по месяцам: первая колонка (названия строк) и шапка закреплены */
.wrap-table:has(table.matrix) { max-height: calc(100vh - 170px); overflow: auto; }
table.matrix th:first-child, table.matrix td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel);
  box-shadow: 1px 0 0 var(--line); min-width: 240px; }
table.matrix tr:hover td:first-child { background: #fafbff; }
table.matrix thead th { position: sticky; top: 0; z-index: 2; background: #fafbfc; }
table.matrix thead th:first-child { z-index: 3; }

/* платёжный календарь: сетка по дням */
.cp-wrap { max-height: calc(100vh - 150px); }
table.cp td, table.cp th { padding: 5px 7px; font-size: 12.5px; }
table.cp th:first-child, table.cp td:first-child { min-width: 250px; max-width: 320px; white-space: normal; }
table.cp .nm { cursor: default; }
table.cp tr[data-id] .nm { cursor: pointer; }
table.cp .tg { display: inline-block; width: 14px; color: var(--muted); transition: transform .12s; }
table.cp tr.open > .nm .tg { transform: rotate(90deg); }
table.cp tr.lv1 td { font-weight: 600; }
table.cp tr.lv2 td { color: #3b4254; }
table.cp tr.lv3 td { color: var(--muted); font-size: 12px; }
table.cp tr.sec td { background: #f4f6fa; font-weight: 700; }
table.cp tr.sec.inc td:first-child, table.cp tr.sec.exp td:first-child { background: #f4f6fa; }
table.cp tr.bal td { background: #eef2fb; font-weight: 700; }
table.cp tr.bal td:first-child { background: #eef2fb; }
table.cp .td-today { background: #fff8e1 !important; }
table.cp .td-we { background: #fafafa; }
table.cp i.pl { color: var(--accent); }
table.cp .sum { border-left: 1px solid var(--line); }

/* выбор юрлиц (несколько) */
details.entity-switch { margin: 0 14px 10px; border: 1px solid #36405e; border-radius: 6px; background: #242d44; }
details.entity-switch > summary { list-style: none; cursor: pointer; padding: 7px 10px; color: #fff; font-size: 13px; }
details.entity-switch > summary::after { content: "▾"; float: right; color: #8b93a7; }
details.entity-switch > summary::-webkit-details-marker { display: none; }
details.entity-switch form { padding: 4px 10px 10px; border-top: 1px solid #36405e; }
.ent-opt { display: flex; gap: 8px; align-items: center; color: #c9cfdb; font-size: 13px; margin: 6px 0; cursor: pointer; }
.ent-btns { display: flex; gap: 6px; margin-top: 8px; }
.ent-note { font-size: 11px; color: #8b93a7; margin-top: 8px; line-height: 1.35; }
.side .entity-switch { padding: 0; }

/* выбор компании для документов и налогов */
.focus-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; margin: -8px 0 16px;
  background: #fff8e1; border: 1px solid #f1dfa6; border-radius: var(--radius); font-size: 13px; }
.focus-bar > span:first-of-type { font-weight: 600; margin-right: 4px; }

/* показатели в карточках (займы) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.kpi { background: var(--card, #fff); border: 1px solid var(--line, #e3e6ec); border-radius: var(--radius); padding: 10px 12px; }
.kpi b { font-size: 17px; }
.chip.bad { background: #fdecec; color: #b42318; }

/* всплывающее окно операции */
body.embed .side, body.embed .focus-bar { display: none !important; }
body.embed .layout { display: block; }
body.embed .main { padding: 14px 18px; max-width: none; }
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1000; display: flex; align-items: flex-start;
  justify-content: center; padding: 3vh 12px; }
.modal-box { background: var(--card, #fff); border-radius: 12px; width: min(1100px, 100%); height: 94vh; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; }
.modal-box iframe { width: 100%; height: 100%; border: 0; }
.modal-close { position: absolute; top: 8px; right: 10px; z-index: 2; border: 0; background: #eef0f4; border-radius: 8px;
  width: 32px; height: 32px; font-size: 18px; cursor: pointer; }
.alloc-table input, .alloc-table select { padding: 4px 6px; }

/* подсказка при наведении: карточка проекта / сделки */
.hov { position: relative; border-bottom: 1px dashed #9aa3b2; cursor: default; }
.hov-pop { display: none; position: absolute; left: 0; top: 100%; z-index: 50; background: #fff; border: 1px solid #e3e6ec;
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 8px 12px; white-space: nowrap; margin-top: 2px; }
.hov-pop b, .hov-pop a, .hov-pop span { display: block; }
.hov:hover .hov-pop, .hov:focus-within .hov-pop { display: block; }


table.matrix th.hist, table.matrix td.hist { background: #fdf3dc !important; }
table.matrix tr.tot td.hist, table.matrix tr.sub td.hist { background: #f8e6bd !important; }
.hist-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #f8e6bd; border: 1px solid #e5c98a; vertical-align: -2px; }
.hist-tag { font-size: 9px; font-weight: 500; color: #b36b00; white-space: nowrap; }
.tax-from { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius); }

/* ---------- значок состояния (замечание 36, вариант А): вместо ✅ ✓ ⚠ ⬜ — static/page-tools.js ---------- */
.ico { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.22em; overflow: hidden; color: transparent; line-height: 1;
  font-size: inherit; text-indent: 0; background: center / contain no-repeat; user-select: none; flex: 0 0 auto; }
.ico.ok { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8' fill='%23e3f4ea'/%3E%3Cpath d='M4.7 8.2 7 10.5l4.3-4.8' fill='none' stroke='%231f8a4c' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.ico.warn { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8' fill='%23fdf1dc'/%3E%3Cpath d='M8 4.3v4.6' stroke='%23b36b00' stroke-width='1.8' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11.4' r='1' fill='%23b36b00'/%3E%3C/svg%3E"); }
.ico.bad { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8' fill='%23fbe6e3'/%3E%3Cpath d='m5.4 5.4 5.2 5.2m0-5.2-5.2 5.2' stroke='%23c0392b' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico.todo { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7.1' fill='none' stroke='%239aa3b2' stroke-width='1.5'/%3E%3C/svg%3E"); }
.ico.opt { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7.1' fill='none' stroke='%239aa3b2' stroke-width='1.5' stroke-dasharray='2.2 2'/%3E%3C/svg%3E"); }
.ico.lg { width: 20px; height: 20px; }
.btn .ico, .chip .ico, .badge .ico { width: 1.1em; height: 1.1em; }

/* ---------- пояснение, свёрнутое в одну строку (замечание 2): «i начало текста…», раскрывается щелчком ---------- */
details.hint.auto { margin: 0 0 8px; max-width: 100%; min-width: 0; }
details.hint.auto > summary { display: flex; min-width: 0; color: var(--muted); }
details.hint.auto > summary::before { color: var(--accent); flex: 0 0 auto; }
details.hint.auto > summary:hover { color: var(--text); }
.hint-peek { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
details.hint.auto[open] > summary .hint-peek { display: none; }
details.hint.auto[open] > summary::after { content: none; }
details.hint.auto > .hint-text { display: block; margin: 6px 0 0; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); line-height: 1.5; max-width: 900px; font-size: 12.5px; color: var(--muted); }
.card > details.hint.auto:last-child, form > details.hint.auto:last-child { margin-bottom: 0; }
body.hints-off .ent-note { display: none; }

/* ---------- таблицы: сортировка по заголовку и фильтр-воронка (замечание 25) — static/page-tools.js ---------- */
table.t th.tt-sort { cursor: pointer; user-select: none; }
table.t th.tt-filter { position: relative; padding-right: 30px; }
table.t th.tt-filter > .tt-f { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); margin: 0; }
@media (pointer: coarse) { table.t th.tt-filter { padding-right: 38px; } }
table.t th.tt-sort:hover { color: var(--text); }
table.t th.tt-asc::after, table.t th.tt-desc::after { content: "▲"; font-size: 9px; margin-left: 4px; color: var(--accent); vertical-align: 1px; }
table.t th.tt-desc::after { content: "▼"; }
.tt-f { display: inline-grid; place-items: center; width: 18px; height: 18px; margin: -2px 0 -3px 3px; padding: 0; border: 0; border-radius: 4px;
  background: none; color: var(--muted); cursor: pointer; opacity: .3; vertical-align: middle; }
.tt-f svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
table.t th:hover .tt-f, .tt-f:focus-visible, .tt-f[aria-expanded="true"] { opacity: 1; }
.tt-f:hover { background: var(--accent-soft); color: var(--accent); }
table.t th.tt-on .tt-f { opacity: 1; color: #fff; background: var(--accent); }
table.t th.tt-on .tt-f svg { fill: currentColor; }
@media (pointer: coarse) { .tt-f { opacity: .7; width: 26px; height: 26px; } }
table.t tr.tt-hide { display: none !important; }
table.t tfoot tr.tt-sum td { background: var(--accent-soft); color: #173a91; font-weight: 600; }
.tt-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 0 0 6px; font-size: 12.5px; color: var(--muted); }
.tt-bar .linkbtn { margin: 0; color: var(--accent); }
.tt-pop { position: absolute; z-index: 90; width: 280px; max-width: calc(100vw - 16px); padding: 10px; display: grid; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(16, 24, 42, .16); font-size: 13px; }
.tt-pop-sort { display: flex; gap: 6px; }
.tt-pop-sort .btn { flex: 1; justify-content: center; }
.tt-vals { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.tt-vals label { display: flex; gap: 6px; align-items: center; margin: 0; padding: 3px 0; color: var(--text); font-size: 13px; cursor: pointer; }
.tt-vals label span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-vals label i { font-style: normal; color: var(--muted); font-size: 11.5px; }
.tt-pop-foot { display: flex; gap: 6px; justify-content: flex-end; }
.tt-scroll { overflow-x: auto; max-width: 100%; }
/* телефон: поля форм — в одну колонку, «на две колонки» не раздвигает форму шире экрана (замечание 26, перенесено из этапа 1) */
@media (max-width: 640px) {
  form.f > *, .cf-grid > *, [style*="grid-column: span"], [style*="grid-column:span"] { grid-column: 1 / -1 !important; }
  form.f, .cf-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .kv { grid-template-columns: minmax(0, 40%) minmax(0, 1fr); }
  .card { padding: 10px 12px; }
  .bar > h1, .bar > h1.grow { white-space: normal !important; min-width: 0; flex: 1 1 100% !important; }
  .bar-more-pop { max-width: calc(100vw - 24px); }
  .bar-more-pop label { white-space: normal !important; }
  .btn { white-space: normal; max-width: 100%; }
}
/* плотные таблицы (замечание 26): серый вторичный текст в ячейке — одной строкой, полностью — при наведении (static/page-tools.js) */
table.t td > div.muted, table.t td > div.small.muted { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1;
  overflow: hidden; line-height: 1.3; word-break: break-word; }
table.t td { line-height: 1.35; }
table.t td.nw, table.t th.nw { white-space: nowrap; }   /* короткие названия (юрлицо) — без переноса */
table.t td > div.muted.l2 { -webkit-line-clamp: 2; line-clamp: 2; min-width: 160px; }   /* назначение платежа — до двух строк */
/* строка действий над длинным списком — закреплена при прокрутке, одна кнопка вместо двух (сверху и снизу) */
.bar.sticky-actions { position: sticky; top: 0; z-index: 6; margin: 0 -4px 8px; padding: 6px 4px; background: var(--bg); }
/* список «За период» у дат отчёта (page-tools.js) */
select.period-pick { width: auto; max-width: 100%; }
/* Стиль компании «на всю программу» (замечание 18, решение Р5): html.ui-<код>, цвета — как у стилей дашборда (static/dash.css) */
html.ui-light { --bg:#f3f2f1; --panel:#fff; --line:#e1dfdd; --text:#252423; --muted:#605e5c; --accent:#118dff; --accent-soft:#eef5fd;
  --ok:#107c10; --bad:#d13438; --warn:#a17f00; --radius:3px; }
html.ui-fin { --bg:#f6f7fb; --panel:#fff; --line:#eceef4; --text:#111827; --muted:#6b7280; --accent:#4f46e5; --accent-soft:#eef2ff;
  --ok:#059669; --bad:#e11d48; --warn:#d97706; --radius:12px; }
html.ui-biz { --bg:#fbfbfa; --panel:#fff; --line:#d9dde3; --text:#0f1b2d; --muted:#5b6575; --accent:#0f3d6e; --accent-soft:#e8eef6;
  --ok:#166534; --bad:#b91c1c; --warn:#a16207; --radius:4px; }
html.ui-warm { --bg:#f7f3ec; --panel:#fffdf9; --line:#e8dfd1; --text:#2b2620; --muted:#7a6f61; --accent:#2f7d5b; --accent-soft:#e9f2ec;
  --ok:#2f7d5b; --bad:#b4442c; --warn:#b7791f; --radius:10px; }
html.ui-fin .card { box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 14px rgba(16,24,40,.06); }
html.ui-warm .card { box-shadow: 0 1px 3px rgba(60,40,10,.06); }
html[class*="ui-"] .btn.primary:hover { background: var(--accent); filter: brightness(.9); }
html[class*="ui-"] table.t tr.sec td { background: var(--accent-soft); }

/* токены API: права по областям (Замечания 1, этап 6) */
.tok-areas { border-collapse: collapse; }
.tok-areas td { padding: 3px 14px 3px 0; white-space: nowrap; }
.tok-areas label { display: inline-flex; align-items: center; gap: 4px; font-weight: normal; margin: 0; }

/* ЭДО: параметры одного оператора сгруппированы, узкий экран — одна колонка. */
.edo-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px 20px; }
.edo-fields > div { min-width:0; }
.edo-fields .edo-wide { grid-column:1 / -1; }
@media (max-width:760px) { .edo-fields { grid-template-columns:minmax(0,1fr); } }

/* История выписок: годы и месяцы раскрываются отдельно. */
#import-history .history-year { margin: 10px 0; }
#import-history .history-month { margin: 8px 0 8px 18px; }
#import-history .history-month > summary { cursor: pointer; margin-bottom: 8px; }

/* Карточки пресетов: описание занимает свободное место, действия выровнены в строке. */
.preset-grid { grid-template-columns:repeat(auto-fit,minmax(235px,1fr)); gap:16px; }
.preset-card { display:flex; flex-direction:column; gap:10px; min-width:0; }
.preset-card .preset-description { flex:1; }
.security-section > summary { cursor:pointer; font-size:1.05rem; }
.security-section[open] > summary { margin-bottom:16px; }
.security-subsection { margin-top:16px; padding-top:12px; border-top:1px solid var(--border, #e5ded3); }
.security-subsection > summary { cursor:pointer; }
#journal td { vertical-align:top; overflow-wrap:anywhere; }
.preset-card .preset-action .btn { width:100%; box-sizing:border-box; text-align:center; }
.preset-card > .small.mt { margin-top:0; min-height:3.2em; }
@supports (grid-template-rows:subgrid) {
  .preset-card { display:grid; grid-template-rows:subgrid; grid-row:span 4; }
}
