/* portfolio-dash — 個股詳情抽屜 */

.sd-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(4, 7, 11, 0.55);
  backdrop-filter: blur(2px);
}
.sd-drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 660px; max-width: calc(100vw - 32px);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 60px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column;
  animation: sd-in 0.18s ease;
}
@keyframes sd-in { from { transform: translateX(36px); opacity: 0; } to { transform: none; opacity: 1; } }

.sd-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px var(--pad);
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}
.sd-head .sym-code { font-size: 17px; }
.sd-head .sym-name { font-size: 12px; }
.sd-price { margin-left: auto; display: flex; align-items: baseline; gap: 7px; }
.sd-price .v { font-family: var(--font-num); font-size: 17px; font-weight: 600; }
.sd-price .c { font-size: 10px; color: var(--text-3); font-family: var(--font-num); }
.sd-close {
  background: none; border: none; color: var(--text-3);
  font-size: 15px; cursor: pointer; padding: 2px 4px;
}
.sd-close:hover { color: var(--text); }

.sd-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--gap); padding: 14px var(--pad) 24px; }

.sd-section { display: flex; flex-direction: column; gap: 8px; }
.sd-sec-head { display: flex; align-items: baseline; gap: 10px; }
.sd-sec-title { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.sd-sec-sub { font-size: 10.5px; color: var(--text-3); }
.sd-sec-head .spacer { flex: 1; }

#sd-chart { width: 100%; height: 250px; }
.sd-chart-note {
  font-size: 10.5px; color: var(--amber);
  background: var(--amber-soft); border: 1px solid rgba(217, 161, 63, 0.3);
  border-radius: var(--radius-sm); padding: 4px 9px;
}
.sd-mock-note { font-size: 10px; color: var(--text-3); }

/* position stats */
.sd-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sd-stat {
  background: var(--panel-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.sd-stat .k { font-size: 10px; color: var(--text-3); white-space: nowrap; }
.sd-stat .v { font-family: var(--font-num); font-size: 14px; font-weight: 600; white-space: nowrap; }
.sd-stat .s { font-size: 10px; font-family: var(--font-num); color: var(--text-3); }

/* contribution split: capital gain vs dividends */
.sd-split { display: flex; flex-direction: column; gap: 5px; }
.sd-split-bar {
  display: flex; height: 14px; border-radius: 4px; overflow: hidden;
  background: var(--panel-3);
}
.sd-split-bar .seg-cap { background: var(--accent); }
.sd-split-bar .seg-div { background: var(--series-myr); }
.sd-split-bar .seg-neg { background: var(--down); }
.sd-split-legend { display: flex; gap: 16px; font-size: 11px; color: var(--text-2); flex-wrap: wrap; }
.sd-split-legend .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.sd-split-legend b { font-family: var(--font-num); color: var(--text); }

/* tables inside drawer */
.sd-section table.data { font-size: 11.5px; }
.sd-section table.data td { height: 28px; padding: 4px 8px; }
.sd-section table.data th { padding: 5px 8px; }

/* what-if simulator */
.sd-sim {
  background: var(--panel-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.sd-sim-controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.sd-sim-controls .field { display: flex; flex-direction: column; gap: 3px; }
.sd-sim-controls label { font-size: 10px; color: var(--text-3); }
.sd-sim-controls input {
  width: 110px; background: var(--panel); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  font-family: var(--font-num); font-size: 12px; padding: 5px 8px;
}
.sd-sim-controls input:focus { outline: none; border-color: var(--accent); }
.sd-sim-result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px 18px; font-size: 11px; }
.sd-sim-result .kv { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--border-soft); }
.sd-sim-result .kv .k { color: var(--text-3); }
.sd-sim-result .kv .v { font-family: var(--font-num); }
.sd-sim-note { font-size: 10px; color: var(--amber); }
.sd-sim-badge {
  font-size: 10px; line-height: 16px; padding: 0 6px; border-radius: 3px;
  color: var(--accent); border: 1px solid rgba(88, 166, 221, 0.4); background: var(--accent-soft);
}

/* dividend type chips (shared with ledger/trades pages) */
.type-chip {
  font-size: 10px; padding: 0 8px; line-height: 17px;
  border-radius: 999px; border: 1px solid var(--border); font-family: var(--font-ui);
}
.chip-cash  { color: var(--accent); border-color: rgba(88, 166, 221, 0.4); background: var(--accent-soft); }
.chip-stock { color: var(--series-myr); border-color: rgba(217, 161, 63, 0.4); background: var(--amber-soft); }
.chip-drip  { color: var(--series-usd); border-color: rgba(155, 134, 216, 0.4); background: rgba(155, 134, 216, 0.12); }
.chip-net   { color: var(--text-2); }

.sd-empty { padding: 18px; font-size: 12px; color: var(--text-3); text-align: center; }

@media (max-width: 720px) {
  .sd-stats { grid-template-columns: repeat(2, 1fr); }
  .sd-sim-result { grid-template-columns: 1fr; }
}
