:root {
  --bg: #f6f6f2;
  --panel: #ffffff;
  --text: #1e2523;
  --muted: #68716e;
  --line: #dcded8;
  --line-strong: #c3c7c0;
  --accent: #c44a3d;
  --accent-soft: #f7e9e5;
  --teal: #147c73;
  --focus: #2c68a2;
  --radius: 6px;
  --shadow: 0 12px 32px rgba(31, 41, 38, 0.09);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(44, 104, 162, 0.22);
  outline-offset: 2px;
}

.app-header {
  min-height: 76px;
  padding: 14px clamp(18px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  border: 1px solid #27302d;
  border-radius: var(--radius);
  background: #27302d;
  font-size: 25px;
}

.brand h1,
.brand p,
.content-toolbar h2,
.content-toolbar p,
.filter-section h2 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.top-nav {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 24px;
}

.top-nav a {
  height: 100%;
  padding: 0 2px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}

.top-nav a:hover {
  color: var(--text);
}

.top-nav a.active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.source-status {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid #bad5cf;
  border-radius: 999px;
  color: #10675f;
  background: #eef8f5;
  font-size: 12px;
  font-weight: 600;
}

.workspace {
  width: 100%;
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.filters {
  padding: 24px 22px 32px;
  background: #f0f1ed;
  border-right: 1px solid var(--line);
  font-size: 12px;
}

.filter-section {
  padding: 0 0 24px;
  margin: 0 0 24px;
  border-bottom: 1px solid var(--line);
}

.filter-section:last-child {
  border-bottom: 0;
}

.filter-section h2 {
  margin-bottom: 12px;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 700;
}

.metric-nav {
  display: grid;
  gap: 2px;
}

.metric-nav button {
  min-height: 38px;
  padding: 5px 8px;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.metric-nav button:hover {
  background: rgba(255, 255, 255, 0.65);
}

.metric-nav button.active {
  border-color: var(--line-strong);
  border-left-color: var(--accent);
  background: var(--panel);
}

.metric-nav strong {
  min-width: 0;
  font-size: 12px;
}

.metric-nav span {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.metric-section {
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.metric-section h2 {
  margin-bottom: 7px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.time-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  width: 28px;
  height: 16px;
  position: relative;
  display: inline-block;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #d9dcd7;
}

.switch-track::after {
  content: "";
  width: 10px;
  height: 10px;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(31, 41, 38, 0.2);
  transition: transform 150ms ease;
}

.switch-control input:checked + .switch-track {
  border-color: var(--teal);
  background: var(--teal);
}

.switch-control input:checked + .switch-track::after {
  transform: translateX(12px);
}

.switch-control input:focus-visible + .switch-track {
  outline: 3px solid rgba(44, 104, 162, 0.22);
  outline-offset: 2px;
}

.text-button {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--focus);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.text-button:hover {
  text-decoration: underline;
}

.field-label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.date-input,
.picker-trigger,
.search-box {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
}

.date-input {
  padding: 7px 9px;
  color: var(--text);
  font-size: 12px;
}

.year-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

.year-options label {
  position: relative;
  cursor: pointer;
}

.year-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.year-options span {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line-strong);
  background: var(--panel);
  font-size: 11px;
  font-weight: 650;
}

.year-options label:last-child span {
  border-right: 0;
}

.year-options input:checked + span {
  background: #27302d;
  color: #fff;
}

.year-options input:focus-visible + span {
  outline: 3px solid rgba(44, 104, 162, 0.22);
  outline-offset: -3px;
}

.month-day-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.month-day-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.month-day-inputs select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 11px;
}

.quick-range,
.picker-actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}

.quick-range button,
.picker-actions button {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.quick-range button:hover,
.picker-actions button:hover {
  background: var(--panel);
}

.picker-actions .picker-done {
  margin-left: auto;
  border-color: #27302d;
  background: #27302d;
  color: #fff;
}

.picker-actions .picker-done:hover {
  background: #3c4642;
}

.country-section {
  position: relative;
  z-index: 4;
}

.country-picker {
  position: relative;
}

.picker-trigger {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}

.picker-trigger:hover {
  border-color: #8f9690;
}

.picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: min(330px, calc(100vw - 32px));
  padding: 10px;
  z-index: 10;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.search-box {
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.country-list {
  max-height: 286px;
  margin-top: 8px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.country-option {
  min-height: 37px;
  padding: 7px 5px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #eceee9;
  cursor: pointer;
  font-size: 11px;
}

.country-option:hover {
  background: #f7f8f5;
}

.country-option.pinned-option {
  background: var(--accent-soft);
  font-weight: 650;
}

.country-option.pinned-last {
  margin-bottom: 6px;
  border-bottom-color: var(--line-strong);
}

.country-option.pinned-option:hover {
  background: #f3ddd8;
}

.country-option input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.country-option .code {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.selection-preview {
  min-height: 20px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.segmented-control {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented-control button {
  min-width: 0;
  min-height: 38px;
  padding: 5px 4px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: var(--panel);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  background: #27302d;
  color: #fff;
}

.definition-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.content {
  min-width: 0;
  padding: 30px clamp(18px, 3.5vw, 54px) 28px;
}

.content-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin-bottom: 5px !important;
  color: var(--accent);
  font-size: 11px;
  line-height: 1.4;
  font-weight: 700;
}

.content-toolbar h2 {
  font-size: 30px;
  line-height: 1.25;
  font-weight: 720;
}

.export-button {
  min-height: 38px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.export-button:hover {
  border-color: #868d88;
  background: #fbfbf9;
}

.export-icon {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.summary-strip {
  margin-top: 25px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-item {
  min-width: 0;
  padding: 15px clamp(10px, 2vw, 22px);
  border-right: 1px solid var(--line);
}

.summary-item:first-child {
  padding-left: 0;
}

.summary-item:last-child {
  border-right: 0;
}

.summary-item span,
.summary-item small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.summary-item strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text);
  font-size: 24px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

body[data-metric="revenue"] .summary-item strong {
  font-size: 20px;
}

.summary-item small {
  min-height: 14px;
  margin-top: 1px;
}

.view-tabs {
  margin-top: 24px;
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.view-tabs button {
  min-height: 38px;
  padding: 8px 1px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.view-tabs button.active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.chart-view {
  min-width: 0;
}

.chart-legend {
  min-height: 45px;
  padding: 12px 0 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}

.legend-item {
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
}

.legend-item.muted {
  opacity: 0.35;
}

.legend-swatch {
  width: 16px;
  height: 3px;
  border-radius: 1px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: clamp(330px, 48vh, 500px);
  min-height: 330px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

#dauChart {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-tooltip {
  position: absolute;
  min-width: 170px;
  max-width: 280px;
  padding: 9px 10px;
  z-index: 3;
  pointer-events: none;
  border-radius: var(--radius);
  background: rgba(30, 37, 35, 0.96);
  color: #fff;
  box-shadow: 0 8px 20px rgba(30, 37, 35, 0.18);
  font-size: 11px;
}

.tooltip-date {
  margin-bottom: 6px;
  color: #cfd5d1;
  font-weight: 650;
}

.tooltip-row {
  margin-top: 3px;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.tooltip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.tooltip-row strong {
  font-variant-numeric: tabular-nums;
}

.tooltip-more {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  color: #cfd5d1;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 5px;
  text-align: center;
}

.empty-state strong {
  font-size: 14px;
}

.empty-state span {
  color: var(--muted);
  font-size: 12px;
}

.table-meta {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.table-scroll {
  width: 100%;
  max-height: clamp(360px, 55vh, 610px);
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  min-width: 120px;
  padding: 9px 11px;
  border-right: 1px solid #eceee9;
  border-bottom: 1px solid #eceee9;
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f0f1ed;
  font-weight: 700;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  min-width: 108px;
  z-index: 1;
  background: var(--panel);
  text-align: left;
}

th:first-child {
  z-index: 3;
  background: #f0f1ed;
}

tbody tr:hover td {
  background: #fafaf7;
}

tbody tr:hover td:first-child {
  background: #f5f6f2;
}

.total-column {
  background: #fbf2ef;
  font-weight: 700;
}

.data-note {
  padding: 15px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .workspace {
    display: block;
  }

  .filters {
    padding: 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filter-section.metric-section {
    grid-column: 1 / -1;
    padding: 0 0 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .metric-nav button {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .filter-section {
    min-width: 0;
    padding: 0 16px 0 0;
    margin: 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .filter-section:last-child {
    padding-right: 0;
    border-right: 0;
  }

  .content {
    padding-top: 24px;
  }

  .summary-item strong {
    font-size: 20px;
  }

  body[data-metric="revenue"] .summary-item strong {
    font-size: 18px;
  }
}

@media (max-width: 640px) {
  .app-header {
    min-height: 68px;
    padding: 10px 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    font-size: 21px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .brand p {
    max-width: 180px;
    font-size: 10px;
  }

  .top-nav {
    margin-left: auto;
  }

  .top-nav a {
    font-size: 12px;
  }

  .source-status {
    display: none;
  }

  .filters {
    display: block;
  }

  .filter-section {
    padding: 0 0 16px;
    margin: 0 0 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filter-section.metric-section {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
  }

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

  .metric-nav button {
    min-height: 54px;
    padding: 7px 6px;
    text-align: center;
  }

  .metric-nav strong {
    font-size: 11px;
  }

  .metric-nav span {
    font-size: 11px;
  }

  .picker-panel {
    position: fixed;
    top: 78px;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }

  .country-list {
    max-height: calc(100vh - 210px);
  }

  .segmented-control button {
    font-size: 11px;
  }

  .content {
    padding: 20px 14px 24px;
  }

  .content-toolbar {
    align-items: center;
  }

  .content-toolbar h2 {
    font-size: 21px;
  }

  .summary-item strong,
  body[data-metric="revenue"] .summary-item strong {
    font-size: 17px;
  }

  .export-button {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
  }

  .export-label {
    display: none;
  }

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

  .summary-item {
    border-bottom: 1px solid var(--line);
  }

  .summary-item:nth-child(2) {
    border-right: 0;
  }

  .summary-item:nth-child(3),
  .summary-item:nth-child(4) {
    border-bottom: 0;
  }

  .summary-item:nth-child(3) {
    padding-left: 0;
  }

  .chart-wrap {
    height: 340px;
    min-height: 340px;
  }

  .chart-tooltip {
    max-width: 230px;
  }
}
