/* Казна города (public/treasury.php, js/pages/treasury.js) */

.trs {
    --trs-card: var(--card-bg, #141419);
    --trs-border: var(--border-color, #22222b);
    --trs-soft: var(--hover-bg-color, #1c1c24);
    --trs-text: var(--text-color, #fff);
    --trs-muted: var(--text-muted, #8b8b98);
    --trs-accent: var(--primary-color, #6a5aff);
    --trs-accent-soft: color-mix(in srgb, var(--trs-accent) 14%, transparent);
    --trs-up: var(--success-color, #28c76f);
    --trs-down: var(--error-color, #ea5455);
    --trs-grid: color-mix(in srgb, var(--trs-border) 70%, transparent);

    max-width: var(--page-max);
    margin: 0 auto;
    padding: 26px var(--page-pad) 44px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: var(--trs-text);
}

.trs h1, .trs h2 { font-weight: normal; margin: 0; }
.trs-muted { color: var(--trs-muted); font-size: 13px; margin: 0; }
.trs-card { background: var(--trs-card); border: 1px solid var(--trs-border); border-radius: 18px; }
.trs-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.trs-card-head h2 { font-size: 18px; }
.trs a:focus-visible, .trs button:focus-visible, .trs-svg:focus-visible { outline: 2px solid var(--trs-accent); outline-offset: 2px; }
.is-up { color: var(--trs-up); }
.is-down { color: var(--trs-down); }

.trs-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.trs-head h1 { font-size: 30px; }

/* Цифры: бюджет крупно, рядом движение за месяц */
.trs-kpis { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); gap: 12px; }
.trs-kpi, .trs-hero { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.trs-lbl { font-size: 13px; color: var(--trs-muted); display: inline-flex; align-items: center; gap: 6px; }
.trs-lbl i { font-size: 11px; }
.trs-kpi b { font-weight: normal; font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trs-hero { background: color-mix(in srgb, var(--trs-accent) 7%, var(--trs-card)); border-color: color-mix(in srgb, var(--trs-accent) 30%, var(--trs-border)); }
.trs-hero-value { font-weight: normal; font-size: 44px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* График */
.trs-chart-card { padding: 18px 20px 14px; display: flex; flex-direction: column; gap: 12px; }
.trs-range { display: flex; padding: 3px; border-radius: 10px; border: 1px solid var(--trs-border); }
.trs-range button { padding: 5px 12px; border: 0; border-radius: 7px; background: none; color: var(--trs-muted); font: inherit; font-size: 13px; cursor: pointer; }
.trs-range button.is-on { background: var(--trs-soft); color: var(--trs-text); }
.trs-chart { position: relative; min-height: 200px; }
.trs-svg { display: block; touch-action: pan-y; }
.trs-grid { stroke: var(--trs-grid); stroke-width: 1; }
.trs-axis { stroke: var(--trs-border); stroke-width: 1; }
.trs-tick { fill: var(--trs-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.trs-line { fill: none; stroke: var(--trs-accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trs-area { fill: var(--trs-accent); fill-opacity: 0.1; stroke: none; }
.trs-dot { fill: var(--trs-accent); stroke: var(--trs-card); stroke-width: 2; }
.trs-cross { stroke: var(--trs-muted); stroke-width: 1; }
.trs-tip {
    position: absolute; pointer-events: none; z-index: 2;
    padding: 8px 10px; border-radius: 10px; border: 1px solid var(--trs-border);
    background: var(--trs-card); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    font-size: 12px; white-space: nowrap;
}
.trs-tip b { display: block; font-weight: normal; font-size: 15px; margin: 2px 0; }
.trs-tip-date, .trs-tip-ch { color: var(--trs-muted); }
.trs-tip-ch.is-up { color: var(--trs-up); }
.trs-tip-ch.is-down { color: var(--trs-down); }

.trs-table-toggle summary { cursor: pointer; font-size: 13px; color: var(--trs-muted); }
.trs-table-wrap { max-height: 240px; overflow: auto; margin-top: 8px; }
.trs-table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.trs-table-wrap th, .trs-table-wrap td { padding: 6px 10px; border-bottom: 1px solid var(--trs-border); text-align: right; }
.trs-table-wrap th:first-child, .trs-table-wrap td:first-child { text-align: left; }
.trs-table-wrap th { font-weight: normal; color: var(--trs-muted); position: sticky; top: 0; background: var(--trs-card); }

/* История и боковая колонка */
.trs-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.trs-history { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.trs-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trs-tabs { display: flex; padding: 3px; border-radius: 10px; border: 1px solid var(--trs-border); }
.trs-tabs a { padding: 6px 12px; border-radius: 7px; color: var(--trs-muted); font-size: 13px; text-decoration: none; }
.trs-tabs a:hover { color: var(--trs-text); }
.trs-tabs a.is-on { background: var(--trs-accent); color: #fff; }
.trs-search { margin: 0 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 0 12px; width: 240px; box-sizing: border-box; border-radius: 10px; border: 1px solid var(--trs-border); color: var(--trs-muted); font-size: 13px; }
.trs-search:focus-within { border-color: var(--trs-accent); }
.trs-search input { flex: 1; min-width: 0; width: 100%; padding: 8px 0; border: 0; outline: 0; background: none; color: var(--trs-text); font: inherit; font-size: 14px; }

.trs-list { display: flex; flex-direction: column; }
.trs-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--trs-border); }
.trs-row:first-child { border-top: 0; }
.trs-who img { width: 34px; height: 34px; border-radius: 9px; display: block; object-fit: cover; image-rendering: pixelated; background: var(--trs-soft); }
.trs-row-main { flex: 1; min-width: 0; }
.trs-row-main b { display: block; font-weight: normal; font-size: 14px; overflow-wrap: anywhere; }
.trs-row-main small { font-size: 12px; color: var(--trs-muted); }
.trs-amount { flex-shrink: 0; font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.trs-empty { margin: 0; padding: 24px; text-align: center; color: var(--trs-muted); border: 1px dashed var(--trs-border); border-radius: 12px; }
.trs-more { align-self: center; padding: 9px 18px; border-radius: 10px; border: 1px solid var(--trs-border); background: var(--trs-soft); color: var(--trs-text); font-size: 14px; text-decoration: none; }
.trs-more:hover { border-color: var(--trs-accent); }
.trs-more.is-loading { opacity: 0.6; pointer-events: none; }

.trs-side { display: flex; flex-direction: column; gap: 16px; }
.trs-mini { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.trs-mini h2 { font-size: 16px; margin-bottom: 2px; }
.trs-top { display: flex; align-items: center; gap: 10px; padding: 5px 6px; margin: 0 -6px; border-radius: 10px; color: inherit; text-decoration: none; font-size: 14px; }
.trs-top:hover { background: var(--trs-soft); }
.trs-top img { width: 28px; height: 28px; border-radius: 7px; image-rendering: pixelated; }
.trs-top-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trs-top-sum { color: var(--trs-muted); white-space: nowrap; font-size: 13px; }
.trs-place { width: 22px; height: 22px; flex-shrink: 0; border-radius: 6px; display: flex; align-items: center; justify-content: center; background: var(--trs-soft); color: var(--trs-muted); font-size: 12px; }
.trs-place-1 { background: color-mix(in srgb, #f5b82e 20%, transparent); color: #d99a0b; }
.trs-place-2 { background: color-mix(in srgb, #a7b0be 22%, transparent); color: #8892a0; }
.trs-place-3 { background: color-mix(in srgb, #c97b4a 20%, transparent); color: #b8693a; }
.trs-exp { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.trs-exp span { min-width: 0; overflow-wrap: anywhere; }
.trs-exp small { display: block; font-size: 12px; color: var(--trs-muted); }
.trs-exp b { font-weight: normal; white-space: nowrap; color: var(--trs-down); }

@media (max-width: 1100px) {
    .trs-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .trs-hero { grid-column: 1 / -1; }
    .trs-grid { grid-template-columns: minmax(0, 1fr); }
    .trs-side { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
    .trs { padding: 16px var(--page-pad) 30px; gap: 12px; }
    .trs-head h1 { font-size: 24px; }
    .trs-kpis { grid-template-columns: 1fr 1fr; }
    .trs-kpis .trs-kpi:last-child { grid-column: 1 / -1; }
    .trs-hero-value { font-size: 34px; }
    .trs-kpi b { font-size: 19px; }
    .trs-chart-card, .trs-history, .trs-mini { padding: 14px; }
    .trs-search { margin-left: 0; width: 100%; }
    .trs-tabs { width: 100%; }
    .trs-tabs a { flex: 1; text-align: center; }
    .trs-side { grid-template-columns: 1fr; }
}
