/* income-v1 — 收入查詢：全部收入途徑，每日 + 累計. Self-contained per prototype principle. */

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ============ APP SHELL ============ */
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 720px);
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* ============ SIDEBAR ============ */
.sidebar { position: sticky; top: 24px; height: calc(100vh - 48px); display: flex; flex-direction: column; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 32px; font-weight: 800; margin-bottom: 36px; color: var(--text); }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar nav a {
  padding: 14px 18px;
  color: var(--text-soft);
  border-radius: 999px;
  font-weight: 600;
  font-size: 16px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sidebar nav a.active,
.sidebar nav a:hover {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}
.new-post {
  border-radius: 999px;
  background: var(--cta-bg);
  color: var(--cta-text);
  font-weight: 700;
  padding: 14px 22px;
  font-size: 16px;
}

/* ============ MAIN ============ */
.main { min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  min-height: 44px;
  gap: 12px;
}
.topbar .back {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  font-size: 22px;
  color: var(--text);
}
.topbar h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.topbar-brand { display: none; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.topbar-brand img { width: 24px; height: 24px; object-fit: contain; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

/* ============ STATS ============ */
.stats-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}
.stat-card.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-color: transparent;
}
.stat-card small {
  display: block;
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.stat-card.primary small { color: rgba(255,255,255,0.78); }
.stat-card b {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.stat-card.primary b { color: white; font-size: 24px; }
.stat-card .unit { font-size: 11px; font-weight: 600; color: var(--text-soft); }
.stat-card.primary .unit { color: rgba(255,255,255,0.82); }

/* ============ PANE NAV ============ */
.pane-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  padding: 4px;
  margin-bottom: 14px;
}
.pane-nav button {
  padding: 9px 0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.pane-nav button.on {
  background: var(--cta-bg);
  color: var(--cta-text);
}
.list-section[hidden] { display: none !important; }

/* ============ LIST SECTIONS ============ */
.list-section { padding: 0; overflow: hidden; margin-bottom: 14px; }
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.list-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.sort-note { font-size: 11px; color: var(--text-soft); font-weight: 600; }

.cat-list,
.day-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.day-list {
  max-height: min(520px, 64vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cat-list li,
.day-list li { border-bottom: 1px solid var(--line); }
.cat-list li:last-child,
.day-list li:last-child { border-bottom: 0; }

/* 途徑累計行 */
.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  transition: background 0.15s;
}
.cat-row:hover { background: var(--surface-soft); }
.cat-row .cicon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary-dark);
  flex-shrink: 0;
}
.cat-row .info { flex: 1; min-width: 0; }
.cat-row .info b { display: block; font-size: 14px; font-weight: 700; }
.cat-row .info small { display: block; font-size: 11px; color: var(--text-soft); margin-top: 2px; font-variant-numeric: tabular-nums; }
.cat-row .earned { text-align: right; flex-shrink: 0; }
.cat-row .earned b,
.day-row .earned b {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: #2775ca;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.cat-row .earned b i,
.day-row .earned b i,
.dd-row b i { font-style: normal; font-size: 10px; font-weight: 600; color: var(--text-muted); }

/* 每日行（accordion） */
.day-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 18px;
  transition: background 0.15s;
}
.day-row:hover { background: var(--surface-soft); }
.day-row .info { flex: 1; min-width: 0; }
.day-row .info b { display: block; font-size: 14px; font-weight: 700; }
.day-row .info small { display: block; font-size: 11px; color: var(--text-soft); margin-top: 2px; }
.day-row .earned { text-align: right; flex-shrink: 0; }
.day-row .chev { flex-shrink: 0; color: var(--text-muted); transition: transform 0.18s; }
.day-row.open .chev { transform: rotate(180deg); }

.day-detail { padding: 2px 18px 12px 68px; display: grid; gap: 7px; }
.day-detail[hidden] { display: none !important; }
.dd-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.dd-row .dd-ic { color: var(--text-muted); display: grid; place-items: center; }
.dd-row .dd-ic svg { width: 14px; height: 14px; }
.dd-row .dd-name { flex: 1; min-width: 0; color: var(--text-soft); font-weight: 600; }
.dd-row b { font-weight: 800; color: #2775ca; font-variant-numeric: tabular-nums; }
.dd-none { font-size: 12px; color: var(--text-muted); }

.info-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.6;
  text-align: center;
}
.info-note a { color: var(--primary-dark); font-weight: 600; }

/* ============ MOBILE NAV ============ */
.mobile-nav { display: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); padding: 16px; gap: 18px; }
}

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; padding: 0; gap: 0; }
  .sidebar { display: none; }
  .main { padding: 14px 16px 90px; }
  .topbar { padding: 4px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
  .topbar .back { display: inline-flex; }
  .topbar h1 { font-size: 18px; text-align: center; }
  .topbar-brand { display: none; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .stats-row .stat-card.primary { grid-column: 1 / -1; }
  .day-detail { padding-left: 18px; }

  .mobile-nav {
    position: fixed;
    left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    padding: 10px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 20;
  }
  .mobile-nav a { text-align: center; font-size: 12px; color: var(--text-soft); padding: 8px 4px; }
  .mobile-nav a.active { color: var(--text); font-weight: 600; }
  .mobile-nav .compose-btn {
    width: 46px; height: 46px;
    margin: auto; padding: 0;
    border-radius: 50%;
    background: var(--cta-bg); color: var(--cta-text);
    display: grid; place-items: center; line-height: 1;
  }
}

/* ============ 收入結餘卡（入口 → income-transfer-v1） ============ */
.bal-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.bal-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-float); }
.bal-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.bal-info b { font-size: 15px; }
.bal-info small { font-size: 12px; color: var(--text-soft); }
.bal-nums { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.bal-nums b {
  font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: baseline; gap: 5px;
}
.bal-nums b i { font-size: 11px; font-weight: 700; font-style: normal; color: var(--text-soft); }
.bn-pulse { color: #047857; }
.bn-usdc { color: #2775ca; }
.bal-chev { color: var(--text-soft); flex: none; }

/* AirDrop 累積卡（入口 → airdrop-v2） */
.air-ic {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-soft, #eef2ff); color: var(--primary);
}

/* Affiliate 行＝入口，撳入 affiliate-v1（人數 + 30 日 / 累計排行榜） */
.cat-row.cat-link { text-decoration: none; color: inherit; cursor: pointer; }
.cat-row.cat-link .cat-chev { flex-shrink: 0; color: var(--text-muted); }

/* ============ 收入走勢 chart（inline SVG，單一系列 USDC 藍 #2775ca — 已過 palette validator） ============ */
.range-row { display: flex; gap: 6px; margin-bottom: 10px; }
.range-row button {
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.range-row button:hover { border-color: var(--primary); color: var(--primary-dark); }
.range-row button.on { background: var(--cta-bg); color: var(--cta-text); border-color: var(--cta-bg); }

.chart-card { padding: 14px 18px 10px; margin-bottom: 14px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.chart-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.chart-sum { font-size: 11px; color: var(--text-soft); font-weight: 600; white-space: nowrap; }
.chart-wrap { position: relative; outline: 0; border-radius: 10px; }
.chart-wrap:focus-visible { box-shadow: 0 0 0 2px var(--primary-soft); }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; } /* 橫掃睇逐日，上下照捲頁 */
.chart-wrap .grid { stroke: var(--line); stroke-width: 1; }             /* hairline、實線、一級離面 */
.chart-wrap .tick { font-size: 10px; fill: var(--text-soft); font-variant-numeric: tabular-nums; }
.chart-wrap .area { fill: #2775ca; fill-opacity: 0.1; }                 /* 面填 10% wash */
.chart-wrap .line { fill: none; stroke: #2775ca; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-wrap .dot { fill: #2775ca; stroke: var(--surface); stroke-width: 2; } /* ≥8px marker + 2px surface ring */
.chart-wrap .end-label { font-size: 11px; font-weight: 800; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; } /* 文字用 text token，唔着系列色；surface halo 免壓線 */
.chart-wrap .xhair { stroke: var(--text-muted, #9ca3af); stroke-width: 1; }
.chart-wrap .hit { fill: transparent; cursor: crosshair; }
.chart-tip {
  position: absolute; top: 6px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-card); padding: 7px 10px; min-width: 96px;
  transform: translateX(-50%);
}
.chart-tip[hidden] { display: none !important; }
.chart-tip b { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tip b i { display: inline-block; width: 12px; height: 2px; border-radius: 1px; background: #2775ca; } /* line-key，唔係色塊 */
.chart-tip small { display: block; font-size: 10.5px; color: var(--text-soft); margin-top: 2px; }

/* ============ 年度收入報表（income-annual-v1）— 基礎樣式照抄 income-v1 ============ */
/* 年份列：單行、可左右拖（年份會愈嚟愈多，唔可以用固定兩格 grid 否則會跌落第二行） */
#year-nav {
  display: flex; grid-template-columns: none;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin-bottom: 14px; cursor: grab; user-select: none;
}
#year-nav::-webkit-scrollbar { display: none; }
#year-nav.dragging { cursor: grabbing; }
#year-nav button { flex: 1 0 96px; white-space: nowrap; }
.yr-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 14px; }
.yr-dl { display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 999px; background: var(--cta-bg); color: var(--cta-text); font-size: 13px; font-weight: 700; }
.yr-dl:hover { opacity: 0.9; }
.yr-period { font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.yr-total .cat-row { background: var(--surface-soft); }
.yr-total .cat-row:hover { background: var(--surface-soft); }
.yr-month .yr-m { flex: 0 0 64px; font-size: 14px; font-weight: 700; display: flex; flex-direction: column; }
.yr-month .yr-m small { font-size: 10.5px; font-weight: 600; color: var(--text-muted); }
.yr-month .yr-bar { flex: 1; min-width: 0; height: 8px; border-radius: 999px; background: var(--surface-soft); overflow: hidden; }
.yr-month .yr-bar i { display: block; height: 100%; border-radius: 999px; background: #2775ca; }
.yr-month.zero .earned b { color: var(--text-muted); }
.yr-toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px); padding: 10px 16px; border-radius: 999px; background: var(--text); color: #fff; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 300; }
.yr-toast.show { opacity: 1; transform: translate(-50%, 0); }
