/* View compositions: page header, grids, the reference revenue card, charts, funnel and sign-in. */
.page-head {
    display: flex;
    margin-bottom: var(--s6);
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s4);
    flex-wrap: wrap;
}

.page-head h1 { outline: none; }
.page-sub { margin-top: var(--s2); color: var(--ink-secondary); font-size: var(--text-md); }
.page-tools { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.status-line { min-height: 20px; color: var(--ink-secondary); font-size: var(--text-sm); }
.status-line.is-error { color: var(--danger-text); }
.status-line:empty { display: none; }

.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s6); }
.section-title { margin: var(--s8) 0 var(--s4); }
.section-title p { margin-top: 4px; color: var(--ink-secondary); font-size: var(--text-sm); }

.grid { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }
.grid-2, .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: minmax(0, 1fr); }

@media (min-width: 640px) {
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.grid-hero { grid-template-columns: minmax(0, 1fr); }

@media (max-width: 479px) {
    .grid-2.grid-collapse { grid-template-columns: minmax(0, 1fr); }
    .segmented { flex-wrap: wrap; overflow: visible; }
    .toolbar.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toolbar.filters .field { flex: none; }
    .toolbar.filters .button { grid-column: 1 / -1; }
}

@media (max-width: 899px) {
    .grid-5 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-hero { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
}

@media (min-width: 1180px) {
    .grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.toolbar {
    display: flex;
    margin-bottom: var(--s4);
    align-items: flex-end;
    gap: var(--s3);
    flex-wrap: wrap;
}

.toolbar .grow { flex: 1 1 260px; }
.toolbar .field { flex: 0 1 180px; }
.toolbar-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.platform-filter { display: grid; gap: var(--s2); font-size: var(--text-xs); }
.platform-note { margin: 0 0 var(--s4); font-size: var(--text-xs); }

/* Revenue card after the reference: label, large amount with dimmed minor units, delta row, bars. */
.hero-card {
    position: relative;
    padding: var(--s5) var(--s5) var(--s5);
    overflow: hidden;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-hero);
    background: linear-gradient(135deg, #edf7f2, #fafdfb 85%);
}

@media (min-width: 640px) {
    .hero-card { padding: var(--s8) var(--s8) var(--s6); border-radius: var(--radius-hero); }
}

.hero-label { margin-bottom: var(--s3); color: var(--ink); font-size: var(--text-lg); font-weight: var(--weight-book); }
.hero-amount { margin-bottom: var(--s2); font-size: 34px; font-weight: var(--weight-book); line-height: 1;
    letter-spacing: -0.02em; overflow-wrap: anywhere; }
.hero-amount .minor { color: var(--ink-secondary); }
.currency-control { margin: 0 0 var(--s6); }
.currency-control .button { min-height: 44px; }
.currency-note { margin-bottom: var(--s4); color: var(--ink-secondary); font-size: var(--text-xs); }
.currency-note a { text-decoration: underline; }
.hero-delta { display: flex; margin-bottom: var(--s6); align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-delta .caption { color: var(--ink-secondary); font-size: var(--text-sm); }

@media (min-width: 640px) {
    .hero-label { margin-bottom: var(--s4); font-size: var(--text-xl); }
    .hero-amount { margin-bottom: var(--s3); font-size: var(--text-hero); }
    .hero-delta { margin-bottom: var(--s8); }
}

/* Charts (inline SVG drawn at the measured width). */
.chart { position: relative; width: 100%; }
.chart:focus-visible { outline-offset: 6px; }
.chart svg { width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-label { fill: var(--ink-secondary); font-size: 11px; font-family: var(--font); }
.chart .axis-label.is-dim { fill: var(--ink-muted); }
.chart .bar { fill: var(--chart-ink); transition: opacity var(--dur-quick) ease; }
.chart .bar.is-partial { fill: var(--chart-ink-partial); }
.chart .bar-global { fill: var(--chart-global); }
.chart .bar-russia { fill: var(--chart-russia); }
.chart .bar-global.is-partial, .chart .bar-russia.is-partial { opacity: 0.4; }
.chart .gap-mark { fill: var(--ink-muted); }
.chart.has-active .bar { opacity: 0.55; }
.chart.has-active .is-active .bar { opacity: 1; }
.chart .hover-band { fill: var(--wash-strong); }
.chart-empty { padding: var(--s8) 0; color: var(--ink-muted); text-align: center; font-size: var(--text-sm); }

.legend { display: flex; margin-bottom: var(--s3); gap: var(--s4); flex-wrap: wrap; color: var(--ink-secondary);
    font-size: var(--text-sm); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }
.swatch-ink { background: var(--chart-ink); }
.swatch-partial { background: var(--chart-ink-partial); }
.swatch-global { background: var(--chart-global); }
.swatch-russia { background: var(--chart-russia); }

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: var(--s3); }

.funnel-step {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
}

.funnel-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.funnel-name { color: var(--ink); font-size: var(--text-md); font-weight: var(--weight-medium); }
.funnel-values { color: var(--ink-secondary); font-size: var(--text-sm); }
.funnel-values strong { color: var(--ink); font-weight: var(--weight-medium); }
.funnel-track { position: relative; height: 10px; overflow: hidden; border-radius: 5px;
    background: var(--wash-strong); }
.funnel-fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--violet);
    transform-origin: left center; animation: grow-x 700ms var(--ease-out) both; }
.funnel-fill.is-partial { background: rgba(123, 96, 222, 0.5); }
.funnel-track.is-unknown { border: 1px dashed var(--wash-strong); background: transparent; }
.funnel-meta { color: var(--ink-muted); font-size: var(--text-xs); }

@keyframes grow-x {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.meter-list { display: flex; flex-direction: column; gap: 14px; }
.meter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--s3); align-items: baseline; }
.meter-row .funnel-track { grid-column: 1 / -1; height: 6px; }
.meter-label { display: inline-flex; align-items: center; gap: var(--s2); min-width: 0; }
.meter-value { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter-value .muted { font-size: var(--text-sm); }

.flags { display: flex; gap: var(--s2); flex-wrap: wrap; }

.coverage { display: flex; flex-direction: column; gap: var(--s2); color: var(--ink-secondary);
    font-size: var(--text-sm); }
.coverage li { display: flex; gap: var(--s2); }
.coverage li::before { flex: none; width: 4px; height: 4px; margin-top: 8px; border-radius: 50%;
    background: var(--ink-muted); content: ""; }

/* Products */
.product-price { margin: var(--s3) 0 var(--s1); font-size: var(--text-2xl); font-weight: var(--weight-book);
    letter-spacing: -0.02em; }
.product-id { color: var(--ink-secondary); }

/* Sign-in */
.login {
    display: flex;
    min-height: calc(100dvh - 64px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s6);
    padding: var(--s8) 0;
}

.login-card {
    width: min(420px, 100%);
    padding: var(--s8) var(--s6) var(--s6);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    background: var(--field);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.login-brand { display: flex; margin-bottom: var(--s6); align-items: center; gap: 10px; }
.login-brand img { width: 36px; height: 36px; }
.login-card h1 { font-size: var(--text-2xl); }
.login-card .page-sub { margin-bottom: var(--s6); }
.login-form { display: flex; flex-direction: column; gap: var(--s4); }
.login-alt { margin-top: var(--s5); text-align: center; font-size: var(--text-sm); }

.empty-inline { padding: var(--s6) var(--s5); color: var(--ink-secondary); text-align: center;
    font-size: var(--text-sm); }

.spaced { margin-top: var(--s6); }
.card-pad { padding: 0 var(--s5); }
.card-pad .toolbar { margin-bottom: var(--s4); }

@media (min-width: 768px) {
    .card-pad { padding: 0 var(--s6); }
}

.chart-figure { margin: 0; }
.chart-table { margin-top: var(--s3); color: var(--ink-secondary); font-size: var(--text-sm); }
.chart-table summary { width: max-content; padding: 6px 0; cursor: pointer; }
.chart-table .table-wrap { max-height: 320px; margin-top: var(--s2); overflow-y: auto; border: 1px solid var(--divider);
    border-radius: var(--radius-md); }
.chart-table .table th, .chart-table .table td { padding: 8px 12px; }

.filter-row { display: flex; margin-bottom: var(--s4); align-items: center; gap: var(--s3); flex-wrap: wrap; }

.tabs {
    display: flex;
    margin-bottom: var(--s6);
    overflow-x: auto;
    gap: var(--s5);
    border-bottom: 1px solid var(--divider);
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    min-height: var(--target);
    padding: 0 2px;
    flex: none;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--ink-secondary);
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    white-space: nowrap;
    transition: color var(--dur-quick) ease, border-color var(--dur-quick) ease;
}

.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { border-bottom-color: var(--ink); color: var(--ink); }
.compare-row { margin: var(--s1) 0 0; }

.hero-card { display: flex; flex-direction: column; }
.hero-card > .chart-figure, .hero-card > .chart-empty { margin-top: auto; }
.wata-net { margin-top: 0; }
.funnel-fill.tone-blue { background: var(--blue); }
.funnel-fill.tone-mint { background: var(--mint); }
.funnel-fill.tone-amber { background: var(--amber-text); }
.funnel-fill.tone-danger { background: var(--danger-text); }
.funnel-fill.tone-plain { background: var(--ink-muted); }
.funnel-fill.tone-violet { background: var(--violet); }

.wata-slot { display: flex; flex-direction: column; gap: var(--s4); }

.dashboard-kpis .kpi { min-height: 116px; background: #eff5fa; }
.dashboard-kpis .kpi:nth-child(2) { background: #eef7f1; }
.dashboard-kpis .kpi:nth-child(3) { background: #f4f1fa; }
.dashboard-kpis .kpi:nth-child(4) { background: #fbf5e9; }
.dashboard-kpis .kpi-value { font-weight: 600; letter-spacing: -.04em; }
.dashboard-details { margin-top: var(--s6); border-top: 1px solid var(--divider); }
.dashboard-details > summary { padding: var(--s4) 0; color: var(--ink-secondary); cursor: pointer; }
.dashboard-details > summary:focus-visible { outline: 2px solid var(--focus); }

@media (max-width: 639px) {
    .view:has(.dashboard-details) .page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
    .view:has(.dashboard-details) .page-sub { font-size: var(--text-xs); }
    .view:has(.dashboard-details) .page-tools { justify-content: flex-end; }
    .view:has(.dashboard-details) .page-tools:has(.status-line:not(:empty)) { grid-column: 1 / -1; }
}
