/* ============================================================
   現代簡約風格 (Minimalist Modern) - 深綠與大地色系
   ============================================================ */
:root {
  --bg: #f4f7f6;
  /* 帶有微綠的大地淺灰底色 */
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --panel-hover: #fcfdfd;
  --panel-2: #f8fafa;
  --input-bg: #ffffff;
  --border: #e8ede9;
  --border-strong: #d1d9d6;
  --shadow-sm: 0 2px 8px rgba(34, 56, 47, 0.04);
  --shadow: 0 12px 32px rgba(34, 56, 47, 0.06);
  --shadow-lg: 0 24px 48px rgba(34, 56, 47, 0.12);
  --r: 24px;
  --r-lg: 32px;
  --primary: #2c5e4f;
  /* 深綠色主調 */
  --earth: #8c6a4f;
  /* 大地色系 */
  --green: #2c8055;
  --up: #d83a3a;
  /* 紅色市場動態提醒 */
  --gold: #d68a2c;
  /* 金黃色股息 */
  --text-main: #1a2620;
  --text-muted: #7a8278;

  /* --- 字體系統 (Typography) --- */
  /* 全局（繁體中文 + 英文） */
  --base-font: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Noto Sans CJK TC", sans-serif;
  /* 金額、數字、百分比（全部統一使用 Noto Sans TC） */
  --num-font: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans CJK TC", sans-serif;
}

/* 專屬深色模式的高對比、深邃色調 */
[data-theme="dark"] {
  --bg: #0f1315;
  /* 更深邃的背景底色 */
  --panel: #181d1f;
  /* 卡片背景 */
  --panel-solid: #181d1f;
  --panel-hover: #1e2426;
  --panel-2: #202628;
  /* 提示區塊與次要背景 */
  --input-bg: #202628;
  /* 輸入框背景 */
  --border: #283236;
  /* 邊框提亮，增加卡片邊界清晰度 */
  --border-strong: #3a474d;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.6);
  --primary: #4fb395;
  /* 深色模式下，主色調需調亮確保高辨識度 */
  --earth: #c79e7f;
  /* 大地色提亮 */
  --green: #46b880;
  /* 跌幅綠提亮 */
  --up: #f05a5a;
  /* 上漲紅提亮 */
  --gold: #f2ae4b;
  /* 金黃色提亮 */
  --text-main: #f0f5f2;
  /* 主文字改為極淺的灰白色，確保極高清晰度 */
  --text-muted: #a3b3aa;
  /* 次要文字也相應提高明度 */
}

body {
  font-family: var(--base-font);
  font-size: 25px;
  background: var(--bg);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- 大量留白與圓角設計 (Card-based layout) --- */
.block,
.overview-main,
.rank-card,
.holding-card,
.activity-item,
.ds-profit-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  transition:
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.3s ease,
    background 0.3s ease,
    filter 0.3s ease,
    border-color 0.3s ease;
}

.block {
  padding: 32px;
}

.overview-main {
  padding: 36px;
}

.holding-card {
  padding: 24px;
  border: 1px solid var(--border);
  opacity: 0;
  animation: fadeSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* --- 1. 互動小卡與大型區塊懸停 (上浮幅度加大 + 陰影擴散 + 背景發亮) --- */
.rank-card:hover,
.activity-item:hover,
.ds-profit-box:hover,
.block:hover,
.overview-main:hover,
.ds-mini-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
  background: var(--panel-hover);
  filter: brightness(1.04);
}

/* 專屬「資產」卡片的綠色發光特效 */
.holding-card:hover {
  transform: translateY(-8px);
  /* 疊加一層淡淡的綠色光暈 */
  box-shadow:
    var(--shadow-lg),
    0 8px 24px rgba(44, 128, 85, 0.15);
  border-color: rgba(44, 128, 85, 0.3);
  background: var(--panel-hover);
  filter: brightness(1.04);
}

/* --- 資訊階層明確 (Typography) --- */
.ov-label {
  color: var(--text-muted);
  font-size: 21px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ov-value {
  color: var(--primary);
  font-size: 62px;
  font-family: var(--num-font);
  font-variant-numeric: tabular-nums;
  /* 金融重點：讓數字等寬，上下對齊不亂跳 */
  /* 頂部大字級 */
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 8px;
  margin-bottom: 24px;
}

.ov-sub-label {
  color: var(--text-muted);
}

.ov-sub-value {
  color: var(--text-main);
  font-family: var(--num-font);
  font-size: 26px;
  font-weight: 700;
}

.ov-sub-value.up {
  color: var(--up);
}

.ov-sub-value.down {
  color: var(--down);
}

/* 成本降低百分比 Pill */
.ov-sub-pill {
  background: #eaf0ee;
  color: var(--primary);
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 17px;
}

/* 首頁總損益數字發光特效 */
#ov-profit,
#ov-realized-profit {
  font-size: 38px;
  font-family: var(--num-font);
  font-variant-numeric: tabular-nums;
  transition:
    color 0.3s ease,
    text-shadow 0.3s ease;
}

#ov-profit.up,
#ov-realized-profit.up {
  text-shadow: 0 4px 24px rgba(216, 58, 58, 0.45);
}

#ov-profit.down,
#ov-realized-profit.down {
  text-shadow: 0 4px 24px rgba(44, 128, 85, 0.45);
}

#ov-profit.gold {
  color: var(--gold);
  text-shadow: 0 4px 24px rgba(214, 138, 44, 0.45);
}

/* --- 總覽主卡片上半部 30% 縮小 (排除下方次要指標) --- */
.overview-main-top .ov-label {
  font-size: 15px;
  margin-bottom: 4px;
}

.overview-main-top .ov-value {
  font-size: 43px;
  margin-top: 6px;
  margin-bottom: 16px;
}

.overview-main-top #ov-profit {
  font-size: 27px;
}

.overview-main-top .term-tip-btn {
  width: 16px;
  height: 16px;
  font-size: 10px;
  margin-left: 4px;
}

/* --- 亮點成就卡片 (Highlight Cards) --- */
.rank-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px;
  flex: 1;
}

.rank-icon {
  width: 42px;
  height: 42px;
  font-size: 26px;
  margin-bottom: 12px;
}

.rank-title {
  font-size: 20px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rank-main {
  font-size: 21px;
  margin-top: 8px;
  font-family: var(--num-font);
}

.rank-amount {
  font-size: 24px;
  margin-top: auto;
  padding-top: 12px;
  font-family: var(--num-font);
  font-variant-numeric: tabular-nums;
}

/* --- 複合排行小卡 --- */
.rank-sub-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.rank-sub-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
  background: var(--panel-hover);
}

/* --- 持股細節卡片 --- */
.hc-cost-box {
  background: var(--panel-2);
  /* 區分淨成本與不含息成本 */
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.hc-symbol {
  color: var(--primary);
  font-size: 25px;
}

/* --- 按鈕與直觀互動暗示 --- */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 600;
  border-radius: 999px;
  /* 圓潤按鈕 */
  padding: 10px 24px;
  box-shadow: 0 4px 12px rgba(44, 94, 79, 0.2);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: #1e4538;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(44, 94, 79, 0.3);
}

/* --- 分割股票與刪除按鈕互動回饋 --- */
#splitStockBtn,
#deleteStockBtn {
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#splitStockBtn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  background: var(--panel);
  border-color: var(--primary);
  color: var(--primary);
}

#deleteStockBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(216, 58, 58, 0.25);
}

#splitStockBtn:active,
#deleteStockBtn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* --- 空狀態設計 (當 Grid 沒資料時顯示黑熊) --- */
#holdingsGrid:empty::before {
  content: "◩ 您的存股籃子空空的...\A 趕快點擊右上角「＋ 新增股票」，種下第一棵小樹苗吧！";
  white-space: pre-wrap;
  grid-column: 1 / -1;
  display: block;
  padding: 100px 20px;
  text-align: center;
  line-height: 1.8;
  background: var(--panel-solid);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r);
  font-weight: 500;
  color: var(--text-muted);
  font-size: 28px;
}

.modal-box {
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {

  #ov-profit,
  #ov-realized-profit {
    font-size: 32px;
  }

  .overview-main-top .ov-value {
    font-size: 24px;
  }

  .overview-main-top #ov-profit {
    font-size: 22px;
  }

  .hide-on-mobile {
    display: none;
  }
}

/* --- 讓切換按鈕在手機版可以水平滑動，不會凸出去 --- */
.seg-toggle {
  max-width: 100%;
  overflow-x: auto;
}

.seg-toggle::-webkit-scrollbar {
  display: none;
}

/* --- 針對 style.css 中繼承過來較小的字體，統一加大 5px --- */
.small,
.muted.small,
.ov-sub-label,
.activity-desc,
.hc-name,
.hc-shares,
.ds-profit-label,
.ds-profit-sub,
.ratio-legend-row .lr-pct,
.ratio-legend-row .lr-amt,
.form-row label {
  font-size: 17px;
}

.activity-date,
.hc-cost-label,
.hc-cost-alt {
  font-size: 16px;
}

/* --- 3. 佔比明細清單懸停 (向右微滑動，增加閱讀指引) --- */
.ratio-legend-row {
  transition: transform 0.2s ease;
}

.ratio-legend-row:hover {
  transform: translateX(6px);
}

/* --- 表格表頭統一粗體，並與內容對齊 --- */
.sub-table th {
  font-size: 16px;
  font-weight: 700;
}

.btn,
.goal-modal-confirm,
.seg,
.ratio-legend-row,
.detail-name,
.ds-label,
.ds-pill,
.sub-table,
.toast {
  font-size: 18px;
}

/* --- 詳細資訊內的三個大分頁 (+2) --- */
.main-tab {
  font-size: 20px;
}

.block-title,
.chart-legend,
.ds-row {
  font-size: 19px;
}

.form-row input,
.form-row select {
  font-size: 19px;
  background: var(--input-bg);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
}

/* --- 數字與日期輸入框優化 --- */
.form-row input[type="number"],
.form-row input[type="date"] {
  font-family: var(--num-font);
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* 隱藏瀏覽器原生的上下增減按鈕 (Spinner)，讓畫面更簡潔 */
.form-row input[type="number"]::-webkit-inner-spin-button,
.form-row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form-row input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* 強制股票代號輸入框自動轉大寫 */
#newSymbol {
  text-transform: uppercase;
}

.block h2,
.ds-unit,
.modal-header h3 {
  font-size: 21px;
}

/* --- SVG 圖示置中微調 --- */
.hc-delete,
.btn-icon-round {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* --- 增加詳細頁小卡片的導圓角 --- */
.ds-mini-card {
  border-radius: 16px;
  transition:
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.3s ease,
    background 0.3s ease,
    filter 0.3s ease,
    border-color 0.3s ease;
}

.ds-mini-card .muted {
  font-size: 15px;
  /* 中文標籤改小 */
}

.ds-mini-card .val {
  font-size: 24px;
  /* 數字改大 */
}

/* --- 漢堡選單 (Dropdown) --- */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 1000;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown-menu.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 17px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-family: inherit;
}

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

.dropdown-item:hover {
  background: var(--panel-2);
  color: var(--primary);
}

/* --- 視圖切換的平滑過場動畫 --- */
main:not(.hidden) {
  animation: viewFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- 確認刪除按鈕按壓特效 --- */
#confirmYesBtn {
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

#confirmYesBtn:active {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 2px 6px rgba(216, 58, 58, 0.2);
}

/* --- 名詞說明「?」按鈕 --- */
.term-tip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.15s;
  flex-shrink: 0;
  font-family: inherit;
  padding: 0;
}

.term-tip-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.15);
}