/* ==========================================================================
   Personal Desktop Accounting System - #C9E4FB Calibrated Soft Pastel Palette
   (以 #C9E4FB 藍色為基準色調，全面淡化對照的極致柔和粉嫩馬卡龍色系)
   ========================================================================== */

:root {
  /* Benchmark Blue: #C9E4FB (Lightness ~89%, Soft Pastel) */
  --blue-benchmark: #c9e4fb;
  --blue-light: #f0f7fe;
  --blue-border: #b8dcf9;
  --blue-text: #2b6cb0;

  /* App Backgrounds */
  --bg-app: #f8fafd;           /* 輕透晴空牛奶白 / Pale Sky White */
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fbfdff;
  --bg-subtle: #f0f6fc;        /* 輕柔淡藍粉霧 / Soft Pastel Mist */
  --bg-input: #ffffff;

  /* Delicate Soft Borders calibrated to #C9E4FB */
  --border-light: #e2effa;      /* 柔和輕藍粉邊框 */
  --border-subtle: #edf5fc;
  --border-focus: #c9e4fb;      /* 基準粉藍聚焦 */

  /* Gentle Warm Navy Slate Text (柔和海鹽暖灰，消除刺眼純黑) */
  --text-main: #334155;         /* 柔和深藍灰 / Soft Navy Slate */
  --text-muted: #64748b;        /* 寧靜灰藍 / Slate Muted */
  --text-subtle: #94a3b8;       /* 淺霧灰藍 / Pale Slate */
  --text-white: #ffffff;

  /* Calibrated Semantic Accents (均對照 #C9E4FB 的明度與柔和度 ~89% 淡化) */
  /* 1. 薄荷綠牛奶 (Mint Green) - 收入 (對照 #C9E4FB: #D1F4E6 / #F2FBF7) */
  --income-primary: #10b981;
  --income-light: #f0fbf6;
  --income-border: #b8ecd6;
  --income-hover: #d1f4e6;
  --income-text: #167950;

  /* 2. 草莓櫻花粉 (Strawberry Pink) - 支出 (對照 #C9E4FB: #FACBD5 / #FEF3F5) */
  --expense-primary: #fb7185;
  --expense-light: #fef2f5;
  --expense-border: #f7b5c3;
  --expense-hover: #facbd5;
  --expense-text: #b8284b;

  /* 3. 雲朵薰衣草紫 (Lavender Violet) - 結餘 & 主題 (對照 #C9E4FB: #DDD1FA / #F7F4FE) */
  --balance-primary: #a78bfa;
  --balance-light: #f7f4fe;
  --balance-border: #cbb8f7;
  --balance-hover: #ddd1fa;
  --balance-text: #5f32b8;

  /* 4. 蜜桃暖杏黃 (Peach Apricot) - 警示 (對照 #C9E4FB: #FDE4C8 / #FFF8F1) */
  --warning-primary: #fb923c;
  --warning-light: #fff8f1;
  --warning-border: #fbd1a3;
  --warning-hover: #fde4c8;
  --warning-text: #b55d08;

  /* 5. 基準天空粉藍 (Baby Sky Blue) - 品牌與月份標籤 */
  --brand-primary: #3b82f6;
  --brand-light: #f0f7fe;
  --brand-border: #c9e4fb;
  --brand-hover: #b8dcf9;
  --brand-text: #2563eb;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Zen Maru Gothic", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Diffused Soft Sky Shadows */
  --shadow-xs: 0 1px 3px rgba(201, 228, 251, 0.25), 0 1px 2px rgba(100, 116, 139, 0.02);
  --shadow-sm: 0 3px 10px rgba(201, 228, 251, 0.35), 0 1px 4px rgba(100, 116, 139, 0.03);
  --shadow-md: 0 8px 24px -2px rgba(201, 228, 251, 0.45), 0 4px 12px -2px rgba(100, 116, 139, 0.04);
  --shadow-lg: 0 16px 36px -4px rgba(201, 228, 251, 0.55), 0 8px 18px -4px rgba(100, 116, 139, 0.05);
  --shadow-modal: 0 25px 50px -12px rgba(51, 65, 85, 0.2);

  /* Radii */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.18s ease;
  --transition-normal: 0.28s ease;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

/* App Layout Grid */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   Left Sidebar (~25% width, min 290px, max 380px)
   ========================================================================== */
.sidebar {
  width: 25%;
  min-width: 290px;
  max-width: 380px;
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1.5px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 2px 0 16px rgba(201, 228, 251, 0.2);
}

.sidebar-header {
  padding: 24px 20px 18px 20px;
  border-bottom: 1.5px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Logo & Brand Wrapper (200px x 200px Centered Prominent Display) */
.brand-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  margin-bottom: 18px;
  width: 100%;
}

.brand-icon-wrapper {
  width: 200px;
  height: 200px;
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 2.5px solid var(--blue-benchmark);
  box-shadow: 0 6px 24px rgba(201, 228, 251, 0.55);
  flex-shrink: 0;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.brand-icon-wrapper:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 30px rgba(201, 228, 251, 0.75);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.brand-text p {
  font-size: 0.8rem;
  color: var(--blue-text);
  font-weight: 700;
  margin-top: 1px;
}

/* Cloud Status & Auth Pill Bar */
.cloud-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  margin-bottom: 14px;
  width: 100%;
  transition: all var(--transition-fast);
}

.cloud-status-card:hover {
  background: var(--blue-light);
  border-color: var(--blue-border);
}

.cloud-status-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.cloud-status-indicator {
  font-size: 0.85rem;
  line-height: 1;
}

.indicator-connected {
  color: #10b981; /* Emerald */
  text-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.indicator-local {
  color: #f59e0b; /* Amber */
}

.indicator-offline {
  color: #ef4444; /* Rose */
}

.cloud-status-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-cloud-settings {
  font-size: 0.82rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-cloud-settings:hover {
  color: var(--blue-text);
  background: #ffffff;
}

.config-instructions-box {
  background: #f8fbfe;
  border: 1.5px solid var(--blue-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.84rem;
}

/* Primary Action Buttons (Calibrated Pastel Pills) */
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.btn-action-income {
  background-color: var(--income-light);
  color: var(--income-text);
  border: 1.5px solid var(--income-border);
}

.btn-action-income:hover {
  background-color: var(--income-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(184, 236, 214, 0.4);
}

.btn-action-expense {
  background-color: var(--expense-light);
  color: var(--expense-text);
  border: 1.5px solid var(--expense-border);
}

.btn-action-expense:hover {
  background-color: var(--expense-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(247, 181, 195, 0.4);
}

.btn-action-month {
  background-color: var(--balance-light);
  color: var(--balance-text);
  border: 1.5px solid var(--balance-border);
}

.btn-action-month:hover {
  background-color: var(--balance-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(203, 184, 247, 0.4);
}

/* Sidebar Navigation Tabs */
.sidebar-nav {
  padding: 12px 16px;
  display: flex;
  gap: 6px;
  border-bottom: 1.5px solid var(--border-subtle);
}

.nav-tab {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-align: center;
  transition: all var(--transition-fast);
}

.nav-tab:hover {
  color: var(--text-main);
  background-color: var(--bg-subtle);
}

.nav-tab.active {
  background-color: var(--blue-light);
  color: var(--blue-text);
  border: 1.5px solid var(--blue-border);
}

/* Sidebar Month List */
.sidebar-months-section {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
}

.section-title {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-subtle);
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  padding-left: 8px;
}

.month-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.month-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1.5px solid transparent;
}

.month-item:hover {
  background-color: var(--bg-subtle);
}

.month-item.active {
  background-color: var(--blue-light);
  border-color: var(--blue-border);
  font-weight: 800;
  color: var(--blue-text);
  box-shadow: var(--shadow-xs);
}

.month-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.month-item-badge {
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
}

.month-item.active .month-item-badge {
  background: #ffffff;
  color: var(--blue-text);
  border: 1px solid var(--blue-border);
  font-weight: 700;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1.5px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  transition: all var(--transition-fast);
}

.footer-btn:hover {
  color: var(--blue-text);
  background-color: var(--blue-light);
  border-color: var(--blue-border);
}

/* ==========================================================================
   Right Main Area (75%)
   ========================================================================== */
.main-content {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  background-color: var(--bg-app);
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Dashboard Header */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.month-nav-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}

.btn-nav-month {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-nav-month:hover {
  color: var(--blue-text);
  background-color: var(--blue-light);
}

/* Account Mode Switcher Pills (雙軌對照 / 工作室 / 個人) */
.account-view-switcher {
  display: flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  gap: 4px;
}

.account-view-tab {
  padding: 6px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.account-view-tab:hover {
  color: var(--text-main);
  background-color: var(--bg-subtle);
}

.account-view-tab.active {
  background-color: var(--blue-benchmark);
  color: #1e4e8c;
  box-shadow: 0 2px 6px rgba(201, 228, 251, 0.6);
}

/* ==========================================================================
   Dual Status Section (Studio vs Personal Side-by-Side Comparison)
   ========================================================================== */
.dual-status-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dual-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.dual-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.dual-card-studio {
  background: linear-gradient(145deg, #ffffff 0%, #f4f8fe 100%);
  border-color: #c9e4fb;
}

.dual-card-personal {
  background: linear-gradient(145deg, #ffffff 0%, #fbf8ff 100%);
  border-color: #e9d5ff;
}

.dual-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dual-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dual-badge {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dual-badge-studio {
  background-color: #c9e4fb;
  color: #1e4e8c;
  border: 1px solid #b8dcf9;
}

.dual-badge-personal {
  background-color: #ddd1fa;
  color: #5f32b8;
  border: 1px solid #cbb8f7;
}

.dual-quick-actions {
  display: flex;
  gap: 6px;
}

.btn-dual-quick {
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-dual-quick-income {
  background-color: var(--income-light);
  color: var(--income-text);
  border: 1px solid var(--income-border);
}

.btn-dual-quick-income:hover {
  background-color: var(--income-hover);
}

.btn-dual-quick-expense {
  background-color: var(--expense-light);
  color: var(--expense-text);
  border: 1px solid var(--expense-border);
}

.btn-dual-quick-expense:hover {
  background-color: var(--expense-hover);
}

.dual-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 10px;
  background: #ffffff;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.dual-mini-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dual-mini-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.dual-mini-val {
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
}

.text-income {
  color: var(--income-text);
}

.text-expense {
  color: var(--expense-text);
}

.dual-balance-highlight {
  color: var(--blue-text);
  font-size: 1.15rem;
}

.dual-card-personal .dual-balance-highlight {
  color: var(--balance-text);
}

/* ==========================================================================
   Summary Stat Cards (3 Major Cards - #C9E4FB Calibrated Palette)
   ========================================================================== */
.stats-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: 18px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.stat-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.stat-tag-income {
  background-color: var(--income-light);
  color: var(--income-text);
  border: 1px solid var(--income-border);
}

.stat-tag-expense {
  background-color: var(--expense-light);
  color: var(--expense-text);
  border: 1px solid var(--expense-border);
}

.stat-tag-balance {
  background-color: var(--balance-light);
  color: var(--balance-text);
  border: 1px solid var(--balance-border);
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.stat-card-income .stat-value {
  color: var(--income-text);
}

.stat-card-expense .stat-value {
  color: var(--expense-text);
}

/* Highlighted Net Balance Card (Lavender Glow) */
.stat-card-balance {
  background: linear-gradient(145deg, #ffffff 0%, #faf8ff 100%);
  border: 1.5px solid var(--balance-border);
  box-shadow: var(--shadow-md);
}

.stat-card-balance .stat-value {
  font-size: 2.05rem;
  font-weight: 900;
}

.stat-card-balance.positive .stat-value {
  color: var(--balance-text);
}

.stat-card-balance.negative {
  background: linear-gradient(145deg, #ffffff 0%, #fff8f1 100%);
  border-color: var(--warning-border);
}

.stat-card-balance.negative .stat-value {
  color: var(--warning-text);
}

.stat-subtext {
  font-size: 0.78rem;
  color: var(--text-subtle);
  margin-top: 8px;
  font-weight: 500;
}

/* ==========================================================================
   Analytics & Chart Section
   ========================================================================== */
.analytics-section {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.analytics-chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1.5px solid var(--border-subtle);
  padding-right: 20px;
}

.donut-chart-container {
  width: 240px;
  height: 240px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-svg {
  width: 100%;
  height: 100%;
}

.donut-center-label {
  font-size: 13px;
  font-weight: 600;
  fill: var(--text-muted);
}

.donut-center-value {
  font-size: 17px;
  font-weight: 800;
  fill: var(--text-main);
}

.donut-slice {
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  transform-origin: center;
}

.donut-slice:hover {
  opacity: 0.88;
  filter: drop-shadow(0 2px 6px rgba(201, 228, 251, 0.5));
}

.empty-chart-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  font-size: 0.85rem;
  gap: 8px;
}

.empty-chart-icon {
  font-size: 2.2rem;
  opacity: 0.8;
}

.analytics-list-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 8px;
}

.analytics-title-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.analytics-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
}

.category-bars-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 210px;
  overflow-y: auto;
  padding-right: 6px;
}

.category-bar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-bar-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
}

.category-bar-name {
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-color-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.category-bar-values {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.category-bar-amount {
  font-weight: 800;
  color: var(--text-main);
  margin-right: 6px;
}

.category-progress-track {
  height: 8px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.category-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Transactions Section & Table
   ========================================================================== */
.transactions-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.transactions-header {
  padding: 18px 24px;
  border-bottom: 1.5px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.transactions-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.transactions-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.transactions-count-badge {
  font-size: 0.8rem;
  color: var(--blue-text);
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

/* Search & Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-input-group {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-input-group:focus-within {
  border-color: var(--blue-benchmark);
  box-shadow: 0 0 0 3px rgba(201, 228, 251, 0.45);
}

.filter-input-group input,
.filter-input-group select {
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.86rem;
  color: var(--text-main);
}

.filter-input-search {
  min-width: 180px;
  flex: 1;
}

.filter-type-pill-group {
  display: flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  gap: 2px;
}

.filter-type-pill {
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.filter-type-pill:hover {
  color: var(--text-main);
}

.filter-type-pill.active {
  background: #ffffff;
  color: var(--blue-text);
  box-shadow: var(--shadow-xs);
}

.btn-clear-filter {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  background: var(--bg-card);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-clear-filter:hover {
  background-color: var(--blue-light);
  color: var(--blue-text);
  border-color: var(--blue-border);
}

/* Table Design */
.table-container {
  overflow-x: auto;
  max-height: 480px;
}

.transactions-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.transactions-table th {
  background: #f8fbfe;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 12px 18px;
  border-bottom: 1.5px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

.transactions-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.transactions-table tr:hover td {
  background-color: var(--bg-card-hover);
}

.col-date {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.badge-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.badge-type-income {
  background-color: var(--income-light);
  color: var(--income-text);
  border: 1px solid var(--income-border);
}

.badge-type-expense {
  background-color: var(--expense-light);
  color: var(--expense-text);
  border: 1px solid var(--expense-border);
}

/* Account Badges (Studio vs Personal) */
.badge-account {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.badge-account-studio {
  background-color: var(--blue-light);
  color: var(--blue-text);
  border: 1px solid var(--blue-border);
}

.badge-account-personal {
  background-color: #f7f4fe;
  color: var(--balance-text);
  border: 1px solid var(--balance-border);
}

.col-category {
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.col-title {
  font-weight: 600;
  color: var(--text-main);
}

.col-amount {
  font-weight: 800;
  font-size: 0.94rem;
  white-space: nowrap;
}

.col-amount-income {
  color: var(--income-text);
}

.col-amount-expense {
  color: var(--expense-text);
}

.col-note {
  color: var(--text-muted);
  font-size: 0.82rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-actions {
  white-space: nowrap;
  text-align: right;
}

.btn-table-action {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: all var(--transition-fast);
  margin-left: 4px;
}

.btn-table-edit {
  color: var(--balance-text);
  background-color: var(--balance-light);
  border: 1px solid var(--balance-border);
}

.btn-table-edit:hover {
  background-color: var(--balance-hover);
}

.btn-table-delete {
  color: var(--expense-text);
  background-color: var(--expense-light);
  border: 1px solid var(--expense-border);
}

.btn-table-delete:hover {
  background-color: var(--expense-hover);
}

/* Empty State */
.empty-transactions-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 14px;
}

.empty-state-icon {
  font-size: 3rem;
  line-height: 1;
}

.empty-state-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.empty-state-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 320px;
}

.empty-state-actions {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}

/* ==========================================================================
   Annual Overview View (年度總覽)
   ========================================================================== */
.annual-view-container {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.annual-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 18px 24px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.annual-year-select {
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.annual-year-select:focus {
  border-color: var(--blue-benchmark);
}

.annual-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.annual-chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.annual-chart-container {
  width: 100%;
  height: 280px;
}

.annual-chart-svg {
  width: 100%;
  height: 100%;
}

.chart-grid-line {
  stroke: #e2effa;
  stroke-dasharray: 4 4;
}

.chart-axis-label {
  font-size: 11px;
  fill: #64748b;
  font-weight: 600;
}

.chart-bar-income {
  fill: #b8ecd6; /* Calibrated Pastel Mint */
  transition: opacity 0.2s;
}

.chart-bar-expense {
  fill: #facbd5; /* Calibrated Pastel Strawberry */
  transition: opacity 0.2s;
}

.chart-hover-col:hover {
  fill: rgba(201, 228, 251, 0.2);
  cursor: pointer;
}

.annual-table-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Chart Tooltip */
.chart-tooltip {
  position: absolute;
  background: rgba(51, 65, 85, 0.94);
  backdrop-filter: blur(4px);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tooltip-header {
  font-weight: 800;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 4px;
  margin-bottom: 2px;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.text-emerald { color: #86efac; }
.text-rose { color: #fca5a5; }
.text-balance { color: #c9e4fb; }

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(51, 65, 85, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  border: 1.5px solid var(--border-light);
}

.modal-backdrop.show .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1.5px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-modal-close {
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-modal-close:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Account Radio / Pill Group */
.account-selector-group {
  display: flex;
  gap: 8px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
}

.account-pill-label {
  flex: 1;
  display: flex;
  cursor: pointer;
}

.account-radio {
  display: none;
}

.account-pill-btn {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  font-size: 0.86rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.account-radio:checked + .account-pill-btn,
.account-pill-btn.active {
  background: #ffffff;
  color: var(--blue-text);
  border-color: var(--blue-border);
  box-shadow: 0 2px 6px rgba(201, 228, 251, 0.4);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-label .required {
  color: var(--expense-primary);
  margin-left: 2px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9rem;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  background-color: var(--bg-input);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue-benchmark);
  box-shadow: 0 0 0 3px rgba(201, 228, 251, 0.45);
}

.amount-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.amount-prefix {
  position: absolute;
  left: 14px;
  font-weight: 800;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.amount-input {
  padding-left: 54px;
  font-size: 1.1rem;
  font-weight: 800;
}

.form-help-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.category-select-row {
  display: flex;
  gap: 8px;
}

.btn-add-custom-cat {
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--blue-text);
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-md);
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.btn-add-custom-cat:hover {
  background: var(--blue-benchmark);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1.5px solid var(--border-subtle);
  background-color: #fbfdff;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-modal-secondary {
  padding: 9px 18px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  background: #ffffff;
  transition: all var(--transition-fast);
}

.btn-modal-secondary:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.btn-modal-primary {
  padding: 9px 20px;
  font-size: 0.88rem;
  font-weight: 800;
  color: #1e4e8c;
  background-color: var(--blue-benchmark);
  border: 1.5px solid var(--blue-border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(201, 228, 251, 0.5);
  transition: all var(--transition-fast);
}

.btn-modal-primary:hover {
  background-color: #b8dcf9;
  transform: translateY(-1px);
}

.btn-modal-danger {
  padding: 9px 20px;
  font-size: 0.88rem;
  font-weight: 800;
  color: #8c1e34;
  background-color: var(--expense-hover);
  border: 1.5px solid var(--expense-border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(250, 203, 213, 0.5);
  transition: all var(--transition-fast);
}

.btn-modal-danger:hover {
  background-color: #f7b5c3;
  transform: translateY(-1px);
}

/* Category Manager Drawer/Modal */
.category-manager-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.category-column {
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fbfdff;
}

.category-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
}

.category-chip-remove {
  color: var(--text-subtle);
  cursor: pointer;
}

.category-chip-remove:hover {
  color: var(--expense-text);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast-item {
  background: #ffffff;
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.25s ease;
}

.toast-item.toast-success {
  border-left: 5px solid var(--income-border);
}

.toast-item.toast-error {
  border-left: 5px solid var(--expense-border);
}

.toast-item.toast-info {
  border-left: 5px solid var(--blue-benchmark);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Hidden Utility */
.hidden {
  display: none !important;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d4e5f5;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #b8d4ee;
}
