:root {
  color-scheme: dark;
  --bg: #0c0f10;
  --surface: #121516;
  --surface-2: #171b1c;
  --line: #2a3031;
  --muted: #8f9997;
  --text: #f5f7f2;
  --lime: #d7ff45;
  --aqua: #67e8cf;
  --red: #ff766f;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

.loading-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 20px; color: var(--muted); }
.loading-screen strong, .loading-screen span { display: block; }
.loading-screen strong { color: var(--text); font-size: 1.15rem; margin-bottom: 2px; }
.loader-mark, .brand-mark { display: flex; gap: 3px; align-items: end; }
.loader-mark i, .brand-mark i { width: 5px; background: var(--lime); display: block; animation: pulse 1.2s infinite ease-in-out; }
.loader-mark i:nth-child(1), .brand-mark i:nth-child(1) { height: 14px; }
.loader-mark i:nth-child(2), .brand-mark i:nth-child(2) { height: 24px; animation-delay: .15s; }
.loader-mark i:nth-child(3), .brand-mark i:nth-child(3) { height: 18px; animation-delay: .3s; }
@keyframes pulse { 50% { opacity: .35; } }

.app { width: min(1540px, calc(100% - 48px)); margin: auto; }
.topbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { color: var(--text); display: flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 750; letter-spacing: -.02em; font-size: 1.1rem; }
.brand-mark i { animation: none; width: 4px; }
.main-nav { display: flex; align-items: center; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.main-nav a { color: var(--muted); text-decoration: none; font-size: .8rem; font-weight: 750; padding: 7px 12px; border-radius: 7px; }
.main-nav a.active { color: #111; background: var(--lime); }
.main-nav a:not(.active):hover { color: var(--text); }
.dataset-meta { color: var(--muted); font-size: .84rem; display: flex; align-items: center; gap: 9px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--aqua); box-shadow: 0 0 0 4px #67e8cf18; }

.overview { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 32px; padding: 72px 0 42px; }
.eyebrow { color: var(--lime); text-transform: uppercase; letter-spacing: .14em; font-size: .73rem; font-weight: 800; margin: 0 0 10px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(3rem, 6.8vw, 7.4rem); line-height: .88; letter-spacing: -.075em; max-width: 970px; margin-bottom: 28px; font-weight: 760; }
h1 em { color: var(--lime); font-style: normal; font-weight: 420; }
.lede { margin: 0; color: var(--muted); font-size: 1.08rem; max-width: 570px; }
.period-control { display: flex; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.period-control button { color: var(--muted); background: transparent; border: 0; border-radius: 8px; min-width: 62px; padding: 10px 14px; font-size: .82rem; font-weight: 800; }
.period-control button.active { color: #111; background: var(--lime); }

.coverage-banner { display: grid; grid-template-columns: minmax(310px, 1fr) minmax(180px, 420px) auto; gap: 22px; align-items: center; background: #181b15; border: 1px solid #3d4525; border-radius: 14px; padding: 15px 18px; margin-bottom: 20px; }
.coverage-copy { display: flex; align-items: center; gap: 12px; }
.coverage-copy div > * { display: block; }
.coverage-copy span:not(.coverage-icon) { color: var(--muted); font-size: .82rem; }
.coverage-icon { width: 27px; height: 27px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid #66732d; color: var(--lime); border-radius: 50%; font-weight: 900; }
.coverage-track { height: 5px; background: #30352a; border-radius: 10px; overflow: hidden; }
.coverage-track span { display: block; height: 100%; background: var(--lime); }

.kpi-grid { display: grid; grid-template-columns: 1.05fr repeat(4, 1fr); gap: 10px; margin-bottom: 10px; }
.kpi-card { min-height: 154px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; }
.kpi-card > span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.kpi-card strong { margin: auto 0 2px; font-size: clamp(1.55rem, 2.3vw, 2.6rem); letter-spacing: -.045em; line-height: 1; white-space: nowrap; }
.kpi-card small { color: var(--muted); font-size: .75rem; }
.kpi-card.lime { background: var(--lime); color: #10130b; border-color: var(--lime); }
.kpi-card.lime > span, .kpi-card.lime small { color: #384016; }

.charts-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 10px; margin-bottom: 10px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.charts-grid .panel { min-height: 440px; padding: 24px; }
.charts-grid .profit-panel { grid-column: 1 / -1; min-height: auto; }
.panel-heading, .explorer-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.panel-heading h2, .explorer-heading h2 { margin: 0; font-size: 1.5rem; letter-spacing: -.035em; }
.panel-heading > span { color: var(--muted); font-size: .78rem; margin-top: 4px; }

.ranking-chart { margin-top: 28px; display: grid; gap: 13px; }
.rank-row { display: grid; grid-template-columns: minmax(150px, 1.2fr) 2fr 90px; gap: 13px; align-items: center; }
.rank-name { min-width: 0; display: flex; align-items: center; gap: 9px; }
.rank-name img { width: 28px; height: 28px; object-fit: cover; border-radius: 7px; background: var(--surface-2); }
.rank-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; font-weight: 650; }
.rank-bar { height: 7px; border-radius: 8px; background: #262c2d; overflow: hidden; }
.rank-bar i { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--lime), var(--aqua)); }
.rank-value { text-align: right; font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--muted); }
.profit-ranking-chart { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 38px; }
.profit-ranking-chart .rank-bar i { background: linear-gradient(90deg, #67e8cf, #d7ff45); }
.profit-ranking-chart .rank-value { color: var(--aqua); }
.provider-bars .rank-row { grid-template-columns: minmax(150px, 1.1fr) 2fr 100px; }
.coverage-cell { min-width: 120px; }
.coverage-meter { height: 4px; margin-top: 5px; overflow: hidden; border-radius: 4px; background: #2b3131; }
.coverage-meter i { display: block; height: 100%; background: var(--lime); }
.provider-name { font-weight: 700; }

.histogram-wrap { height: 285px; margin-top: 28px; }
.histogram-wrap svg { width: 100%; height: 100%; overflow: visible; }
.histogram-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; border-top: 1px solid var(--line); padding-top: 10px; }

.explorer { padding: 26px; margin-bottom: 40px; }
.export-button { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 10px 14px; font-size: .82rem; font-weight: 750; }
.export-button:hover { border-color: var(--lime); color: var(--lime); }
.filters { display: grid; grid-template-columns: 1.6fr repeat(3, minmax(155px, .7fr)); gap: 10px; margin: 28px 0 22px; }
.filters.provider-filters { grid-template-columns: 1.6fr repeat(2, minmax(190px, .8fr)); }
.filters label { position: relative; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.filters input, .filters select { width: 100%; min-height: 44px; background: #0e1112; border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 0 12px; font-size: .86rem; }
.search-field kbd { position: absolute; right: 10px; bottom: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; min-width: 23px; text-align: center; font: .72rem/21px inherit; }
.table-summary { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; }
.table-summary strong { font-size: 1.1rem; }
.table-summary span { color: var(--muted); font-size: .8rem; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 1020px; }
th { color: var(--muted); text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px; }
td { border-top: 1px solid #222728; padding: 10px; font-size: .83rem; }
th.number, td.number { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; transition: background .15s ease; }
tbody tr:hover { background: #181c1d; }
.game-cell { display: flex; align-items: center; gap: 11px; min-width: 245px; }
.game-cell img { width: 42px; height: 42px; object-fit: cover; border-radius: 9px; background: var(--surface-2); }
.game-cell strong, .game-cell small { display: block; }
.game-cell strong { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-cell small { color: var(--muted); font-size: .7rem; }
.provider-pill { color: #cbd2d0; }
.positive { color: var(--aqua); }
.negative { color: var(--red); }
.missing { color: #697270; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; border-top: 1px solid var(--line); padding-top: 20px; margin-top: 8px; color: var(--muted); font-size: .8rem; }
.pagination button { border: 1px solid var(--line); color: var(--text); background: var(--surface-2); border-radius: 8px; padding: 8px 12px; }
.pagination button:disabled { opacity: .35; cursor: default; }

footer { min-height: 110px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 20px; color: var(--muted); font-size: .78rem; }
footer span { color: var(--text); font-weight: 800; }
footer p { margin: 0; }

dialog { width: min(680px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 22px; background: #111516; color: var(--text); padding: 28px; box-shadow: 0 30px 90px #000a; }
dialog::backdrop { background: #050707d9; backdrop-filter: blur(7px); }
.dialog-close { position: absolute; right: 17px; top: 14px; border: 0; background: transparent; color: var(--muted); font-size: 1.8rem; }
.dialog-head { display: flex; align-items: center; gap: 16px; padding-right: 35px; margin-bottom: 26px; }
.dialog-head img { width: 70px; height: 70px; object-fit: cover; border-radius: 15px; }
.dialog-head h2 { margin: 0 0 3px; font-size: 1.7rem; }
.dialog-head p { color: var(--muted); margin: 0; }
.dialog-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.dialog-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; padding: 15px; }
.dialog-stat span, .dialog-stat small { display: block; color: var(--muted); font-size: .72rem; }
.dialog-stat strong { display: block; font-size: 1.45rem; margin: 8px 0 2px; }
.period-table { width: 100%; min-width: 0; margin-top: 22px; }
.period-table td:first-child { text-transform: uppercase; color: var(--muted); font-size: .7rem; font-weight: 800; }
.dialog-error { border: 1px solid #523936; background: #211817; color: #ffaaa5; padding: 16px; border-radius: 12px; }

@media (max-width: 1000px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card:first-child { grid-column: span 2; }
  .charts-grid { grid-template-columns: 1fr; }
  .charts-grid .profit-panel { grid-column: auto; }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .filters.provider-filters { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .app { width: min(100% - 24px, 1540px); }
  .overview { grid-template-columns: 1fr; padding-top: 48px; }
  .topbar { display: grid; grid-template-columns: 1fr auto; padding: 12px 0; gap: 12px; }
  .main-nav { grid-row: 2; grid-column: 1 / -1; }
  .main-nav a { flex: 1; text-align: center; }
  .dataset-meta { justify-self: end; }
  h1 { font-size: clamp(3rem, 16vw, 5.4rem); }
  .period-control { width: 100%; }
  .period-control button { flex: 1; min-width: 0; }
  .coverage-banner { grid-template-columns: 1fr auto; }
  .coverage-track { grid-row: 2; grid-column: 1 / -1; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card { min-height: 132px; padding: 17px; }
  .kpi-card:first-child { grid-column: span 2; }
  .charts-grid .panel, .explorer { padding: 18px; }
  .filters { grid-template-columns: 1fr; }
  .filters.provider-filters { grid-template-columns: 1fr; }
  .rank-row { grid-template-columns: minmax(120px, 1fr) 1.2fr 70px; }
  .profit-ranking-chart { grid-template-columns: 1fr; }
  .explorer-heading { align-items: end; }
  footer { flex-direction: column; align-items: start; justify-content: center; }
  .dialog-grid { grid-template-columns: 1fr 1fr; }
}
