/* =========================
   Theme Tokens（Dark/Light）
   切換方式：<html data-theme="dark|light">
   目的：把顏色集中管理，2.1 先試切換，後續 2.2 / 3.x 直接沿用
   ========================= */

:root{
  /* typography */
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
          "Noto Sans", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* layout tokens */
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0,0,0,0.35);

  /* motion */
  --theme-trans: 160ms ease;
}

/* 預設：dark（你目前的 UI 視覺） */
html[data-theme="dark"]{
  --bg: #070b14;
  --panel: rgba(255,255,255,0.04);
  --panel2: rgba(255,255,255,0.06);
  --line: rgba(255,255,255,0.10);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.62);

  --primary: #4f8cff;
  --primary2: rgba(79,140,255,0.18);
  --danger: #ff4f70;
  --danger2: rgba(255,79,112,0.18);

  --pos: #72f3a6;
  --neg: #ff5b70;

  /* Topbar / Drawer */
  --topbar-bg: rgba(7, 11, 20, 0.65);
  --nav-text: rgba(255,255,255,0.85);
  --brand-border: rgba(255,255,255,0.14);

  /* 背景漸層（頁面底圖） */
  --bg-grad1: rgba(79,140,255,0.12);
  --bg-grad2: rgba(255,79,112,0.10);
  --bg-grad3: rgba(114,243,166,0.08);
}

/* Light（CFO 友善、白底清楚格線） */
html[data-theme="light"]{
  /* Page background (報表底色：淡灰，不要霧白) */
  --bg: #f3f4f6;

  /* Surfaces（卡片/表格底：要夠白） */
  --panel: #ffffff;
  --panel2: #f9fafb;

  /* Gridlines（Light 的線條要清楚） */
  --line: #e5e7eb;

  /* Text */
  --text: #111827;
  --muted: #6b7280;

  /* Brand */
  --primary: #2563eb;
  --primary2: rgba(37,99,235,0.12);
  --danger: #e11d48;
  --danger2: rgba(225,29,72,0.10);

  /* Status */
  --pos: #0f9d58;
  --neg: #dc2626;

  /* Topbar / Drawer */
  --topbar-bg: rgba(255,255,255,0.92);
  --nav-text: rgba(17,24,39,0.88);
  --brand-border: rgba(17,24,39,0.16);

  /* 背景漸層（Light 版幾乎關掉玻璃感） */
  --bg-grad1: rgba(37,99,235,0.04);
  --bg-grad2: rgba(225,29,72,0.02);
  --bg-grad3: rgba(15,157,88,0.02);
}


*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% 10%, var(--bg-grad1), transparent 60%),
    radial-gradient(900px 500px at 80% 10%, var(--bg-grad2), transparent 60%),
    radial-gradient(900px 700px at 60% 90%, var(--bg-grad3), transparent 60%),
    var(--bg);
  transition: background var(--theme-trans), color var(--theme-trans);
}

a{ color: var(--primary); text-decoration:none; }
a:hover{ text-decoration:underline; }

.row{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.small{ font-size:12px; }
.muted{ color: var(--muted); }
.mono{ font-family: var(--mono); }
.pos{ color: var(--pos); }
.neg{ color: var(--neg); }

/* ---------- layout ---------- */
.container{
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 18px 40px;
}

/* ✅ trades full width */
.container-wide{
  max-width: none;
  padding-left: 16px;
  padding-right: 16px;
}

/* ---------- topbar ---------- */
.topbar{
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
}

.topbar-inner{
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
}

.brand{ display:flex; align-items:center; gap:10px; }
.brand-badge{
  width: 34px; height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(79,140,255,0.35), rgba(255,79,112,0.25));
  border: 1px solid var(--brand-border);
  box-shadow: 0 10px 26px rgba(0,0,0,0.25);
}
.brand-title{ font-weight: 700; letter-spacing: 0.3px; }

.nav{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.nav a{
  padding: 7px 10px;
  border-radius: 12px;
  color: var(--nav-text);
  border: 1px solid transparent;
}
.nav a:hover{
  background: var(--panel2);
  border-color: var(--line);
  text-decoration:none;
}

/* ---------- cards ---------- */
.card{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  margin-top: 14px;
}

/* ✅ full width card */
.card-wide{
  width: 100%;
}

.card-title{
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* ---------- buttons ---------- */
.btn{
  appearance:none;
  border: 1px solid var(--brand-border);
  background: var(--panel2);
  color: rgba(255,255,255,0.92);
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 13px;
  cursor:pointer;
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
  user-select:none;
}
.btn:hover{
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.18);
}
.btn:active{ transform: translateY(1px); }

.btn.primary{
  background: var(--primary2);
  border-color: rgba(79,140,255,0.42);
}
.btn.primary:hover{
  background: rgba(79,140,255,0.24);
  border-color: rgba(79,140,255,0.55);
}

.btn.danger{
  background: var(--danger2);
  border-color: rgba(255,79,112,0.45);
}
.btn.danger:hover{
  background: rgba(255,79,112,0.26);
  border-color: rgba(255,79,112,0.60);
}

.iconbtn{
  width: 34px; height: 34px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  cursor:pointer;
  transition: background var(--theme-trans), border-color var(--theme-trans), color var(--theme-trans);
}
.iconbtn:hover{
  background: var(--panel);
  border-color: var(--line);
}

/* ---------- inputs ---------- */
input, select, textarea{
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  padding: 9px 10px;
  outline: none;
  font-size: 13px;
  transition: background var(--theme-trans), border-color var(--theme-trans), color var(--theme-trans);
}
input::placeholder, textarea::placeholder{ color: var(--muted); opacity: .55; }
input:focus, select:focus, textarea:focus{
  border-color: rgba(79,140,255,0.55);
  box-shadow: 0 0 0 3px rgba(79,140,255,0.15);
}

/* ---------- forms ---------- */
.formgrid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 12px;
  margin-top: 12px;
}
.formgrid label{
  display:flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.78);
}

/* ---------- table ---------- */
.table-wrap{
  overflow:auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-top: 12px;
  background: rgba(0,0,0,0.10);
  max-height: 72vh;
}

/* ✅ even wider feel (no extra padding loss) */
.table-wrap-wide{
  width: 100%;
}

table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1450px; /* allow horizontal scroll */
}

thead th{
  position: sticky;
  top: 0;
  background: rgba(10,16,30,0.95);
  backdrop-filter: blur(10px);
  z-index: 3;
  text-align: left;
  padding: 10px 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.86);
  border-bottom: 1px solid rgba(255,255,255,0.10);
  white-space: nowrap;
}

tbody td{
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 13px;
  color: rgba(255,255,255,0.88);
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:hover td{
  background: rgba(255,255,255,0.03);
}

tbody td.mono{
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.1px;
}

thead th:first-child{ border-top-left-radius: 14px; }
thead th:last-child{ border-top-right-radius: 14px; }

/* ---------- Excel-like header UI ---------- */
.th-wrap{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap:10px;
}

.th-label{
  user-select:none;
  cursor:pointer;
  color: rgba(255,255,255,0.88);
}

.filter-btn{
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid var(--brand-border);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.72);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height: 1;
}
.filter-btn:hover{
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.20);
}
.filter-btn.active{
  border-color: rgba(79,140,255,0.55);
  background: rgba(79,140,255,0.18);
  color: rgba(255,255,255,0.92);
}

/* ---------- popover ---------- */
.filter-popover{
  position: absolute;
  width: 320px;
  border-radius: 16px;
  border: 1px solid var(--brand-border);
  background: rgba(12, 16, 28, 0.92);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.55);
  padding: 12px;
  z-index: 500;
}

.fp-title{
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
  color: rgba(255,255,255,0.90);
}

.fp-input{
  border-radius: 12px;
  border: 1px solid var(--brand-border);
  background: var(--panel2);
  color: rgba(255,255,255,0.92);
  padding: 9px 10px;
  font-size: 13px;
  outline: none;
}

.fp-range{
  display:flex;
  gap:10px;
}

.fp-actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top: 12px;
}

.fp-muted{
  color: rgba(255,255,255,0.60);
  font-size: 12px;
}

/* actions column buttons tighter */
tbody td .btn{
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 12px;
}

/* ---------- modal ---------- */
.modal{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
  background: rgba(0,0,0,0.55);
  z-index: 200;
}
.modal.hidden{ display:none; }

/* =====================================================
   Utilities
===================================================== */
.hidden{ display:none !important; } /* ✅ for collapsible panels / popovers across pages */

.modal-card{
  width: 100%;
  max-width: 920px;
  border-radius: 18px;
  border: 1px solid var(--brand-border);
  background: rgba(12, 16, 28, 0.92);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.55);
  padding: 14px 14px 12px;
}

.modal-h{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.modal-title{
  font-weight: 800;
  letter-spacing: 0.2px;
}

.modal-f{
  display:flex;
  align-items:center;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.10);
  margin-top: 12px;
}

/* ---------- responsive ---------- */
@media (max-width: 900px){
  .formgrid{ grid-template-columns: 1fr; }
  .topbar-inner{
    flex-direction: column;
    align-items: flex-start;
  }
}

/* subtle scrollbar */
.table-wrap::-webkit-scrollbar{ height: 10px; width: 10px; }
.table-wrap::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
}
.table-wrap::-webkit-scrollbar-track{
  background: rgba(255,255,255,0.04);
}


/* =========================
   App Shell + Drawer
========================= */
:root{
  --drawer-w: 260px;
  --drawer-w-collapsed: 72px;
}

/* shell layout */
.app-shell{
  display:flex;
  min-height: calc(100vh - 64px); /* topbar height */
}
.app-content{
  flex:1;
  min-width: 0;
  padding-left: 0;
}

/* topbar tweak (if you already have .topbar, keep yours; this just补強) */
.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(6,10,18,.88);
  backdrop-filter: blur(10px);
}
.topbar-left{ display:flex; align-items:center; gap:12px; }
.topbar-right{ display:flex; align-items:center; gap:10px; }

.iconbtn-lg{
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 18px;
}

/* drawer */
.drawer{
  width: var(--drawer-w);
  flex: 0 0 var(--drawer-w);
  border-right: 1px solid rgba(255,255,255,.08);
  background: rgba(10,14,22,.62);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 64px; /* under topbar */
  height: calc(100vh - 64px);
  overflow: hidden;
}
.drawer-inner{
  height: 100%;
  padding: 14px 12px;
  overflow:auto;
}
.drawer-sec{ margin-bottom: 18px; }
.drawer-sec-title{
  font-size: 12px;
  letter-spacing: .08em;
  color: rgba(255,255,255,.55);
  margin: 6px 10px 10px;
  text-transform: uppercase;
}
.drawer-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  margin: 6px 6px;
  border-radius: 12px;
  color: rgba(255,255,255,.86);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.03);
}
.drawer-item:hover{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.10);
}
.drawer-item.active{
  background: linear-gradient(180deg, rgba(59,130,246,.22), rgba(59,130,246,.10));
  border-color: rgba(59,130,246,.28);
  color: rgba(255,255,255,.95);
}
.drawer-dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
}
.drawer-item.active .drawer-dot{
  background: rgba(59,130,246,.9);
}

/* drawer: section title with actions */
.drawer-sec-title-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.icon-btn{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.86);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.icon-btn:hover{ background: rgba(255,255,255,.07); }
.icon-btn.active{
  border-color: rgba(59,130,246,.35);
  background: rgba(59,130,246,.16);
}

/* report sheets list */
.report-sheets{ display:flex; flex-direction:column; gap: 6px; }
.sheet-item{ position: relative; }
.sheet-actions{
  margin-left:auto;
  display:flex;
  gap: 6px;
  align-items:center;
}
.mini-btn{
  width: 34px;
  height: 32px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.03);
  color: rgba(255,255,255,.80);
  cursor: pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.mini-btn:hover{ background: rgba(255,255,255,.07); }
.mini-btn.del{ border-color: rgba(244,63,94,.28); }
.sheet-rename-input{
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(59,130,246,.28);
  color: rgba(255,255,255,.95);
  border-radius: 10px;
  padding: 6px 10px;
  outline: none;
}

.drawer-add{
  margin: 10px 6px 6px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px dashed rgba(255,255,255,.16);
  background: rgba(255,255,255,.02);
  color: rgba(255,255,255,.86);
  cursor:pointer;
}
.drawer-add:hover{ background: rgba(255,255,255,.05); }

/* drawer resizer */
.drawer-resizer{
  position:absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
}
.no-select{ user-select:none; }

/* desktop collapsed */
body.drawer-collapsed .drawer{
  width: var(--drawer-w-collapsed);
  flex-basis: var(--drawer-w-collapsed);
}
body.drawer-collapsed .drawer-text,
body.drawer-collapsed .drawer-sec-title,
body.drawer-collapsed .drawer-add,
body.drawer-collapsed .sheet-actions,
body.drawer-collapsed .drawer-resizer{
  display:none !important;
}
body.drawer-collapsed .drawer-item{ justify-content:center; }

.drawer-foot{
  padding: 10px;
  opacity: .7;
}

/* overlay for small screens */
.drawer-overlay{
  display:none;
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0,0,0,.45);
}

/* responsive: drawer becomes off-canvas */
@media (max-width: 1100px){
  .drawer{
    position: fixed;
    top: 64px;
    left: 0;
    z-index: 70;
    transform: translateX(-110%);
    transition: transform .18s ease;
  }
  body.drawer-open .drawer{
    transform: translateX(0);
  }
  .drawer-overlay{
    display:none;
  }
  body.drawer-open .drawer-overlay{
    display:block;
  }
}


.fxcell-pos{ background: rgba(114,243,166,0.12); }
.fxcell-neg{ background: rgba(255,91,112,0.12); }
.fxcell-na { color: rgba(255,255,255,0.38); }
.fx-matrix table{ min-width: 1100px; }
.fx-matrix td, .fx-matrix th{ text-align: right; }
.fx-matrix th.sticky-col{
  position: sticky;
  left: 0;
  z-index: 2;
  background: rgba(10,16,30,0.95);
}
.fx-matrix td.sticky-col{
  position: sticky;
  left: 0;
  z-index: 1;
  background: rgba(0,0,0,0.18);
}
/* ---------- FX Trend (new) ---------- */
.kpi-grid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
@media (max-width: 1100px){
  .kpi-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.kpi-card{
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  padding: 12px 12px 10px;
}
.kpi-title{ font-size: 12px; color: rgba(255,255,255,0.70); }
.kpi-value{ font-size: 22px; font-weight: 800; letter-spacing: 0.2px; margin-top: 4px; }
.kpi-sub{ font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 4px; }

.chart-box{
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0,0,0,0.10);
}
.chart-box .chart{
  width: 100%;
  min-height: 560px;
}

/* =====================================================================
   Page Custom Styles
   =====================================================================
   2.1.輸入外匯原始部位明細  (fx_raw_positions_v2.html)
   - 會看到的按鈕/文字：
     「匯入部位資料（CSV / Excel）」
     「定義部位名稱（Account → Position Name）」
     「+ 新增單筆」「下載 CSV」「刷新」
   - 這一頁專屬：部位名稱 Mapping Modal、badge 樣式、表頭次標
   ===================================================================== */

.page-fx-raw .th-sub{
  display:block;
  font-size:11px;
  opacity:.72;
  margin-top:2px;
  font-weight:500;
  white-space:nowrap;
}

/* 「Rule」狀態標籤：default / mapping / manual */
.page-fx-raw .badge{
  display:inline-flex;
  align-items:center;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  line-height:16px;
  border:1px solid rgba(255,255,255,.14);
  opacity:.95;
}
.page-fx-raw .badge.default{ background:rgba(255,255,255,.04); }
.page-fx-raw .badge.mapping{ background:rgba(66,153,225,.12); border-color:rgba(66,153,225,.35); }
.page-fx-raw .badge.manual{  background:rgba(236,201,75,.10); border-color:rgba(236,201,75,.35); }

/* 「部位名稱定義（Account → Position Name）」彈窗：左右雙欄布局 */
.page-fx-raw .map-modal-card{
  width:min(1240px,96vw);
  max-width:1240px;
  max-height:calc(100vh - 80px);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.page-fx-raw .map-tabs{
  display:flex;
  gap:8px;
  margin-top:10px;
  margin-bottom:8px;
}

/* Tabs：建立/套用｜規則總覽 */
.page-fx-raw .map-tab{
  padding:8px 12px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.03);
  cursor:pointer;
  font-weight:700;
  font-size:13px;
  color:rgba(255,255,255,.86);
}
.page-fx-raw .map-tab:hover{ background:rgba(255,255,255,.06); }
.page-fx-raw .map-tab.active{
  background:rgba(66,153,225,.22);
  border-color:rgba(66,153,225,.55);
  box-shadow:0 0 0 1px rgba(66,153,225,.18) inset;
}

.page-fx-raw .map-body{ flex:1; overflow:hidden; display:flex; flex-direction:column; }
.page-fx-raw .map-pane{ flex:1; overflow:hidden; }
.page-fx-raw .map-grid{ display:flex; gap:12px; height:100%; }

.page-fx-raw .map-left{
  flex:1;
  min-width:520px;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.page-fx-raw .map-left .table-wrap{
  flex:1;
  overflow:auto;
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px;
}
.page-fx-raw .map-right{ width:380px; min-width:320px; flex-shrink:0; }
.page-fx-raw .map-right .card{ position:sticky; top:0; }

/* Mapping 清單表格（左側）：讓文字可以省略號、欄寬可調 */
.page-fx-raw #mapPool table{ table-layout:fixed; }
.page-fx-raw .map-table{ width:100%; border-collapse:collapse; table-layout:fixed; }
.page-fx-raw .map-table th,
.page-fx-raw .map-table td{
  padding:4px 8px;          /* 更緊密 */
  font-size:12.5px;
  vertical-align:top;
  min-width:0;              /* 允許縮到更小 */
}
.page-fx-raw .map-table td .ellipsis{
  display:block;
  max-width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* 欄寬：保留重要欄位可讀性（避免全部被縮成 20px） */
.page-fx-raw #mapPool .map-table th:nth-child(1),
.page-fx-raw #mapPool .map-table td:nth-child(1){ width:44px; }   /* 勾選 */
.page-fx-raw #mapPool .map-table th:nth-child(2),
.page-fx-raw #mapPool .map-table td:nth-child(2){ width:160px; }  /* Account */
.page-fx-raw #mapPool .map-table th:nth-child(5),
.page-fx-raw #mapPool .map-table td:nth-child(5){ width:120px; }  /* Rule */
.page-fx-raw #mapPool .map-table th:nth-child(6),
.page-fx-raw #mapPool .map-table td:nth-child(6){ width:90px; text-align:right; } /* 影響筆數 */

.page-fx-raw .map-kpi{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-top:8px; }
.page-fx-raw .map-kpi .pill{
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
  border-radius:999px;
  padding:4px 10px;
  font-size:12px;
}
.page-fx-raw .map-note{ border-left:3px solid rgba(66,153,225,.45); padding-left:10px; }

/* 共用：hidden */
.page-fx-raw .hidden{ display:none!important; }

/* Resizable columns：表頭右邊緣可拖拉 */
.page-fx-raw .map-table th{ position:relative; }
.page-fx-raw .col-resizer{
  position:absolute;
  top:0;
  right:-2px;
  width:6px;
  height:100%;
  cursor:col-resize;
  user-select:none;
}
.page-fx-raw .col-resizer:hover{ background:rgba(255,255,255,.10); }
.page-fx-raw .col-resizer:active{ background:rgba(66,153,225,.25); }

/* =====================================================================
   2.2.輸入外匯避險交易明細  (trades.html)
   - 會看到的按鈕/文字：
     「上傳 CSV」「下載 CSV」「+ 新增交易」「刷新」
   - 這一頁專屬：Filter Popover（Excel 風格漏斗）更像 panel
   ===================================================================== */

/* 讓交易頁的 select/input 更像「表單控件」一致高度 */
.page-trades .modal-card select,
.page-trades .modal-card input,
.page-trades .filter-popover select,
.page-trades .filter-popover input{
  height:42px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(0,0,0,.20);
  color:rgba(255,255,255,.92);
  padding:0 12px;
  outline:none;
}
.page-trades .modal-card select:focus,
.page-trades .modal-card input:focus,
.page-trades .filter-popover select:focus,
.page-trades .filter-popover input:focus{
  border-color:rgba(120,180,255,.55);
}

/* 原生 select 的下拉箭頭（仍是 native select） */
.page-trades .modal-card select,
.page-trades .filter-popover select{
  appearance:none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255,255,255,.75) 50%),
    linear-gradient(135deg, rgba(255,255,255,.75) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 18px,
    calc(100% - 12px) 18px;
  background-size:6px 6px, 6px 6px;
  background-repeat:no-repeat;
  padding-right:34px;
}

/* 交易頁：避免 popover 被表格 sticky header 蓋住 */
.page-trades .filter-popover{ z-index:20000; }

/* Filter Popover：做成像「Excel/面板」的容器 */
.page-trades .fp-panel{
  border-radius:16px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(12,16,26,.98);
  box-shadow:0 24px 80px rgba(0,0,0,.55);
  overflow:hidden;
  backdrop-filter: blur(10px);
  width:320px;
}
.page-trades .fp-head{
  padding:10px 12px 8px;
  border-bottom:1px solid rgba(255,255,255,.08);
  display:flex;
  flex-direction:column;
  gap:8px;
}
.page-trades .fp-title{
  font-size:13px;
  font-weight:900;
  opacity:.92;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.page-trades .fp-search{
  width:100%;
  height:36px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(0,0,0,.20);
  color:rgba(255,255,255,.92);
  padding:0 12px;
  outline:none;
}
.page-trades .fp-search:focus{ border-color:rgba(120,180,255,.55); }

.page-trades .fp-list{
  max-height:320px;
  overflow:auto;
  padding:8px;
}
.page-trades .fp-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 10px;
  border-radius:12px;
  cursor:pointer;
  user-select:none;
  font-size:14px;
}
.page-trades .fp-item:hover{ background:rgba(255,255,255,.06); }
.page-trades .fp-check{
  width:18px;
  height:18px;
  border-radius:6px;
  border:1px solid rgba(255,255,255,.18);
  background:rgba(0,0,0,.20);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:12px;
  opacity:.85;
  flex:0 0 auto;
}
.page-trades .fp-item[data-checked="1"] .fp-check{
  border-color:rgba(255,90,140,.9);
  background:rgba(255,90,140,.22);
  box-shadow:0 0 0 3px rgba(255,90,140,.10);
}
.page-trades .fp-item[data-checked="1"] .fp-check::before{
  content:"✓";
  color:rgba(255,255,255,.95);
  font-weight:900;
  transform: translateY(-0.5px);
}
.page-trades .fp-foot{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  align-items:center;
  padding:10px 10px;
  border-top:1px solid rgba(255,255,255,.08);
}
.page-trades .fp-mini{
  margin-right:auto;
  font-size:12px;
  opacity:.75;
  padding:6px 8px;
}

/* =====================================================================
   Drawer（左側選單）客製化樣式
   - 對應畫面：左側「參考資料 / 輸入原始資料 / 報表」清單
   - 來源：drawer.html 內原本的 <style> + drawer.css
   ===================================================================== */

/* ===== Drawer section style：區塊分群（參考資料 / 輸入原始資料 / 報表） ===== */
.drawer-sec{
  padding-bottom: 6px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* 「參考資料 / 輸入原始資料 / 報表」標題文字 */
.drawer-sec-title{
  font-size: 14px;
  font-weight: 600;
  color: #e6ebf2;
  letter-spacing: 0.08em;
  margin: 18px 12px 8px;
  opacity: 0.95;
}

/* 左側清單項目文字（例如：2.1.輸入外匯原始部位明細 / 2.2.輸入外匯避險交易明細） */
.drawer-item .drawer-text{
  font-size: 13px;
  color: #cfd6e4;
}

/* 左側目前所在頁（藍色底） */
.drawer-item.active{
  background: linear-gradient(
    90deg,
    rgba(60, 120, 255, 0.18),
    rgba(60, 120, 255, 0.05)
  );
}
.drawer-item.active .drawer-text{
  color: #ffffff;
  font-weight: 600;
}

/* ===== 只強化「報表」這個 section ===== */
/* 你在 UI 看到的文字：『報表』 */
.drawer-sec-report .drawer-sec-title,
.drawer-sec:has(.drawer-sec-title-row) .drawer-sec-title{
  color: #ffffff;
  font-size: 14.5px;
  letter-spacing: 0.1em;
}

/* 『報表』區塊底色微微不同（很淡，不突兀） */
.drawer-sec-report,
.drawer-sec:has(.drawer-sec-title-row){
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0)
  );
  border-radius: 10px;
  padding-top: 4px;
}


/* =====================================================
   Light Theme Overrides (colors only)
   說明：原檔很多元件仍用 dark 的硬編碼色（rgba(255,255,255,...) / 深色底）
   這裡只在 light theme 下改顏色，不動字體/間距/結構
===================================================== */

html[data-theme="light"] body{
  /* 讓漸層更淡、背景更乾淨（不改 layout） */
  background:
    radial-gradient(1200px 600px at 20% 10%, var(--bg-grad1), transparent 60%),
    radial-gradient(900px 500px at 80% 10%, var(--bg-grad2), transparent 60%),
    radial-gradient(900px 700px at 60% 90%, var(--bg-grad3), transparent 60%),
    var(--bg);
}

/* ---------- Topbar（後段有硬寫 dark 背景，這裡矯正） ---------- */
html[data-theme="light"] .topbar{
  background: var(--topbar-bg) !important;
  border-bottom: 1px solid var(--line) !important;
}

/* ---------- Cards ---------- */
html[data-theme="light"] .card{
  box-shadow: 0 12px 32px rgba(0,0,0,0.10);
}

/* ---------- Buttons（原本 .btn 文字是白色，light 會看起來像 disabled） ---------- */
html[data-theme="light"] .btn{
  background: #ffffff;
  color: #1f2937;
  border-color: rgba(17,24,39,0.18);
}
html[data-theme="light"] .btn:hover{
  background: #f3f4f6;
  border-color: rgba(17,24,39,0.26);
}
html[data-theme="light"] .btn.primary{
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}
html[data-theme="light"] .btn.primary:hover{
  background: #1d4ed8;
}
html[data-theme="light"] .btn.danger{
  background: rgba(225,29,72,0.12);
  color: #9f1239;
  border-color: rgba(225,29,72,0.28);
}
html[data-theme="light"] .btn.danger:hover{
  background: rgba(225,29,72,0.16);
  border-color: rgba(225,29,72,0.36);
}

/* icon buttons */
html[data-theme="light"] .iconbtn,
html[data-theme="light"] .icon-btn,
html[data-theme="light"] .mini-btn{
  background: #ffffff;
  color: #1f2937;
  border-color: rgba(17,24,39,0.16);
}
html[data-theme="light"] .iconbtn:hover,
html[data-theme="light"] .icon-btn:hover,
html[data-theme="light"] .mini-btn:hover{
  background: #f3f4f6;
}

/* ---------- Inputs ---------- */
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea{
  background: #ffffff;
  color: #111827;
  border-color: rgba(17,24,39,0.18);
}
html[data-theme="light"] input:focus,
html[data-theme="light"] select:focus,
html[data-theme="light"] textarea:focus{
  border-color: rgba(37,99,235,0.65);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.16);
}

/* ---------- Table（讓 row/hover/header 在 light 清楚） ---------- */
html[data-theme="light"] .table-wrap{
  background: #ffffff;
  border-color: var(--line);
}
html[data-theme="light"] table{
  background: #ffffff;
}
html[data-theme="light"] thead th{
  background: #ffffff !important;
  color: #111827 !important;
  border-bottom: 1px solid var(--line) !important;
}
html[data-theme="light"] .th-label{
  color: #111827 !important;
}
html[data-theme="light"] tbody td{
  color: #1f2937 !important;
  border-bottom: 1px solid var(--line) !important;
}
html[data-theme="light"] tbody tr:nth-child(even) td{
  background: #f9fafb;
}
html[data-theme="light"] tbody tr:hover td{
  background: #eef2ff;
}

/* Excel-like filter button */
html[data-theme="light"] .filter-btn{
  background: #ffffff;
  color: #374151;
  border-color: rgba(17,24,39,0.18);
}
html[data-theme="light"] .filter-btn:hover{
  background: #f3f4f6;
  border-color: rgba(17,24,39,0.26);
}
html[data-theme="light"] .filter-btn.active{
  background: #e0e7ff;
  border-color: rgba(99,102,241,0.55);
  color: #1e3a8a;
}

/* ---------- Drawer（後段大量 hardcode 白字/深底，這裡只矯正色） ---------- */
html[data-theme="light"] .drawer{
  background: #f9fafb !important;
  border-right: 1px solid var(--line) !important;
}
html[data-theme="light"] .drawer-sec{
  border-bottom: 1px solid rgba(17,24,39,0.08) !important;
}
html[data-theme="light"] .drawer-sec-title{
  color: #374151 !important;
}
html[data-theme="light"] .drawer-item{
  background: transparent !important;
  border-color: transparent !important;
  color: #374151 !important;
}
html[data-theme="light"] .drawer-item .drawer-text{
  color: #374151 !important;
}
html[data-theme="light"] .drawer-item:hover{
  background: #f3f4f6 !important;
}
html[data-theme="light"] .drawer-item.active{
  background: #eef2ff !important;
  border-color: #c7d2fe !important;
  color: #1e3a8a !important;
}
html[data-theme="light"] .drawer-item.active .drawer-text{
  color: #1e3a8a !important;
}
html[data-theme="light"] .drawer-dot{
  background: rgba(17,24,39,0.28) !important;
}
html[data-theme="light"] .drawer-item.active .drawer-dot{
  background: #2563eb !important;
}

/* ---------- Modal / Popover（light 不要黑玻璃） ---------- */
html[data-theme="light"] .modal{
  background: rgba(0,0,0,0.25);
}
html[data-theme="light"] .modal-card{
  background: #ffffff !important;
  border-color: var(--line) !important;
  box-shadow: 0 20px 50px rgba(0,0,0,0.18) !important;
}
html[data-theme="light"] .modal-h{
  border-bottom: 1px solid var(--line) !important;
}
html[data-theme="light"] .modal-f{
  border-top: 1px solid var(--line) !important;
}
html[data-theme="light"] .filter-popover{
  background: #ffffff !important;
  border-color: var(--line) !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18) !important;
}
html[data-theme="light"] .fp-title,
html[data-theme="light"] .fp-muted{
  color: #111827 !important;
  opacity: .9;
}

/* ---------- Page-specific bits that were white-on-dark (2.1 mapping) ---------- */
html[data-theme="light"] .page-fx-raw .badge{
  border-color: rgba(17,24,39,0.16);
  color: #111827;
}
html[data-theme="light"] .page-fx-raw .badge.default{ background: #f3f4f6; }
html[data-theme="light"] .page-fx-raw .badge.mapping{ background: #e0e7ff; border-color: #c7d2fe; color:#1e3a8a; }
html[data-theme="light"] .page-fx-raw .badge.manual{  background: rgba(245,158,11,0.14); border-color: rgba(245,158,11,0.32); color:#7c2d12; }

/* ---------- FX matrix sticky col colors ---------- */
html[data-theme="light"] .fx-matrix th.sticky-col{ background: #ffffff !important; }
html[data-theme="light"] .fx-matrix td.sticky-col{ background: #f9fafb !important; }
html[data-theme="light"] .fxcell-na{ color: rgba(17,24,39,0.40) !important; }



/* =====================================================
   Light Fix Pack (v2)
   - 修正：金額正負色（pos/neg）被 table td 規則蓋掉
   - 修正：scrollbar 在 light 變得看不見
   - 修正：部位名稱定義 Modal 的 Tabs（建立/套用、規則總覽）在 light 不清楚
   ※ 只改顏色，不動字體/間距/結構
===================================================== */

/* --- 1) 正負數顏色：提高 specificity，避免被 html[data-theme=light] tbody td 蓋掉 --- */
html[data-theme="light"] .pos,
html[data-theme="light"] tbody td.pos,
html[data-theme="light"] .pos *{
  color: var(--pos) !important;
}
html[data-theme="light"] .neg,
html[data-theme="light"] tbody td.neg,
html[data-theme="light"] .neg *{
  color: var(--neg) !important;
}

/* 如果你有用 fxcell-pos/fxcell-neg（矩陣/表格 highlight），light 下補強對比 */
html[data-theme="light"] .fxcell-pos{ background: rgba(15, 157, 88, 0.12) !important; }
html[data-theme="light"] .fxcell-neg{ background: rgba(220, 38, 38, 0.12) !important; }

/* --- 2) Scrollbar：light 下用深色 thumb，讓水平/垂直滾動條看得見 --- */
html[data-theme="light"] .table-wrap::-webkit-scrollbar,
html[data-theme="light"] .drawer-inner::-webkit-scrollbar,
html[data-theme="light"] .fp-list::-webkit-scrollbar,
html[data-theme="light"] .map-left .table-wrap::-webkit-scrollbar{
  height: 10px;
  width: 10px;
}
html[data-theme="light"] .table-wrap::-webkit-scrollbar-thumb,
html[data-theme="light"] .drawer-inner::-webkit-scrollbar-thumb,
html[data-theme="light"] .fp-list::-webkit-scrollbar-thumb,
html[data-theme="light"] .map-left .table-wrap::-webkit-scrollbar-thumb{
  background: rgba(17,24,39,0.28);
  border-radius: 999px;
}
html[data-theme="light"] .table-wrap::-webkit-scrollbar-thumb:hover,
html[data-theme="light"] .drawer-inner::-webkit-scrollbar-thumb:hover,
html[data-theme="light"] .fp-list::-webkit-scrollbar-thumb:hover,
html[data-theme="light"] .map-left .table-wrap::-webkit-scrollbar-thumb:hover{
  background: rgba(17,24,39,0.38);
}
html[data-theme="light"] .table-wrap::-webkit-scrollbar-track,
html[data-theme="light"] .drawer-inner::-webkit-scrollbar-track,
html[data-theme="light"] .fp-list::-webkit-scrollbar-track,
html[data-theme="light"] .map-left .table-wrap::-webkit-scrollbar-track{
  background: rgba(17,24,39,0.06);
  border-radius: 999px;
}

/* Firefox scrollbar（不影響 Chromium，但保險） */
html[data-theme="light"] .table-wrap,
html[data-theme="light"] .drawer-inner,
html[data-theme="light"] .fp-list,
html[data-theme="light"] .map-left .table-wrap{
  scrollbar-color: rgba(17,24,39,0.32) rgba(17,24,39,0.06);
  scrollbar-width: thin;
}

/* --- 3) 2.1「部位名稱定義」Modal Tabs：建立/套用 & 規則總覽（light 下文字更清楚） --- */
html[data-theme="light"] .page-fx-raw .map-tab{
  background: #ffffff;
  border-color: #d1d5db;
  color: #374151;
}
html[data-theme="light"] .page-fx-raw .map-tab:hover{
  background: #f3f4f6;
}
html[data-theme="light"] .page-fx-raw .map-tab.active{
  background: #e0e7ff;
  border-color: #2563eb;
  color: #1e3a8a;
  box-shadow: 0 0 0 1px rgba(37,99,235,0.10) inset;
}

/* mapping modal 內的深色輸入（原本是 dark 風格）在 light 轉為白底 */
html[data-theme="light"] .page-fx-raw .map-modal-card input,
html[data-theme="light"] .page-fx-raw .map-modal-card select{
  background: #ffffff !important;
  color: #111827 !important;
  border-color: #d1d5db !important;
}



/* =====================================================
   Light Fix – 2.2「新增交易」Modal（只調顏色，不動尺寸/字體/間距）
   目標：避免灰底像 disabled，恢復「可編輯」語意 + 清楚的 focus/disabled 狀態
===================================================== */
html[data-theme="light"] .page-trades .modal-card{
  background:#ffffff;
  border:1px solid #e5e7eb;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

html[data-theme="light"] .page-trades .modal-h{
  border-bottom:1px solid #e5e7eb;
}
html[data-theme="light"] .page-trades .modal-f{
  border-top:1px solid #e5e7eb;
}

/* ✅ labels / helper text：不要沿用 dark 的白字 */
html[data-theme="light"] .page-trades .formgrid label{
  color:#374151;
}
html[data-theme="light"] .page-trades .modal-card .muted,
html[data-theme="light"] .page-trades .modal-card .muted.small{
  color:#6b7280;
}

/* ✅ form controls：白底 + 明確邊框（可編輯語意） */
html[data-theme="light"] .page-trades .modal-card input,
html[data-theme="light"] .page-trades .modal-card select,
html[data-theme="light"] .page-trades .modal-card textarea{
  background:#ffffff;
  color:#111827;
  border:1px solid #d1d5db;
}

/* placeholder：更淡，跟 value 拉開層級 */
html[data-theme="light"] .page-trades .modal-card input::placeholder,
html[data-theme="light"] .page-trades .modal-card textarea::placeholder{
  color:#9ca3af;
  opacity:1;
}

/* hover：輕微加深邊框（仍不搶戲） */
html[data-theme="light"] .page-trades .modal-card input:hover,
html[data-theme="light"] .page-trades .modal-card select:hover,
html[data-theme="light"] .page-trades .modal-card textarea:hover{
  border-color:#cbd5e1;
}

/* focus：清楚的藍框 + 淡藍 focus ring（Excel / ERP 手感） */
html[data-theme="light"] .page-trades .modal-card input:focus,
html[data-theme="light"] .page-trades .modal-card select:focus,
html[data-theme="light"] .page-trades .modal-card textarea:focus{
  border-color:#2563eb;
  box-shadow:0 0 0 3px rgba(37,99,235,0.15);
}

/* ✅ disabled / readonly：才使用灰底（避免全部都像 disabled） */
html[data-theme="light"] .page-trades .modal-card input:disabled,
html[data-theme="light"] .page-trades .modal-card select:disabled,
html[data-theme="light"] .page-trades .modal-card textarea:disabled,
html[data-theme="light"] .page-trades .modal-card input[readonly],
html[data-theme="light"] .page-trades .modal-card textarea[readonly]{
  background:#f3f4f6;
  color:#9ca3af;
  border-color:#e5e7eb;
  cursor:not-allowed;
}

/* ✅ select 下拉箭頭：light 下用深灰箭頭（覆蓋 page-trades 內原本白箭頭） */
html[data-theme="light"] .page-trades .modal-card select{
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(55,65,81,.85) 50%),
    linear-gradient(135deg, rgba(55,65,81,.85) 50%, transparent 50%);
}

/* Modal overlay：light 下不要太黑 */
html[data-theme="light"] .modal{
  background: rgba(17,24,39,0.18);
}


/* =====================================================
   Dropdown tone design (Dark & Light)
   Scope: native <select> in modals/forms
   Goal: readable options, calm hover/active, no "OS-gray" feel
===================================================== */

/* Light dropdown tokens */
html[data-theme="light"]{
  --dd-bg: #ffffff;
  --dd-border: #d1d5db;
  --dd-text: #111827;
  --dd-muted: #6b7280;
  --dd-hover: #f3f4f6;
  --dd-active: #e0e7ff;
  --dd-active-text: #1e3a8a;
  --dd-shadow: 0 12px 24px rgba(0,0,0,0.12);
}

/* Dark dropdown tokens */
html[data-theme="dark"]{
  --dd-bg: #0b1220;           /* deep navy */
  --dd-border: rgba(255,255,255,0.14);
  --dd-text: rgba(255,255,255,0.92);
  --dd-muted: rgba(255,255,255,0.65);
  --dd-hover: rgba(255,255,255,0.07);
  --dd-active: rgba(99,102,241,0.35);
  --dd-active-text: rgba(255,255,255,0.95);
  --dd-shadow: 0 18px 36px rgba(0,0,0,0.55);
}

/* 1) The closed select control (avoid weird background patterns) */
.modal-card select,
.filter-popover select,
.fp-panel select{
  background-color: var(--dd-bg);
  color: var(--dd-text);
  border-color: var(--dd-border);
  box-shadow: none;
  background-image: none !important; /* remove any legacy gradients/icons */
}

/* Add a simple caret using a mask (keeps sizing stable) */
.modal-card select,
.filter-popover select,
.fp-panel select{
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* caret */
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px 14px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20'><path fill='rgba(55,65,81,0.85)' d='M5.5 7.5l4.5 5 4.5-5z'/></svg>");
}

/* Dark: caret should be light */
html[data-theme="dark"] .modal-card select,
html[data-theme="dark"] .filter-popover select,
html[data-theme="dark"] .fp-panel select{
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20'><path fill='rgba(255,255,255,0.75)' d='M5.5 7.5l4.5 5 4.5-5z'/></svg>");
}

/* Focus ring for select (consistent with inputs) */
.modal-card select:focus,
.filter-popover select:focus,
.fp-panel select:focus{
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* 2) The opened dropdown list (options) — works in most Chromium browsers */
.modal-card select option,
.filter-popover select option,
.fp-panel select option,
.modal-card select optgroup{
  background: var(--dd-bg);
  color: var(--dd-text);
}

/* Hover (browser support varies; harmless if ignored) */
.modal-card select option:hover,
.filter-popover select option:hover,
.fp-panel select option:hover{
  background: var(--dd-hover);
  color: var(--dd-text);
}

/* Selected/checked */
.modal-card select option:checked,
.filter-popover select option:checked,
.fp-panel select option:checked{
  background: var(--dd-active);
  color: var(--dd-active-text);
}

/* 3) If you have a custom dropdown panel (some pages render a div list),
      make sure it uses dropdown tokens too. (Safe: only applies if classes exist) */
.dropdown,
.select-menu,
.select-popover{
  background: var(--dd-bg);
  color: var(--dd-text);
  border: 1px solid var(--dd-border);
  box-shadow: var(--dd-shadow);
}

.dropdown .item:hover,
.select-menu .item:hover,
.select-popover .item:hover{
  background: var(--dd-hover);
}

.dropdown .item.active,
.select-menu .item.active,
.select-popover .item.active{
  background: var(--dd-active);
  color: var(--dd-active-text);
}


/* =========================
   v5 – Drawer (Light) Fixes
   1) "+新增統整報告" (.drawer-add) text/border visible
   2) Drawer item outlines clearer (no layout changes)
   ========================= */

html[data-theme="light"] .drawer-add{
  color: #1f2937 !important;
  background: #ffffff !important;
  border: 1px dashed #cbd5e1 !important;
}
html[data-theme="light"] .drawer-add:hover{
  background: #f3f4f6 !important;
  border-color: #94a3b8 !important;
}

/* 每個頁面按鈕的外框線更清楚 */
html[data-theme="light"] .drawer-item{
  background: #ffffff !important;
  border-color: #e5e7eb !important;
}
html[data-theme="light"] .drawer-item:hover{
  border-color: #d1d5db !important;
}
html[data-theme="light"] .drawer-item.active{
  border-color: #c7d2fe !important; /* keep */
}

/* Drawer 內的動作 icon（編輯/複製/刪除）外框更清楚 */
html[data-theme="light"] .drawer .iconbtn{
  background: #ffffff !important;
  border-color: #e5e7eb !important;
  color: #374151 !important;
}
html[data-theme="light"] .drawer .iconbtn:hover{
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
}



/* =====================================================
   1. 匯率歷史資料及預測（fx_matrix.html）
   目的：
   - 把 fx_matrix.html 內 <style> 全部抽離到 style.css
   - Light theme 灰階更乾淨（不要霧灰）
   - 矩陣 hover/高亮在 Light 更清楚
   - 自製下拉（ms dropdown）提供 Light 版外觀
===================================================== */

/* ---------- Page Layout ---------- */
.fxmx-page{
  padding: 22px 22px 18px;
  height: 100%;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  gap: 14px;
}
.fxmx-title{ font-size:22px; font-weight:900; margin-bottom: 4px; }
.fxmx-sub{ font-size: 13px; opacity: .78; margin-bottom: 12px; }

/* 內容卡片（日期 / 顯示模式 / 說明） */
.fxmx-card{
  border-radius: 16px;
  padding: 12px;
  flex: 0 0 auto;
}

/* Dark：保留玻璃感 */
html[data-theme="dark"] .fxmx-card{
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.15);
  backdrop-filter: blur(10px);
}

/* Light：回到報表卡片語意（白底 + 清楚線條） */
html[data-theme="light"] .fxmx-card{
  border: 1px solid var(--line);
  background: var(--panel);
}

/* Controls */
.fxmx-controls{
  display:flex;
  flex-wrap:wrap;
  gap: 12px;
  align-items:flex-end;
}
.fxmx-field{
  display:flex;
  flex-direction:column;
  gap:7px;
  min-width: 260px;
  flex: 1 1 280px;
}
.fxmx-field label{ font-size:13px; opacity:.82; }

.fxmx-help{ font-size:12px; opacity:.72; margin-top: 4px; }
.fxmx-help.warn{ color: rgba(255,185,90,.95); opacity: 1; }

/* Date input：跟下拉同一高度/形狀 */
.date-input{
  height:42px;
  border-radius:14px;
  padding: 0 14px;
  outline:none;
}

/* Dark date input */
html[data-theme="dark"] .date-input{
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.20);
  color: rgba(255,255,255,.92);
}
html[data-theme="dark"] .date-input:focus{ border-color: rgba(120,180,255,.55); }

/* Light date input */
html[data-theme="light"] .date-input{
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
}
html[data-theme="light"] .date-input:focus{
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* ---------- Matrix Table Card ---------- */
.fxmx-table-card{
  border-radius: 16px;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  display:flex;
  flex-direction:column;
}

/* Dark */
html[data-theme="dark"] .fxmx-table-card{
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.10);
}

/* Light */
html[data-theme="light"] .fxmx-table-card{
  border: 1px solid var(--line);
  background: var(--panel);
}

/* IMPORTANT: force both scrolls to exist */
.fxmx-scroller{
  height: 100%;
  min-height: 0;
  overflow-x: auto !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

/* Matrix table */
table.fxmx-table{
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

table.fxmx-table th,
table.fxmx-table td{
  padding: 12px 14px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Dark gridlines */
html[data-theme="dark"] table.fxmx-table th,
html[data-theme="dark"] table.fxmx-table td{
  border-bottom: 1px solid rgba(255,255,255,.06);
  border-right: 1px solid rgba(255,255,255,.04);
}

/* Light gridlines */
html[data-theme="light"] table.fxmx-table th,
html[data-theme="light"] table.fxmx-table td{
  border-bottom: 1px solid var(--line);
  border-right: 1px solid rgba(17,24,39,0.06);
  color: #111827;
}

/* Sticky header */
table.fxmx-table thead th{
  position: sticky;
  top: 0;
  z-index: 5;
  font-weight: 900;
}
html[data-theme="dark"] table.fxmx-table thead th{
  background: rgba(0,0,0,.28);
}
html[data-theme="light"] table.fxmx-table thead th{
  background: #ffffff;
}

/* Sticky left */
.sticky-left{
  position: sticky;
  left: 0;
  z-index: 6;
}
html[data-theme="dark"] .sticky-left{ background: rgba(0,0,0,.30); }
html[data-theme="light"] .sticky-left{ background: #f9fafb; }

/* Numbers / pct colors */
td.pct{ text-align:right; font-weight:900; }
td.num{ text-align:right; font-weight:800; }
td.num.mono{ font-variant-numeric: tabular-nums; }

td.pct.pos{ color: #25f3c2; }
td.pct.neg{ color: #ff4d6d; }
td.pct.zero{ color: rgba(255,255,255,.55); }

/* Light pct palette（不要霓虹，偏報表） */
html[data-theme="light"] td.pct.pos{ color: #059669; }
html[data-theme="light"] td.pct.neg{ color: #dc2626; }
html[data-theme="light"] td.pct.zero{ color: #6b7280; }

/* Hover highlight: clearer in Light */
.hl{ background: rgba(120,180,255,.10) !important; }
html[data-theme="light"] .hl{
  background: rgba(37,99,235,0.14) !important; /* stronger than v4 */
}

/* ---------- ms dropdown (顯示模式) ---------- */
.ms{ position:relative; width:100%; }
.ms-pop{ display:none; z-index: 20000; }

/* Button */
.ms-btn{
  width:100%;
  height:42px;
  border-radius:14px;
  display:flex; align-items:center; justify-content:space-between;
  padding: 0 14px;
  cursor:pointer;
  user-select:none;
}
.ms-btn .hint{
  opacity:.92; font-size:13px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  max-width: 100%;
}

/* Dark button */
html[data-theme="dark"] .ms-btn{
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.20);
  color: rgba(255,255,255,.92);
}
html[data-theme="dark"] .ms-btn:hover{ border-color: rgba(120,180,255,.35); }

/* Light button */
html[data-theme="light"] .ms-btn{
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
}
html[data-theme="light"] .ms-btn:hover{ border-color: rgba(37,99,235,0.45); }

/* Panel */
.ms-panel{
  border-radius: 16px;
  overflow: hidden;
}

/* Dark panel */
html[data-theme="dark"] .ms-panel{
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(12, 16, 26, .98);
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
}

/* Light panel */
html[data-theme="light"] .ms-panel{
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
}

/* Head */
.ms-head{
  padding: 10px 12px 8px;
  display:flex; flex-direction:column; gap:8px;
}
html[data-theme="dark"] .ms-head{ border-bottom: 1px solid rgba(255,255,255,.08); }
html[data-theme="light"] .ms-head{ border-bottom: 1px solid var(--line); }

.ms-title{
  font-size: 13px;
  font-weight: 900;
  opacity:.9;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
}
html[data-theme="light"] .ms-title{ color:#111827; opacity: 1; }

/* Search（目前 fx_matrix.html 沒用到，但保留相容） */
.ms-search{
  width: 100%;
  height: 36px;
  border-radius: 12px;
  padding: 0 12px;
  outline: none;
}
html[data-theme="dark"] .ms-search{
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.20);
  color: rgba(255,255,255,.92);
}
html[data-theme="dark"] .ms-search:focus{ border-color: rgba(120,180,255,.55); }

html[data-theme="light"] .ms-search{
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
}
html[data-theme="light"] .ms-search:focus{
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* List */
.ms-list{
  max-height: 320px;
  overflow: auto;
  padding: 8px;
}
.ms-item{
  display:flex; align-items:center; gap:10px;
  padding: 10px 10px;
  border-radius: 12px;
  cursor:pointer;
  font-size: 14px;
  user-select:none;
}

/* ✅ 避免「兩個勾勾」：隱藏原生 checkbox / radio，僅顯示 .ms-check（客製勾勾） */
.ms-item input[type="checkbox"],
.ms-item input[type="radio"]{ display:none !important; }

/* 行高固定，避免不同瀏覽器把 row 撐開 */
.ms-item{ line-height: 1.4; }
html[data-theme="dark"] .ms-item:hover{ background: rgba(255,255,255,.06); }
html[data-theme="light"] .ms-item:hover{ background: rgba(37,99,235,0.08); }

/* Check */
.ms-check{
  width:18px; height:18px;
  border-radius: 6px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size: 12px;
  opacity: .85;
  flex: 0 0 auto;
}
html[data-theme="dark"] .ms-check{
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.20);
}
html[data-theme="light"] .ms-check{
  border: 1px solid #cbd5e1;
  background: #ffffff;
}

.ms-item[data-checked="1"] .ms-check{
  border-color: rgba(255,90,140,.9);
  background: rgba(255,90,140,.22);
  box-shadow: 0 0 0 3px rgba(255,90,140,.10);
}
html[data-theme="light"] .ms-item[data-checked="1"] .ms-check{
  border-color: rgba(37,99,235,0.80);
  background: rgba(37,99,235,0.14);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.ms-item[data-checked="1"] .ms-check::before{
  content:"✓";
  font-weight: 900;
  transform: translateY(-0.5px);
}
html[data-theme="dark"] .ms-item[data-checked="1"] .ms-check::before{ color: rgba(255,255,255,.95); }
html[data-theme="light"] .ms-item[data-checked="1"] .ms-check::before{ color: #1d4ed8; }

/* Footer */
.ms-footer{
  display:flex; gap:10px;
  justify-content:flex-end;
  padding:10px 10px;
  align-items:center;
}
html[data-theme="dark"] .ms-footer{ border-top: 1px solid rgba(255,255,255,.08); }
html[data-theme="light"] .ms-footer{ border-top: 1px solid var(--line); }

.ms-mini{ font-size:12px; opacity:.75; margin-right:auto; padding:6px 8px; }

/* Scrollbars inside matrix and ms-list already handled globally in v2+; keep extra clarity for fxmx */
html[data-theme="light"] #fxmxScroller::-webkit-scrollbar-thumb,
html[data-theme="light"] .ms-list::-webkit-scrollbar-thumb{
  background: rgba(17,24,39,0.28);
}
html[data-theme="light"] #fxmxScroller::-webkit-scrollbar-thumb:hover,
html[data-theme="light"] .ms-list::-webkit-scrollbar-thumb:hover{
  background: rgba(17,24,39,0.40);
}


/* ======================================================================
   Page 3.1 – 外匯避險前部位統整 (fx_monthly_matrix)
   Light theme polish: 篩選條件卡片灰階、合計列、曝險拆解表頭匯率
======================================================================== */

/* 篩選條件（light）：淡藍灰卡片 + 清楚邊框 */
html[data-theme="light"] .fxm-card,
html[data-theme="light"] .filter-card.fxm-card {
  background: #f6f8fb !important;
  border: 1px solid #dbe2ec !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06) !important;
}

html[data-theme="light"] .fxm-card .fxm-card-header,
html[data-theme="light"] .filter-card.fxm-card .fxm-card-header {
  border-bottom: 1px solid #dbe2ec !important;
}

html[data-theme="light"] .fxm-collapse,
html[data-theme="light"] .fxm-card .fxm-collapse {
  color: #111827 !important;
}

html[data-theme="light"] .fxm-collapse .ico,
html[data-theme="light"] .fxm-card .fxm-collapse .ico {
  background: #ffffff !important;
  border: 1px solid #dbe2ec !important;
  color: #374151 !important;
}

/* 篩選卡片內的 input/select（light）：白底、清楚邊框、focus ring */
html[data-theme="light"] .fxm-card input,
html[data-theme="light"] .fxm-card select,
html[data-theme="light"] .fxm-card textarea {
  background: #ffffff !important;
  border-color: #d1d5db !important;
  color: #111827 !important;
}
html[data-theme="light"] .fxm-card input::placeholder,
html[data-theme="light"] .fxm-card textarea::placeholder {
  color: #9ca3af !important;
}
html[data-theme="light"] .fxm-card input:focus,
html[data-theme="light"] .fxm-card select:focus,
html[data-theme="light"] .fxm-card textarea:focus {
  border-color: rgba(37, 99, 235, 0.65) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18) !important;
}

/* 合計列（light）：淡底 + 上邊界，避免警示感（兼容多種 class 命名） */
html[data-theme="light"] table.fxm-table tfoot th,
html[data-theme="light"] table.fxm-table tfoot td,
html[data-theme="light"] table.fxm-table tr.total-row th,
html[data-theme="light"] table.fxm-table tr.total-row td,
html[data-theme="light"] table.fxm-table tr.fxm-total th,
html[data-theme="light"] table.fxm-table tr.fxm-total td {
  background: #eef3f8 !important;
  border-top: 1px solid #d5dde8 !important;
  color: #111827 !important;
}
html[data-theme="light"] table.fxm-table tr.total-row th,
html[data-theme="light"] table.fxm-table tr.total-row td,
html[data-theme="light"] table.fxm-table tr.fxm-total th,
html[data-theme="light"] table.fxm-table tr.fxm-total td {
  font-weight: 700 !important;
}

/* 正負值顏色（light） */
html[data-theme="light"] table.fxm-table .num.pos,
html[data-theme="light"] table.fxm-table td.pos,
html[data-theme="light"] table.fxm-table span.pos {
  color: #0f766e !important;
}
html[data-theme="light"] table.fxm-table .num.neg,
html[data-theme="light"] table.fxm-table td.neg,
html[data-theme="light"] table.fxm-table span.neg {
  color: #b91c1c !important;
}

/* Sticky 左/右欄（light）：漸層更自然 */
html[data-theme="light"] .sticky-left,
html[data-theme="light"] .sticky-right {
  background: linear-gradient(90deg, rgba(246, 248, 251, 0.98), rgba(246, 248, 251, 0.90)) !important;
  box-shadow: 0 0 0 transparent !important;
}

/* 曝險拆解表頭匯率（light）：用藍灰 meta，而非螢光綠 */
html[data-theme="light"] .fxpair-rate,
html[data-theme="light"] .fx-pair-rate,
html[data-theme="light"] .rate-badge {
  color: #2563eb !important;
  font-weight: 700 !important;
}

/* 曝險拆解表頭（light）：更像報表 header */
html[data-theme="light"] .fxpair-table thead th,
html[data-theme="light"] table.fxpair-table thead th,
html[data-theme="light"] table.fxm-pair thead th {
  background: #ffffff !important;
  border-bottom: 1px solid #e5e7eb !important;
  color: #111827 !important;
}

/* =======================================================================
   3.1 外匯避險前部位統整（fx_monthly_matrix.html）
   - 把 fx_monthly_matrix.html 內的 <style> 搬到這裡（建議移除 inline style）
   - ✅ 建議在該頁 <body> 加上 class="page-fx-monthly"
   ======================================================================= */

body.page-fx-monthly{
  --fxm-left-col-w: 320px;
  --fxm-num-col-w: 150px;
  --fxm-head-row2-top: 44px;

  /* 讓此頁用「瀏覽器層級捲動」：避免跑版 / 雙重 scroll */
  height: auto;
  overflow: auto;
}
body.page-fx-monthly .app-shell,
body.page-fx-monthly .app-content{
  height: auto;
  overflow: visible;
}

/* ===== Page header ===== */
body.page-fx-monthly .fxm-page{
  padding: 22px 22px 18px;
  display: block;
  overflow: visible;
}
body.page-fx-monthly .fxm-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom: 12px;
}
body.page-fx-monthly .fxm-title{
  font-size:22px;
  font-weight:900;
  letter-spacing:.2px;
}
body.page-fx-monthly .fxm-actions{
  display:flex;
  align-items:center;
  gap:10px;
}
body.page-fx-monthly .fxm-status{
  display:flex;
  align-items:center;
  gap:8px;
  user-select:none;
}
body.page-fx-monthly .fxm-status .dot{
  width:10px; height:10px; border-radius:999px;
  background: rgba(80,255,200,.85);
  box-shadow: 0 0 0 3px rgba(80,255,200,.12);
}
body.page-fx-monthly .fxm-status .dot.err{
  background: rgba(255,90,120,.95);
  box-shadow: 0 0 0 3px rgba(255,90,120,.14);
}
body.page-fx-monthly .fxm-status .text{
  font-size:12px;
  opacity:.78;
  max-width: 640px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* ===== Cards (篩選條件 / 表格容器) ===== */
body.page-fx-monthly .fxm-card,
body.page-fx-monthly .fxm-table-card,
body.page-fx-monthly .fxp-table-card{
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 36px rgba(0,0,0,.18);
}
body.page-fx-monthly .fxm-card{ padding: 14px; }
body.page-fx-monthly .fxm-table-card,
body.page-fx-monthly .fxp-table-card{ padding: 0; overflow:hidden; }

html[data-theme="light"] body.page-fx-monthly .fxm-card,
html[data-theme="light"] body.page-fx-monthly .fxm-table-card,
html[data-theme="light"] body.page-fx-monthly .fxp-table-card{
  background: rgba(255,255,255,.92);
  border-color: rgba(15,23,42,.12);
  box-shadow: 0 10px 30px rgba(2,6,23,.08);
}

/* 篩選條件：header */
body.page-fx-monthly .fxm-card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 12px;
}
body.page-fx-monthly .fxm-collapse{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-weight:900;
  user-select:none;
  cursor:pointer;
}
body.page-fx-monthly .fxm-collapse .ico{ opacity:.8; }

/* 篩選條件：controls */
body.page-fx-monthly .fxm-controls{ display:block; }

/* ✅ 篩選條件收合：JS 會在 #fxmControlCard 加上 .collapsed */
body.page-fx-monthly .fxm-card.collapsed .fxm-controls{ display:none; }
body.page-fx-monthly .fxm-card-header{ cursor:pointer; user-select:none; }

/* ✅「顯示單位」：<select#fxmUnitMode> 只當 state holder，不顯示（避免多一列） */
body.page-fx-monthly #fxmUnitMode{ display:none; }
body.page-fx-monthly .fxm-row{
  display:flex;
  gap:12px;
  align-items:flex-end;
  margin-bottom: 10px;
}
body.page-fx-monthly .fxm-row:last-child{ margin-bottom:0; }
body.page-fx-monthly .fxm-field{ flex:1; min-width: 240px; }
body.page-fx-monthly .fxm-field label{
  display:block;
  font-size:12px;
  opacity:.72;
  margin: 0 0 6px;
}
body.page-fx-monthly .fxm-field .input,
body.page-fx-monthly .fxm-field select,
body.page-fx-monthly .fxm-field input{
  width:100%;
}

/* ===== Multi-select (Entity/Currency) ===== */
body.page-fx-monthly .ms{ position:relative; }
body.page-fx-monthly .ms.w50{ flex:1.2; }
body.page-fx-monthly .ms .ms-display{
  display:flex;
  align-items:center;
  gap:10px;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.18);
  cursor:pointer;
}
html[data-theme="light"] body.page-fx-monthly .ms .ms-display{
  background: rgba(248,250,252,.92);
  border-color: rgba(15,23,42,.14);
}
body.page-fx-monthly .ms .ms-display .val{
  flex:1;
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-size:13px;
  opacity:.92;
}
body.page-fx-monthly .ms .ms-display .caret{ opacity:.65; }

body.page-fx-monthly .ms .ms-panel{
  position:absolute;
  top: calc(100% + 8px);
  left:0;
  right:0;
  z-index: 50;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(12,16,22,.98);
  box-shadow: 0 18px 48px rgba(0,0,0,.35);
  overflow:hidden;
}
html[data-theme="light"] body.page-fx-monthly .ms .ms-panel{
  background: rgba(255,255,255,.98);
  border-color: rgba(15,23,42,.14);
  box-shadow: 0 18px 38px rgba(2,6,23,.14);
}
body.page-fx-monthly .ms .ms-panel .ms-panel-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
html[data-theme="light"] body.page-fx-monthly .ms .ms-panel .ms-panel-head{
  border-bottom-color: rgba(15,23,42,.08);
}
body.page-fx-monthly .ms .ms-panel .ms-panel-title{
  font-weight: 900;
  font-size: 13px;
}
body.page-fx-monthly .ms .ms-panel .ms-panel-body{ max-height: 360px; overflow:auto; }
body.page-fx-monthly .ms .ms-item{
  display:flex;
  gap:10px;
  align-items:center;
  padding: 10px 12px;
  cursor:pointer;
}
body.page-fx-monthly .ms .ms-item:hover{
  background: rgba(56,189,248,.12);
}
html[data-theme="light"] body.page-fx-monthly .ms .ms-item:hover{
  background: rgba(37,99,235,.06);
}
body.page-fx-monthly .ms .ms-item .ck{
  width:18px; height:18px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.18);
  display:grid; place-items:center;
  font-size: 12px;
  color: transparent;
}
html[data-theme="light"] body.page-fx-monthly .ms .ms-item .ck{
  border-color: rgba(15,23,42,.18);
}
body.page-fx-monthly .ms .ms-item.active .ck{
  background: rgba(37,99,235,.95);
  border-color: rgba(37,99,235,.95);
  color: #fff;
}
body.page-fx-monthly .ms .ms-item .label{
  flex:1;
  font-size: 13px;
  opacity:.92;
}
body.page-fx-monthly .ms .ms-panel .ms-panel-foot{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.10);
}
html[data-theme="light"] body.page-fx-monthly .ms .ms-panel .ms-panel-foot{
  border-top-color: rgba(15,23,42,.08);
}

/* ===== Tables (上方矩陣 / 下方曝險拆解) ===== */
body.page-fx-monthly .fxm-table-scroller,
body.page-fx-monthly .fxp-table-scroller{
  overflow:auto;
}

/* base table */
body.page-fx-monthly table.fxm-table,
body.page-fx-monthly table.fxp-table{
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}
body.page-fx-monthly table.fxm-table th,
body.page-fx-monthly table.fxm-table td,
body.page-fx-monthly table.fxp-table th,
body.page-fx-monthly table.fxp-table td{
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  border-right: 1px solid rgba(255,255,255,.06);
  white-space: nowrap;
}
html[data-theme="light"] body.page-fx-monthly table.fxm-table th,
html[data-theme="light"] body.page-fx-monthly table.fxm-table td,
html[data-theme="light"] body.page-fx-monthly table.fxp-table th,
html[data-theme="light"] body.page-fx-monthly table.fxp-table td{
  border-bottom-color: rgba(15,23,42,.08);
  border-right-color: rgba(15,23,42,.06);
}

/* headers sticky */
body.page-fx-monthly table.fxm-table thead th,
body.page-fx-monthly table.fxp-table thead th{
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(10,14,20,.85);
  backdrop-filter: blur(10px);
  font-weight: 900;
}
html[data-theme="light"] body.page-fx-monthly table.fxm-table thead th,
html[data-theme="light"] body.page-fx-monthly table.fxp-table thead th{
  background: rgba(248,250,252,.96);
  color: rgba(15,23,42,.92);
}
body.page-fx-monthly table.fxm-table thead tr:nth-child(1) th{ top: 0; }
body.page-fx-monthly table.fxm-table thead tr:nth-child(2) th{ top: var(--fxm-head-row2-top); }

/* column widths */
body.page-fx-monthly table.fxm-table th.rowhdr,
body.page-fx-monthly table.fxm-table td.rowhdr{
  width: var(--fxm-left-col-w);
  min-width: var(--fxm-left-col-w);
}
body.page-fx-monthly table.fxm-table th.num,
body.page-fx-monthly table.fxm-table td.num{
  width: var(--fxm-num-col-w);
  min-width: var(--fxm-num-col-w);
  text-align: right;
}
body.page-fx-monthly table.fxp-table td.num,
body.page-fx-monthly table.fxp-table th.num{
  text-align: right;
}

/* sticky left / right */
body.page-fx-monthly .sticky-left{
  position: sticky;
  left: 0;
  z-index: 6;
  background: linear-gradient(to right, rgba(10,14,20,.98), rgba(10,14,20,.88));
  box-shadow: 10px 0 24px rgba(0,0,0,.25);
}
html[data-theme="light"] body.page-fx-monthly .sticky-left{
  background: linear-gradient(to right, rgba(248,250,252,.98), rgba(248,250,252,.90));
  box-shadow: 10px 0 22px rgba(2,6,23,.10);
}
body.page-fx-monthly .sticky-right{
  position: sticky;
  right: 0;
  z-index: 6;
  background: linear-gradient(to left, rgba(10,14,20,.98), rgba(10,14,20,.88));
  box-shadow: -10px 0 24px rgba(0,0,0,.25);
}
html[data-theme="light"] body.page-fx-monthly .sticky-right{
  background: linear-gradient(to left, rgba(248,250,252,.98), rgba(248,250,252,.90));
  box-shadow: -10px 0 22px rgba(2,6,23,.10);
}
body.page-fx-monthly thead .sticky-left,
body.page-fx-monthly thead .sticky-right{ z-index: 8; }
body.page-fx-monthly tfoot .sticky-left,
body.page-fx-monthly tfoot .sticky-right{ z-index: 8; }

/* total row (合計) — 兩個 table 都用 tfoot */
body.page-fx-monthly table.fxm-table tfoot th,
body.page-fx-monthly table.fxm-table tfoot td,
body.page-fx-monthly table.fxp-table tfoot th,
body.page-fx-monthly table.fxp-table tfoot td{
  font-weight: 900;
  position: sticky;
  bottom: 0;
  z-index: 4;
  border-bottom: none;
  border-top: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(12, 91, 114, .46), rgba(12, 91, 114, .34));
}
body.page-fx-monthly table.fxm-table tfoot th,
body.page-fx-monthly table.fxp-table tfoot th{ z-index: 7; }

html[data-theme="light"] body.page-fx-monthly table.fxm-table tfoot th,
html[data-theme="light"] body.page-fx-monthly table.fxm-table tfoot td,
html[data-theme="light"] body.page-fx-monthly table.fxp-table tfoot th,
html[data-theme="light"] body.page-fx-monthly table.fxp-table tfoot td{
  border-top-color: rgba(15,23,42,.12);
  background: linear-gradient(180deg, rgba(37, 99, 235, .14), rgba(37, 99, 235, .07));
}

/* hover highlight：行 hover 更清楚 */
body.page-fx-monthly table.fxm-table tbody tr:hover td,
body.page-fx-monthly table.fxp-table tbody tr:hover td{
  background: rgba(56, 189, 248, .10);
}
html[data-theme="light"] body.page-fx-monthly table.fxm-table tbody tr:hover td,
html[data-theme="light"] body.page-fx-monthly table.fxp-table tbody tr:hover td{
  background: rgba(37, 99, 235, .06);
}

/* 下方曝險拆解：括號匯率顏色更自然 */
body.page-fx-monthly .fxpair-rate{
  color: rgba(40, 240, 200, 0.95);
  font-weight: 900;
}
html[data-theme="light"] body.page-fx-monthly .fxpair-rate{
  color: rgba(2, 132, 199, .95);
}

/* =======================================================================
   Page 3.2 – 外匯風險管理（fx_pair_summary.html）
   收斂：原本在 HTML 的 inline style → 全部搬到這裡
   Light theme 重點：格線清楚、hover 方框明顯、輸入框可讀
   ======================================================================= */

body.page-fx-pair-summary{
  --fxm-left-col-w: 360px;
  --fxm-num-col-w: 160px;
  --fxm-head-row2-top: 44px;

  /* scenario palette (shared) */
  --sc-mtm: rgba(15,157,88,.95);
  --sc-val: rgba(37,99,235,.95);
  --sc-mid: rgba(124,58,237,.95);
  --sc-low: rgba(225,29,72,.95);
  --sc-high: rgba(245,158,11,.95);

  --fxp-hover-outline: rgba(37,99,235,.40);
  --fxp-hover-inset: rgba(37,99,235,.38);
}
html[data-theme="dark"] body.page-fx-pair-summary{
  --sc-mtm: rgba(0, 220, 170, .95);
  --sc-val: rgba(120, 180, 255, .95);
  --sc-mid: rgba(180, 140, 255, .95);
  --sc-low: rgba(255, 90, 120, .95);
  --sc-high: rgba(255, 200, 0, .95);

  --fxp-hover-outline: rgba(255,255,255,.35);
  --fxp-hover-inset: rgba(255,255,255,.38);
}

/* avoid double scroll */
body.page-fx-pair-summary, body.page-fx-pair-summary html{ height:auto; overflow:auto; }
body.page-fx-pair-summary .app-shell,
body.page-fx-pair-summary .app-content{ height:auto; overflow:visible; }

body.page-fx-pair-summary .fxm-page{ padding:22px 22px 18px; min-height:100%; display:block; overflow:visible; }

/* ===== table layout ===== */
body.page-fx-pair-summary table.fxm-table{ width:max-content; min-width:100%; border-collapse:collapse; table-layout:fixed; }
body.page-fx-pair-summary table.fxm-table col.col-left{ width: var(--fxm-left-col-w); }
body.page-fx-pair-summary table.fxm-table col.col-num{ width: var(--fxm-num-col-w); }

body.page-fx-pair-summary table.fxm-table th,
body.page-fx-pair-summary table.fxm-table td{
  padding: 12px 14px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid rgba(17,24,39,0.06);
  font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] body.page-fx-pair-summary table.fxm-table th,
html[data-theme="dark"] body.page-fx-pair-summary table.fxm-table td{
  border-bottom-color: rgba(255,255,255,.06);
  border-right-color: rgba(255,255,255,.04);
}

body.page-fx-pair-summary table.fxm-table thead th{
  font-weight: 900;
  position: sticky;
  z-index: 5;
  top: 0;
  background: var(--panel);
}
html[data-theme="dark"] body.page-fx-pair-summary table.fxm-table thead th{ background: rgba(0,0,0,.28); }

body.page-fx-pair-summary th.corner{ text-align:left; }
body.page-fx-pair-summary th.rowhdr{ text-align:left; font-weight:800; padding-left:14px; }
html[data-theme="light"] body.page-fx-pair-summary th.rowhdr{ background:#f8fafc; }
html[data-theme="dark"] body.page-fx-pair-summary th.rowhdr{ background: rgba(0,0,0,.18); }

body.page-fx-pair-summary td.num{ text-align:right; }
body.page-fx-pair-summary td.num.pos{ color: var(--pos); font-weight:800; }
body.page-fx-pair-summary td.num.neg{ color: var(--neg); font-weight:800; }
body.page-fx-pair-summary td.num.zero{ color: var(--muted); font-weight:800; }

/* sticky left/right */
body.page-fx-pair-summary .sticky-left{
  position: sticky;
  left: 0;
  z-index: 6;
  background: linear-gradient(90deg, var(--panel2), rgba(255,255,255,0));
}
body.page-fx-pair-summary .sticky-right{
  position: sticky;
  right: 0;
  z-index: 6;
  background: linear-gradient(270deg, var(--panel2), rgba(255,255,255,0));
}
html[data-theme="dark"] body.page-fx-pair-summary .sticky-left{
  background: linear-gradient(90deg, rgba(10,14,20,.98), rgba(10,14,20,.88));
  box-shadow: 10px 0 24px rgba(0,0,0,.35);
}
html[data-theme="dark"] body.page-fx-pair-summary .sticky-right{
  background: linear-gradient(270deg, rgba(10,14,20,.98), rgba(10,14,20,.88));
  box-shadow: -10px 0 24px rgba(0,0,0,.35);
}
body.page-fx-pair-summary thead .sticky-left,
body.page-fx-pair-summary thead .sticky-right{ z-index: 8; }

/* ===== summary rows (Rate / P&L) ===== */
body.page-fx-pair-summary tr.fxp-sum-row th,
body.page-fx-pair-summary tr.fxp-sum-row td{
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
}
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-row th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-row td{
  background: rgba(0,0,0,.18);
  border-bottom-color: rgba(255,255,255,.05);
}

body.page-fx-pair-summary tr.fxp-sum-divider th,
body.page-fx-pair-summary tr.fxp-sum-divider td{
  border-top: 1px solid rgba(17,24,39,0.12);
}
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-divider th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-divider td{
  border-top-color: rgba(255,255,255,.12);
}

body.page-fx-pair-summary tr.fxp-sum-spacer th,
body.page-fx-pair-summary tr.fxp-sum-spacer td{
  padding: 6px 14px;
  background: var(--panel);
}

/* row kind tints (light subtle, dark keep strong) */
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-gross th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-gross td{ background: rgba(37,99,235,.07); }
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-net th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-net td{ background: rgba(15,157,88,.07); }
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-pnl th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-pnl td{ background: rgba(245,158,11,.08); }
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge td{ background: rgba(17,24,39,.03); }
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge-sub th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge-sub td{ background: rgba(17,24,39,.02); }
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-rate th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-rate td{ background: rgba(37,99,235,.04); }

html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-gross th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-gross td{ background: rgba(30,110,255,.10); }
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-net th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-net td{ background: rgba(0,200,160,.10); }
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-pnl th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-pnl td{ background: rgba(255,200,0,.08); }
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge td{ background: rgba(255,255,255,.06); }
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge-sub th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge-sub td{ background: rgba(255,255,255,.035); }
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-rate th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-rate td{ background: rgba(120,180,255,.06); }

/* pnl book emphasis */
body.page-fx-pair-summary tr.fxp-pnl-book th,
body.page-fx-pair-summary tr.fxp-pnl-book td{ background: rgba(15,157,88,.08) !important; }
body.page-fx-pair-summary tr.fxp-pnl-mtm th,
body.page-fx-pair-summary tr.fxp-pnl-mtm td{ background: rgba(15,157,88,.12) !important; }
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-pnl-book th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-pnl-book td{ background: rgba(0,200,160,.10) !important; }
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-pnl-mtm th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-pnl-mtm td{ background: rgba(0,200,160,.14) !important; }

/* scenario inputs */
body.page-fx-pair-summary .fxp-rate-input{
  width: 100%;
  height: 34px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  padding: 0 10px;
  outline: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
body.page-fx-pair-summary .fxp-rate-input:focus{
  border-color: rgba(37,99,235,.65);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
html[data-theme="dark"] body.page-fx-pair-summary .fxp-rate-input{
  border-color: rgba(255,255,255,.14);
  background: rgba(0,0,0,.20);
  color: rgba(255,255,255,.92);
}
html[data-theme="dark"] body.page-fx-pair-summary .fxp-rate-input:focus{
  border-color: rgba(120,180,255,.55);
  box-shadow: 0 0 0 3px rgba(120,180,255,.12);
}

body.page-fx-pair-summary .fxp-rate-input.fxp-override{
  border-color: rgba(37,99,235,.55);
  background: rgba(37,99,235,.08);
  box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}
html[data-theme="dark"] body.page-fx-pair-summary .fxp-rate-input.fxp-override{
  border-color: rgba(120,180,255,.55);
  background: rgba(120,180,255,.12);
  box-shadow: 0 0 0 3px rgba(120,180,255,.08);
}

/* left accent bar */
body.page-fx-pair-summary tr.fxp-sum-row[data-group="rate"] th.rowhdr.sticky-left,
body.page-fx-pair-summary tr.fxp-sum-row[data-group="pnl"]  th.rowhdr.sticky-left{ position: sticky; }
body.page-fx-pair-summary tr.fxp-sum-row[data-group="rate"] th.rowhdr.sticky-left::after,
body.page-fx-pair-summary tr.fxp-sum-row[data-group="pnl"]  th.rowhdr.sticky-left::after{
  content:"";
  position:absolute;
  left:0; top:0; bottom:0;
  width:3px;
  opacity:.9;
  background: rgba(17,24,39,.10);
}
body.page-fx-pair-summary tr.fxp-sum-row[data-scenario="mtm"]  th.rowhdr.sticky-left::after{ background: var(--sc-mtm); }
body.page-fx-pair-summary tr.fxp-sum-row[data-scenario="val"]  th.rowhdr.sticky-left::after{ background: var(--sc-val); }
body.page-fx-pair-summary tr.fxp-sum-row[data-scenario="mid"]  th.rowhdr.sticky-left::after{ background: var(--sc-mid); }
body.page-fx-pair-summary tr.fxp-sum-row[data-scenario="low"]  th.rowhdr.sticky-left::after{ background: var(--sc-low); }
body.page-fx-pair-summary tr.fxp-sum-row[data-scenario="high"] th.rowhdr.sticky-left::after{ background: var(--sc-high); }

/* hover linkage: same scenario row gets boxed */
body.page-fx-pair-summary tr.fxp-sum-row[data-group="rate"]:hover,
body.page-fx-pair-summary tr.fxp-sum-row[data-group="pnl"]:hover{
  outline: 1px solid var(--fxp-hover-outline);
  outline-offset: -1px;
}
body.page-fx-pair-summary tr.fxp-sum-row.fxp-scenario-hover th,
body.page-fx-pair-summary tr.fxp-sum-row.fxp-scenario-hover td{
  box-shadow: inset 0 0 0 1.5px var(--fxp-hover-inset);
  background-image: linear-gradient(to right, rgba(17,24,39,.03), rgba(17,24,39,0));
}
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-row.fxp-scenario-hover th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-row.fxp-scenario-hover td{
  background-image: linear-gradient(to right, rgba(255,255,255,.03), rgba(255,255,255,0));
}
body.page-fx-pair-summary tr.fxp-sum-row.fxp-scenario-hover{
  outline: 2px solid var(--fxp-hover-outline);
  outline-offset: -2px;
}



/* ======================================================================
   Page 3.2 – 外匯風險管理 (fx_pair_summary)
   小強化：篩選條件字體/註解、重點列強調、子層箭頭
======================================================================== */

/* --- 篩選條件：字級/字重/註解一致化 --- */
body.page-fx-pair-summary .fxm-card .fxm-card-header{
  padding: 14px 16px;
}
body.page-fx-pair-summary .fxm-collapse{
  font-weight: 700;
  letter-spacing: .2px;
}
body.page-fx-pair-summary .fxm-controls{
  padding: 14px 16px 12px;
}
body.page-fx-pair-summary .fxm-field > label{
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .15px;
}
body.page-fx-pair-summary .fxm-note{
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.35;
  opacity: .9;
}
html[data-theme="dark"] body.page-fx-pair-summary .fxm-note{
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.78);
}
html[data-theme="light"] body.page-fx-pair-summary .fxm-note{
  background: rgba(37,99,235,0.06);
  border: 1px solid rgba(37,99,235,0.18);
  color: rgba(15,23,42,.78);
}

/* 讓「影響：...」這種註解更像說明文字（左側小色條） */
body.page-fx-pair-summary .fxm-note{
  position: relative;
  padding-left: 12px;
}
body.page-fx-pair-summary .fxm-note:before{
  content:"";
  position:absolute;
  left: 8px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
  opacity: .65;
}

/* --- 展開/收合的小按鈕（表格列） --- */
body.page-fx-pair-summary .fxp-mini-toggle{
  width: 26px;
  height: 26px;
  border-radius: 9px;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
html[data-theme="dark"] body.page-fx-pair-summary .fxp-mini-toggle{
  border-color: rgba(255,255,255,.12);
  background: rgba(255,255,255,.03);
}
body.page-fx-pair-summary .fxp-mini-toggle:hover{
  background: var(--panel);
  border-color: rgba(37,99,235,.35);
}

/* --- 重點列：避險前外匯部位 / 避險交易 --- */
body.page-fx-pair-summary tr.fxp-sum-kind-gross th,
body.page-fx-pair-summary tr.fxp-sum-kind-gross td{
  font-weight: 800;
}
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-gross th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-gross td{
  background: linear-gradient(90deg, rgba(37,99,235,.22), rgba(0,0,0,.18));
  border-bottom-color: rgba(255,255,255,.08);
}
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-gross th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-gross td{
  background: linear-gradient(90deg, rgba(37,99,235,.10), rgba(255,255,255,0));
  border-bottom-color: rgba(15,23,42,.10);
}

/* 左側強調條 */
body.page-fx-pair-summary tr.fxp-sum-kind-gross th.rowhdr{
  position: relative;
}
body.page-fx-pair-summary tr.fxp-sum-kind-gross th.rowhdr:before{
  content:"";
  position:absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 999px;
  background: var(--accent);
  opacity: .8;
}

/* 避險交易列：次要強調（更沈穩） */
body.page-fx-pair-summary tr.fxp-sum-kind-hedge th,
body.page-fx-pair-summary tr.fxp-sum-kind-hedge td{
  font-weight: 800;
}
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge td{
  background: rgba(255,255,255,.04);
}
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-sum-kind-hedge td{
  background: rgba(15,23,42,.03);
}

/* --- 子列：明顯的「子箭頭」與縮排 --- */
body.page-fx-pair-summary tr.fxp-under-gross th.fxp-sum-sub,
body.page-fx-pair-summary tr.fxp-hedge-sub th.fxp-sum-sub{
  padding-left: 34px !important;
  font-weight: 650;
  opacity: .95;
  position: relative;
}
body.page-fx-pair-summary tr.fxp-under-gross th.fxp-sum-sub:before,
body.page-fx-pair-summary tr.fxp-hedge-sub th.fxp-sum-sub:before{
  content: "↳";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  opacity: .70;
  font-weight: 800;
}

/* 子列 hover 更清楚 */
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-under-gross:hover th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-hedge-sub:hover th,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-under-gross:hover td,
html[data-theme="dark"] body.page-fx-pair-summary tr.fxp-hedge-sub:hover td{
  background: rgba(255,255,255,.04);
}
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-under-gross:hover th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-hedge-sub:hover th,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-under-gross:hover td,
html[data-theme="light"] body.page-fx-pair-summary tr.fxp-hedge-sub:hover td{
  background: rgba(37,99,235,0.06);
}

/* 小修：總計 sticky-right 數字避免在強調列被遮到 */
body.page-fx-pair-summary td.sticky-right{
  backdrop-filter: blur(10px);
}

/* ======================================================================
   小補丁：避免「顯示單位/Entity」下拉看到原生 radio/checkbox 圓點
   （如果某些頁面 class 沒套到 ms-item，這段也能兜底）
======================================================================== */
.ms-pop input[type="checkbox"],
.ms-pop input[type="radio"]{
  appearance: none !important;
  -webkit-appearance: none !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  outline: 0 !important;
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ======================================================================
   FIX: Page 3.2「外匯風險管理」篩選條件收合
   - fx_pair_summary.js 會在 #fxpControlCard toggle .collapsed
   - 但原本的 CSS 只對 body.page-fx-monthly 生效，導致 3.2 收合無效
   ====================================================================== */

body.page-fx-pair-summary .fxm-card.collapsed .fxm-controls{ display:none; }
body.page-fx-pair-summary .fxm-card-header{ cursor:pointer; user-select:none; }

/* 同步讓 3.2 的收合 header 點擊區域更明確 */
body.page-fx-pair-summary .fxm-collapse{ cursor:pointer; user-select:none; }

/*（可選）如果未來 3.2 也有 hidden state-holder 的 select，可直接沿用這個 pattern */
/* body.page-fx-pair-summary select[data-hidden-holder="1"]{ display:none; } */


/* ---------- Trades header filter popover (2.2) : make Light theme match 2.1 ---------- */
html[data-theme="light"] .page-trades .filter-btn{
  background:#ffffff;
  color:#111827;
  border-color: rgba(17,24,39,0.20);
}
html[data-theme="light"] .page-trades .filter-btn:hover{
  background:#f3f4f6;
  border-color: rgba(17,24,39,0.28);
}
html[data-theme="light"] .page-trades .filter-btn.active{
  border-color: rgba(37,99,235,0.55);
  background: rgba(37,99,235,0.10);
  color:#111827;
}

html[data-theme="light"] .page-trades .fp-title,
html[data-theme="light"] .page-trades .fp-muted{
  color:#111827 !important;
  opacity:.9;
}

html[data-theme="light"] .page-trades .fp-input{
  background:#ffffff;
  color:#111827;
  border-color: rgba(17,24,39,0.18);
}
html[data-theme="light"] .page-trades .fp-input::placeholder{ color: rgba(17,24,39,0.45); }

html[data-theme="light"] .page-trades .fp-panel{
  background:#ffffff;
  border-color: rgba(17,24,39,0.14);
  box-shadow: 0 24px 80px rgba(0,0,0,0.18);
  backdrop-filter: blur(14px);
}
html[data-theme="light"] .page-trades .fp-head{
  border-bottom:1px solid rgba(17,24,39,0.10);
}
html[data-theme="light"] .page-trades .fp-search{
  background:#f3f4f6;
  border-color: rgba(17,24,39,0.14);
  color:#111827;
}
html[data-theme="light"] .page-trades .fp-search::placeholder{ color: rgba(17,24,39,0.45); }

html[data-theme="light"] .page-trades .fp-item{
  border-color: rgba(17,24,39,0.08);
}
html[data-theme="light"] .page-trades .fp-item:hover{
  background: rgba(37,99,235,0.08);
}
html[data-theme="light"] .page-trades .fp-item .fp-text{
  color:#111827;
  opacity:.95;
}
html[data-theme="light"] .page-trades .fp-check{
  border-color: rgba(17,24,39,0.18);
  background:#ffffff;
}
html[data-theme="light"] .page-trades .fp-foot{
  border-top:1px solid rgba(17,24,39,0.10);
}


/* =========================
   1.2 匯率趨勢（Dashboard）
   ========================= */
.fx-trend-page .fx-trend-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

/* tile card */
.fx-trend-page .fx-tile{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.10);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.fx-trend-page .fx-tile:hover{
  border-color: var(--line-strong);
  box-shadow: 0 8px 22px rgba(0,0,0,.16);
}

.fx-trend-page .fx-tile-hd{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.fx-trend-page .fx-tile-title{
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fx-trend-page .fx-chart{
  width: 100%;
  height: 320px; /* 讓小圖更像你示意圖的比例 */
}

/* add-card (dashed + big plus) */
.fx-trend-page .fx-add-tile{
  background: transparent;
  border: 2px dashed var(--line-strong);
  border-radius: 14px;
  min-height: 370px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.fx-trend-page .fx-add-tile:hover{
  background: rgba(255,255,255,.04);
  border-color: var(--brand);
}
.fx-trend-page .fx-add-tile .plus{
  font-size: 64px;
  line-height: 1;
  font-weight: 800;
  opacity: .85;
}


/* =========================================
   FX Trend: popup（修正「+沒反應」）
   ========================================= */
#fxTrendPairPop{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 3000;
  background: rgba(0,0,0,.18);
  backdrop-filter: blur(2px);
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
}

#fxTrendPairPop.open{
  display: flex;
}

#fxTrendPairMS{
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 180px);
  overflow: auto;
  border-radius: 14px;
}

/* range buttons next to title */
.fx-trend-page .fx-range{
  display:flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.fx-trend-page .fx-range-btn{
  border: 1px solid var(--line, rgba(0,0,0,.12));
  background: rgba(255,255,255,.7);
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.fx-trend-page .fx-range-btn.active{
  border-color: var(--brand, #3b82f6);
  background: rgba(59,130,246,.12);
}
