/* ── Telegram 主题适配 ── */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f0f0f0);
  --text: var(--tg-theme-text-color, #1a1a1a);
  --hint: var(--tg-theme-hint-color, #999999);
  --accent: var(--tg-theme-button-color, #3390ec);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #3390ec);
  --border: var(--tg-theme-secondary-bg-color, #e5e5e5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  padding-bottom: 60px;
  -webkit-font-smoothing: antialiased;
}

/* ── 页面容器 ── */
#app {
  max-width: 480px;
  margin: 0 auto;
}

.page {
  padding: 12px;
  min-height: calc(100vh - 60px);
}

/* ── 底部导航 ── */
#tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg);
  border-top: 0.5px solid var(--border);
  padding: 4px 0;
  padding-bottom: calc(4px + env(safe-area-inset-bottom));
  z-index: 100;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  cursor: pointer;
  transition: color 0.2s;
  color: var(--hint);
}

.tab svg {
  fill: currentColor;
}

.tab span {
  font-size: 10px;
  font-weight: 500;
}

.tab.active {
  color: var(--accent);
}

/* ── 筛选区 ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 16px;
  border: none;
  background: var(--bg);
  color: var(--hint);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.channel-select {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 0.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23999' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ── 统计卡片网格 ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 14px;
}

.stat-card.highlight {
  grid-column: 1 / -1;
  background: var(--accent);
  color: var(--accent-text);
}

.stat-card .label {
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 4px;
}

.stat-card.highlight .label {
  color: var(--accent-text);
  opacity: 0.8;
}

.stat-card .value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-card.highlight .value {
  font-size: 28px;
}

/* ── 列表 ── */
.list-section {
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
}

.list-item {
  padding: 12px 14px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item .left {
  flex: 1;
  min-width: 0;
}

.list-item .title {
  font-size: 14px;
  font-weight: 500;
}

.list-item .subtitle {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}

.list-item .right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.list-item .amount {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.list-item .amount.positive {
  color: #34c759;
}

.list-item .amount.negative {
  color: #ff3b30;
}

.list-item .detail {
  font-size: 11px;
  color: var(--hint);
  margin-top: 2px;
}

/* ── 状态标签 ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.badge.pending {
  background: #fff3cd;
  color: #856404;
}

.badge.paid {
  background: #d4edda;
  color: #155724;
}

.badge.cancelled {
  background: #f8d7da;
  color: #721c24;
}

/* ── 结算卡片 ── */
.settlement-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 8px;
}

.settlement-card .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.settlement-card .month {
  font-size: 16px;
  font-weight: 600;
}

.settlement-card .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.settlement-card .row .k {
  color: var(--hint);
}

.settlement-card .row .v {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.settlement-card .commission {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 0.5px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settlement-card .commission .v {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

/* ── 加载与空状态 ── */
.loading, .empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--hint);
  font-size: 14px;
}

.loading::after {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
  margin: 12px auto 0;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── 滚动加载更多 ── */
.load-more {
  text-align: center;
  padding: 16px;
  color: var(--hint);
  font-size: 13px;
}

/* ── 页面标题 ── */
.page-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* ── 未绑定页面 ── */
.unbound-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 24px;
}

.unbound-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.unbound-screen h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.unbound-screen p {
  color: var(--hint);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.6;
}

.unbound-id-box {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 16px;
  width: 100%;
  max-width: 280px;
}

.unbound-label {
  display: block;
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 6px;
}

.unbound-id {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.unbound-copy {
  padding: 10px 24px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* ── 语言切换按钮 ── */
.lang-btn {
  position: fixed;
  top: 8px;
  right: 12px;
  z-index: 101;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
