/* PSYS 自訂樣式：只保留 Bootstrap 沒有對應元件的部分（側邊導覽列、收支行事曆
   格狀版面、KIND_COLOR 色點用的 .status-dot）。其餘版面一律用 Bootstrap 6 的
   card/list-group/row-col/collapse/offcanvas 等內建元件，不重複造輪子。 */

/* ---------- 側邊導覽列 ---------- */

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 14px 0;
  background: var(--bs-body-bg-opaque, oklch(0.144 0.0048 245));
  border-right: 1px solid var(--bs-border-color);
  z-index: 1030;
}
.app-sidebar-brand { display: flex; }
.app-sidebar-brand img { border-radius: 8px; }
.app-sidebar-icons {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.app-sidebar .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--bs-fg-2);
  background: transparent;
  border: none;
  font-size: 20px;
  text-decoration: none;
}
.app-sidebar .nav-icon:hover { color: var(--bs-fg-body); background: var(--bs-secondary-bg-subtle); }
.app-sidebar .nav-icon.active { color: #fff; background: var(--bs-primary-bg); }
.app-sidebar-logout { display: flex; }
.nav-icon-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bs-secondary-bg-subtle);
  font-size: 13px;
  font-weight: 700;
}
.app-sidebar .nav-icon.active .nav-icon-badge { background: rgba(255, 255, 255, 0.25); }

body { padding-left: 64px; }

@media (max-width: 767.98px) {
  .app-sidebar {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 56px;
    flex-direction: row;
    padding: 0 8px;
    border-right: none;
    border-top: 1px solid var(--bs-border-color);
  }
  .app-sidebar-icons { flex-direction: row; justify-content: space-around; }
  body { padding-left: 0; padding-bottom: 56px; }
}

/* ---------- 側邊欄 K 標誌：快速問答小幫手 ---------- */

.assistant-trigger {
  display: flex;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.assistant-trigger img { border-radius: 8px; }
.assistant-trigger.active img { box-shadow: 0 0 0 2px var(--bs-primary-bg); }

.assistant-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
}
.assistant-backdrop.show { display: flex; }

.assistant-modal {
  width: 50vw;
  height: 80vh;
  max-width: 960px;
  min-width: 320px;
  background: var(--bs-secondary-bg-subtle);
  border: 1px solid var(--bs-border-color);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.assistant-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--bs-border-color);
  flex: 0 0 auto;
}
.assistant-icon-btn {
  border: none;
  background: transparent;
  color: var(--bs-fg-2);
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.assistant-icon-btn:hover { background: var(--bs-secondary-bg); color: var(--bs-fg-body); }

.assistant-chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.assistant-empty-hint { text-align: center; margin-top: 40px; }

.assistant-exchange { display: flex; flex-direction: column; gap: 6px; }
.assistant-exchange .assistant-q {
  align-self: flex-end;
  background: var(--bs-primary-bg);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px 12px 2px 12px;
  max-width: 80%;
  white-space: pre-wrap;
}
.assistant-exchange .assistant-a {
  align-self: flex-start;
  background: var(--bs-secondary-bg);
  padding: 8px 12px;
  border-radius: 12px 12px 12px 2px;
  max-width: 85%;
  white-space: pre-wrap;
  line-height: 1.6;
}
.assistant-exchange .assistant-a.assistant-loading { color: var(--bs-fg-2); }
.assistant-exchange .assistant-a.assistant-error { color: var(--bs-danger-bg); }

.assistant-form { border-top: 1px solid var(--bs-border-color); padding: 10px 14px; flex: 0 0 auto; }
.assistant-input {
  width: 100%;
  resize: none;
  overflow-y: auto;
  background: transparent;
  color: inherit;
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.4;
  max-height: 160px;
}
.assistant-input:focus { outline: none; border-color: var(--bs-primary-bg); }

@media (max-width: 767.98px) {
  .assistant-modal { width: 92vw; height: 85vh; }
  .assistant-exchange .assistant-q,
  .assistant-exchange .assistant-a { max-width: 92%; }
}

/* 通用的「桌面並排、手機堆疊」小工具（例如資產配置頁的本月狀態/資產配置比例、
   戰情室的流動現金/預算進度條）：CDN 載的這版 Bootstrap 6 alpha 沒有
   col-lg-*/row-cols-lg-* 這類響應式斷點 class（整包都沒有，不是這裡漏寫），
   所以斷點切換自己手刻，比照 .app-sidebar 既有的做法；非響應式的 flex/gap
   工具類（d-flex/flex-column/gap-4）正常可用，底下只補響應式切換這一小塊。 */
.psys-flex-row-lg > * { min-width: 0; }
@media (min-width: 992px) {
  .psys-flex-row-lg { flex-direction: row; }
  .psys-flex-row-lg > * { flex: 1 1 0; }
}

/* 這版 Bootstrap 6 alpha 同樣沒有 .text-muted/.text-danger/.btn-primary 這類
   語意顏色 class（整包查過確認沒有，連 app.css 既有的 cal-income/cal-expense
   都是改用 var(--bs-success-bg)/var(--bs-danger-bg) 繞過這個問題），.psys-muted
   比照同一套做法，給新加的區塊（戰情室）用，不是這裡漏寫。 */
.psys-muted { color: var(--bs-fg-2); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  display: inline-block;
  background: #94a3b8;
}

/* 個股詳情頁頂部（代碼/現價/漲跌/參考連結）永遠置頂，捲動財務預測/訊號時間軸
   等長表格時隨時看得到現價跟能點去外部網站對照，背景用跟側邊欄一樣的不透明
   變數，不然底下內容捲上來會透出來疊字。 */
.stock-detail-header {
  position: sticky;
  top: 0;
  z-index: 1010;
  background: var(--bs-body-bg-opaque, oklch(0.144 0.0048 245));
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--bs-border-color);
}

/* 帳戶頁籤自訂顏色：未選取時文字套用帳戶顏色（JS inline style 已設 color），
   選取時整顆按鈕變成該顏色的底色 + 白字，跟 Bootstrap 預設 active 樣式區分開。 */
.account-tab-btn.active {
  background-color: var(--acc-color) !important;
  border-color: var(--acc-color) !important;
  color: #fff !important;
}

/* ---------- 收支行事曆 ---------- */

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  font-size: 13px;
  text-align: center;
  margin-bottom: 4px;
}
.cal-weekdays span { color: var(--bs-fg-2); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 16px;
}

.cal-cell {
  background: var(--bs-secondary-bg-subtle);
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  padding: 5px;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-cell-empty { background: transparent; border-color: transparent; }
.cal-cell-today { border-color: var(--bs-primary-bg); border-width: 2px; }
.cal-cell-has-value { background: rgba(96, 165, 250, 0.15); }
.cal-cell-selected { box-shadow: 0 0 0 2px #facc15 inset; }

.cal-cell-head { display: flex; justify-content: space-between; align-items: center; }
.cal-date { font-size: 14px; font-weight: 600; color: var(--bs-fg-2); }
.cal-cell .btn { padding: 0 6px; font-size: 13px; line-height: 1.5; }
.cal-view-btn { background: none; border: none; padding: 0; line-height: 1; font-size: 13px; color: var(--bs-fg-2); opacity: 0.6; cursor: pointer; }
.cal-view-btn:hover { opacity: 1; }

.cal-cell-totals { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
/* 收入綠/支出紅（正向綠、負向紅，全站統一），轉帳另外拆方向：轉入藍、轉出紫，
   跟 wealth.js 的 LEDGER_INCOME_COLOR/LEDGER_EXPENSE_COLOR/TRANSFER_IN_COLOR/
   TRANSFER_OUT_COLOR 保持同一套色票。 */
.cal-income { color: var(--bs-success-bg); }
.cal-expense { color: var(--bs-danger-bg); font-weight: 600; }
.cal-transfer-in { color: #60a5fa; font-weight: 600; }
.cal-transfer-out { color: #a78bfa; font-weight: 600; }
.cal-credit { color: #c084fc; font-weight: 600; }

.cal-dots {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.cal-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 9px;
  display: inline-block;
}
.cal-dot-more {
  font-size: 11px;
  color: var(--bs-fg-2);
}

.day-entry-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 576px 以下行事曆整個隱藏（改用日期選擇器），所以這裡只需要照顧 576~767.98px
   這段「能看到行事曆、但欄位還是偏窄」的手機/小平板寬度，欄位縮一點但字級不縮回原本過小的大小。 */
@media (max-width: 767.98px) {
  .cal-cell { padding: 4px; min-height: 68px; gap: 2px; }
  .cal-cell .btn { padding: 0 4px; }
  .day-entry-text { white-space: normal; }
}

