/* ============ Watchlist ============ */

/* Donut layout — horizontal */
.donut-layout {
  display: flex; align-items: flex-start; gap: 28px;
  padding: 20px 24px;
}
@media (max-width: 640px) { .donut-layout { flex-direction: column; align-items: center; gap: 16px; } }

.donut-svg-wrap {
  flex-shrink: 0; width: 200px;
}
.donut-svg-wrap svg { width: 100%; display: block; }

.donut-right {
  flex: 1; display: flex; flex-direction: column; gap: 16px; padding-top: 8px;
}

/* Stats strip */
.donut-stats {
  display: flex; gap: 0;
  border: 1px solid var(--paper-line);
}
.ds-cell {
  flex: 1; text-align: center;
  padding: 12px 8px;
  border-right: 1px solid var(--paper-line);
}
.ds-cell:last-child { border-right: none; }
.ds-lbl {
  font-size: var(--fs-nano); letter-spacing: .18em;
  color: var(--ink-mute); margin-bottom: 5px;
}
.ds-val {
  font-family: 'Times New Roman', serif;
  font-size: 17px; font-weight: 700;
  color: var(--ink);
}

/* Empty prompt */
.donut-empty-prompt {
  padding: 16px 18px;
  border: 1px dashed var(--paper-line);
  background: var(--paper-bright);
}
.wl-portfolio { display: flex; flex-direction: column; gap: 6px; }
.wl-port-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0;
}
.wl-port-lbl {
  font-family: 'Times New Roman', serif;
  font-variant: small-caps;
  font-size: var(--fs-nano); letter-spacing: .2em;
  color: var(--ink-mute);
}
.wl-port-val {
  font-family: 'Times New Roman', serif;
  font-size: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Edit mode inputs */
.wl-edit-input {
  font-family: 'Times New Roman', serif;
  font-size: 15px;
  padding: 6px 10px;
  border: 1px solid var(--gold);
  background: var(--paper);
  color: var(--ink);
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.wl-edit-input:focus { border-color: var(--gold-deep); box-shadow: 0 0 0 2px rgba(184,146,77,.15); }
.wl-edit-input::placeholder { color: var(--ink-mute); font-style: italic; font-size: 12px; }

/* Group tabs */
.wl-group-tabs {
  display: flex; gap: 4px; align-items: stretch;
  padding: 8px 12px;
  background: var(--paper-bright);
  border: 1px solid var(--ink);
  margin-bottom: 18px;
  position: relative;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.wl-group-tabs::-webkit-scrollbar { display: none; }
.wl-group-tabs::before {
  content: ""; position: absolute; inset: 4px; border: 1px solid var(--paper-line); pointer-events: none;
}
.wl-group-tab {
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--paper-line);
  cursor: pointer;
  transition: all .15s ease;
  text-align: left;
  position: relative; z-index: 1;
  min-width: 160px;
}
.wl-group-tab:hover { background: var(--paper); }
.wl-group-tab.active { background: var(--ink); border-color: var(--ink); }
.wl-gt-row1 {
  display: flex; align-items: baseline; gap: 6px;
}
.wl-gt-row1 .kai {
  font-family: 'BiauKai', '標楷體', serif;
  font-size: 16px; letter-spacing: .12em;
  color: var(--ink); font-weight: 700;
}
.wl-group-tab.active .wl-gt-row1 .kai { color: var(--paper-bright); }
.wl-gt-count {
  font-family: 'Times New Roman', serif;
  font-size: 12px; color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.wl-group-tab.active .wl-gt-count { color: var(--gold-leaf); }
.wl-gt-row2 {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 2px;
}
.wl-gt-en {
  font-family: 'Times New Roman', serif;
  font-style: italic;
  font-size: var(--fs-nano);
  color: var(--ink-mute);
}
.wl-group-tab.active .wl-gt-en { color: var(--gold-leaf); }
.wl-gt-pnl {
  font-family: 'Times New Roman', serif;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Group header */
.wl-group-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--paper-line);
}
.wl-group-title {
  font-family: 'Times New Roman', serif;
  font-size: 36px; font-weight: 700;
  display: flex; align-items: baseline; gap: 12px;
  margin: 6px 0 6px;
}
.wl-group-title .kai { font-family: 'BiauKai', '標楷體', serif; letter-spacing: .12em; }
.wl-group-note {
  font-family: 'BiauKai', '標楷體', serif;
  font-size: 13px; letter-spacing: .08em;
  color: var(--ink-mute);
  font-style: italic;
}

/* Watchlist cards (clipping book) */
.wl-items {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 32px;
}
@media (max-width: 900px) { .wl-items { grid-template-columns: 1fr; } }
.wl-card {
  position: relative;
  background: var(--paper-bright);
  border: 1px solid var(--ink);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.wl-card .corner-tl,
.wl-card .corner-tr,
.wl-card .corner-bl,
.wl-card .corner-br {
  position: absolute; width: 10px; height: 10px;
  border-color: var(--gold); border-style: solid; border-width: 0;
  z-index: 2;
}
.wl-card .corner-tl { top: 2px; left: 2px; border-top-width: 1px; border-left-width: 1px; }
.wl-card .corner-tr { top: 2px; right: 2px; border-top-width: 1px; border-right-width: 1px; }
.wl-card .corner-bl { bottom: 2px; left: 2px; border-bottom-width: 1px; border-left-width: 1px; }
.wl-card .corner-br { bottom: 2px; right: 2px; border-bottom-width: 1px; border-right-width: 1px; }

.wl-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--paper-line);
  margin-bottom: 12px;
}
.wl-card-id {
  display: flex; align-items: center; gap: 14px;
}
.wl-card-code {
  font-family: 'Times New Roman', serif;
  font-size: 28px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.wl-card-name {
  font-family: 'BiauKai', '標楷體', serif;
  font-size: 19px;
  letter-spacing: .12em;
  font-weight: 700;
  line-height: 1.2;
}
.wl-card-meta {
  font-family: 'Times New Roman', serif;
  font-style: italic;
  font-size: var(--fs-nano);
  color: var(--ink-mute);
  letter-spacing: .04em;
  margin-top: 2px;
}
.wl-card-meta a { color: var(--gold-deep); text-decoration: none; }
.wl-card-meta a:hover { color: var(--gold); }
.wl-card-price { text-align: right; }
.wl-card-now {
  font-family: 'Times New Roman', serif;
  font-size: 24px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.wl-card-day {
  font-family: 'Times New Roman', serif;
  font-size: 12px; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.wl-card-rm {
  background: transparent;
  border: 1px solid var(--paper-line);
  color: var(--ink-mute);
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 14px; line-height: 1;
  transition: all .15s ease;
}
.wl-card-rm:hover { background: var(--bear); color: #fff; border-color: var(--bear); }

.wl-card-pos {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 0;
  padding: 8px 0;
  border-bottom: 1px dashed var(--paper-line);
  margin-bottom: 12px;
}
.wl-pos-cell {
  padding: 0 12px;
  border-right: 1px solid var(--paper-line);
}
.wl-pos-cell:last-child { border-right: none; }
.wl-pos-cell .lbl {
  display: block;
  font-family: 'Times New Roman', serif;
  font-variant: small-caps;
  font-size: var(--fs-nano);
  letter-spacing: .18em;
  color: var(--ink-mute);
}
.wl-pos-cell .val {
  display: block;
  font-family: 'Times New Roman', serif;
  font-size: 14px;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.wl-pos-cell .val small {
  font-size: var(--fs-nano); font-weight: 400; color: var(--ink-mute);
  margin-left: 3px;
}

.wl-card-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.wl-note-tag {
  font-family: 'Times New Roman', serif;
  font-variant: small-caps;
  font-size: var(--fs-nano);
  letter-spacing: .2em;
  color: var(--gold-deep);
  white-space: nowrap;
  padding-top: 8px;
  flex-shrink: 0;
}
.wl-note-tag .kai { font-variant: normal; color: var(--ink); letter-spacing: .12em; font-weight: 700; }
.wl-note-area {
  flex: 1;
  font-family: 'BiauKai', '標楷體', serif;
  font-size: 13px;
  letter-spacing: .06em;
  line-height: 1.75;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  padding: 8px 12px;
  resize: vertical;
  outline: none;
  transition: border-color .15s ease;
}
.wl-note-area:focus { border-color: var(--ink); }

/* ── 動效升級層 v1(與 styles.css frame-card 一致)── */
.wl-card {
  animation: riseIn .5s cubic-bezier(.22,.8,.36,1) both;
  transition: transform .28s cubic-bezier(.22,.8,.36,1), box-shadow .28s ease;
}
.wl-card:nth-of-type(2) { animation-delay: .06s; }
.wl-card:nth-of-type(3) { animation-delay: .12s; }
.wl-card:nth-of-type(4) { animation-delay: .18s; }
.wl-card:nth-of-type(n+5) { animation-delay: .24s; }
.wl-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.wl-card .corner-tl, .wl-card .corner-tr,
.wl-card .corner-bl, .wl-card .corner-br {
  transition: width .3s cubic-bezier(.22,.8,.36,1), height .3s cubic-bezier(.22,.8,.36,1);
}
.wl-card:hover .corner-tl, .wl-card:hover .corner-tr,
.wl-card:hover .corner-bl, .wl-card:hover .corner-br { width: 16px; height: 16px; }
@media (prefers-reduced-motion: reduce) {
  .wl-card { animation: none; }
  .wl-card:hover { transform: none; }
}

/* 停損觸發徽章呼吸 */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ═══ 自選股美學升級層 v2 · 手寫帳冊風 ═══════════════════
   概念：交易績效區是一本元大營業廳的老帳冊——
   硃砂帳線、橫格紙、墨章、金箔書籤；整塊可回退 */

/* ── KPI 卡：頂緣金刻度 + 浮起 ── */
.kpi-card { position: relative; overflow: hidden;
  transition: transform .28s cubic-bezier(.22,.8,.36,1), box-shadow .28s ease; }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 14px;
  width: 28px; height: 3px;
  background: linear-gradient(90deg, var(--gold), transparent); }
.kpi-card:hover { transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(26,36,56,.09); }

/* ── 倉位卡：帳冊頁 ── */
.pos-card { position: relative;
  transition: box-shadow .28s ease, border-color .28s ease; }
/* 左緣硃砂帳線（老帳簿的紅色邊線）*/
.pos-card::before { content: ''; position: absolute; top: 0; bottom: 0; left: 32px;
  width: 1px; background: rgba(194,58,43,.16); pointer-events: none; z-index: 1; }
.pos-card:hover { box-shadow: 0 6px 20px rgba(26,36,56,.08);
  border-color: var(--gold) !important; }
/* 頭列底部金線：懸停自左舒展 */
.pos-card-head { position: relative; }
.pos-card-head::after { content: ''; position: absolute; left: 14px; right: 60%; bottom: 0;
  height: 1px; background: linear-gradient(90deg, var(--gold), transparent);
  opacity: 0; transition: opacity .25s ease, right .35s cubic-bezier(.22,.8,.36,1); }
.pos-card:hover .pos-card-head::after { opacity: .9; right: 14px; }

/* ── 展開區：橫格帳冊紙 ── */
.pos-detail {
  background:
    linear-gradient(180deg, rgba(184,146,77,.045), transparent 56px),
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(26,36,56,.045) 27px 28px);
}
/* 表格：表頭 small-caps、列懸停金邊書籤 */
.pos-detail table thead th { font-variant: small-caps; letter-spacing: .14em; }
.pos-detail tbody tr { transition: background .15s ease, box-shadow .15s ease; }
.pos-detail tbody tr:hover { background: rgba(184,146,77,.08);
  box-shadow: inset 3px 0 0 var(--gold); }

/* ── 已清倉：硃砂騎縫章 ── */
.pos-closed { opacity: .92; }
.pos-closed > .pos-card-head::before {
  content: '結 清'; position: absolute; right: 110px; top: 50%;
  transform: translateY(-50%) rotate(-9deg);
  font-family: 'BiauKai', '標楷體', serif; font-size: 13px; letter-spacing: .3em;
  color: rgba(194,58,43,.5); border: 1.5px solid rgba(194,58,43,.4);
  border-radius: 3px; padding: 1px 6px 1px 9px; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);
}

/* ── 輸入框：帳簿手寫格 ── */
.wl-edit-input { font-variant-numeric: tabular-nums; }
.pos-detail .wl-edit-input, .fee-bar .wl-edit-input {
  background: rgba(255,255,255,.55); }

/* ── 費率設定列：印刷品天頭雙細線 ── */
.fee-bar { border-top: 3px double var(--ink) !important; }
.fee-bar button { transition: background .18s ease, color .18s ease, transform .12s ease; }
.fee-bar button:active { transform: translateY(1px); }

/* ── 自選卡 wl-card：懸停角落花飾 + 細微光暈 ── */
.wl-card { transition: box-shadow .3s ease, transform .3s ease; }
.wl-card::after { content: '❦'; position: absolute; right: 12px; bottom: 8px;
  font-size: 12px; color: var(--gold); opacity: 0;
  transform: rotate(-10deg) translateY(3px);
  transition: opacity .3s ease, transform .3s ease; pointer-events: none; }
.wl-card:hover::after { opacity: .6; transform: rotate(-10deg) translateY(0); }

/* ── 數字統一 tabular，帳目對齊 ── */
.pos-card, .kpi-card { font-variant-numeric: tabular-nums; }

/* ── 倉位展開動畫：帳頁翻開 ── */
.pos-detail { animation: ledgerOpen .3s cubic-bezier(.22,.8,.36,1) both; }
@keyframes ledgerOpen {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .pos-detail { animation: none; }
  .kpi-card, .pos-card, .wl-card { transition: none; }
}

/* ═══ 持股帳房 v3 · 總帳 Hero 與快速加入 ═══════════════ */
.ph-hero {
  display: flex; gap: 28px; align-items: stretch; flex-wrap: wrap;
  border-top: 3px double var(--ink); border-bottom: 1px solid var(--ink);
  padding: 26px 6px 22px; margin: 18px 0 22px; position: relative;
}
.ph-hero::after { content: '❦'; position: absolute; top: 10px; right: 8px;
  color: var(--gold); font-size: 14px; opacity: .7; }
.ph-hero-left { flex: 0 0 auto; min-width: 220px; }
.ph-hero-kicker {
  font-family: 'Times New Roman', serif; font-style: italic;
  font-size: var(--fs-nano); letter-spacing: .22em; color: var(--gold-deep, #9a7b35);
}
.ph-hero-title { font-size: 34px; font-weight: 700; letter-spacing: .18em;
  margin: 6px 0 8px; line-height: 1.15; }
.ph-hero-date { font-size: 11.5px; color: var(--ink-mute);
  font-family: 'Times New Roman', serif; font-style: italic; letter-spacing: .04em; }
.ph-hero-right { flex: 1; min-width: 300px; display: flex; gap: 26px;
  align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.ph-hero-main { text-align: right; }
.ph-hero-lbl { font-family: 'Times New Roman', serif; font-style: italic;
  font-size: var(--fs-nano); letter-spacing: .12em; color: var(--ink-mute); }
.ph-hero-val { font-size: 40px; font-weight: 700; line-height: 1.1;
  border-bottom: 3px solid var(--gold); display: inline-block; padding-bottom: 2px;
  font-variant-numeric: tabular-nums; }
.ph-hero-stats { display: grid; grid-template-columns: auto auto;
  gap: 6px 22px; align-content: center; }
.ph-stat { display: flex; flex-direction: column; }
.ph-stat-lbl { font-family: 'BiauKai', '標楷體', serif; font-size: var(--fs-nano);
  color: var(--ink-mute); letter-spacing: .1em; }
.ph-stat-val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

.ph-add { display: flex; border: 1px solid var(--ink); margin-bottom: 14px; background: var(--paper-bright); }
.ph-add-input { flex: 1; padding: 11px 16px; border: none; outline: none;
  font-family: 'Times New Roman', serif; font-size: 16px; font-weight: 700;
  letter-spacing: .08em; background: transparent; color: var(--ink); }
.ph-add-input::placeholder { font-weight: 400; color: var(--ink-mute);
  font-style: italic; letter-spacing: 0; font-size: 13px; }
.ph-add-btn { padding: 11px 20px; border: none; cursor: pointer;
  font-size: 13px; letter-spacing: .14em; transition: background .15s ease; flex-shrink: 0; }
.ph-add-btn.watch { background: transparent; color: var(--ink-soft, var(--ink));
  border-left: 1px solid var(--paper-line); }
.ph-add-btn.watch:hover { background: var(--paper-deep, #efe9d8); }
.ph-add-btn.hold { background: var(--ink); color: var(--paper-bright); }
.ph-add-btn.hold:hover { background: var(--gold-deep, #9a7b35); }

.ph-empty { text-align: center; padding: 40px 0; margin-bottom: 28px;
  border: 1px dashed var(--paper-line); color: var(--ink-mute);
  font-size: 14px; letter-spacing: .12em; line-height: 2; }
@media (max-width: 700px) {
  .ph-hero { padding: 18px 2px 16px; gap: 14px; }
  .ph-hero-title { font-size: 26px; }
  .ph-hero-val { font-size: 30px; }
  .ph-hero-right { justify-content: flex-start; }
  /* 手機：解除固定 min-width，讓 hero 兩欄優雅換行不貼邊（稽核 P0-2） */
  .ph-hero-left { min-width: 0; }
  .ph-hero-right { min-width: 0; gap: 14px; }
  /* 手機字級地板：分組分頁不小於可讀下限（稽核 P1-1） */
  .wl-group-tab { min-width: 128px; }
}
