:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --bg-strong: #eef2fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: rgba(17, 24, 39, 0.1);
  --line-strong: rgba(17, 24, 39, 0.18);
  --accent: #315bda;
  --accent-soft: rgba(49, 91, 218, 0.12);
  --accent-active: #e7eeff;
  --positive: #0d7a54;
  --negative: #b93d28;
  --metric-dau: #2d6cdf;
  --metric-dau-soft: rgba(45, 108, 223, 0.12);
  --metric-revenue: #11885d;
  --metric-revenue-soft: rgba(17, 136, 93, 0.12);
  --metric-iapRevenue: #d47a1f;
  --metric-iapRevenue-soft: rgba(212, 122, 31, 0.14);
  --metric-spend: #c34b36;
  --metric-spend-soft: rgba(195, 75, 54, 0.12);
  --metric-profit: #6b5bd2;
  --metric-profit-soft: rgba(107, 91, 210, 0.14);
  --shadow: 0 18px 42px rgba(31, 41, 55, 0.08);
  --chart-grid: rgba(49, 91, 218, 0.16);
}

html.theme-dark,
body.theme-dark {
  color-scheme: dark;
  --bg: #0f1117;
  --bg-strong: #171a22;
  --panel: rgba(26, 31, 39, 0.94);
  --panel-strong: #1b2028;
  --ink: #eef2f7;
  --muted: #98a3b3;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.18);
  --accent: #7e67d8;
  --accent-soft: rgba(126, 103, 216, 0.16);
  --accent-active: rgba(126, 103, 216, 0.24);
  --positive: #53d39b;
  --negative: #ff8e73;
  --metric-dau: #7ba8ff;
  --metric-dau-soft: rgba(123, 168, 255, 0.18);
  --metric-revenue: #68d7a9;
  --metric-revenue-soft: rgba(104, 215, 169, 0.18);
  --metric-iapRevenue: #f6b05f;
  --metric-iapRevenue-soft: rgba(246, 176, 95, 0.2);
  --metric-spend: #ff8b72;
  --metric-spend-soft: rgba(255, 139, 114, 0.18);
  --metric-profit: #a995ff;
  --metric-profit-soft: rgba(169, 149, 255, 0.2);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  --chart-grid: rgba(126, 103, 216, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.72), transparent 26%),
    linear-gradient(180deg, var(--bg-strong) 0%, var(--bg) 42%, var(--bg) 100%);
  transition: background 180ms ease, color 180ms ease;
}

html.theme-dark body,
body.theme-dark {
  background: linear-gradient(180deg, #131720 0%, #0f1117 100%);
}

body.is-loading {
  overflow: hidden;
}

.screen.is-hidden {
  display: none;
}

.auth-boot.is-hidden,
.shell.is-hidden,
.auth-gate.is-hidden,
.table-shell.is-hidden {
  display: none;
}

.auth-boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-boot-card {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--muted);
}

.auth-boot-spinner {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

.auth-boot-text {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.auth-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  text-align: center;
}

.auth-card h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

.auth-badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: max-content;
  margin: 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-message {
  min-height: 18px;
  color: var(--muted);
  font-size: 14px;
}

.auth-message.is-error {
  color: var(--negative);
}

.auth-sign-in-button {
  width: 100%;
  justify-content: center;
}

.shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 0;
  align-items: start;
}

.page-header,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  padding: 24px 16px 20px;
  border-radius: 0 24px 24px 0;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  min-height: 100dvh;
  overflow: auto;
  z-index: 30;
  border-left: 0;
  border-top: 0;
  border-bottom: 0;
  box-shadow: none;
}

.content-shell {
  min-width: 0;
  min-height: 100dvh;
  padding: 24px 28px 48px;
}

body.sidebar-collapsed .shell {
  grid-template-columns: 88px minmax(0, 1fr);
}

.content-stage {
  position: relative;
  min-width: 0;
}

.desktop-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
  padding: 0 0 18px;
}

.desktop-screen-title {
  font-size: 20px;
  line-height: 1.1;
  color: var(--ink);
}

.mobile-topbar {
  display: none;
}

.mobile-screen-title {
  font-size: 17px;
  line-height: 1.1;
  color: var(--ink);
}

.nav-backdrop {
  display: none;
}

.page-nav-row,
.page-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.page-nav-row {
  width: 100%;
}

.page-nav-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
}

.page-nav-label {
  min-width: 0;
  white-space: nowrap;
}

.page-nav-button.is-active {
  background: var(--accent-active);
  border-color: var(--accent);
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.sidebar-footer-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.hero-status.is-hidden {
  display: none;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d5a021;
}

.ghost-button,
.primary-button,
.date-presets button,
.metric-card,
select,
input {
  font: inherit;
}

.ghost-button,
.primary-button,
.date-presets button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.ghost-button,
.date-presets button {
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost-button:hover,
.date-presets button:hover {
  border-color: var(--line-strong);
}

.theme-toggle-button {
  margin-top: 4px;
}

.sidebar-toggle-button {
  margin-top: 4px;
}

.page-nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.page-nav-icon svg {
  width: 18px;
  height: 18px;
}

body.sidebar-collapsed .page-header {
  padding-inline: 10px;
}

body.sidebar-collapsed .page-nav-button {
  justify-content: center;
  padding-inline: 0;
}

body.sidebar-collapsed .page-nav-label,
body.sidebar-collapsed .hero-status {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle-button .page-nav-label {
  display: none;
}

.primary-button {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.settings-panel {
  margin-top: 18px;
  padding: 22px;
  border-radius: 20px;
  height: calc(100dvh - 90px);
  display: flex;
  flex-direction: column;
}

.freshness-panel {
  margin-top: 18px;
  padding: 22px;
  border-radius: 20px;
  height: auto;
  display: flex;
  flex-direction: column;
}

.purchases-panel {
  margin-top: 18px;
  position: relative;
}

.analytics-panel {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.analytics-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.analytics-toolbar-secondary {
  align-items: flex-start;
}

.analytics-date-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.analytics-date-inputs input {
  min-width: 148px;
}

.analytics-headline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.analytics-headline-compact {
  flex: 1;
}

.analytics-kpi {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.analytics-kpi span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.analytics-kpi strong {
  font-size: 20px;
}

.analytics-metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.analytics-metric-card {
  cursor: default;
}

.analytics-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.analytics-section-title {
  margin: 0 0 14px;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.analytics-table-shell table {
  width: 100%;
}

.analytics-row-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analytics-row-title span {
  color: var(--muted);
  font-size: 12px;
}

.digest-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.digest-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
}

.digest-list span {
  color: var(--muted);
}

.digest-imports {
  display: grid;
  gap: 12px;
}

.digest-imports div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
}

.panel-empty {
  color: var(--muted);
}

.panel-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.purchases-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.purchases-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: flex-end;
}

.purchases-control {
  min-width: 132px;
}

.purchases-control input {
  min-width: 0;
  width: 100%;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel-soft);
}

.segmented-control button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  font: inherit;
}

.segmented-control button.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.purchases-metric-card {
  cursor: pointer;
}

.purchases-metric-card:not([data-purchases-metric]) {
  cursor: default;
}

.purchases-name-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.purchases-primary-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.purchases-primary-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.purchases-primary-content > strong,
.purchases-primary-content > .row-label,
.purchases-primary-content > .country-label {
  min-width: 0;
}

.purchases-name-cell strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.purchases-secondary-text {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.purchases-chart-shell {
  margin-bottom: 18px;
}

#purchasesTimeseriesChart {
  width: 100%;
  height: 240px !important;
}

#purchasesTable {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.purchases-table-shell {
  width: 100%;
  overflow: hidden;
  max-height: none;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  isolation: isolate;
  container-type: inline-size;
}

#purchasesTable .col-purchases-primary {
  width: 43%;
}

#purchasesTable .col-share {
  width: 9%;
}

#purchasesTable .col-count {
  width: 8.5%;
}

#purchasesTable .col-money {
  width: 12%;
}

#purchasesTable thead th {
  position: static;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#purchasesTable thead th,
#purchasesTable tbody td {
  padding: 11px 14px;
}

#purchasesTable thead th:first-child,
#purchasesTable tbody td:first-child {
  text-align: left;
}

#purchasesTable thead th:nth-child(2),
#purchasesTable tbody td:nth-child(2) {
  text-align: right;
}

#purchasesTable thead th:nth-child(n + 3),
#purchasesTable tbody td:nth-child(n + 3) {
  text-align: right;
}

@container (max-width: 920px) {
  #purchasesTable .col-purchases-primary {
    width: 52%;
  }

  #purchasesTable colgroup col:nth-child(2),
  #purchasesTable thead th:nth-child(2),
  #purchasesTable tbody td:nth-child(2) {
    display: none;
  }
}

@container (max-width: 760px) {
  #purchasesTable .col-purchases-primary {
    width: 58%;
  }

  #purchasesTable .col-share {
    width: 12%;
  }

  #purchasesTable colgroup col:nth-child(2),
  #purchasesTable thead th:nth-child(2),
  #purchasesTable tbody td:nth-child(2),
  #purchasesTable colgroup col:nth-child(5),
  #purchasesTable thead th:nth-child(5),
  #purchasesTable tbody td:nth-child(5) {
    display: none;
  }
}

#purchasesTable thead th[data-purchases-column] {
  cursor: pointer;
}

#purchasesTable tbody td {
  vertical-align: middle;
}

#purchasesTable tbody td:not(:first-child) {
  font-variant-numeric: tabular-nums;
}

#purchasesTable tbody td:nth-child(2) {
  color: var(--muted);
}

.selection-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selection-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.selection-chip:hover {
  border-color: var(--line-strong);
}

.selection-chip.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  color: var(--accent-strong);
}

.selection-chip small {
  color: var(--muted);
  font-size: 11px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 18px;
}

.freshness-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.freshness-copy {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 640px;
}

.settings-editor {
  width: min(860px, calc(100vw - 24px));
  padding: 22px;
}

.settings-editor-header {
  margin-bottom: 18px;
}

.settings-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.settings-sections {
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
}

.settings-status {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--muted);
}

.settings-status.is-success {
  color: var(--positive);
  border-color: color-mix(in srgb, var(--positive) 36%, var(--line));
}

.settings-status.is-error {
  color: var(--negative);
  border-color: color-mix(in srgb, var(--negative) 36%, var(--line));
}

.settings-status.is-hidden {
  display: none;
}

select,
input {
  min-height: 46px;
  width: 100%;
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
}

.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.date-presets button.is-active,
.ghost-button.is-active {
  background: var(--accent-active);
  border-color: var(--accent);
}

.label-mobile {
  display: none;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
}

.toolbar-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 16px;
  text-transform: none;
  letter-spacing: 0;
}

.toolbar-field > span {
  white-space: nowrap;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 14px;
}

.chart-toolbar-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
}

.toolbar-menu-button {
  width: auto;
  min-width: 0;
  white-space: nowrap;
  justify-content: center;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: #e76d2f;
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

.count-badge.is-hidden {
  display: none;
}

#filterSummary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 22px;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid transparent;
}

.filter-tag.is-include {
  color: #0d7a54;
  background: rgba(13, 122, 84, 0.12);
  border-color: rgba(13, 122, 84, 0.2);
}

body.theme-dark .filter-tag.is-include {
  color: #79e0b8;
  background: rgba(83, 211, 155, 0.16);
  border-color: rgba(83, 211, 155, 0.28);
}

.filter-tag.is-exclude {
  color: #b93d28;
  background: rgba(185, 61, 40, 0.12);
  border-color: rgba(185, 61, 40, 0.2);
}

body.theme-dark .filter-tag.is-exclude {
  color: #ffb19f;
  background: rgba(255, 142, 115, 0.16);
  border-color: rgba(255, 142, 115, 0.28);
}

.filter-tag button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.filter-hint {
  color: var(--muted);
  font-size: 13px;
}

.overlay-card {
  position: fixed;
  z-index: 30;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  max-height: min(70vh, calc(100dvh - 24px));
  overflow: auto;
}

.overlay-card.is-hidden,
.loading-overlay.is-hidden,
.modal-shell.is-hidden,
.compare-custom-fields.is-hidden {
  display: none;
}

.menu-card {
  width: auto;
  min-width: 0;
  max-width: min(220px, calc(100vw - 28px));
  padding: 8px;
  border-radius: 16px;
}

.menu-card button {
  display: block;
  width: auto;
  min-width: 164px;
  min-height: 42px;
  font-size: 16px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  border-radius: 10px;
  padding: 0 12px;
  cursor: pointer;
}

.menu-card button:hover,
.menu-card button.is-active {
  background: var(--accent-active);
}

.popover-card {
  width: min(420px, calc(100vw - 28px));
  padding: 18px;
  border-radius: 18px;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.overlay-header h3 {
  margin: 0;
  font-size: 28px;
}

.overlay-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.overlay-section + .overlay-section {
  margin-top: 16px;
}

.overlay-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.overlay-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 10, 18, 0.34);
  backdrop-filter: blur(4px);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 14, 22, 0.18);
}

body.theme-dark .loading-overlay {
  background: rgba(4, 6, 10, 0.52);
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--accent) 16%, transparent);
  border-top-color: var(--accent);
  animation: loading-spin 0.85s linear infinite;
  flex: 0 0 auto;
}

@keyframes loading-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.modal-card {
  width: min(780px, calc(100vw - 24px));
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 22px;
  padding: 20px;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.modal-date-presets {
  margin-bottom: 16px;
}

.compare-options {
  display: grid;
  gap: 12px;
}

.compare-option {
  min-height: 64px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.compare-option.is-active {
  border-color: var(--accent);
  background: var(--accent-active);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 18px;
}

.metric-card {
  --metric-color: var(--accent);
  --metric-soft: var(--accent-soft);
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 18px;
  text-align: center;
  cursor: pointer;
  background: transparent;
  border: none;
  box-shadow: none;
  transition: background 120ms ease, transform 120ms ease;
}

.metric-card:hover {
  transform: translateY(-1px);
}

.metric-card.is-active {
  background: linear-gradient(180deg, color-mix(in srgb, var(--metric-soft) 92%, transparent), color-mix(in srgb, var(--metric-soft) 42%, transparent) 100%);
}

.metric-card[data-metric="dau"] {
  --metric-color: var(--metric-dau);
  --metric-soft: var(--metric-dau-soft);
}

.metric-card[data-metric="revenue"] {
  --metric-color: var(--metric-revenue);
  --metric-soft: var(--metric-revenue-soft);
}

.metric-card[data-metric="iapRevenue"] {
  --metric-color: var(--metric-iapRevenue);
  --metric-soft: var(--metric-iapRevenue-soft);
}

.metric-card[data-metric="spend"] {
  --metric-color: var(--metric-spend);
  --metric-soft: var(--metric-spend-soft);
}

.metric-card[data-metric="profit"] {
  --metric-color: var(--metric-profit);
  --metric-soft: var(--metric-profit-soft);
}

.metric-card span {
  color: color-mix(in srgb, var(--metric-color) 70%, var(--muted));
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-card strong {
  color: var(--metric-color);
  font-size: clamp(24px, 3vw, 34px);
}

.metric-grid.is-compact .metric-card {
  gap: 5px;
  padding: 14px 16px;
}

.metric-grid.is-compact .metric-card strong {
  font-size: clamp(22px, 2.7vw, 30px);
}

.metric-prev {
  min-height: 16px;
  font-size: 12px;
  color: var(--muted);
}

.metric-prev.is-hidden {
  visibility: hidden;
}

.metric-grid.is-compact .metric-prev {
  display: none;
}

.metric-prev.is-positive {
  color: var(--positive);
}

.metric-prev.is-negative {
  color: var(--negative);
}

.panel {
  margin-top: 18px;
  padding: 20px;
  border-radius: 22px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 22px;
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.chart-panel {
  overflow: hidden;
  padding-top: 16px;
}

.chart-shell {
  min-height: 290px;
  padding: 14px 16px 8px;
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 90%, transparent), transparent 100%);
  border: 1px solid var(--line);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

#timeseriesChart {
  width: 100%;
  height: 260px !important;
}

.table-shell {
  overflow: auto;
  max-height: min(62dvh, 920px);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

#profitTableShell {
  overflow: hidden;
  max-height: none;
  container-type: inline-size;
}

#settingsTableShell {
  overflow: auto;
  max-height: none;
  container-type: inline-size;
}

#purchaseAliasesTableShell {
  overflow: auto;
  max-height: none;
  container-type: inline-size;
}

#freshnessTableShell {
  overflow: hidden;
  max-height: none;
  container-type: inline-size;
}

.settings-panel .table-shell,
.freshness-panel .table-shell {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#settingsTable {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

#purchaseAliasesTable {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

#freshnessTable {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

#breakdownTable {
  width: 100%;
  min-width: 0;
}

#breakdownTable .col-name {
  width: auto;
}

#breakdownTable .col-dau {
  width: 9ch;
}

#breakdownTable .col-count {
  width: 10ch;
}

#breakdownTable .col-money {
  width: 12.5ch;
}

#breakdownTable thead th,
#breakdownTable tbody td,
#breakdownTable tfoot td {
  padding: 10px 12px;
}

#breakdownTable thead th {
  position: static;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#breakdownTable tfoot td {
  position: static;
}

#settingsTable .col-settings-app {
  width: auto;
}

#settingsTable .col-settings-platform {
  width: 7.5rem;
}

#settingsTable .col-settings-store {
  width: 9rem;
}

#settingsTable .col-settings-bundle {
  width: 12rem;
}

#settingsTable .col-settings-sku {
  width: 7rem;
}

#settingsTable .col-settings-action {
  width: 5rem;
}

#purchaseAliasesTable .col-settings-app {
  width: auto;
}

#purchaseAliasesTable .col-settings-platform {
  width: 7.5rem;
}

#purchaseAliasesTable .col-settings-bundle {
  width: 14rem;
}

#purchaseAliasesTable .col-settings-action {
  width: 5rem;
}

#settingsTable thead th,
#settingsTable tbody td {
  padding: 7px 8px;
}

#purchaseAliasesTable thead th,
#purchaseAliasesTable tbody td {
  padding: 7px 8px;
}

#settingsTable thead th {
  position: static;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#purchaseAliasesTable thead th {
  position: static;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#freshnessTable .col-freshness-source {
  width: 14rem;
}

#freshnessTable .col-freshness-last-update {
  width: 11rem;
}

#freshnessTable .col-freshness-status {
  width: 6.5rem;
}

#freshnessTable .col-freshness-next-update {
  width: 11.5rem;
}

#freshnessTable .col-freshness-action {
  width: 7.25rem;
}

#freshnessTable thead th,
#freshnessTable tbody td {
  padding: 8px 8px;
}

#freshnessTable thead th {
  position: static;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

thead th,
tbody td,
tfoot td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

thead th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-strong);
}

thead th.is-sorted {
  color: var(--ink);
}

#breakdownTable thead th:first-child,
#breakdownTable tbody td:first-child,
#breakdownTable tfoot td:first-child,
#settingsTable thead th:first-child,
#settingsTable tbody td:first-child,
#purchaseAliasesTable thead th:first-child,
#purchaseAliasesTable tbody td:first-child {
  text-align: left;
}
#purchasesTable thead th:first-child,
#purchasesTable tbody td:first-child {
  text-align: left;
}

#breakdownTable thead th:first-child,
#breakdownTable tbody td:first-child,
#breakdownTable tfoot td:first-child,
#purchasesTable thead th:first-child,
#purchasesTable tbody td:first-child {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#breakdownTable thead th:not(:first-child),
#breakdownTable tbody td:not(:first-child),
#breakdownTable tfoot td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@container (max-width: 1180px) {
  #breakdownTable colgroup col:nth-child(2),
  #breakdownTable thead th:nth-child(2),
  #breakdownTable tbody td:nth-child(2),
  #breakdownTable tfoot td:nth-child(2) {
    display: none;
  }
}

@container (max-width: 1040px) {
  #breakdownTable colgroup col:nth-child(3),
  #breakdownTable thead th:nth-child(3),
  #breakdownTable tbody td:nth-child(3),
  #breakdownTable tfoot td:nth-child(3) {
    display: none;
  }
}

@container (max-width: 920px) {
  #breakdownTable colgroup col:nth-child(7),
  #breakdownTable thead th:nth-child(7),
  #breakdownTable tbody td:nth-child(7),
  #breakdownTable tfoot td:nth-child(7) {
    display: none;
  }
}

@container (max-width: 820px) {
  #breakdownTable colgroup col:nth-child(4),
  #breakdownTable thead th:nth-child(4),
  #breakdownTable tbody td:nth-child(4),
  #breakdownTable tfoot td:nth-child(4) {
    display: none;
  }
}

#settingsTable thead th:last-child,
#settingsTable tbody td:last-child,
#purchaseAliasesTable thead th:last-child,
#purchaseAliasesTable tbody td:last-child {
  text-align: right;
}

#settingsTable thead th:nth-child(2),
#settingsTable tbody td:nth-child(2),
#settingsTable thead th:nth-child(4),
#settingsTable tbody td:nth-child(4) {
  text-align: left;
}

#settingsTable thead th:nth-child(3),
#settingsTable tbody td:nth-child(3),
#settingsTable thead th:nth-child(5),
#settingsTable tbody td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#settingsTable tbody td[colspan] {
  text-align: left !important;
}

#purchaseAliasesTable tbody td:nth-child(2) {
  text-align: left;
}

#purchaseAliasesTable tbody td:nth-child(3) {
  text-align: left;
}

#purchaseAliasesTable tbody td[colspan] {
  text-align: left !important;
}

@container (max-width: 1280px) {
  #settingsTable colgroup col:nth-child(4),
  #settingsTable thead th:nth-child(4),
  #settingsTable tbody td:nth-child(4) {
    display: none;
  }
}

@container (max-width: 1120px) {
  #settingsTable colgroup col:nth-child(2),
  #settingsTable thead th:nth-child(2),
  #settingsTable tbody td:nth-child(2) {
    display: none;
  }
}

@container (max-width: 980px) {
  #settingsTable colgroup col:nth-child(5),
  #settingsTable thead th:nth-child(5),
  #settingsTable tbody td:nth-child(5) {
    display: none;
  }
}

#freshnessTable thead th {
  text-align: left;
}

#freshnessTable thead th:first-child {
  text-align: left;
}

#freshnessTable thead th:last-child {
  text-align: right;
}

#freshnessTable tbody td:nth-child(2),
#freshnessTable tbody td:nth-child(3),
#freshnessTable tbody td:nth-child(4) {
  text-align: left;
}

#freshnessTable tbody td:last-child {
  text-align: right;
}

#freshnessTable tbody td[colspan] {
  text-align: left !important;
}

@container (max-width: 920px) {
  #freshnessTable colgroup col:nth-child(4),
  #freshnessTable thead th:nth-child(4),
  #freshnessTable tbody td:nth-child(4) {
    display: none;
  }
}

@container (max-width: 760px) {
  #freshnessTable colgroup col:nth-child(2),
  #freshnessTable thead th:nth-child(2),
  #freshnessTable tbody td:nth-child(2) {
    display: none;
  }
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

tfoot td {
  font-weight: 700;
  position: sticky;
  bottom: 0;
  background: var(--panel-strong);
  z-index: 1;
}

#breakdownTable tfoot.is-hidden {
  display: none;
}

.row-name {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.row-name-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.game-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex: 0 0 26px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.setting-icon-large {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  flex: 0 0 auto;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.settings-form label {
  display: grid;
  gap: 8px;
}

.settings-form label span {
  color: var(--muted);
  font-size: 14px;
}

.settings-form label.is-hidden {
  display: none;
}

.settings-form-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
}

.settings-preview-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.settings-preview-meta {
  margin: 6px 0 0;
  color: var(--muted);
}

.settings-icon-button {
  white-space: nowrap;
  flex: 0 0 auto;
}

.settings-app-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-app-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.settings-app-meta {
  display: none;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  white-space: normal;
}

.settings-action-cell {
  text-align: right;
}

.freshness-source {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.freshness-source strong,
.freshness-source span {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.freshness-source span,
.freshness-muted {
  color: var(--muted);
  font-size: 12px;
}

.freshness-last-update,
.freshness-next-update,
.freshness-status-cell {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.freshness-last-update strong,
.freshness-next-update strong {
  font-size: 14px;
}

.freshness-action-cell {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.freshness-run-button {
  min-width: 92px;
}

.freshness-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  border: 1px solid transparent;
}

.freshness-status-trigger {
  cursor: help;
}

.freshness-status-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.freshness-status-chip.is-success {
  color: var(--positive);
  background: color-mix(in srgb, var(--positive) 10%, transparent);
  border-color: color-mix(in srgb, var(--positive) 24%, var(--line));
}

.freshness-status-chip.is-running {
  color: var(--metric-dau);
  background: color-mix(in srgb, var(--metric-dau) 10%, transparent);
  border-color: color-mix(in srgb, var(--metric-dau) 24%, var(--line));
}

.freshness-status-chip.is-partial {
  color: var(--metric-dau);
  background: color-mix(in srgb, var(--metric-dau) 12%, transparent);
  border-color: color-mix(in srgb, var(--metric-dau) 30%, var(--line));
}

.freshness-status-chip.is-error {
  color: var(--negative);
  background: color-mix(in srgb, var(--negative) 10%, transparent);
  border-color: color-mix(in srgb, var(--negative) 24%, var(--line));
}

.freshness-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.freshness-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  border: 1px solid transparent;
}

.freshness-day.is-present {
  color: var(--positive);
  background: color-mix(in srgb, var(--positive) 10%, transparent);
  border-color: color-mix(in srgb, var(--positive) 24%, var(--line));
}

.freshness-day.is-partial {
  color: var(--metric-dau);
  background: color-mix(in srgb, var(--metric-dau) 12%, transparent);
  border-color: color-mix(in srgb, var(--metric-dau) 30%, var(--line));
}

.freshness-day.is-missing {
  color: var(--negative);
  background: color-mix(in srgb, var(--negative) 10%, transparent);
  border-color: color-mix(in srgb, var(--negative) 24%, var(--line));
}

.freshness-day.is-neutral {
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  border-color: color-mix(in srgb, var(--muted) 24%, var(--line));
}

.freshness-error-tooltip {
  position: fixed;
  z-index: 36;
  width: min(340px, calc(100vw - 20px));
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.freshness-error-tooltip .tooltip-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.freshness-error-tooltip .tooltip-title {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.35;
}

.freshness-error-tooltip .tooltip-line {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.freshness-error-tooltip.is-warning {
  border-color: color-mix(in srgb, var(--negative) 26%, var(--line));
}

.row-label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
  flex: 0 0 auto;
}

.row-action {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}

.row-action.is-active {
  border-color: var(--accent);
  background: var(--accent-active);
}

.row-action.is-include {
  color: var(--positive);
}

.row-action.is-exclude {
  color: var(--negative);
}

.country-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.country-label .flag-icon {
  width: 18px;
  height: 13px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line-strong) 80%, transparent);
  display: inline-flex;
  flex: 0 0 auto;
}

.country-flag-fallback {
  width: 18px;
  height: 13px;
  border-radius: 3px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 80%, transparent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.18)),
    linear-gradient(135deg, #667085, #344054);
  color: white;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.country-label-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.value-positive {
  color: var(--positive);
}

.value-negative {
  color: var(--negative);
}

.delta-chip {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.delta-chip.is-positive {
  color: var(--positive);
}

.delta-chip.is-negative {
  color: var(--negative);
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  body.sidebar-collapsed .shell {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  .content-shell {
    padding-inline: 20px;
  }
}

@media (max-width: 780px) {
  .shell {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 0 18px;
  }

  .content-shell {
    display: grid;
    gap: 8px;
    padding: 8px 8px 20px;
    min-width: 0;
    align-content: start;
  }

  .content-stage {
    display: block;
    min-width: 0;
    align-content: start;
  }

  .content-shell > * {
    min-width: 0;
  }

  .desktop-topbar {
    display: none;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 0 2px;
  }

  .mobile-nav-toggle {
    min-height: 34px;
    border-radius: 999px;
    width: 40px;
    min-width: 40px;
    padding-inline: 0;
    font-size: 13px;
    justify-content: center;
  }

  .page-header {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    z-index: 40;
    transform: translateX(calc(-100% - 20px));
    transition: transform 160ms ease;
    overflow: auto;
    min-height: 100dvh;
    border-radius: 0 22px 22px 0;
    padding-top: 18px;
  }

  body.nav-open .page-header {
    transform: translateX(0);
  }

  body.sidebar-collapsed .shell {
    grid-template-columns: 1fr;
  }

  body.sidebar-collapsed .page-header {
    padding-inline: 16px;
  }

  body.sidebar-collapsed .page-nav-button {
    justify-content: flex-start;
    padding-inline: 14px;
  }

  body.sidebar-collapsed .page-nav-label,
  body.sidebar-collapsed .hero-status {
    display: revert;
  }

  body.sidebar-collapsed .sidebar-toggle-button {
    display: none;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(3, 6, 12, 0.54);
    backdrop-filter: blur(2px);
    z-index: 30;
  }

  .nav-backdrop.is-hidden {
    display: none;
  }

  .sidebar-toggle-button {
    display: none;
  }

  .toolbar-actions,
  .chart-legend {
    justify-content: stretch;
  }

  .chart-controls {
    display: grid;
    gap: 4px;
    margin-top: 8px;
    margin-bottom: 8px;
  }

  .date-presets,
  .toolbar-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 1px;
    scrollbar-width: none;
  }

  .date-presets::-webkit-scrollbar,
  .toolbar-actions::-webkit-scrollbar {
    display: none;
  }

  .toolbar-field {
    flex: 0 0 auto;
    gap: 8px;
    font-size: 15px;
  }

  .date-presets button,
  .toolbar-menu-button {
    min-height: 40px;
    padding-inline: 14px;
    font-size: 14px;
  }

  .toolbar-menu-button {
    min-width: 0;
  }

  .label-desktop {
    display: none;
  }

  .label-mobile {
    display: inline;
  }

  .metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }

  .metric-card[data-metric="profit"] {
    grid-column: 1 / -1;
  }

  .metric-card.is-active {
    grid-column: span 1;
  }

  .metric-card {
    padding: 10px 12px;
    gap: 4px;
    min-width: 0;
  }

  .metric-card span {
    font-size: 10px;
  }

  .metric-card strong {
    font-size: clamp(20px, 5vw, 24px);
    overflow-wrap: anywhere;
  }

  .metric-card[data-metric="profit"] strong {
    font-size: clamp(22px, 6vw, 28px);
  }

  .settings-form-preview {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .settings-icon-button {
    width: 100%;
  }

  .chart-shell {
    margin-top: 0;
    min-height: 0;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 10px 10px 4px;
  }

  #timeseriesChart {
    width: 100% !important;
    max-width: 100%;
    height: 200px !important;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }

  .settings-form {
    grid-template-columns: 1fr;
  }

  .settings-editor {
    padding: 18px;
  }

  .page-header,
  .panel,
  .chart-panel {
    padding: 12px;
    border-radius: 16px;
  }

  #settingsScreen,
  #profitScreen,
  #purchasesScreen,
  #importsScreen,
  .settings-panel,
  .freshness-panel {
    min-height: 0;
    height: auto;
  }

  #profitScreen:not(.is-hidden),
  #purchasesScreen:not(.is-hidden),
  #importsScreen:not(.is-hidden) {
    display: block;
  }

  .purchases-toolbar {
    flex-direction: column;
  }

  .purchases-controls {
    width: 100%;
    justify-content: stretch;
  }

  .purchases-control,
  .purchases-controls > button {
    width: 100%;
  }

  .purchases-summary-grid {
    grid-template-columns: 1fr;
  }

  .purchases-chart-shell {
    padding-inline: 10px;
  }

  #purchasesTimeseriesChart {
    white-space: normal;
    height: 190px !important;
  }

  .panel {
    margin-top: 0;
    white-space: normal;
  }

  .chart-panel {
    padding-top: 10px;
  }

  #profitScreen > .chart-panel,
  #profitScreen > .panel,
  #purchasesScreen > .purchases-panel,
  #importsScreen > .freshness-panel {
    margin-top: 0;
  }

  .table-shell {
    white-space: normal;
    width: 100%;
    min-width: 0;
    overflow: visible;
    max-height: none;
    border: 0;
    background: transparent;
  }

  table,
  #breakdownTable,
  #settingsTable,
  #purchaseAliasesTable,
  #purchasesTable,
  #freshnessTable {
    display: block;
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }

  #breakdownTable colgroup,
  #settingsTable colgroup,
  #purchaseAliasesTable colgroup,
  #purchasesTable colgroup,
  #freshnessTable colgroup {
    display: none;
  }

  #breakdownTable thead,
  #breakdownTable tfoot,
  #settingsTable thead,
  #purchaseAliasesTable thead,
  #purchasesTable thead,
  #freshnessTable thead {
    display: none;
  }

  #breakdownTable tbody,
  #settingsTable tbody,
  #purchaseAliasesTable tbody,
  #purchasesTable tbody,
  #freshnessTable tbody {
    display: grid;
    gap: 10px;
    width: 100%;
    min-width: 0;
    align-content: start;
  }

  #breakdownTable tbody.is-total-view,
  #purchasesTable tbody.is-total-view {
    gap: 12px;
  }

  #breakdownTable tbody tr,
  #settingsTable tbody tr,
  #purchaseAliasesTable tbody tr,
  #purchasesTable tbody tr,
  #freshnessTable tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-strong);
    min-width: 0;
    max-width: none;
  }

  #breakdownTable tbody.is-total-view tr {
    grid-template-columns: 1fr;
  }

  #purchasesTable tbody.is-total-view tr {
    grid-template-columns: 1fr;
  }

  #breakdownTable tbody td,
  #settingsTable tbody td,
  #purchaseAliasesTable tbody td,
  #purchasesTable tbody td,
  #freshnessTable tbody td {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    text-align: left !important;
  }

  #purchasesTable tbody td:nth-child(2),
  #purchasesTable tbody td:nth-child(5) {
    display: flex !important;
  }

  #breakdownTable tbody td::before,
  #settingsTable tbody td::before,
  #purchaseAliasesTable tbody td::before,
  #purchasesTable tbody td::before,
  #freshnessTable tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  #breakdownTable tbody td:first-child,
  #settingsTable tbody td:first-child,
  #purchaseAliasesTable tbody td:first-child,
  #purchasesTable tbody td:first-child,
  #freshnessTable tbody td:first-child {
    grid-column: 1 / -1;
  }

  #breakdownTable tbody.is-total-view td,
  #purchasesTable tbody.is-total-view td,
  #freshnessTable tbody td[colspan] {
    grid-column: 1 / -1;
  }

  #breakdownTable tbody td:first-child::before,
  #settingsTable tbody td:first-child::before,
  #purchaseAliasesTable tbody td:first-child::before,
  #purchasesTable tbody td:first-child::before,
  #freshnessTable tbody td:first-child::before,
  #freshnessTable tbody td[colspan]::before {
    display: none;
  }

  #settingsTable tbody td:last-child,
  #purchaseAliasesTable tbody td:last-child {
    grid-column: 1 / -1;
    align-items: flex-end;
  }

  #freshnessTable tbody td:last-child {
    align-items: flex-start;
  }

  #breakdownTable tbody td > *,
  #settingsTable tbody td > *,
  #purchaseAliasesTable tbody td > *,
  #purchasesTable tbody td > *,
  #freshnessTable tbody td > * {
    min-width: 0;
    max-width: 100%;
  }

  .settings-app-meta {
    display: block;
  }
}

@media (max-width: 560px) {
  .shell {
    padding-bottom: 16px;
  }

  .mobile-topbar {
    gap: 6px;
  }

  .mobile-screen-title {
    font-size: 14px;
  }

  #settingsTable tbody tr,
  #purchaseAliasesTable tbody tr,
  #purchasesTable tbody tr,
  #freshnessTable tbody tr {
    grid-template-columns: 1fr;
  }

  #settingsTable tbody td,
  #settingsTable tbody td:last-child,
  #purchaseAliasesTable tbody td,
  #purchaseAliasesTable tbody td:last-child,
  #purchasesTable tbody td,
  #freshnessTable tbody td {
    grid-column: 1 / -1;
    align-items: flex-start;
  }

  .chart-shell {
    padding-inline: 8px;
  }

  #timeseriesChart,
  #purchasesTimeseriesChart {
    height: 178px !important;
  }
}
