/* Редизайн кабінету «Термінал» (IFMT-6925, інкремент 5): «Аналітика» — вкладки, період, «Огляд», графіки, таблиці.
   Джерело — еталон prototype v7.10: assets/app.css (.tabs, .an-*, .chart*, .legend, .sw*, .delta, .money-*, .income-ledger, .il-*).
   Класи ті самі, що в еталоні; область дії — .rd, rem — еталон × 1,6 (корінь кабінету 10px), як у components.css. */

/* ——— Вкладки (roving tabindex) ——— */
.rd .tabs { display: flex; gap: .4rem; border-bottom: 1px solid var(--line); margin-bottom: var(--s-4); overflow-x: auto; scrollbar-width: none; }
.rd .tabs::-webkit-scrollbar { display: none; }
.rd .tabs [role="tab"] { border: 0; background: none; font: 500 var(--t-m)/1.2 var(--font); color: var(--ink-3); padding: 1.2rem 1.4rem; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; border-radius: 0; }
.rd .tabs [role="tab"]:hover { color: var(--ink); }
.rd .tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--action); }
.rd .tabs [role="tab"]:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-s); }

/* ——— Період ——— */
.rd .an-period { margin-top: var(--s-5); margin-bottom: var(--s-4); padding-bottom: var(--s-1); }
.rd .an-period-row { display: flex; align-items: center; gap: var(--s-2) var(--s-3); flex-wrap: wrap; margin-bottom: .8rem; }
.rd .an-period-l { font-size: var(--t-s); font-weight: 500; color: var(--ink-2); }
.rd .an-custom { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.rd .an-custom label { margin: 0; }
.rd .an-custom input[type="date"] { width: auto; }
.rd .an-custom-error { flex-basis: 100%; margin-top: 0; }
.rd .an-notice { margin-bottom: var(--s-4); }
.rd .an-notice .notice-body p { margin: .4rem 0 0; }
.rd .an-tab-text { margin-bottom: 1.2rem; }

/* ——— Суми й порівняння ——— */
.rd .money-label { font-size: var(--t-l); color: var(--ink-2); font-weight: 500; }
.rd .label-note { display: block; font-size: var(--t-xs); color: var(--ink-3); margin-top: .2rem; font-weight: 400; }
.rd .money-value { font-size: min(clamp(3.2rem, 3.4vw, var(--t-money)), 10cqi); font-weight: 700; letter-spacing: -.03em; line-height: 1.05; margin: 1rem 0 1.2rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd .money-value .cur { font-size: .5em; font-weight: 500; letter-spacing: 0; color: var(--ink-2); margin-left: .6rem; }
.rd .delta { display: inline-flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-weight: 500; color: var(--ink-2); }
.rd .delta .icon { display: inline; vertical-align: -3px; margin-right: .2rem; }
.rd .delta > span[aria-hidden] { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0 .4rem; }
.rd .delta-main { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0 .6rem; }
.rd .delta.up { color: var(--ok-text); }
.rd .delta.down { color: var(--danger); }
.rd .delta.flat { color: var(--ink-3); }
.rd .delta-abs { font-weight: 400; }
.rd .delta-dark.up { color: #B9E39C; }
.rd .delta-dark.down { color: #FFB4B8; }
.rd .delta-dark.flat { color: var(--deep-muted); }

/* ——— «Огляд» ——— */
.rd .an-hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--s-5); margin-bottom: var(--s-5); }
.rd .an-gross { padding: var(--s-6); background: var(--canvas); border-radius: var(--r-l); container-type: inline-size; }
.rd .an-compare { display: flex; align-items: center; gap: .4rem 1rem; flex-wrap: wrap; }
.rd .an-help-btn { min-width: 2.8rem; min-height: 2.8rem; width: 2.8rem; height: 2.8rem; padding: 0; color: var(--ink-3); }
.rd .an-help-text { margin-top: .8rem; color: var(--ink-2); max-width: 60ch; }
.rd .an-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); margin: var(--s-5) 0 0; padding-top: var(--s-4); border-top: 1px solid var(--line); }
.rd .an-kpis dt { font-size: var(--t-s); color: var(--ink-3); font-weight: 400; }
.rd .an-kpis dd { margin: .4rem 0 0; }
.rd .an-kpis dd.num { font-size: var(--t-l); font-weight: 500; }
.rd .an-kpis .delta, .rd .an-pair-kpi .delta { font-size: var(--t-s); }
.rd .an-kpis .delta.up:not(.flat), .rd .an-kpis .delta.down:not(.flat),
.rd .an-pair-kpi .delta.up:not(.flat), .rd .an-pair-kpi .delta.down:not(.flat) { color: var(--ink-2); }
@container (max-width: 76rem) { .rd .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.rd .payout { padding: var(--s-6); border-radius: var(--r-l); background: var(--brand-deep); color: var(--deep-text); display: flex; flex-direction: column; position: relative; overflow: hidden; }
/* меню «Показувати податок» виходить за низ картки — не обрізаємо його й кладемо картку над сусідніми блоками */
.rd.an .payout { overflow: visible; z-index: 1; }
.rd .payout .money-label { color: var(--deep-muted); }
.rd .payout .label-note { color: var(--deep-muted); }
.rd .payout-acc { color: var(--deep-muted); font-size: var(--t-s); margin-top: .4rem; }
.rd .payout :focus-visible { box-shadow: 0 0 0 3px var(--brand-deep), 0 0 0 5px var(--deep-accent); }
.rd .an-net { display: block; }
.rd .an-net-na { font-size: var(--t-xl); font-weight: 500; color: var(--deep-text); margin: 1rem 0 .4rem; }
.rd .an-tax { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid rgba(255, 255, 255, .22); }
.rd .an-tax-sel { display: flex; flex-direction: column; gap: .4rem; margin-top: var(--s-4); font-weight: 400; }
.rd .an-tax-sel select, .rd .an-tax-sel .sel-btn { background-color: rgba(255, 255, 255, .1); color: var(--deep-text); border-color: var(--deep-field-border); max-width: 28rem; }
.rd .an-tax-sel .sel { max-width: 28rem; }
.rd .an-tax-sel option { color: #1F2326; }

.rd .chart { padding: var(--s-5) 0 0; border-top: 1px solid var(--line); }
.rd .chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-4); }
.rd .an-rev { margin-top: var(--s-2); }
.rd .an-sec { margin-top: var(--s-6); }
.rd .an-trio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.25fr); column-gap: var(--s-5); row-gap: var(--s-6); margin-top: var(--s-6); align-items: start; }
.rd .an-trio > :first-child { grid-row: span 2; }
.rd .an-trio > .chart:not(:first-child) { grid-column: 2; }
.rd .an-pair-kpi { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin: 0 0 .4rem; line-height: 1.2; }
.rd .an-pair-kpi strong { font-size: var(--t-xl); font-weight: 700; }
.rd .an-pair-kpi + .chart-sub { margin: .4rem 0 1.2rem; }

/* Розкладка доходу замість кільцевої діаграми */
.rd .income-ledger { display: grid; gap: var(--s-4); margin-top: var(--s-4); }
.rd .il-rows { margin: 0; border-top: 1px solid var(--line); }
.rd .il-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 3.5em; gap: var(--s-3); align-items: baseline; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.rd .il-row dt { display: flex; align-items: center; gap: var(--s-2); color: var(--ink-2); min-width: 0; font-weight: 400; }
.rd .il-row dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd .il-row .il-amt { font-weight: 500; color: var(--ink); }
.rd .il-row.il-na .il-amt { font-weight: 400; color: var(--ink-3); white-space: normal; }
/* у вузькій колонці «З чого складається дохід» (десктоп, «Великий текст») підпис не вужчий за своє найдовше слово —
   інакше «Повернення» налазило на «немає даних»; на телефоні колонка на всю ширину, там обмеження зайве */
@media (min-width: 641px) { .rd .il-row { grid-template-columns: minmax(min-content, 1fr) auto 3.5em; } }
.rd .il-row .il-pct { font-size: var(--t-s); color: var(--ink-3); }
.rd .il-note { font-size: var(--t-s); color: var(--ink-3); }

/* ——— Легенда ——— */
.rd .legend { list-style: none; margin: 0; padding: 0; font-size: var(--t-s); }
.rd .legend-inline { display: flex; flex-wrap: wrap; gap: .6rem 1.6rem; color: var(--ink-2); }
.rd .legend-inline li { display: flex; align-items: center; gap: .6rem; }
.rd .sw { width: 1.2rem; height: 1.2rem; border-radius: 3px; display: inline-block; flex: none; }
.rd .sw-line { height: 3px; width: 18px; border-radius: 2px; background: var(--action); }
.rd .sw-prev { background: repeating-linear-gradient(90deg, var(--ink-4) 0 5px, transparent 5px 8px); }
.rd .sw-fc { background: repeating-linear-gradient(90deg, var(--action) 0 5px, transparent 5px 8px); }
.rd .sw-avg { background: var(--action); }
.rd .sw-band { background: var(--brand-soft); border: 1px dashed var(--action); }
.rd .sw-bar { background: var(--bar); box-shadow: inset 0 0 0 1px var(--action); }
.rd .sw-ret { background: var(--brand); }
.rd .sw-sold { background: var(--brand); }
.rd .sw-none { visibility: hidden; }

/* ——— Графік ——— */
.rd .chart-body { position: relative; }
.rd .chart-body[role="group"] { border-radius: var(--r-s); }
.rd .chart-body[role="group"]:focus { outline: none; }
.rd .chart-body[role="group"]:focus-visible { box-shadow: var(--focus); }
.rd .chart-sub { margin: -.8rem 0 .8rem; }
.rd .chart-note { margin-top: .8rem; }
.rd .chart-axis-note { font-size: var(--t-xs); color: var(--ink-3); margin-top: .4rem; }
.rd .chart-svg { display: block; width: 100%; height: 180px; overflow: visible; }
.rd .chart-svg > :not(.bar-hit) { pointer-events: none; }
.rd .chart-svg .bar { fill: var(--bar); stroke: var(--action); stroke-width: 1; vector-effect: non-scaling-stroke; transition: fill .15s; } /* контур дає 3:1, світла заливка лишається */
.rd .chart-svg .bar.today { fill: var(--brand); }
.rd .chart-svg .bar.is-on { fill: var(--action); }
.rd .chart-svg .bar-ret { fill: var(--brand); }
.rd .chart-svg .bar-hit { fill: transparent; cursor: default; }
.rd .chart-svg .axis { font-size: 12px; fill: var(--ink-3); font-family: var(--font); }
.rd .chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.rd .chart-svg .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.rd .chart-svg .line-cur { stroke: var(--action); }
.rd .chart-svg .line-prev { stroke: var(--ink-4); stroke-width: 2; }
.rd .chart-svg .line-fc { stroke: var(--action); }
.rd .chart-svg .line-avg { stroke: var(--action); stroke-width: 2; }
.rd .chart-svg .dot-avg { fill: var(--surface); stroke: var(--action); stroke-width: 2; }
.rd .chart-svg .axis-avg { fill: var(--ink-3); }
.rd .chart-svg .band { fill: var(--brand-soft); stroke: var(--action); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.rd .chart-svg .cursor { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.rd .chart-tip { position: absolute; z-index: 2; pointer-events: none; background: var(--tip-bg); color: var(--tip-fg); padding: .8rem 1rem; border-radius: var(--r-s); font-size: var(--t-s); white-space: normal; width: max-content; max-width: 100%; transform: translate(-50%, -100%); box-shadow: var(--shadow-1); }
.rd .chart-tip[hidden] { display: none; }
.rd .chart-tip.tip-left { transform: translate(calc(-100% + 16px), -100%); }
.rd .chart-tip.tip-right { transform: translate(-16px, -100%); }
.rd .tip-muted { opacity: .75; }
html[data-a11y="lowvision"] .rd .chart-svg .axis { font-size: 15px; }

/* ——— «Продажі й прогноз» ——— */
.rd .an-fc-kpis { display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-6); margin: var(--s-3) 0 var(--s-4); }
.rd .an-fc-kpis > div { display: flex; flex-direction: column; gap: .2rem; }
.rd .an-fc-kpis strong { font-size: var(--t-l); }
.rd .an-fc-total strong { color: var(--ok-text); }

/* ——— Таблиці «За точками», «За касирами» ——— */
.rd .pt-an-name { display: flex; align-items: center; gap: 1rem; min-width: 15rem; }
.rd .pt-an tbody th, .rd .ca-an tbody th, .rd .pt-an tfoot th, .rd .ca-an tfoot th { font-size: var(--t-m); font-weight: 500; color: var(--ink); white-space: normal; padding: 1.4rem 1.6rem; }
.rd .pt-an tfoot td, .rd .ca-an tfoot td, .rd .pt-an tfoot th, .rd .ca-an tfoot th { border-top: 1px solid var(--line-strong); font-weight: 500; }
.rd .pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: 1.2rem .4rem 0; font-size: var(--t-s); color: var(--ink-3); flex-wrap: wrap; }
.rd .pager .btn { color: var(--ink); }

@media (max-width: 1280px) { .rd .an-hero { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1100px) {
  .rd .an-trio { grid-template-columns: minmax(0, 1fr); }
  .rd .an-trio > :first-child { grid-row: auto; max-width: 56rem; }
  .rd .an-trio > .chart:not(:first-child) { grid-column: auto; }
}
@media (max-width: 640px) {
  .rd .an-gross, .rd .payout { padding: var(--s-5); }
  .rd .pt-an-name { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { .rd .chart-svg .bar { transition: none; } }
