:root {
  --primary: #E53935;
  --primary-dark: #C62828;
  --primary-light: #FFEBEE;
  --primary-soft: rgba(229, 57, 53, 0.12);
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --bg: #FFFFFF;
  --card: #FFFFFF;
  --border: #ECEEF2;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --clip-radius: 22px;
  --clip-pill: 999px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 56px;
  --nav-float-gap: 20px;
  --app-height: 100dvh;
  --a-stock: #E53935;
  --us-stock: #2E7D32;
  --wealth: #C9A227;
  --loss: #2E7D32;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background: transparent;
}

html.is-fixed-page,
html.is-fixed-page body {
  overflow: hidden;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  min-height: -webkit-fill-available;
  overscroll-behavior: none;
}

body.page-home,
body.page-profile-body,
body.app-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.app-shell {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100%;
  position: relative;
  background: transparent;
}

.page-home .app-shell,
.page-profile-body .app-shell,
.app-page .app-shell {
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.page-content-compact {
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px calc(var(--nav-height) + var(--safe-bottom) + var(--nav-float-gap) * 2 + 12px);
}

/* Clip containers */
.clip-bar {
  background: var(--card);
  border-radius: var(--clip-pill);
  padding: 6px 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.clip-panel {
  background: var(--card);
  border-radius: var(--clip-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.clip-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--clip-pill);
  padding: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.clip-tab {
  flex: 1;
  padding: 9px 10px;
  text-align: center;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--clip-pill);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.clip-tab.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.clip-nav-wrap {
  position: fixed;
  bottom: calc(var(--nav-float-gap) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 402px;
  z-index: 100;
  pointer-events: none;
}

.clip-nav-wrap .bottom-nav {
  pointer-events: auto;
}

/* Home — no scroll viewport */
.page-home {
  overflow: hidden;
}

.page-home .app-shell {
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.home-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px calc(var(--nav-height) + var(--nav-float-gap) + var(--safe-bottom) + 8px);
  min-height: 0;
  overflow: hidden;
}

.home-main {
  flex-shrink: 0;
}

.page-home.keyboard-open .home-viewport {
  flex: 1;
  min-height: 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.page-home.keyboard-open.keyboard-gap-fallback .home-viewport {
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px) + var(--keyboard-gap, 0px) * 0.35);
}

.page-home.keyboard-open .home-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--keyboard-gap, 0px);
}

.page-home.keyboard-open .btn-save-clip {
  display: none;
}

.page-home.keyboard-open .amount-input:focus {
  scroll-margin-top: 12px;
  scroll-margin-bottom: 20px;
}

.page-home.keyboard-open .clip-nav-wrap {
  visibility: hidden;
  pointer-events: none;
}

.home-viewport .date-nav-compact,
.stats-viewport .date-nav-compact {
  margin-bottom: 8px;
  padding: 8px 12px;
}

.home-viewport .date-nav-compact button,
.stats-viewport .date-nav-compact button {
  width: 38px;
  height: 38px;
  font-size: 20px;
  border-radius: var(--clip-pill);
}

.home-viewport .date-nav-compact .date-display .date-main,
.stats-viewport .date-nav-compact .date-display .date-main {
  font-size: 17px;
}

.home-viewport .date-nav-compact .date-display .date-sub,
.stats-viewport .date-nav-compact .date-display .date-sub {
  font-size: 12px;
}

.day-summary-v2.day-summary-clip {
  padding: 12px 14px 10px;
  margin-bottom: 8px;
}

.day-summary-v2.day-summary-clip .summary-head {
  text-align: center;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(229, 57, 53, 0.08);
}

.day-summary-v2.day-summary-clip .summary-label {
  font-size: 12px;
  margin-bottom: 4px;
}

.day-summary-v2.day-summary-clip .summary-total .amount {
  font-size: 30px;
}

.day-summary-v2.day-summary-clip .summary-total .currency {
  font-size: 16px;
}

.day-summary-v2.day-summary-clip .summary-breakdown {
  gap: 6px;
}

.day-summary-v2.day-summary-clip .breakdown-cell {
  padding: 8px 6px;
}

.day-summary-v2.day-summary-clip .cell-label {
  font-size: 11px;
  margin-bottom: 3px;
}

.day-summary-v2.day-summary-clip .cell-value {
  font-size: 14px;
}

.day-summary-v2.day-summary-clip::before {
  width: 90px;
  height: 90px;
  top: -36px;
  right: -24px;
}

.summary-inline .summary-total {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.summary-inline .summary-total .amount.positive { color: var(--primary); }
.summary-inline .summary-total .amount.negative { color: var(--loss); }
.summary-inline .summary-total.tone-positive .currency { color: var(--primary); }
.summary-inline .summary-total.tone-negative .currency { color: var(--loss); }

.summary-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.summary-inline .summary-main {
  flex-shrink: 0;
  min-width: 108px;
}

.summary-inline .summary-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
  display: block;
}

.summary-inline .summary-total .amount {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.summary-inline .summary-total .currency {
  font-size: 15px;
}

.summary-breakdown-inline {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  min-width: 0;
}

.summary-breakdown-inline .breakdown-cell {
  padding: 6px 4px;
  border-radius: 10px;
}

.summary-breakdown-inline .cell-label {
  font-size: 10px;
  margin-bottom: 2px;
}

.summary-breakdown-inline .cell-value {
  font-size: 13px;
}

.home-records {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-home .record-row {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 14px 14px 18px;
  min-height: 56px;
  margin-bottom: 0;
  border-radius: 0 var(--clip-radius) var(--clip-radius) 0;
  overflow: hidden;
}

.page-home .record-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.page-home .record-row-top .type-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.page-home .record-row .type-icon {
  width: 34px;
  height: 34px;
  font-size: 18px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.page-home .record-row .type-icon i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  line-height: 1;
}

.page-home .record-row .type-name {
  font-size: 15px;
  font-weight: 600;
}

.page-home .record-row .record-input-row {
  flex: 1;
  max-width: 210px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
}

.page-home .record-row .record-input-row .currency {
  font-size: 18px;
}

.page-home .record-row .record-input-row input {
  font-size: 20px;
  padding: 4px 0;
}

.page-home .record-row .convert-hint {
  font-size: 10px;
  margin-top: 4px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fx-strip {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 8px 0;
  min-height: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.fx-strip b {
  color: var(--us-stock);
  font-weight: 700;
}

.btn-save-clip {
  flex-shrink: 0;
  margin-top: auto;
  padding: 13px 20px;
  font-size: 16px;
  border-radius: var(--clip-pill);
  border: none;
}

@media (max-height: 680px) {
  .day-summary-v2.day-summary-clip .summary-total .amount { font-size: 26px; }
  .home-viewport .date-nav-compact button { width: 34px; height: 34px; font-size: 18px; }
  .page-home .record-row { padding: 11px 12px 11px 16px; min-height: 50px; }
  .page-home .record-row .record-input-row input { font-size: 18px; }
  .btn-save-clip { padding: 10px 18px; font-size: 15px; }
}

.page-profile {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

.page-profile-body {
  overflow: hidden;
}

.page-profile-body .app-shell {
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.profile-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px calc(var(--nav-height) + var(--nav-float-gap) + var(--safe-bottom) + 8px);
  min-height: 0;
  overflow: hidden;
}

.profile-viewport .profile-header {
  padding: 20px 16px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.profile-viewport .profile-avatar {
  width: 60px;
  height: 60px;
  font-size: 30px;
  margin-bottom: 10px;
}

.profile-viewport .profile-name {
  font-size: 19px;
}

.profile-viewport .menu-list {
  flex-shrink: 0;
  margin-bottom: 12px;
}

.profile-viewport .menu-item {
  padding: 13px 16px;
}

.profile-viewport .btn-logout {
  margin-top: auto;
  flex-shrink: 0;
  border-radius: var(--clip-pill);
}

/* Stats — fixed shell, scroll inside content only */
.page-stats .app-shell {
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stats-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px calc(var(--nav-height) + var(--nav-float-gap) + var(--safe-bottom) + 8px);
}

.stats-viewport .clip-tabs,
.stats-viewport .stats-tabs {
  flex-shrink: 0;
}

.scroll-pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.page-header-compact {
  padding: 8px 12px 6px;
}

.page-header-compact h1 {
  font-size: 17px;
}

.page-header-compact .subtitle {
  display: none;
}

.date-nav-compact {
  padding: 6px 10px;
  margin-bottom: 8px;
}

.date-nav-compact button {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.date-nav-compact .date-display .date-main {
  font-size: 15px;
}

.date-nav-compact .date-display .date-sub {
  font-size: 11px;
}

.day-summary-compact {
  padding: 12px 14px;
  margin-bottom: 8px;
}

/* Home summary card v2 */
.day-summary-v2 {
  background: linear-gradient(165deg, #FFF8F8 0%, #FFFFFF 45%);
  border-radius: var(--radius);
  padding: 18px 16px 14px;
  margin-bottom: 10px;
  box-shadow: 0 4px 18px rgba(229, 57, 53, 0.1);
  border: 1px solid rgba(229, 57, 53, 0.1);
  position: relative;
  overflow: hidden;
  color: var(--text);
}

.day-summary-v2::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(229, 57, 53, 0.12) 0%, transparent 68%);
  pointer-events: none;
}

.day-summary-v2 .summary-head {
  text-align: center;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(229, 57, 53, 0.08);
}

.day-summary-v2 .summary-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
}

.day-summary-v2 .summary-total {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.day-summary-v2 .summary-total .amount {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  color: var(--text);
}

.day-summary-v2 .summary-total .amount.positive {
  color: var(--primary);
}

.day-summary-v2 .summary-total .amount.negative {
  color: var(--loss);
}

.day-summary-v2 .summary-total .currency {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}

.day-summary-v2 .summary-total.tone-positive .currency { color: var(--primary); }
.day-summary-v2 .summary-total.tone-negative .currency { color: var(--loss); }

.day-summary-v2 .summary-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.day-summary-v2 .breakdown-cell {
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}

.day-summary-v2 .breakdown-cell.a-stock {
  background: #FEF2F2;
}

.day-summary-v2 .breakdown-cell.us-stock {
  background: #F0F7F0;
}

.day-summary-v2 .breakdown-cell.wealth {
  background: #FFFBEB;
}

.day-summary-v2 .cell-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.day-summary-v2 .breakdown-cell.a-stock .cell-label { color: var(--a-stock); }
.day-summary-v2 .breakdown-cell.us-stock .cell-label { color: var(--us-stock); }
.day-summary-v2 .breakdown-cell.wealth .cell-label { color: var(--wealth); }

.day-summary-v2 .cell-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.day-summary-v2 .cell-value.positive { color: var(--primary); }
.day-summary-v2 .cell-value.negative { color: var(--loss); }
.day-summary-v2 .cell-value.zero { color: var(--text-secondary); }

.day-summary-compact .summary-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.day-summary-compact .label {
  margin-bottom: 0;
  font-size: 12px;
}

.day-summary-compact .total-row {
  margin-bottom: 0;
}

.day-summary-compact .total-row .amount {
  font-size: 24px;
}

.day-summary-compact .total-row .currency {
  font-size: 14px;
}

.day-summary-compact .mini-breakdown {
  gap: 8px;
}

.day-summary-compact .mini-item .mini-label {
  font-size: 10px;
}

.day-summary-compact .mini-item .mini-value {
  font-size: 12px;
}

.record-card-compact {
  padding: 10px 12px 10px 16px;
  margin-bottom: 8px;
}

.record-card-compact .record-card-header {
  margin-bottom: 6px;
}

.record-card-compact .type-icon {
  width: 28px;
  height: 28px;
  font-size: 15px;
}

.record-card-compact .type-name {
  font-size: 14px;
}

.record-card-compact .record-input-row .currency {
  font-size: 16px;
}

.record-card-compact .record-input-row input {
  font-size: 20px;
}

.convert-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.4;
}

.convert-hint b {
  color: var(--us-stock);
  font-weight: 700;
}

.convert-hint .convert-rate {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-save-inline {
  margin-top: 4px;
  padding: 12px;
  font-size: 15px;
}

.page-content {
  padding: 16px 16px calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

.page-header {
  padding: 12px 16px 8px;
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-header .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.2s;
}

.bottom-nav a.active {
  color: var(--primary);
}

.bottom-nav a i {
  font-size: 22px;
  margin-bottom: -8px;
}

.clip-nav-wrap .bottom-nav.clip-nav {
  position: static;
  transform: none;
  width: 100%;
  max-width: none;
  height: var(--nav-height);
  padding-bottom: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--clip-pill);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.clip-nav-wrap .bottom-nav.clip-nav a.active {
  font-weight: 600;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--clip-radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

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

.btn-primary:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

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

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

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

/* Type badges */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.type-badge.a-stock { background: rgba(229, 57, 53, 0.1); color: var(--a-stock); }
.type-badge.us-stock { background: rgba(46, 125, 50, 0.1); color: var(--us-stock); }
.type-badge.wealth { background: rgba(201, 162, 39, 0.12); color: var(--wealth); }

/* Amount display */
.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.amount.positive { color: var(--primary); }
.amount.negative { color: var(--loss); }
.amount.zero { color: var(--text-muted); font-weight: 500; }

.amount-lg {
  font-size: 28px;
  letter-spacing: -0.5px;
}

.amount-md {
  font-size: 18px;
}

/* Breakdown bar */
.breakdown-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin: 10px 0 8px;
  background: var(--border);
}

.breakdown-bar span {
  height: 100%;
  transition: width 0.3s;
}

.breakdown-bar .seg-a { background: var(--a-stock); }
.breakdown-bar .seg-u { background: var(--us-stock); }
.breakdown-bar .seg-w { background: var(--wealth); }

.breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.breakdown-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.breakdown-legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(26, 26, 46, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 999;
  transition: transform 0.3s;
  max-width: 90%;
  text-align: center;
}

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

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: transparent;
}

.login-logo {
  width: 72px;
  height: 72px;
  background: var(--primary);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(229, 57, 53, 0.3);
}

.login-logo i {
  font-size: 36px;
  color: #fff;
}

.login-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.login-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 36px;
}

.login-form {
  width: 100%;
  max-width: 360px;
}

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

/* Date picker row */
.date-nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: var(--clip-pill);
  padding: 10px 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.date-nav button {
  position: relative;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--clip-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.date-nav button:active {
  background: var(--primary-soft);
}

.date-nav .date-display {
  text-align: center;
  flex: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.date-nav .date-display .date-main {
  font-size: 16px;
  font-weight: 700;
}

.date-nav .date-display .date-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.date-picker-hidden {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  z-index: -1;
}

/* Record cards */
.record-card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 16px 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.record-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 0;
}

.record-card.a-stock::before { background: var(--a-stock); }
.record-card.us-stock::before { background: var(--us-stock); }
.record-card.wealth::before { background: var(--wealth); }

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

.record-card-header .type-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-card-header .type-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.record-card.a-stock .type-icon { background: rgba(229, 57, 53, 0.1); color: var(--a-stock); }
.record-card.us-stock .type-icon { background: rgba(46, 125, 50, 0.1); color: var(--us-stock); }
.record-card.wealth .type-icon { background: rgba(201, 162, 39, 0.12); color: var(--wealth); }

.record-card-header .type-name {
  font-size: 15px;
  font-weight: 700;
}

.record-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.record-input-row .currency {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-secondary);
}

.record-input-row input {
  flex: 1;
  border: none;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  outline: none;
  background: transparent;
  font-variant-numeric: tabular-nums;
}

.record-input-row input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.rate-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.rate-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}

.rate-row .rate-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  width: 100%;
  margin-bottom: 2px;
}

.rate-row .rate-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.rate-row .rate-input {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  outline: none;
}

.rate-row .rate-input:focus {
  border-color: var(--us-stock);
}

/* Save bar */
.save-bar {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  padding: 10px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
  z-index: 90;
}

.save-bar .btn {
  font-size: 16px;
  padding: 14px;
}

.save-bar .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Summary strip */
.day-summary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(229, 57, 53, 0.25);
}

.day-summary .label {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 4px;
}

.day-summary .total-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 14px;
}

.day-summary .total-row .currency {
  font-size: 18px;
  font-weight: 600;
}

.day-summary .total-row .amount {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  color: #fff;
}

.day-summary .total-row .amount.negative {
  color: #C8E6C9;
}

.day-summary .mini-breakdown {
  display: flex;
  gap: 16px;
}

.day-summary .mini-item {
  flex: 1;
}

.day-summary .mini-item .mini-label {
  font-size: 11px;
  opacity: 0.75;
  margin-bottom: 2px;
}

.day-summary .mini-item .mini-value {
  font-size: 14px;
  font-weight: 700;
}

/* Stats tabs (clip style) */
.stats-tabs,
.clip-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--clip-pill);
  padding: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.stats-tab,
.clip-tab {
  flex: 1;
  padding: 9px 10px;
  text-align: center;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--clip-pill);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.stats-tab.active,
.clip-tab.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* Calendar */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-header button {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}

.calendar-header .month-label {
  font-size: 16px;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekday {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0;
  font-weight: 600;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

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

.calendar-day.other-month {
  color: var(--text-muted);
  opacity: 0.4;
}

.calendar-day.today {
  background: var(--primary-soft);
  font-weight: 700;
  color: var(--primary);
}

.calendar-day.selected {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.calendar-day .day-num {
  line-height: 1;
}

.calendar-day .day-amount {
  font-size: 9px;
  margin-top: 2px;
  font-weight: 600;
  opacity: 0.85;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day .day-amount.positive {
  color: #C62828;
}

.calendar-day .day-amount.negative {
  color: #2E7D32;
}

.calendar-day.selected .day-amount.positive,
.calendar-day.selected .day-amount.negative {
  color: rgba(255, 255, 255, 0.95);
}

.calendar-board {
  padding: 12px;
  margin-bottom: 12px;
}

.mini-card-board-summary .summary-value.positive { color: var(--primary); }
.mini-card-board-summary .summary-value.negative { color: var(--loss); }
.mini-card-board-summary .summary-value.zero { color: var(--text-muted); }

/* Mini card grid (month/year stats) */
.mini-card-board {
  background: var(--card);
  border-radius: var(--clip-radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.mini-card-board-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

.mini-card-board-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--clip-pill);
  margin-bottom: 14px;
}

.mini-card-board-summary .summary-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.mini-card-board-summary .summary-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

.mini-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mini-card {
  aspect-ratio: 1;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
}

.mini-card:active {
  transform: scale(0.96);
}

.mini-card.zero {
  background: #F3F4F6;
  color: var(--text-muted);
}

.mini-card.positive {
  background: #FFEBEE;
  color: #C62828;
}

.mini-card.negative {
  background: #E8F5E9;
  color: #2E7D32;
}

.mini-card.selected {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: none;
}

.mini-card.selected.positive,
.mini-card.selected.negative,
.mini-card.selected.zero {
  background: var(--primary);
  color: #fff;
}

.mini-card.selected .mini-label,
.mini-card.selected .mini-value {
  color: #fff;
}

.mini-card .mini-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.mini-card .mini-value {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-card.zero .mini-value {
  font-weight: 500;
}

@media (min-width: 380px) {
  .mini-card-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Month/Year large cards (legacy, kept for detail) */
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

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

.stat-card-header .period {
  font-size: 16px;
  font-weight: 700;
}

.stat-card-header .total {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.stat-card-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.stat-card-details .detail-item {
  text-align: center;
  padding: 8px 4px;
  background: var(--bg);
  border-radius: 8px;
}

.stat-card-details .detail-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.stat-card-details .detail-value {
  font-size: 13px;
  font-weight: 700;
}

/* Profile */
.profile-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 24px 20px;
  text-align: center;
  color: #fff;
  border-radius: var(--clip-radius);
  margin: 0 0 12px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(229, 57, 53, 0.15);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 32px;
  border: 3px solid rgba(255, 255, 255, 0.4);
}

.profile-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-id {
  font-size: 13px;
  opacity: 0.8;
}

.menu-list {
  background: var(--card);
  border-radius: var(--clip-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

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

.menu-item:active {
  background: var(--bg);
}

.menu-item .menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-size: 18px;
}

.menu-item .menu-icon.red { background: rgba(229, 57, 53, 0.1); color: var(--primary); }
.menu-item .menu-icon.blue { background: rgba(46, 125, 50, 0.1); color: var(--us-stock); }
.menu-item .menu-icon.green { background: rgba(201, 162, 39, 0.12); color: var(--wealth); }
.menu-item .menu-icon.gray { background: var(--bg); color: var(--text-secondary); }

.menu-item .menu-text {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.menu-item .menu-extra {
  font-size: 13px;
  color: var(--text-muted);
  margin-right: 4px;
}

.menu-item .menu-arrow {
  color: var(--text-muted);
  font-size: 16px;
}

.btn-logout {
  margin-top: 8px;
  background: var(--card);
  color: var(--primary);
  border: 1.5px solid var(--border);
}

/* Period nav — legacy alias, shares date-nav look */
.period-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--card);
  border-radius: var(--clip-pill);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.period-nav button {
  width: 38px;
  height: 38px;
  border: none;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--clip-pill);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.period-nav .period-label {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  flex: 1;
}

/* Selected day detail panel */
.day-detail-panel {
  background: var(--card);
  border-radius: var(--clip-radius);
  padding: 16px;
  margin-top: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.day-detail-panel .panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

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

.empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

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

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

@media (max-width: 360px) {
  .stat-card-details .detail-value {
    font-size: 12px;
  }
}
