/* ============================================================
   個人經營報表 PBS Demo — 增補樣式（疊加於 W2 / dalton 之上）
   一律引用 W2 token，不寫死色值。
   ============================================================ */

.hidden { display: none !important; }
.clickable { cursor: pointer; }
.drill-hint { color: var(--text-3); margin-left: 6px; font-weight: 700; opacity: 0; transition: 0.14s var(--ease); }
tr.clickable:hover .drill-hint { opacity: 1; }

/* ---------- SF 入口頁 ---------- */
.launch { max-width: 860px; margin: 0 auto; padding: 26px 24px 60px; }
.launch-top { display: flex; justify-content: flex-end; }
.launch-hero { text-align: center; margin: 8px 0 26px; }
.launch-hero h1 { font-size: 24px; }
.launch .bd { display: flex; align-items: center; }
.launch .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #3fa0ff); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; box-shadow: 0 4px 12px rgba(8, 117, 225, 0.3); }

.sf-frame { overflow: hidden; }
.sf-chrome { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: var(--shell-2); border-bottom: 1px solid var(--hairline); }
.sf-chrome > span { width: 10px; height: 10px; border-radius: 99px; background: var(--hairline); }
.sf-url { flex: 1; margin-left: 10px; height: 24px; border-radius: 99px; background: var(--surface); border: 1px solid var(--hairline); font: 500 11px/22px var(--font-mono); color: var(--text-3); padding: 0 12px; }
.sf-bar { padding: 12px 18px; background: var(--accent); color: #fff; font-weight: 700; font-size: 13.5px; letter-spacing: 0.01em; }
[data-theme='dark'] .sf-bar { color: var(--bg-app); }
.sf-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 18px; background: var(--bg-app); }
.sf-tile { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--hairline); font-size: 13px; font-weight: 600; color: var(--text-2); min-height: 86px; }
.sf-tile .ic { font-size: 20px; }
.sf-tile.pbs { border: 1.6px solid var(--btn-primary); color: var(--text); cursor: pointer; box-shadow: 0 4px 14px rgba(225, 126, 0, 0.16); }
.sf-tile.pbs:hover { background: var(--shell); }
.sf-tile.pbs .open { position: absolute; bottom: 10px; right: 12px; color: var(--btn-primary); font-weight: 800; }
.how-grid .card { height: 100%; }

#sso-overlay { position: fixed; inset: 0; background: rgba(20, 40, 80, 0.32); z-index: 80; display: grid; place-items: center; }
.sso-box { padding: 26px 40px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.spin { width: 26px; height: 26px; border-radius: 99px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: pbs-spin 0.8s linear infinite; }
@keyframes pbs-spin { to { transform: rotate(360deg); } }

/* ---------- 總覽 ---------- */
.ov-fields { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 12.5px; color: var(--text); }
.ov-fields b { color: var(--text-3); font-weight: 600; margin-right: 6px; font-size: 11.5px; }
.ov-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .ov-grid { grid-template-columns: 1fr; } }

.sumtbl tbody td { height: 42px; }
.sumtbl tr.sec td { height: 34px; background: var(--shell); color: var(--text-2); font-weight: 700; font-size: 12px; letter-spacing: 0.02em; }
.sumtbl tr.net td { height: 52px; font-weight: 800; font-size: 15px; border-top: 2px solid var(--text); }
.sumtbl td.pos { color: var(--ok); font-weight: 600; }

.mixrow { display: grid; grid-template-columns: minmax(90px, auto) 1fr auto; gap: 10px; align-items: center; padding: 4px 0; font-size: 12.5px; }
.mixrow .mk { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mixrow .mb { height: 10px; border-radius: 99px; background: var(--shell-2); overflow: hidden; display: block; }
.mixrow .mb > span { display: block; height: 100%; border-radius: 99px; }
.mixrow .mv { white-space: nowrap; font-size: 12px; }

/* ---------- 損益表 ---------- */
.statement-card { overflow: hidden; }
.st-head { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 18px 22px 14px; border-bottom: 2px solid var(--text); flex-wrap: wrap; }
.st-table { font-variant-numeric: tabular-nums; }
.st-table thead th { height: 48px; vertical-align: middle; }
.st-table thead th.num, .st-table td.num { text-align: right; font-family: var(--font-mono); }
.st-table tbody td { height: 40px; font-size: 13.5px; }
.st-table tr.st-sec td { height: 36px; background: var(--shell); font-weight: 700; font-size: 12px; color: var(--text-2); letter-spacing: 0.02em; }
.st-table tr.st-sub td { font-weight: 700; border-top: 1px solid var(--text-2); background: color-mix(in srgb, var(--shell) 55%, transparent); }
.st-table tr.st-net td { height: 56px; font-weight: 800; font-size: 16px; border-top: 3px double var(--text); }
.st-table tr.st-supp td { height: 34px; color: var(--text-2); font-size: 12.5px; border-bottom: 0; }
.st-less { display: inline-block; font-size: 11px; color: var(--text-3); border: 1px solid var(--hairline); border-radius: 4px; padding: 0 4px; margin-right: 8px; vertical-align: 1px; }
.st-up { color: var(--ok); font-weight: 600; }
.st-down { color: var(--bad); font-weight: 600; }
.yoy { font-size: 12px; }
tr.faintrow td { color: var(--text-3); }
tr.mutedrow td { color: var(--text-2); }
.st-foot { padding: 12px 22px 16px; font-size: 11.5px; border-top: 1px solid var(--hairline-2); }

/* ---------- 來源 chip ---------- */
.src-chip { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px; background: var(--shell-2); border: 1px solid var(--hairline); font: 600 10.5px var(--font-mono); color: var(--text-2); white-space: nowrap; }

/* ---------- 下鑽抽屜 ---------- */
.drawer.wide { width: 470px; max-width: 92vw; display: flex; flex-direction: column; }
.dr-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--hairline); }
.dr-h h3 { font-size: 14.5px; }
.dr-b { padding: 16px 18px; overflow-y: auto; flex: 1; }
.dr-item { border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.dr-item.slim { padding: 9px 14px; font-size: 12.5px; }
.split { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--shell); font-size: 11.5px; color: var(--text-3); }
.split-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12.5px; color: var(--text-2); }
.split-row:first-of-type { margin-top: 6px; }

/* ---------- 團隊 ---------- */
.insight { display: flex; flex-direction: column; gap: 3px; font-size: 13px; padding: 10px 12px; border-radius: var(--r-md); background: var(--shell); }
.insight .muted { font-size: 12.5px; line-height: 1.6; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent-700); }

/* ---------- 資料整合 ---------- */
.conn-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 12.5px; color: var(--text); }
.conn-meta b { display: block; color: var(--text-3); font-weight: 600; font-size: 11px; margin-bottom: 1px; }
@media (max-width: 700px) { .conn-meta { grid-template-columns: 1fr; } }

/* ---------- 計算規則 ---------- */
.formula { display: flex; gap: 12px; align-items: flex-start; }
.fno { width: 22px; height: 22px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-700); display: grid; place-items: center; font: 700 11.5px var(--font-sans); flex: none; margin-top: 1px; }

/* ---------- 列印（匯出 PDF） ---------- */
@media print {
  .no-print, .subnav, .tbar, .toast-stack, #drawer-root { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
  .card, .statement-card { box-shadow: none; border-color: #999; }
  .st-table tbody td, .st-table thead th { height: 34px; }
}

/* ---------- v2：圖標 / 英雄區 / KPI / 環形圖 ---------- */
.ic-svg { display: inline-block; vertical-align: -3px; flex: none; }
.btn .ic-svg, .iconbtn .ic-svg { vertical-align: middle; }
.badge .ic-svg { vertical-align: -2px; }

.tile-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.tile-ic .ic-svg { vertical-align: 0; }

.launch-title { font-size: 19px; margin-top: 24px; }

.hero {
  display: flex; gap: 28px; align-items: stretch; justify-content: space-between;
  padding: 22px 26px; margin-bottom: 16px; border-radius: var(--r-xl);
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 7%, var(--surface)), var(--surface) 58%);
  border: 1px solid var(--hairline); box-shadow: var(--e1); flex-wrap: wrap;
}
.hero-l { display: flex; flex-direction: column; gap: 13px; min-width: 300px; flex: 1; }
.hero-r { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; min-width: 240px; }
.hero-lab { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: 0.02em; }
.hero-num { font-size: 38px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); line-height: 1.1; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font: 600 12px var(--font-sans); background: var(--shell-2); color: var(--text-2); border: 1px solid var(--hairline); }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.hero-kpis { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.hero-kpi { display: flex; gap: 12px; align-items: baseline; font-size: 12.5px; color: var(--text-2); }
.hero-kpi b { font-size: 14px; color: var(--text); }

.kpi { min-height: 128px; }
.kpi .lab { align-items: center; }
.kpi-ic { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.kpi-spark { position: absolute; right: 12px; bottom: 10px; opacity: 0.9; }
.kpi .delta { position: relative; z-index: 1; }

.donut-wrap { display: flex; gap: 16px; align-items: center; }
.donut-legend { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.dl-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.dl-k { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-v { color: var(--text); font-weight: 600; }

.st-strip { display: flex; gap: 26px; padding: 14px 22px; border-bottom: 1px solid var(--hairline-2); background: color-mix(in srgb, var(--shell) 60%, transparent); flex-wrap: wrap; }
.st-stat { display: flex; gap: 10px; align-items: center; }
.st-stat span { display: block; font-size: 11.5px; color: var(--text-3); }
.st-stat b { font-size: 15.5px; color: var(--text); }

.emp-menu { max-height: 420px; overflow-y: auto; min-width: 250px; }
.mi.mi-on { background: var(--accent-soft); color: var(--accent-700); }

/* 窄螢幕 */
@media (max-width: 900px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
  .sf-tiles { grid-template-columns: 1fr 1fr; }
  .st-head { flex-direction: column; }
  .hero { flex-direction: column; }
  .hero-r { align-items: flex-start; }
}
