/* Бухгалтерия · «Сводка руководству» (NIPI-056): страница, форма дня, виджет и график.
   Цвета серий проверены на различимость (в т. ч. при нарушениях цветового зрения) и контраст ≥ 3:1
   к светлой и тёмной поверхности; текст использует цвета темы (--text, --muted), а не цвета серий. */
:root { --cs-in: #3a6fd8; --cs-out: #d97706; }
[data-theme="dark"], .theme-dark, .dark { --cs-in: #5b8def; --cs-out: #d97706; }

.cash-summary { display: flex; flex-direction: column; gap: 20px; }
.cash-summary .num, .cs-widget .num, .cs-day-detail .num, .cs-day-form .num, #modal-body .cs-table .num { text-align: right; white-space: nowrap; }
.cs-period { align-items: center; }
.cs-period label, .cs-other-day { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.cs-period input, .cs-other-day input { min-width: 0; }
.cs-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cs-check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.cs-hint p { margin: 0; color: var(--muted); }

.cs-totals, .cs-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.cs-kpi { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.cs-kpi-label { font-size: 13px; color: var(--muted); }
.cs-kpi-value { font-size: 20px; font-weight: 700; color: var(--text); display: flex; flex-direction: column; }
.cs-money { display: block; }
.cs-kpi > span:not(.cs-kpi-label):not(.cs-kpi-value) { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 14px; }
.cs-kpi > span .cs-money { display: inline; font-weight: 600; }
.cs-neg { color: var(--danger); }
.cs-accounts summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.cs-accounts ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.cs-accounts li { display: flex; justify-content: space-between; gap: 10px; }

/* Легенда и график: тонкие столбцы, скругление со стороны значения, сетка приглушена */
.cs-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.cs-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cs-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: baseline; flex-shrink: 0; }
.cs-swatch.cs-in { background: var(--cs-in); }
.cs-swatch.cs-out { background: var(--cs-out); }
.cs-chart-wrap { min-width: 0; }
.cs-chart-box { position: relative; }
.cs-chart { display: block; width: 100%; height: auto; overflow: visible; }
.cs-chart .cs-grid { stroke: var(--border); stroke-width: 1; }
.cs-chart .cs-axis { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.cs-chart .cs-tick { fill: var(--muted); font-size: 11px; font-family: inherit; }
.cs-chart .cs-bar.cs-in { fill: var(--cs-in); }
.cs-chart .cs-bar.cs-out { fill: var(--cs-out); }
.cs-chart .cs-hit { fill: transparent; }
.cs-chart .cs-day { cursor: pointer; outline: none; }
.cs-chart .cs-day:hover .cs-hit, .cs-chart .cs-day:focus .cs-hit { fill: var(--muted); fill-opacity: .08; }
.cs-chart .cs-day.selected .cs-hit { fill: var(--primary); fill-opacity: .12; }
.cs-chart .cs-day:focus-visible .cs-hit { stroke: var(--primary); stroke-width: 1.5; }
.cs-chart .cs-empty-dot { fill: var(--muted); opacity: .5; }
.cs-tooltip { position: absolute; top: 0; transform: translateX(-50%); pointer-events: none; z-index: 2; min-width: 150px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14); font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
.cs-tooltip b { margin-left: 4px; }

.cs-detail { margin-top: 12px; }
.cs-detail > .btn { margin-top: 8px; }
.cs-day-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.cs-day-head .cs-money { display: inline; margin-left: 4px; }
.cs-entries-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.cs-entries h4, .cs-subtitle { font-size: 14px; margin: 0 0 6px; }
.cs-subtitle { margin-top: 18px; }
.cs-entries table td, .cs-table td { padding: 6px 8px; }
.cs-entries tfoot td, .cs-table tfoot td, .cs-form-table tfoot td { font-weight: 700; border-bottom: none; }
.cs-unrecorded td { color: var(--muted); }

/* Форма дня */
.cs-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.cs-section { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px 6px; margin: 0; min-width: 0; }
.cs-section legend { font-weight: 700; padding: 0 6px; display: inline-flex; align-items: center; }
.cs-form-table { width: 100%; table-layout: fixed; }
.cs-form-table th, .cs-form-table td { padding: 4px 6px; }
.cs-form-table th { white-space: normal; }
.cs-form-table input, .cs-form-table select { width: 100%; min-width: 0; }
.cs-section .cs-form-table th:nth-child(2) { width: 28%; }
.cs-section .cs-form-table th:nth-child(3) { width: 25%; }
.cs-section .cs-form-table th:last-child { width: 40px; }
.cs-section .cs-form-table tfoot td:first-child { overflow: visible; white-space: nowrap; }
.cs-balances th:nth-child(2), .cs-balances th:nth-child(4) { width: 22%; }
.cs-balances th:nth-child(3) { width: 24%; }
.cs-day-form input.invalid { border-color: var(--danger); }
.cs-day-totals { display: flex; gap: 20px; flex-wrap: wrap; margin: 14px 0 4px; font-size: 14px; }
.cs-day-totals .cs-money { display: inline; }
.cs-sum .cs-money { display: inline; margin-left: 4px; }
.cs-day-form > label { display: block; margin-top: 16px; }
.cs-delete { margin-right: auto; }

.cs-widget .card-header { margin-bottom: 10px; }
@media (max-width: 640px) {
  .cs-section .cs-form-table th:nth-child(3) { width: 30%; }
}

/* Подсказки контрагентов (NIPI-059): список в document.body, position: fixed — не обрезается таблицей и окном */
.cs-suggest { position: fixed; z-index: 70; overflow-y: auto; overscroll-behavior: contain; padding: 4px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18); -webkit-overflow-scrolling: touch; }
.cs-suggest-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; cursor: pointer; min-height: 40px; justify-content: center; }
.cs-suggest-item:hover { background: var(--bg); }
.cs-suggest-item[aria-selected="true"] { background: var(--primary); color: #fff; }
.cs-suggest-item[aria-selected="true"] .cs-suggest-meta { color: inherit; opacity: .85; }
.cs-suggest-name { font-weight: 600; overflow-wrap: anywhere; }
.cs-suggest-meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.cs-suggest-inactive .cs-suggest-name { opacity: .7; }
.cs-day-form input.cs-linked, .cs-day-form input[name=label][title] { border-left: 3px solid var(--primary); }
