:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-strong: #15313b;
  --text: #17252b;
  --muted: #64757d;
  --line: #d9e1e4;
  --accent: #0f8f83;
  --accent-strong: #0a6b63;
  --warn: #c76a32;
  --danger: #b7413d;
  --soft: #eef6f3;
  --shadow: 0 16px 42px rgba(21, 49, 59, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 143, 131, 0.08), transparent 320px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.global-shell {
  width: min(1760px, calc(100vw - 32px));
}

.domestic-shell {
  width: min(1760px, calc(100vw - 32px));
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--panel-strong);
}

.page-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.page-tabs a {
  min-width: 112px;
  padding: 13px 18px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  color: #4f5e64;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.page-tabs a:hover {
  color: var(--accent-strong);
}

.page-tabs a.active {
  background: rgba(238, 246, 243, 0.98);
  color: #06933d;
  border-color: var(--line);
  box-shadow: inset 0 -3px 0 #14b35c;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.status-strip a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

.status-dot.ready {
  background: var(--accent);
}

.control-band,
.summary-band,
.ranking-band,
.table-band {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-band {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) repeat(4, minmax(142px, 1fr));
  gap: 14px;
  padding: 16px;
  align-items: end;
}

label {
  min-width: 0;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 131, 0.14);
}

.wide {
  grid-column: span 2;
}

.actions {
  display: flex;
  gap: 10px;
}

button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

button svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 800;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.summary-band,
.ranking-band,
.table-band {
  margin-top: 18px;
  padding: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-title > button,
.pager button {
  width: 40px;
  padding: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.domestic-shell .metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 12px;
}

.country-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 12px;
}

.country-card {
  min-height: 168px;
  padding: 14px;
}

.country-card .platform-name {
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 900;
  color: var(--panel-strong);
}

.country-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(112px, 0.75fr);
  gap: 12px;
}

.country-primary strong {
  margin-top: 8px;
  font-size: 24px;
}

.country-secondary {
  display: grid;
  align-content: end;
  gap: 6px;
  min-height: 82px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.country-secondary strong {
  margin-top: 6px;
  font-size: 20px;
}

.country-secondary .compare {
  margin-top: 0;
}

.platform-order-split {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.platform-order-split > div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.platform-order-split strong {
  margin-top: 6px;
  font-size: 18px;
}

.metric {
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, var(--soft));
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
  line-height: 1.2;
  color: var(--panel-strong);
  overflow-wrap: anywhere;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.platform-name {
  display: block;
  margin-bottom: 12px;
  color: var(--panel-strong);
  font-size: 18px;
  font-weight: 900;
}

.platform-metric .platform-name {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 900;
}

.platform-metric {
  min-height: 150px;
  padding: 14px;
}

.metric-pair {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.platform-metric .metric-pair > div {
  min-height: 86px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.metric-pair strong {
  font-size: 18px;
}

.ranking-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ranking-wrap table {
  min-width: 900px;
}

.ranking-wrap th:first-child,
.ranking-wrap td:first-child {
  width: 72px;
  text-align: center;
}

.rank-badge {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.compare {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.compare.up {
  color: #0b7d45;
}

.compare.down {
  color: var(--danger);
}

.compare.flat {
  color: var(--muted);
}

.rate-source {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.message {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(199, 106, 50, 0.35);
  border-radius: 6px;
  background: rgba(199, 106, 50, 0.08);
  color: #7c3d19;
}

.table-wrap {
  max-height: calc(100vh - 110px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.overseas-control {
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
}

.overseas-table-wrap {
  max-height: calc(100vh - 180px);
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f1f5f5;
  color: #31464e;
  font-weight: 800;
}

.sticky-col {
  position: sticky;
  background: #fff;
}

th.sticky-col {
  z-index: 5;
  background: #f1f5f5;
}

td.sticky-col {
  z-index: 2;
}

.sticky-platform {
  left: 0;
  width: 220px;
  min-width: 220px;
  max-width: 220px;
}

.sticky-sales {
  left: 220px;
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  box-shadow: 1px 0 0 var(--line);
}

th.sticky-sales {
  z-index: 6;
}

.platform-row .sticky-col {
  background: #eef6f3;
}

tbody tr:hover .sticky-col {
  background: #edf8f6;
}

.compare-col {
  min-width: 132px;
}

.table-compare {
  font-weight: 800;
}

.table-compare.up {
  color: #0b7d45;
}

.table-compare.down {
  color: var(--danger);
}

.table-compare.flat {
  color: var(--muted);
}

tbody tr:hover {
  background: rgba(15, 143, 131, 0.06);
}

.platform-row {
  background: #eef6f3;
  font-weight: 800;
}

.platform-row td {
  border-bottom-color: #c9dbd7;
}

.shop-row td:first-child {
  color: #31464e;
}

.tree-toggle {
  width: 28px;
  height: 28px;
  margin-right: 8px;
  padding: 0;
  vertical-align: middle;
}

.tree-toggle svg {
  width: 16px;
  height: 16px;
}

.tree-indent {
  display: inline-block;
  width: 36px;
}

.empty {
  height: 180px;
  color: var(--muted);
  text-align: center;
}

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

  .metric-grid {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
  }

  .country-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .overseas-control {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 14px;
  }

  .topbar {
    min-height: auto;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 0 18px;
  }

  .page-tabs {
    overflow-x: auto;
  }

  h1 {
    font-size: 25px;
  }

  .control-band {
    grid-template-columns: 1fr;
  }

  .country-grid,
  .overseas-control {
    grid-template-columns: 1fr;
  }

  .country-metrics {
    grid-template-columns: 1fr;
  }

  .country-secondary {
    min-height: auto;
    padding-top: 10px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .wide {
    grid-column: auto;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .platform-metric .metric-pair {
    grid-template-columns: 1fr;
  }
}
