/* статистика по анкетам и фин.модель. Классы: st- — «Статистика» и общее, fm- — «Фин.модель». */

.st-busy { opacity: .6; }
.st-red, .tbl .num .st-red, .st-tile-num.st-red { color: var(--red); }
.st-wrap { overflow-wrap: anywhere; }
.st-h { font-size: 20px; }
.st .tabs { display: flex; }

/* ── панель периода ── */
.st-period { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 12px; }
.st-seg button { white-space: nowrap; }
.st-nav { display: flex; align-items: center; gap: 10px; min-width: 0; }
.st-nav .btn.icon { font-size: 22px; line-height: 1; }
.st-period-label { min-width: 190px; text-align: center; font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.st-nav.only-label .st-period-label { min-width: 0; text-align: left; color: var(--ink-2); }
.st-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.st-custom > span { color: var(--ink-3); font-size: 14px; }
.st-custom .inp { width: auto; min-width: 150px; }
.st-cost-nav { max-width: 420px; }
.st-cost-nav .st-period-label { flex: 1 1 auto; min-width: 0; }
.st-cost-lead { max-width: 90ch; }

/* ── плитки ── */
.st-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.st-tiles.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.st-tiles.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.st-tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.st-tile { position: relative; padding: 16px 18px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.st-tile.go:hover { border-color: var(--ink-3); }
.st-tile-name { font: 500 12px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); overflow-wrap: anywhere; }
.st-tile-go { padding: 0; border: 0; background: none; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; text-align: left; }
.st-tile-go::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: var(--r); }
.st-tile-go:focus-visible { outline: none; }
.st-tile-go:focus-visible::after { outline: 2px solid var(--blue); outline-offset: 2px; }
.st-tile-num { font: 700 28px/1.15 var(--display); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.st-tile-num.long { font-size: 22px; }
.st-tile-sub { font-size: 13.5px; line-height: 1.4; color: var(--ink-2); overflow-wrap: anywhere; }
.st-tile-sub .linkbtn { position: relative; z-index: 1; font-size: 13.5px; }
.st-tiles.six .st-tile { padding: 14px; }
.st-tiles.six .st-tile-num { font-size: 24px; }
.st-tiles.six .st-tile-num.long { font-size: 19px; }
.st-mark { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: var(--line); }
.st-mark.ok { background: var(--marker); }
.st-mark.wait { background: var(--sticky); box-shadow: inset 0 0 0 1px #d8b93a; }
.st-mark.no { background: var(--red); }

/* ── исходы пробных, метки ── */
.st-outcomes { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; padding: 14px 18px; }
.st-outcomes-side { font-size: 13.5px; color: var(--ink-2); }
.st-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.st-tags .tag { white-space: normal; line-height: 1.25; }
.tbl .sub .st-share { padding: 3px 7px; font-size: 11.5px; }
.tbl .sub .st-share.plain { padding: 0; border: 0; background: none; color: var(--ink-3); }

/* ── таблицы ── */
.st-tbl .sub { font-family: var(--display); font-weight: 400; white-space: normal; }
.st-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.st-name .linkbtn, .st-name .t { overflow-wrap: anywhere; }
.st-acc tbody tr { cursor: pointer; }
.st-acc tbody tr:hover td { background: var(--paper-2); }
.st-pick { max-width: 340px; }

/* ── числа в ряд ── */
.st-four { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.st-four.three { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 840px; }
.st-fact { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 10px 12px; min-width: 0; }
.st-fact b { display: block; font: 700 22px/1.2 var(--display); overflow-wrap: anywhere; }
.st-fact span { display: block; font-size: 13px; line-height: 1.3; color: var(--ink-2); }
.st-fact.ok { background: var(--marker-soft); border-color: transparent; }
.st-fact.ok b { color: var(--marker-ink); }
.st-fact.wait { background: var(--sticky-soft); border-color: transparent; }
.st-fact.no b { color: var(--red); }

/* ── график по дням ── */
.st-chart-box > * + * { margin-top: 10px; }
.st-chart-scroll { overflow-x: auto; }
.st-chart { display: flex; align-items: stretch; gap: 4px; min-width: 0; }
.st-chart.dense { gap: 2px; }
.st-chart.long { min-width: 760px; }
.st-col { flex: 1 1 0; min-width: 6px; display: flex; flex-direction: column; align-items: stretch; }
.st-col-n { min-height: 18px; font: 500 11px/18px var(--mono); color: var(--ink-2); text-align: center; white-space: nowrap; }
.st-chart.dense .st-col-n { display: none; }
.st-col-bars { position: relative; height: 130px; border-bottom: 1px solid var(--line); }
.st-bar-a, .st-bar-b { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 4px 4px 0 0; }
.st-bar-a { background: #C9D0C6; }
.st-bar-b { left: 22%; right: 22%; background: var(--marker); }
.st-col.today .st-col-bars { background: rgba(22, 155, 80, .08); }
.st-col.future { opacity: .4; }
.st-col-d { min-height: 18px; margin-top: 4px; font: 500 11px/1.3 var(--mono); color: var(--ink-3); text-align: center; white-space: nowrap; }
.st-col.today .st-col-d { color: var(--marker-ink); font-weight: 700; }
.st-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.st-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.st-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #C9D0C6; }
.st-key.b, .st-key.up { background: var(--marker); }
.st-key.down { background: var(--red); }
.st-key.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }

/* ── неделя плитками ── */
.st-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.st-day { padding: 12px; min-width: 0; }
.st-day.today { border-color: var(--marker); box-shadow: 0 0 0 1px var(--marker); }
.st-day.future { opacity: .5; }
.st-day-name { font: 500 12px/1.3 var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.st-day-n { font-size: 13px; color: var(--ink-2); }
.st-day-n b { font: 700 20px/1.25 var(--display); margin-right: 2px; }
.st-day-n.a b { color: var(--marker-ink); }
.st-day-n.b b { color: #9A7A00; }
.st-day-n.c b { color: var(--ink-3); }

/* ── окна ── */
.modal .box.st-box { width: min(900px, 100%); }
.st-box .box-head h2 { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; min-width: 0; }
.st-sec > * + * { margin-top: 8px; }
.st-sec h3 { font-size: 16px; }
.st-win p { overflow-wrap: anywhere; }
.st-un { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.st-un-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) auto auto; gap: 4px 14px; align-items: baseline; padding: 11px 14px; color: var(--ink); text-decoration: none; font-size: 15px; }
.st-un-row + .st-un-row { border-top: 1px solid var(--line); }
.st-un-row:hover { background: var(--paper-2); }
.st-un-row b, .st-un-row span { overflow-wrap: anywhere; min-width: 0; }

/* ── расходы ── */
.st-costs td { vertical-align: middle; }
.st-costs .st-amt { max-width: 170px; font-family: var(--mono); }
.st-costs td:nth-child(3) .inp { min-width: 180px; }
.st-costs .st-who { font-size: 13.5px; color: var(--ink-3); }
.st-costs .sub { max-width: 34ch; }
.st-cost-name { min-width: 200px; }
.st-btns { gap: 10px; }

/* ── фин.модель ── */
.fm-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; padding: 14px 16px; }
.fm-bar-pick { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; flex: 1 1 320px; min-width: 0; }
.fm-bar-pick .field { flex: 1 1 240px; max-width: 420px; }
.fm-bar-pick .tag { margin-bottom: 9px; }
.fm-bar-hint { flex: 1 0 100%; margin: 0; }
.fm-cols { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.fm-out { min-width: 0; }
.fm-out .tabs { display: flex; }
.fm-fields { min-width: 0; }
.fm-group { padding: 0; }
.fm-group > summary { cursor: pointer; padding: 14px 16px; font-weight: 650; font-size: 16px; border-radius: var(--r); }
.fm-group[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; }
.fm-group-body { padding: 16px; display: grid; gap: 16px; }
.fm-inp { display: flex; align-items: center; gap: 8px; }
.fm-inp .inp { flex: 1 1 auto; min-width: 0; max-width: 200px; font-family: var(--mono); font-size: 16px; }
.fm-inp select.inp { max-width: none; font-family: var(--display); }
.fm-inp .inp.bad { border-color: var(--red); }
.fm-unit { color: var(--ink-3); font-size: 14px; }
.fm-reset { font-size: 17px; color: var(--ink-2); }
.fm-quick { gap: 6px; margin-top: 8px; }
.fm-fact { margin-top: 6px; font-size: 13.5px; line-height: 1.4; color: var(--marker-ink); overflow-wrap: anywhere; }
.fm-fact.weak { color: var(--ink-3); }
.fm-fact .tag { padding: 3px 7px; font-size: 11px; }
.fm-fact .linkbtn { font-size: 13.5px; }
.fm-field .ferr { margin-top: 6px; }
.fm-months h3 { font-size: 16px; }
.fm-months-row > * + * { margin-top: 8px; }
.fm-months-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; font-size: 14.5px; }
.fm-months-head .linkbtn { font-size: 13.5px; }
.fm-months-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 6px; }
.fm-m { display: block; min-width: 0; }
.fm-m span { display: block; font: 500 11px/1.3 var(--mono); text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; text-align: center; }
.fm-m .inp { padding: 8px 2px; min-height: 40px; text-align: center; font-family: var(--mono); font-size: 16px; -moz-appearance: textfield; appearance: textfield; }
.fm-m .inp::-webkit-outer-spin-button, .fm-m .inp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fm-stale { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.fm-block h2 { font-size: 19px; }
.fm-block.good { background: var(--marker-soft); border-color: transparent; }
.fm-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.fm-two p { overflow-wrap: anywhere; }
.fm-hour td.fm-strong { color: var(--ink); font-weight: 700; }
.fm-lines { padding: 6px 18px; }
.fm-row { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 18px; padding: 10px 0; font-size: 15px; }
.fm-row + .fm-row { border-top: 1px solid var(--line); }
.fm-row span { min-width: 0; overflow-wrap: anywhere; }
.fm-row small { display: block; font-size: 13px; color: var(--ink-3); }
.fm-row b { white-space: nowrap; font: 600 14px/1.5 var(--mono); }
.fm-row.total { border-top: 2px solid var(--line); font-weight: 650; }
.fm-row.total b { font-size: 16px; }
.fm-row.total.neg b { color: var(--red); }
.fm-todo { margin: 0; padding-left: 20px; line-height: 1.7; }
.st-tile.wide-text .st-tile-num { font-size: 22px; }

/* график плана */
.fm-chart { position: relative; display: flex; align-items: stretch; }
.fm-col { flex: 1 1 0; min-width: 0; }
.fm-col-bars { position: relative; height: 210px; }
.fm-b { position: absolute; }
i.fm-b.up { left: 14%; width: 38%; background: var(--marker); border-radius: 4px 4px 0 0; }
i.fm-b.down { left: 14%; width: 38%; background: var(--red); border-radius: 0 0 4px 4px; }
i.fm-b.inv { left: 54%; width: 30%; background: #C9D0C6; border-radius: 0 0 4px 4px; }
.fm-dot { position: absolute; left: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--ink); z-index: 2; }
.fm-col-d { margin-top: 6px; font: 500 11px/1.3 var(--mono); color: var(--ink-3); text-align: center; }
.fm-col-d span { display: block; }
.fm-chart-area { position: absolute; top: 0; left: 0; right: 0; height: 210px; pointer-events: none; z-index: 1; }
.fm-zero { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--ink-3); }
.fm-line { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: visible; }
.fm-line polyline { fill: none; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }

/* таблица плана: прокрутка внутри своей области, первый столбец закреплён */
.fm-plan { font-size: 13.5px; }
.fm-plan th, .fm-plan td { white-space: nowrap; }
.fm-plan thead th { white-space: normal; min-width: 84px; }
.fm-plan .fm-first { position: sticky; left: 0; z-index: 1; min-width: 92px; text-align: left; background: var(--paper); border-right: 1px solid var(--line); font: 600 13.5px/1.5 var(--display); letter-spacing: 0; text-transform: none; color: var(--ink); }
.fm-plan thead .fm-first, .fm-plan tfoot .fm-first { background: var(--paper-2); }
.fm-plan tbody th { border-bottom: 1px solid var(--line); padding: 11px 10px 11px 14px; }
.fm-plan tfoot th { border-top: 2px solid var(--line); padding: 11px 10px 11px 14px; }

@media (max-width: 1500px) {
  .st-tiles.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .st-tiles.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .st-tiles, .st-tiles.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fm-cols { grid-template-columns: minmax(0, 1fr); }
  .fm-out { order: -1; }
  .st-week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1181px) {
  .fm-up { display: none; }
  .st-tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1700px) {
  .st-tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ── телефон ── */
@media (max-width: 700px) {
  .st-actions { width: 100%; }
  .st-actions .btn { flex: 1 1 auto; min-height: 44px; }
  .st-period { flex-direction: column; align-items: stretch; padding: 10px; }
  .st-seg { display: flex; }
  .st-seg button { flex: 1 1 0; min-height: 42px; padding: 8px 6px; }
  .st-nav { justify-content: space-between; }
  .st-period-label { min-width: 0; flex: 1 1 auto; }
  .st-custom { flex-direction: column; align-items: stretch; }
  .st-custom > span { margin-bottom: -4px; }
  .st-custom .inp, .st-custom .btn { width: 100%; font-size: 16px; }
  .st-custom .btn { min-height: 44px; }
  .st-tiles, .st-tiles.six, .st-tiles.five, .st-tiles.three, .st-tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .st-tile, .st-tiles.six .st-tile { padding: 12px; }
  .st-tile-num, .st-tiles.six .st-tile-num { font-size: 20px; }
  .st-tile-num.long, .st-tiles.six .st-tile-num.long, .st-tile.wide-text .st-tile-num { font-size: 17px; }
  .st-tile-name { font-size: 11px; letter-spacing: .03em; }
  .st-tile-sub { font-size: 12.5px; }
  .st-outcomes { padding: 12px; }
  .st-four, .st-four.three { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .st-week { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .st-pick { max-width: none; }
  .st-pick .inp { font-size: 16px; }
  .st-col-bars { height: 110px; }
  .st-chart.long { min-width: 0; }
  .st-chart.long .st-col { flex: 0 0 9px; }
  /* карточки вместо таблиц: название сверху, число под ним, дальше подписанные строки */
  .tbl.cards.sortable.st-tbl:not(.fm-hour) tbody td[data-label]:nth-child(2) { display: none; }
  .tbl.cards.st-tbl td:first-child { font-size: 16px; }
  .st-un-row { grid-template-columns: minmax(0, 1fr); }
  .tbl.cards.st-costs td[data-label]::before { margin-bottom: 4px; }
  .tbl.cards.st-costs .inp { width: 100%; max-width: none; min-width: 0; font-size: 16px; min-height: 44px; }
  .st-cost-name { min-width: 0; }
  .st-btns { flex-direction: column; align-items: stretch; }
  .st-btns .btn { width: 100%; min-height: 44px; }
  .st-win-btns .btn { flex: 1 1 auto; min-height: 44px; }
  .fm-bar { padding: 12px; }
  .fm-bar-pick .field { max-width: none; }
  .fm-bar-pick select.inp { font-size: 16px; }
  .fm-bar-btns { width: 100%; }
  .fm-bar-btns .btn:not(.icon) { flex: 1 1 auto; min-height: 44px; }
  .fm-bar-btns .btn.icon { min-height: 44px; width: 44px; }
  .fm-up { width: 100%; min-height: 44px; }
  .fm-two { grid-template-columns: minmax(0, 1fr); }
  .fm-lines { padding: 4px 14px; }
  .fm-group-body { padding: 14px 12px; }
  .fm-inp .inp { max-width: none; }
  .fm-plan .fm-first { min-width: 78px; }
  .fm-form form > .row .btn { flex: 1 1 auto; min-height: 44px; }
}
@media (max-width: 339px) {
  .st-tiles, .st-tiles.six, .st-tiles.five, .st-tiles.three, .st-tiles.four { grid-template-columns: minmax(0, 1fr); }
}
