/* ===== CSS Variables ===== */
:root {
  --primary: #1565C0;
  --primary-light: #42A5F5;
  --primary-lighter: #E3F2FD;
  --accent: #FF8F00;
  --accent-light: #FFB300;
  --bg: #F5F7FA;
  --bg-white: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #64748B;
  --text-light: #94A3B8;
  --border: #E2E8F0;
  --success: #43A047;
  --warning: #EF6C00;
  --error: #E53935;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --nav-height: 56px;
  --bottom-nav-height: 64px;
}

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Login Page ===== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-box {
  background: var(--bg-white);
  border-radius: 20px;
  padding: 40px 32px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-box h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--primary);
}

.login-box .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.login-box .emoji-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.login-input:focus {
  border-color: var(--primary-light);
}

.login-btn {
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-btn:hover { background: var(--primary-light); }

.login-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 20px;
}

/* ===== Top Navigation (Desktop) ===== */
.top-nav {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.top-nav .logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-nav .nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.top-nav .nav-links a {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.top-nav .nav-links a:hover,
.top-nav .nav-links a.active {
  background: var(--primary-lighter);
  color: var(--primary);
  text-decoration: none;
}

/* ===== Bottom Navigation (Mobile) ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav .nav-items {
  display: flex;
  height: 100%;
  list-style: none;
}

.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-light);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
  text-decoration: none;
}

.bottom-nav .nav-item .nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.bottom-nav .nav-item.active,
.bottom-nav .nav-item:hover {
  color: var(--primary);
}

/* ===== Page Container ===== */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.page-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.btn-record {
  padding: 8px 16px;
  font-size: 0.9rem;
  white-space: nowrap;
  text-decoration: none;
}

.btn-record:hover { text-decoration: none; }

.btn-link-del {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 0;
  margin-top: 2px;
}

.btn-link-del:hover { color: var(--error); }

/* ===== Expenses page ===== */
.muted-sm { color: var(--text-light); font-size: 0.85rem; }

/* card-balance rows */
.bal-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.bal-row:last-child { border-bottom: none; }
.bal-row.hist { opacity: 0.72; }
.bal-title { font-weight: 600; }
.bal-tag {
  margin-left: 6px;
  font-size: 0.68rem;
  background: var(--border);
  color: var(--text-secondary);
  padding: 1px 7px;
  border-radius: 10px;
  vertical-align: middle;
}
.bal-cats { font-size: 0.75rem; color: var(--text-light); margin-top: 3px; }
.bal-val {
  text-align: right;
  font-weight: 700;
  color: var(--primary);
  font-size: 1.2rem;
  white-space: nowrap;
}
.bal-row.hist .bal-val { color: var(--text-secondary); }
.bal-asof { font-size: 0.7rem; color: var(--text-light); font-weight: 400; margin-top: 3px; }

/* yearly totals */
.yr-block { padding: 12px 0; border-bottom: 1px solid var(--border); }
.yr-block:last-child { border-bottom: none; }
.yr-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.yr-year { font-weight: 700; }
.yr-total { font-weight: 700; color: var(--primary); white-space: nowrap; font-size: 1.1rem; }
.yr-items { display: flex; flex-wrap: wrap; gap: 6px 14px; }

/* ledger rows */
.led-row { cursor: default; align-items: flex-start; }
.led-amt { font-weight: 700; font-size: 1rem; }
.led-acct { font-size: 0.82rem; color: var(--text-secondary); font-weight: 500; margin-left: 4px; }
.led-toggle {
  margin-left: 8px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}
.led-detail {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.led-item { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.7; }
.led-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.tx-edit-btn { cursor: pointer; font-size: 0.95rem; opacity: 0.55; }
.tx-edit-btn:hover { opacity: 1; }
.tx-edit {
  margin-top: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tx-edit .form-input { padding: 6px 8px; font-size: 0.85rem; }
.tx-edit-btns { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.tx-del-icon { margin-left: auto; cursor: pointer; font-size: 1.05rem; opacity: 0.55; }
.tx-del-icon:hover { opacity: 1; }
/* 考级/比赛 编辑行：类别 | 金额 | 明细 | 操作，单行不换行 */
.exam-edit-row, .exam-edit-head {
  display: grid;
  grid-template-columns: 72px 66px minmax(0, 150px) auto;
  align-items: center;
  gap: 6px;
}
.exam-edit-head { font-size: 0.7rem; color: var(--text-light); padding-top: 2px; }
/* 行与行之间要有间距（外层是普通 div，吃不到 .tx-edit 的 flex gap） */
.exam-edit-row + .exam-edit-row { margin-top: 6px; }
.record-item.exam-editing .led-right { display: none; }
.exam-edit-cat {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exam-edit-row .form-input, .exam-edit-row .form-select {
  padding: 5px 6px;
  font-size: 0.82rem;
  width: 100%;
  min-width: 0;
}
.exam-edit-row .form-select { padding-right: 2px; }
.exam-row-ops { display: flex; align-items: center; gap: 8px; padding-left: 2px; }
.exam-row-ops .exam-x { font-size: 1rem; line-height: 1; color: var(--text-light); font-weight: 600; }
.exam-row-ops .exam-x:hover { color: var(--error); }
/* 保存/取消：比行距再拉开一点，按钮也小一号 */
.exam-btns { margin-top: 12px; gap: 8px; }
.exam-btns .btn { padding: 5px 16px; font-size: 0.78rem; }
.exam-edit-top { display: flex; align-items: center; gap: 6px; }
.exam-edit-top .form-input { min-width: 0; }
.exam-edit-top .exam-date { flex: none; width: 130px; }
@media (max-width: 420px) {
  .exam-edit-row, .exam-edit-head { grid-template-columns: 62px 58px minmax(0, 140px) auto; gap: 4px; }
  .exam-edit-cat { font-size: 0.76rem; }
  .exam-edit-row .form-input, .exam-edit-row .form-select { font-size: 0.78rem; padding: 5px 4px; }
  .exam-edit-top .exam-date { width: 120px; }
}

/* 充值/余额 timeline rows */
.stg-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.stg-row:last-child { border-bottom: none; }
.stg-label { color: var(--text-secondary); }
.stg-amt { font-weight: 600; color: var(--success); white-space: nowrap; }
.stg-amt.neg { color: var(--error); }
.stg-bal { font-weight: 700; color: var(--primary); white-space: nowrap; }

/* equipment page */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip:hover { border-color: var(--primary-light); }
.chip-idle.active { background: var(--accent); border-color: var(--accent); }
.chan { font-size: 0.78rem; color: var(--text-light); margin-left: 8px; }

/* expense module sub-tabs + actions (one row) */
.exp-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.exp-tabs { display: flex; gap: 4px; }
.exp-tab {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
  text-decoration: none;
  transition: all 0.15s;
}
.exp-tab:hover { color: var(--primary); text-decoration: none; }
.exp-tab.active { background: var(--primary-lighter); color: var(--primary); }
.exp-actions { display: flex; gap: 8px; }

/* expense stat-card period sub-label */
.period-sub { font-size: 0.74rem; color: var(--text-light); font-weight: 400; }
/* taller stat card: amount vertically centered, label pinned to bottom */
.sc-tall { display: flex; flex-direction: column; min-height: 100px; }
.sc-tall .stat-value { flex: 1; display: flex; align-items: center; justify-content: center; }
.sc-tall .stat-label { margin-top: 0; }

/* stacked monthly chart */
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 10px; }
.lg-item { display: inline-flex; align-items: center; gap: 4px; font-size: 0.74rem; color: var(--text-secondary); }
.lg-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-stack { display: flex; flex-direction: column-reverse; overflow: hidden; background: transparent; }
.chart-stack.empty { background: var(--border); }
.chart-stack.current-month { outline: 2px solid var(--accent); outline-offset: 1px; }
.chart-stack .seg { width: 100%; flex-shrink: 0; }
.chart-stack:hover { transform: none; }
.chart-bar-col.active .chart-stack { outline: 2px solid var(--primary); outline-offset: 1px; }
.chart-bar-col.active .chart-stack.current-month { outline-color: var(--accent); }

.chart-detail {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.cd-head { font-size: 0.9rem; margin-bottom: 8px; color: var(--text-secondary); }
.cd-head b { color: var(--text); }
.cd-rows { display: flex; flex-wrap: wrap; gap: 7px 16px; }
.cd-row { display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem; color: var(--text-secondary); }
.cd-row b { color: var(--text); font-weight: 600; }

.equip-idle { background: #FFF8E1; border-radius: var(--radius-sm); }
.equip-detail-btn { margin-left: 6px; cursor: pointer; font-size: 0.95rem; }
.equip-detail {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.meas-row { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.8; }
.meas-img {
  max-width: 200px;
  max-height: 260px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  display: block;
}
.idle-tag {
  font-size: 0.68rem;
  background: #FFE0B2;
  color: #E65100;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
  vertical-align: middle;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* ===== Stat Cards Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-card .stat-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.stat-card .stat-breakdown {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  line-height: 1.5;
}
.stat-card .stat-breakdown .type-tag {
  font-size: 0.65rem;
  padding: 1px 6px;
  margin-right: 0;
  text-align: center;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== Heatmap ===== */
.heatmap-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  padding-top: 32px;
}

.heatmap-wrapper {
  display: inline-flex;
  gap: 3px;
  min-width: min-content;
}

.heatmap-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #EBEDF0;
  cursor: pointer;
  position: relative;
}

.heatmap-cell[data-level="1"] { background: #C6E48B; }
.heatmap-cell[data-level="2"] { background: #7BC96F; }
.heatmap-cell[data-level="3"] { background: #239A3B; }
.heatmap-cell[data-level="4"] { background: #196127; }

.heatmap-cell .tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 10;
}

.heatmap-cell:hover .tooltip,
.heatmap-cell.active .tooltip { display: block; }

.heatmap-cell .tooltip.tip-left {
  left: auto;
  right: 0;
  transform: none;
}

.heatmap-cell .tooltip.tip-right {
  left: 0;
  transform: none;
}

.heatmap-months {
  display: flex;
  font-size: 0.7rem;
  color: var(--text-light);
  margin-bottom: 4px;
  padding-left: 32px;
}

.heatmap-months span {
  flex: 1;
  min-width: 45px;
}

.heatmap-days {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-right: 6px;
  font-size: 0.65rem;
  color: var(--text-light);
  justify-content: space-between;
  padding: 2px 0;
}

.heatmap-body {
  display: flex;
  align-items: flex-start;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 8px;
  justify-content: flex-end;
}

.heatmap-legend .legend-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* ===== Progress Bar ===== */
.progress-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.progress-label {
  min-width: 48px;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--primary);
}

.progress-name {
  flex: 1;
  font-size: 0.98rem;
  color: var(--text);
}

.progress-bar-wrap {
  flex: 2;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  border-radius: 4px;
  transition: width 0.6s ease;
}

.progress-pct {
  min-width: 40px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

/* ===== Status Badge ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-mastered { background: #E8F5E9; color: var(--success); }
.badge-learning { background: #FFF3E0; color: var(--accent); }
.badge-not-started { background: #F5F5F5; color: var(--text-light); }

/* ===== Course type tags ===== */
.type-tag {
  display: inline-block;
  padding: 2px 8px;
  margin-right: 4px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  background: var(--primary-lighter);
  color: var(--primary);
}
.type-tag:last-child { margin-right: 0; }
.type-ice      { background: #E3F2FD; color: #1565C0; }
.type-land     { background: #FFF3E0; color: #E65100; }
.type-dance    { background: #FCE4EC; color: #C2185B; }
.type-fitness  { background: #E8F5E9; color: #2E7D32; }
.type-private  { background: #F3E5F5; color: #6A1B9A; }
.type-group    { background: #E0F7FA; color: #006064; }
.type-other    { background: #F5F5F5; color: #616161; }
.type-trr      { background: #EDE7F6; color: #4527A0; }

/* ===== Record List ===== */
.record-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

.record-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.monthly-summary-card {
  border-left: 3px solid var(--primary);
  background: var(--primary-lighter);
}

.record-date {
  min-width: 48px;
  text-align: center;
}

.record-date .day {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.record-date .month {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.record-info {
  flex: 1;
  min-width: 0;
}

.record-info .title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-info .meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.record-duration {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

/* ===== Monthly Chart ===== */
.monthly-chart-outer {
  display: flex;
  align-items: flex-end;
}

.monthly-chart {
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  min-width: 0;
}

.chart-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 176px; /* match chart-bars-wrap */
  margin-right: 4px;
  flex-shrink: 0;
  margin-bottom: 20px; /* x-label height */
  padding-top: 36px; /* match tooltip room */
}

.chart-y-label {
  font-size: 0.7rem;
  color: var(--text-light);
  text-align: right;
  min-width: 28px;
  line-height: 1;
}

.chart-bars-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: min-content;
}

.chart-bars-wrap {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 176px; /* 140 bar area + 36 tooltip room */
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  padding: 36px 4px 0 8px; /* top=tooltip room */
  position: relative;
}

.chart-grid-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--border);
  pointer-events: none;
}

.chart-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  position: relative;
  height: 100%;
  z-index: 1;
}

/* Hovered or tapped bar rises above siblings */
.chart-bar-col:hover,
.chart-bar-col.active {
  z-index: 20;
}

.chart-bar {
  width: 24px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  position: relative;
  min-height: 2px;
}

.chart-bar:hover {
  background: var(--primary-light);
  transform: scaleX(1.1);
}

.chart-bar.current-month {
  background: var(--accent);
}

.chart-bar.current-month:hover {
  background: var(--accent-light);
}

.chart-bar.empty {
  background: var(--border);
  min-height: 2px;
}

.chart-bar .chart-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.chart-bar .chart-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text);
}

/* Edge tooltip alignment: left-edge bars align right, right-edge bars align left */
.chart-bar .chart-tooltip.tip-right {
  left: 0;
  transform: none;
}
.chart-bar .chart-tooltip.tip-right::after {
  left: 12px;
  transform: none;
}
.chart-bar .chart-tooltip.tip-left {
  left: auto;
  right: 0;
  transform: none;
}
.chart-bar .chart-tooltip.tip-left::after {
  left: auto;
  right: 12px;
  transform: none;
}

/* Show tooltip on hover (desktop) and on .active (mobile tap) */
.chart-bar:hover .chart-tooltip,
.chart-bar-col.active .chart-tooltip {
  display: block;
}

.chart-x-labels {
  display: flex;
  gap: 4px;
  padding: 0 4px 0 8px;
}

.chart-x-label {
  width: 24px;
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-light);
  margin-top: 4px;
  flex-shrink: 0;
}

.chart-x-label.year-start {
  font-weight: 700;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .chart-bar {
    width: 18px;
  }
  .chart-x-label {
    width: 18px;
    font-size: 0.6rem;
  }
  .chart-bars-wrap {
    gap: 3px;
  }
  .chart-x-labels {
    gap: 3px;
  }
  .chart-y-axis {
    height: 156px; /* 120 + 36 */
  }
  .chart-bars-wrap {
    height: 156px; /* 120 bar area + 36 tooltip room */
  }
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.filter-select:focus { border-color: var(--primary-light); }

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-white);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--primary-light);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-light); }

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover { background: #CBD5E1; }

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover { background: var(--accent-light); }

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary-light);
  background: var(--primary-lighter);
}

.upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.upload-zone .upload-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.upload-zone .upload-hint {
  color: var(--text-light);
  font-size: 0.8rem;
  margin-top: 4px;
}

/* ===== Voice Queue Item ===== */
.voice-item {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.voice-item .voice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.voice-item .voice-status {
  font-size: 0.8rem;
  font-weight: 600;
}

.voice-item .voice-status.pending { color: var(--warning); }
.voice-item .voice-status.processing { color: var(--primary-light); }
.voice-item .voice-status.done { color: var(--success); }
.voice-item .voice-status.error { color: var(--error); }

.voice-transcript {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 8px 0;
  max-height: 200px;
  overflow-y: auto;
}

/* ===== Timeline (Milestones) ===== */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid var(--bg-white);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.timeline-item.highlight::before {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.timeline-date {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 600;
}

.timeline-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 4px 0;
}

.timeline-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.timeline-type {
  display: inline-block;
  margin-top: 6px;
}

/* ===== Exam Progress Cards ===== */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.exam-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}

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

.exam-system-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.exam-badge-isi {
  background: #E8F5E9;
  color: #2E7D32;
}

.exam-badge-isu {
  background: #E3F2FD;
  color: #1565C0;
}

.exam-cat-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.exam-level-display {
  line-height: 1;
}

.exam-level-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.exam-level-max {
  font-size: 0.9rem;
  color: var(--text-light);
}

.exam-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

.badge-exam {
  background: #EDE7F6;
  color: #5E35B1;
}

.timeline-item.exam::before {
  background: #7E57C2;
  box-shadow: 0 0 0 2px #7E57C2;
}

.badge-competition {
  background: #FFF3E0;
  color: #E65100;
}

.timeline-item.competition::before {
  background: #FB8C00;
  box-shadow: 0 0 0 2px #FB8C00;
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.btn-icon:hover {
  background: rgba(0,0,0,0.05);
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.tab {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab.active,
.tab:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Segmented control (iOS-style) — used by 技术进度 category tabs */
.seg-tabs {
  display: flex;
  gap: 4px;
  background: #eceff4;
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 20px;
}
.seg-tab {
  flex: 1;
  text-align: center;
  padding: 11px 6px;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.seg-tab .seg-ico { margin-right: 5px; }
.seg-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(20, 40, 80, 0.14);
}

/* ===== Audio Player ===== */
.audio-player {
  width: 100%;
  margin: 8px 0;
  border-radius: var(--radius-sm);
}

/* ===== Detail Page ===== */
.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-header .back-btn {
  font-size: 1.2rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

.detail-header .back-btn:hover {
  background: var(--border);
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* ===== Loading / Empty States ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state .empty-text {
  font-size: 1rem;
}

/* ===== Toast Notification ===== */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .top-nav .nav-links { display: none; }
  .bottom-nav { display: block; }

  .page { padding: 16px 12px; }
  .page-title { font-size: 1.3rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .stat-value { font-size: 1.5rem; }

  .heatmap-cell { width: 12px; height: 12px; }

  .filter-bar { flex-direction: column; }
  .filter-select { width: 100%; }
}

@media (min-width: 769px) {
  .bottom-nav { display: none !important; }
  .top-nav .nav-links { display: flex; }
  body { padding-bottom: 20px; }
}
