@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f5f7fb;
  --bg-2: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #5b6473;
  --border: #e2e8f0;
  --border-soft: rgba(15, 23, 42, 0.08);
  --primary: #1e40af;
  --primary-press: #1d4ed8;
  --primary-soft: rgba(30, 64, 175, 0.14);
  --accent: #f59e0b;
  --grid: rgba(15, 23, 42, 0.05);
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 8px 18px rgba(15, 23, 42, 0.08);
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --mono: "Fira Code", "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Fira Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(900px 520px at 15% -10%, rgba(30, 64, 175, 0.18), transparent 60%),
    radial-gradient(700px 380px at 95% 0%, rgba(245, 158, 11, 0.16), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 65%, #f8fafc 100%);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.65;
}

.app {
  max-width: 1024px;
  margin: 0 auto;
  padding: 28px 18px 56px;
}

.topbar {
  padding: 8px 4px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

.title-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.subtitle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  max-width: 100%;
  white-space: normal;
}

.store-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid rgba(30, 64, 175, 0.25);
  box-shadow: 0 8px 18px rgba(30, 64, 175, 0.12);
}

.section-label {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-soft);
}

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

.card h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
}

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

.form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}

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

input,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(30, 64, 175, 0.5);
  box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.12);
  background: var(--surface-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  box-shadow: none;
}

.btn.ghost:hover {
  background: var(--surface-2);
}

.btn.small {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.btn.primary {
  background: linear-gradient(180deg, #2b59c3 0%, var(--primary) 100%);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(30, 64, 175, 0.25);
}

.btn.primary:hover {
  transform: translateY(-1px);
}

.btn.primary:active {
  transform: translateY(0);
  background: var(--primary-press);
}

.error {
  color: #ff3b30;
  font-size: 13px;
}

.hidden {
  display: none;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.header-row {
  align-items: flex-start;
  flex-wrap: wrap;
}

.header-row > :first-child {
  flex: 1;
  min-width: 220px;
}

.settlement-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 0 22px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
}

.settlement-status.pending {
  color: #111827;
}

.settlement-status.settled {
  color: #c53030;
  border: 3px solid rgba(197, 48, 48, 0.75);
  border-radius: 12px;
  background: rgba(197, 48, 48, 0.06);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
  transform: rotate(-8deg);
}

.month-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: nowrap;
}

.month-label {
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 2.5em;
}

.month-picker select {
  flex: 1;
  min-width: 140px;
  border: none;
  padding: 4px 2px;
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.tabs {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  width: 100%;
  max-width: 380px;
}

.tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tab:hover {
  background: rgba(30, 64, 175, 0.08);
  color: var(--text);
}

.tab.active {
  background: linear-gradient(180deg, #2b59c3 0%, var(--primary) 100%);
  color: #ffffff;
  border-color: rgba(30, 64, 175, 0.35);
  box-shadow: 0 8px 18px rgba(30, 64, 175, 0.2);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.metric {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: var(--surface);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.metric .label {
  color: var(--muted);
  font-size: 13px;
}

.metric .value {
  font-size: 22px;
  font-weight: 600;
  margin-top: 8px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.metric.highlight {
  border-color: rgba(30, 64, 175, 0.35);
  background: linear-gradient(180deg, var(--primary-soft), rgba(255, 255, 255, 0.96));
}

.detail-section {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.detail-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.rank-section {
  margin-top: 18px;
}

.rank-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.rank-header h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.rank-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.rank-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
}

.rank-item.top-1 {
  border-color: rgba(245, 158, 11, 0.6);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.18), rgba(255, 255, 255, 0.96));
  box-shadow: 0 8px 18px rgba(245, 158, 11, 0.2);
}

.rank-item.top-2 {
  border-color: rgba(148, 163, 184, 0.7);
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.2), rgba(255, 255, 255, 0.96));
}

.rank-item.top-3 {
  border-color: rgba(249, 115, 22, 0.55);
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.18), rgba(255, 255, 255, 0.96));
}

.rank-item.me {
  border-color: rgba(245, 158, 11, 0.7);
  background: rgba(245, 158, 11, 0.12);
}

.rank-num {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.rank-item.top-1 .rank-num {
  background: #f59e0b;
  color: #1f2937;
  border-color: rgba(245, 158, 11, 0.6);
}

.rank-item.top-2 .rank-num {
  background: #cbd5e1;
  color: #1f2937;
  border-color: rgba(148, 163, 184, 0.7);
}

.rank-item.top-3 .rank-num {
  background: #fb923c;
  color: #1f2937;
  border-color: rgba(249, 115, 22, 0.6);
}

.rank-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rank-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.rank-value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.table {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.table .row {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}

.table .row:nth-child(even) {
  background: rgba(248, 250, 252, 0.6);
}

.table .row:last-child {
  border-bottom: none;
}

.table .row.table-header {
  background: rgba(30, 64, 175, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 12px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  animation: rise 0.45s ease both;
}

.metric {
  animation: rise 0.55s ease both;
}

.metric:nth-child(2) { animation-delay: 0.04s; }
.metric:nth-child(3) { animation-delay: 0.08s; }
.metric:nth-child(4) { animation-delay: 0.12s; }
.metric:nth-child(5) { animation-delay: 0.16s; }

@media (max-width: 720px) {
  .app {
    padding: 20px 14px 44px;
  }

  .title {
    font-size: 26px;
  }

  .subtitle {
    font-size: 11px;
  }

  .store-badge {
    font-size: 12px;
  }

  .card {
    padding: 16px;
  }

  .metric .value {
    font-size: 20px;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .header-row > :first-child {
    min-width: 0;
  }

  .settlement-status {
    width: 100%;
    min-height: 64px;
    font-size: 30px;
    letter-spacing: 0.05em;
    text-align: center;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    align-self: flex-start;
  }

  .tabs {
    width: 100%;
    justify-content: space-between;
  }

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

  .rank-item {
    grid-template-columns: 28px 1fr auto;
    row-gap: 0;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --bg-2: #0f172a;
    --surface: #0f172a;
    --surface-2: #121b2f;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.2);
    --border-soft: rgba(148, 163, 184, 0.16);
    --primary: #60a5fa;
    --primary-press: #3b82f6;
    --primary-soft: rgba(96, 165, 250, 0.18);
    --accent: #fbbf24;
    --grid: rgba(148, 163, 184, 0.08);
    --shadow: 0 18px 40px rgba(2, 6, 23, 0.6);
    --shadow-soft: 0 10px 24px rgba(2, 6, 23, 0.5);
  }

  body {
    background:
      radial-gradient(900px 520px at 15% -10%, rgba(96, 165, 250, 0.22), transparent 60%),
      radial-gradient(700px 380px at 95% 0%, rgba(251, 191, 36, 0.18), transparent 55%),
      linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 70%, #0b1424 100%);
  }

  .subtitle {
    border-color: rgba(96, 165, 250, 0.4);
    background: rgba(96, 165, 250, 0.15);
    color: #bfdbfe;
  }

  .store-badge {
    background: rgba(15, 23, 42, 0.95);
    color: #f8fafc;
    border-color: rgba(96, 165, 250, 0.5);
    box-shadow: 0 12px 22px rgba(2, 6, 23, 0.6);
  }

  input,
  select {
    background: #0b1324;
    color: var(--text);
    border-color: rgba(148, 163, 184, 0.25);
  }

  .month-picker {
    background: rgba(15, 23, 42, 0.9);
  }

  .tabs {
    background: rgba(15, 23, 42, 0.85);
  }

  .tab:hover {
    background: rgba(96, 165, 250, 0.14);
    color: var(--text);
  }

  .btn.ghost {
    border-color: rgba(148, 163, 184, 0.3);
    color: var(--text);
  }

  .btn.ghost:hover {
    background: rgba(148, 163, 184, 0.15);
  }

  .tab.active {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
    border-color: rgba(96, 165, 250, 0.4);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.35);
    color: #ffffff;
  }

  .metric {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(148, 163, 184, 0.2);
  }

  .settlement-status.pending {
    color: #e2e8f0;
  }

  .settlement-status.settled {
    color: #fca5a5;
    border-color: rgba(252, 165, 165, 0.8);
    background: rgba(239, 68, 68, 0.14);
    box-shadow: inset 0 0 0 2px rgba(15, 23, 42, 0.65);
  }

  .metric.highlight {
    border-color: rgba(96, 165, 250, 0.5);
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.24), rgba(15, 23, 42, 0.92));
  }

  .detail-section {
    background: rgba(15, 23, 42, 0.92);
  }

  .table {
    background: rgba(15, 23, 42, 0.85);
  }

  .table .row.table-header {
    background: rgba(96, 165, 250, 0.16);
  }

  .rank-item {
    background: rgba(15, 23, 42, 0.85);
    border-color: rgba(148, 163, 184, 0.2);
  }

  .rank-item.top-1 {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), rgba(15, 23, 42, 0.92));
  }

  .rank-item.top-2 {
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.24), rgba(15, 23, 42, 0.92));
  }

  .rank-item.top-3 {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.22), rgba(15, 23, 42, 0.92));
  }

  .table .row:nth-child(even) {
    background: rgba(2, 6, 23, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .metric,
  .btn {
    animation: none;
    transition: none;
  }
}
