* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --card: #ffffff;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-d: #1d4ed8;
  --text: #1e293b;
  --muted: #64748b;
  --pos: #dc2626;   /* 漲/正：紅 (台股慣例) */
  --neg: #16a34a;   /* 跌/負：綠 */
}

body {
  font-family: "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  line-height: 1.5;
}

header {
  background: var(--bg);
  color: #fff;
  padding: 18px 28px 0;
}
header h1 { font-size: 22px; font-weight: 600; margin-bottom: 12px; }

nav { display: flex; gap: 6px; }
.tab {
  background: transparent;
  color: #94a3b8;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 20px;
  font-size: 15px;
  cursor: pointer;
  transition: .15s;
}
.tab:hover { color: #e2e8f0; }
.tab.active { color: #fff; border-bottom-color: var(--accent); }

/* 股票資訊內的子分頁(淺色內容區) */
.subnav {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 16px; border-bottom: 1px solid var(--line);
}
.subtab {
  background: transparent; border: none; border-bottom: 3px solid transparent;
  padding: 9px 16px; font-size: 14px; color: var(--muted); cursor: pointer;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.panel { padding: 22px 28px; max-width: 1400px; margin: 0 auto; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.row { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; margin-bottom: 16px; }
.row:last-child { margin-bottom: 0; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .range-group > label {
  font-size: 13px; font-weight: 600; color: var(--muted);
}
select, input[type=number], input[type=text] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  min-width: 120px;
}
select:focus, input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.ranges { gap: 26px; }
.range-group {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 5px 6px;
}
.range-group > label { grid-column: 1 / -1; margin-bottom: 2px; }
.range-group input { width: 90px; min-width: 0; }
.range-group span { color: var(--muted); text-align: center; }

/* 產業別複選 */
.multiselect { position: relative; }
.ms-toggle {
  min-width: 160px; text-align: left;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; background: #fff; color: var(--text);
  cursor: pointer;
}
.ms-toggle:hover { border-color: var(--accent); }
.ms-panel {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
  width: 260px; max-height: 320px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 8px;
}
.ms-actions { display: flex; gap: 8px; padding: 2px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.ms-actions button {
  flex: 1; border: 1px solid var(--line); background: #f8fafc; border-radius: 6px;
  padding: 5px; font-size: 13px; cursor: pointer;
}
.ms-actions button:hover { background: #eef2ff; border-color: var(--accent); }
.ms-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.ms-item:hover { background: #f1f5f9; }
.ms-item input { width: 16px; height: 16px; min-width: 0; cursor: pointer; }

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 15px;
  cursor: pointer;
}
button.primary:hover { background: var(--accent-d); }

/* 黃色警示按鈕(會員管理·刪除此會員)：與 primary 同尺寸，色彩提醒不要誤按 */
button.warn {
  background: #fbbf24;
  color: #78350f;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button.warn:hover { background: #f59e0b; }

/* 購買紀錄：狀態切換(segmented) + 標記完成按鈕 */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { border: none; background: #fff; color: var(--muted); padding: 6px 12px;
  font-size: 14px; cursor: pointer; border-left: 1px solid var(--line); }
.seg-btn:first-child { border-left: none; }
.seg-btn.active { background: var(--accent); color: #fff; }
.seg-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px;
  background: #dc2626; color: #fff; font-size: 12px; font-weight: 700; }
.seg-btn.active .seg-badge { background: #fff; color: #dc2626; }
button.pur-done { padding: 5px 12px; border: none; border-radius: 7px; background: #16a34a;
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
button.pur-done:hover { background: #15803d; }

/* 檔案選擇按鈕(會員管理·匯入合約 CSV)：與 primary 按鈕同樣式 */
#adm-ct-file::file-selector-button {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 10px 22px; font-size: 15px; cursor: pointer; margin-right: 10px;
}
#adm-ct-file::file-selector-button:hover { background: var(--accent-d); }
#btn-reset, #btn-default, #btn-trend-reset, #btn-trend-default {
  background: #f1f5f9; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 18px; cursor: pointer; font-size: 14px;
}
.actions { align-items: center; }
.hint { color: var(--muted); font-size: 13px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; position: sticky; top: 0; cursor: pointer; user-select: none; }
th.text, td.text { text-align: left; }
tbody tr:hover { background: #f8fafc; }
.code { font-weight: 600; color: var(--accent); cursor: pointer; }
.code:hover { text-decoration: underline; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef2ff; color: #4338ca; }
.pill.otc { background: #ecfeff; color: #0e7490; }

/* 會員等級徽章 */
.tier-badge { display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff; margin-right: 8px; white-space: nowrap; }
.tier-bronze { background: #b45309; }   /* 銅卡 */
.tier-gold { background: #ca8a04; }      /* 金卡 */
.tier-expiry { color: #eab308; font-size: 12px; font-weight: 600; margin-right: 10px; white-space: nowrap; }

/* 篩選結果下方：簡稱與單位說明(整齊網格排版) */
.abbr-note { margin-top: 10px; padding: 10px 14px; background: #f8fafc;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; color: var(--muted); }
.abbr-note > b { color: var(--text); font-size: 13px; }
.abbr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 4px 18px; margin-top: 6px; }
.abbr-grid span { white-space: nowrap; }
.abbr-grid b { color: var(--text); }

/* 最近四年：年度股價高/低、EPS、本益比 */
.annual-title { font-size: 14px; font-weight: 600; color: var(--text);
  margin: 2px 0 8px; padding-left: 8px; border-left: 4px solid var(--accent); }
.annual-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.annual-table { table-layout: fixed; font-size: 14px;
  font-variant-numeric: tabular-nums; }
table.annual-table th, table.annual-table td {
  text-align: center; white-space: nowrap; padding: 9px 10px;
  border-bottom: 1px solid var(--line); }
table.annual-table thead th {
  position: static; cursor: default; background: #f1f5f9;
  color: var(--muted); font-weight: 600; letter-spacing: .3px; }
table.annual-table tbody tr:last-child td { border-bottom: none; }
table.annual-table tbody tr:nth-child(even) { background: #fafbfc; }
table.annual-table tbody tr:hover { background: #eef2ff; }
table.annual-table th:first-child,
table.annual-table td:first-child { width: 90px; }
table.annual-table td.rowlabel { text-align: left; font-weight: 600;
  color: var(--text); background: #f8fafc; }
table.annual-table .pe-sep { color: var(--muted); margin: 0 2px; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.na  { color: #cbd5e1; }

/* 健診狀態：警示=紅、正常=綠(與台股漲跌色無關) */
.status-warn { color: #dc2626; font-weight: 600; }
.status-ok   { color: #16a34a; font-weight: 600; }

/* 股價健診條件：填空句式 */
.health-conds { margin-top: 14px; }
.cond-line { font-size: 15px; color: var(--text); margin: 8px 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.cond-text { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
/* 條件序號徽章 */
.cond-badge { flex: 0 0 auto; display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--accent); background: rgba(37,99,235,.10); white-space: nowrap; }
.cond-hint { flex-basis: 100%; margin-left: 0; }
input.inline-num { width: 72px; min-width: 0; margin: 0 4px; padding: 5px 8px; }
select.inline-sel { min-width: 0; margin: 0 4px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; }

/* 財報查詢：八季財報 / 一年營收表格 — 數字等寬對齊、表頭非排序樣式 */
#company-detail table { font-variant-numeric: tabular-nums; }
#company-detail thead th { position: static; cursor: default; }

/* 財務健診內層三分頁(六大指標 / 財務地雷 / 成長力分析) */
.fin-subnav { margin-top: 4px; }
.fin-tab { background: transparent; border: none; border-bottom: 3px solid transparent;
  padding: 9px 16px; font-size: 14px; color: var(--muted); cursor: pointer; }
.fin-tab:hover { color: var(--text); }
.fin-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
table.growth-table { font-variant-numeric: tabular-nums; }
table.growth-table thead th { position: static; cursor: default; }

/* 健診區塊標題 / 營收成長性評分徽章 */
.sec-h { margin: 16px 0 10px; font-size: 15px; color: var(--text);
         border-left: 4px solid var(--accent); padding-left: 8px; }
.grade-badge { display: inline-block; padding: 2px 12px; border-radius: 6px;
               color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; }

/* 財務健診表格對齊：固定欄寬、說明欄自動換行 */
#finhealth-result table.rate-table,
#finhealth-result table.mine-table { table-layout: fixed; }
#finhealth-result table.rate-table th:nth-child(1),
#finhealth-result table.rate-table td:nth-child(1) { width: 130px; }
#finhealth-result table.rate-table td:nth-child(2) { white-space: normal; }
#finhealth-result table.mine-table th:nth-child(1),
#finhealth-result table.mine-table td:nth-child(1) { width: 40%; }
#finhealth-result table.mine-table th:nth-child(2),
#finhealth-result table.mine-table td:nth-child(2) { width: 96px; }
#finhealth-result table.mine-table td:nth-child(3) { white-space: normal; }
#finhealth-result table td { vertical-align: middle; }

.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.result-head h3 { font-size: 16px; }
.count-badge { background: var(--accent); color:#fff; padding: 3px 12px; border-radius: 999px; font-size: 13px; }
.table-wrap { max-height: 65vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* 搜尋 */
.search-box { display: flex; gap: 10px; }
.search-box input { flex: 1; min-width: 0; }
.search-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-size: 14px; background:#fff;
}
.chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.detail h2 { font-size: 20px; margin-bottom: 4px; }
.detail .sub { color: var(--muted); margin-bottom: 18px; }

/* 登入頁 */
.login-gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  z-index: 100;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 44px;
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.3);
  max-width: 420px;
}
.login-card h1 { font-size: 26px; margin-bottom: 6px; color: var(--text); }
.login-card .slogan { color: var(--accent); font-size: 15px; font-weight: 600; margin-bottom: 18px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.brand-slogan { font-size: 14px; font-weight: 400; color: #94a3b8; margin-left: 10px; }
#g_id_signin { display: flex; justify-content: center; min-height: 44px; }
.login-msg { margin-top: 18px; color: var(--pos); font-size: 14px; min-height: 20px; }

/* 使用者列 */
.header-top { display: flex; justify-content: space-between; align-items: center; }
.user-box { display: flex; align-items: center; gap: 12px; }
.user-email { color: #cbd5e1; font-size: 14px; }
#btn-logout {
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 13px;
}
#btn-logout:hover { background: rgba(255,255,255,.22); }
.detail h4 { margin: 18px 0 10px; font-size: 15px; color: var(--text); border-left: 4px solid var(--accent); padding-left: 8px; }
.chart-box { height: 320px; margin: 14px 0 6px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.chart-box.chart-box-tall { height: 480px; }
.loading { color: var(--muted); padding: 12px; }

/* EPS 預測熱力圖 */
table.heat { table-layout: fixed; }
table.heat th, table.heat td { text-align: center; border: 1px solid #fff; }
table.heat thead th { background: #f8fafc; color: var(--muted); position: sticky; top: 0; }
table.heat tbody th { background: #f1f5f9; color: var(--text); }
#predict-result h3 { font-size: 15px; margin-top: 6px; }
#predict-result h3 + .table-wrap { margin-bottom: 20px; }

/* 股價健診：圖表縮放控制列(快捷按鈕 + 雙握把範圍軸) */
.chart-zoom { margin: 12px 0 4px; }
.zoom-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.zoom-label { color: var(--muted); font-size: 13px; }
.zoom-presets button { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font-size: 13px; color: var(--text); cursor: pointer; }
.zoom-presets button:hover { border-color: var(--accent); color: var(--accent); }
.zoom-presets button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.zoom-range { position: relative; height: 28px; margin-top: 12px; }
.zoom-range .zoom-track, .zoom-range .zoom-fill {
  position: absolute; top: 12px; height: 4px; border-radius: 2px; pointer-events: none; }
.zoom-range .zoom-track { left: 0; right: 0; background: #e2e8f0; }
.zoom-range .zoom-fill { left: 0; width: 100%; background: var(--accent); }
/* 兩條 range 疊在同一軌道上：軌道透明、只讓握把可點 */
.zoom-range input[type=range] { position: absolute; left: 0; top: 0; width: 100%; height: 28px;
  margin: 0; background: transparent; pointer-events: none;
  -webkit-appearance: none; appearance: none; }
.zoom-range input[type=range]::-webkit-slider-runnable-track { background: transparent; height: 28px; }
.zoom-range input[type=range]::-moz-range-track { background: transparent; height: 28px; }
.zoom-range input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
  pointer-events: auto; width: 16px; height: 16px; margin-top: 6px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.2); cursor: pointer; }
.zoom-range input[type=range]::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,.2); cursor: pointer; }
.zoom-dates { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* 老客戶購買方案 */
.promo-card { max-width: 900px; margin: 0 auto; }
.promo-title { font-size: 20px; margin-bottom: 4px; }
.promo-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.promo-plans { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.promo-plan { position: relative; flex: 0 1 258px; border: 1px solid var(--line);
  border-radius: 12px; padding: 20px 16px; text-align: center; background: #fff;
  display: flex; flex-direction: column; justify-content: space-between; }
.promo-plan.promo-highlight { border-color: var(--accent); box-shadow: 0 2px 10px rgba(37,99,235,.12); }
.promo-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 12px; border-radius: 999px; white-space: nowrap; }
.promo-plan-name { font-size: 15px; font-weight: 600; color: var(--text);
  line-height: 1.5; margin: 6px 0 14px; min-height: 46px; }
.promo-plan-price { margin: 6px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.promo-orig { font-size: 14px; color: var(--muted); text-decoration: line-through; }
.promo-offer { display: inline-flex; align-items: baseline; }
.promo-amt { font-size: 30px; font-weight: 800; color: var(--pos); }
.promo-unit { font-size: 14px; color: var(--muted); }
.promo-plan-note { margin-top: 10px; font-size: 13px; color: var(--pos); font-weight: 600; }
/* 已到期老客戶：續約表單提示 */
.promo-renew-note { margin-top: 18px; padding: 12px 14px; font-size: 14px; line-height: 1.7;
  color: var(--text); background: #fffbeb; border: 1px solid #fcd34d; border-radius: 10px; }
.promo-renew-note a { color: var(--accent); word-break: break-all; }
.promo-footnote { margin-top: 20px; font-size: 13px; color: var(--muted);
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.promo-notes { margin: 6px 0 0; padding-left: 20px; }
.promo-notes li { margin: 3px 0; }

/* 金卡鎖定訊息內的「前往購買方案」連結 */
.goto-promo { display: inline-block; margin-top: 10px; color: var(--accent);
  font-weight: 600; text-decoration: underline; cursor: pointer; }
.goto-promo:hover { opacity: .85; }

/* 依合約動態產生的可購買方案清單 */
.promo-purchase { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.promo-buy-title { font-size: 16px; margin-bottom: 12px; }
.promo-options { display: flex; flex-direction: column; gap: 10px; }
.promo-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; }
.promo-opt-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.promo-opt-name { font-weight: 600; font-size: 15px; }
.promo-opt-price { color: var(--pos); font-weight: 600; }
.promo-opt-cap { color: var(--muted); font-size: 13px; }
.promo-opt-years { flex-basis: 100%; margin-top: 2px; color: var(--muted); font-size: 13px; }
.promo-select { padding: 8px 22px; border: none; border-radius: 8px; background: var(--accent);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; flex: 0 0 auto; }
.promo-select:hover { opacity: .9; }

/* 購買彈窗 */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-box { position: relative; background: #fff; border-radius: 14px;
  padding: 24px 24px 20px; width: min(420px, 100%); max-height: 90vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal-box h3 { margin: 0 0 12px; font-size: 18px; }
.modal-close { position: absolute; top: 10px; right: 12px; border: none; background: none;
  font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
.buy-plan-line { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.buy-unit-line { font-size: 14px; color: var(--text); margin-bottom: 14px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.buy-field { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 12px 0; font-size: 14px; }
.buy-field > span { color: var(--muted); flex: 0 0 auto; }
.buy-field select { flex: 1 1 auto; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font-size: 14px; }
.buy-hint { font-size: 12px; color: #16a34a; margin: -6px 0 4px; }
.buy-total { margin: 16px 0 6px; padding: 10px 12px; background: #f8fafc;
  border: 1px solid var(--line); border-radius: 8px; font-size: 15px; text-align: center; }
.buy-actions { display: flex; gap: 10px; margin-top: 14px; }
.buy-actions button { flex: 1; padding: 10px 0; border-radius: 8px; font-size: 15px; cursor: pointer; }
.buy-actions #buy-cancel { border: 1px solid var(--line); background: #fff; color: var(--text); }
.buy-msg { margin-top: 10px; font-size: 13px; text-align: center; min-height: 18px; }
.buy-msg.ok { color: #16a34a; }
.buy-msg.err { color: #dc2626; }

/* ===================== 響應式(手機/平板) ===================== */
@media (max-width: 640px) {
  /* 老客戶購買方案：卡片改為單欄堆疊 */
  .promo-plans { gap: 18px; }
  .promo-plan { flex-basis: 100%; }
  .promo-plan-name { min-height: 0; }

  /* 頁首 */
  header { padding: 12px 14px 0; }
  header h1 { font-size: 18px; margin-bottom: 10px; }
  .brand-slogan { display: none; }            /* 手機隱藏 slogan，留標題 */
  .header-top { flex-wrap: wrap; gap: 6px; }
  .user-email { font-size: 12px; }
  #btn-logout { padding: 5px 10px; font-size: 12px; }

  /* 分頁列：可橫向滑動，不換行擠壓 */
  nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { flex: 0 0 auto; white-space: nowrap; padding: 10px 12px; font-size: 14px; }
  .subnav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .subtab { flex: 0 0 auto; white-space: nowrap; padding: 9px 12px; }

  /* 版面留白縮小 */
  .panel { padding: 14px 12px; }
  .card { padding: 14px; border-radius: 10px; }

  /* 表單列改為上下堆疊、輸入框滿版 */
  .row { flex-direction: column; align-items: stretch; gap: 12px; }
  .row.ranges { gap: 12px; }
  .row.actions { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .field { width: 100%; }
  .field select,
  .field input[type=number],
  .field input[type=text] { width: 100%; }
  input.inline-num { width: 64px; }           /* 健診填空框維持小尺寸 */

  /* 趨勢/健診條件：手機把序號徽章獨立成一行標頭，句子在下方整齊換行 */
  .cond-line { gap: 6px; padding: 10px 12px; margin: 10px 0;
    background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; }
  .cond-badge { flex: 0 0 100%; }
  .cond-text { row-gap: 8px; }
  .cond-hint { font-size: 12px; color: var(--muted); }

  /* 產業複選面板不超出畫面 */
  .ms-toggle { width: 100%; }
  .ms-panel { width: min(300px, 88vw); }

  /* 搜尋框：輸入與按鈕分兩行 */
  .search-box { flex-direction: column; }
  .search-box .primary { width: 100%; }

  /* 表格：縮小字級/間距(寬表仍可左右滑) */
  table { font-size: 13px; }
  th, td { padding: 7px 8px; }
  /* 財務健診表格：手機讓文字換行，避免欄位文字溢出、互相重疊 */
  #finhealth-result table.rate-table th, #finhealth-result table.rate-table td,
  #finhealth-result table.mine-table th, #finhealth-result table.mine-table td {
    white-space: normal; word-break: break-word; vertical-align: top;
  }
  #finhealth-result table.rate-table th:nth-child(1),
  #finhealth-result table.rate-table td:nth-child(1) { width: 110px; }
  #finhealth-result table.mine-table th:nth-child(1),
  #finhealth-result table.mine-table td:nth-child(1) { width: 44%; }
  #finhealth-result table.mine-table th:nth-child(2),
  #finhealth-result table.mine-table td:nth-child(2) { width: 72px; white-space: nowrap; }

  /* 圖表高度略降 */
  .chart-box { height: 260px; padding: 8px; }
  .chart-box.chart-box-tall { height: 380px; }

  /* 登入卡片 */
  .login-card { padding: 28px 22px; margin: 0 12px; }

  /* 結果標題與徽章換行不擠 */
  .result-head { flex-wrap: wrap; gap: 8px; }
}

/* ---------- 會員管理：原始合約 / 修改合約 兩區塊 ---------- */
.ct-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px 14px;
  margin-bottom: 14px;
}
.ct-block-title {
  font-size: 13px; font-weight: 700; color: var(--muted);
  margin-bottom: 10px;
}
/* 原始合約為唯讀快照：底色區隔，但文字仍要看得清楚(蓋掉瀏覽器的 disabled 灰化) */
.ct-orig { background: #f8fafc; }
.ct-orig input[disabled] {
  background: #ffffff;
  color: var(--text);
  opacity: 1;
  -webkit-text-fill-color: var(--text);   /* Safari/iOS 會忽略 color */
  cursor: default;
}

/* ---------- 龍蝦/海龜指標圖 ---------- */
.chart-imgs { margin-top: 12px; display: flex; flex-direction: column; gap: 16px; }
.chart-imgs img {
  max-width: 100%; height: auto; display: block;
  border: 1px solid var(--line); border-radius: 8px;
}
.chart-imgs .chart-empty { color: var(--muted); font-size: 14px; padding: 20px 0; }
