/* ════════════════════════════════════════════════
   元大銀行 信用風險 AI 分析平台 — 主樣式
   設計風格：專業、簡潔、深藍調
════════════════════════════════════════════════ */
:root {
  --navy:    #0058A6;
  --navy2:   #006EC0;
  --blue:    #2b6cb0;
  --blue-lt: #ebf4ff;
  --gold:    #f97316;
  --bg:      #f0f4f8;
  --panel:   #ffffff;
  --border:  #dde3ed;
  --t1:      #1a202c;
  --t2:      #2d3748;
  --t3:      #4a5568;
  --t4:      #718096;
  --t5:      #a0aec0;
  --green:   #276749;
  --green-bg:#e6f4ed;
  --red:     #c53030;
  --red-bg:  #fff5f5;
  --amber:   #92400e;
  --amber-bg:#fffbeb;
  --sidebar-w: 220px;
  --topbar-h:  56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: var(--t2);
  min-height: 100vh;
}

/* ── 登入畫面 ─────────────────────────────────── */
.login-screen {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
}
.login-card {
  background: var(--panel); border-radius: 12px;
  padding: 40px; width: 340px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.logo-mark {
  width: 48px; height: 48px; background: var(--navy);
  border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: var(--gold);
  font-size: 1.1rem; font-weight: 700; letter-spacing: .03em;
}
.login-title { font-size: 1.1rem; font-weight: 700; color: var(--navy); }
.login-sub   { font-size: .75rem; color: var(--t4); margin-top: 2px; }
.login-divider { height: 1px; background: var(--border); margin-bottom: 24px; }
.login-input {
  width: 100%; border: 1.5px solid var(--border);
  border-radius: 6px; padding: 11px 14px;
  font-family: inherit; font-size: .9rem; color: var(--t1);
  outline: none; transition: border-color .15s;
  margin-bottom: 12px;
}
.login-input:focus { border-color: var(--blue); }
.login-btn {
  width: 100%; background: var(--navy); color: white;
  border: none; border-radius: 6px; padding: 12px;
  font-family: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; transition: background .15s; letter-spacing: .03em;
}
.login-btn:hover { background: var(--navy2); }
.login-err { font-size: .8rem; color: var(--red); text-align: center; margin-top: 10px; }

/* ── 主框架 ─────────────────────────────────────── */
.app { min-height: 100vh; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h); background: var(--navy);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.menu-btn {
  background: none; border: none; color: rgba(255,255,255,.7);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px;
  border-radius: 4px; transition: color .15s;
}
.menu-btn:hover { color: white; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  background: var(--gold); color: var(--navy);
  font-weight: 700; font-size: .8rem; padding: 4px 8px;
  border-radius: 4px; letter-spacing: .05em;
}
.brand-logo { height: 32px; width: auto; display: block; border-radius: 5px; }
.brand-name { color: rgba(255,255,255,.9); font-weight: 600; font-size: .9rem; }

.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #48bb78; animation: blink 2.5s infinite;
}
@keyframes blink { 0%,100%{opacity:1}50%{opacity:.3} }
.topbar-date { color: rgba(255,255,255,.55); font-size: .72rem; }

/* ── 側邊欄 ─────────────────────────────────────── */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--navy);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s ease;
  z-index: 150; overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 140;
}
.sidebar-overlay.show { display: block; }

.nav-items { flex: 1; padding: 12px 0; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; background: none; border: none;
  color: rgba(255,255,255,.65); cursor: pointer;
  font-family: inherit; font-size: .875rem;
  transition: all .15s; text-align: left;
  border-left: 3px solid transparent;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.07); }
.nav-item.active {
  color: white; background: rgba(255,255,255,.1);
  border-left-color: var(--gold);
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-footer {
  padding: 16px 20px; color: rgba(255,255,255,.3);
  font-size: .65rem; border-top: 1px solid rgba(255,255,255,.1);
}
.nav-group {
  margin: 6px 8px 10px;
  border-radius: 8px;
  overflow: hidden;
}
.nav-group-label {
  font-size: .57rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; padding: 8px 16px 4px;
}
.nav-group .nav-item { padding-left: 16px; padding-right: 12px; }
.nav-group-p1 { background: rgba(120,190,255,.14); }
.nav-group-p1 .nav-group-label { color: rgba(140,215,255,.85); }
.nav-group-p2 { background: rgba(255,185,70,.1); }
.nav-group-p2 .nav-group-label { color: rgba(255,205,100,.85); }
.nav-group-p3 { background: rgba(95,220,155,.1); }
.nav-group-p3 .nav-group-label { color: rgba(110,225,165,.85); }

/* ── 主內容 ─────────────────────────────────────── */
.content {
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  padding: 24px 20px;
  transition: margin-left .25s;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── 通用元件 ─────────────────────────────────── */
.page-title {
  font-size: 1.2rem; font-weight: 700; color: var(--navy);
  margin-bottom: 4px;
}
.page-sub { font-size: .8rem; color: var(--t4); margin-bottom: 20px; }

.card {
  background: var(--panel); border-radius: 8px;
  border: 1px solid var(--border); padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: .78rem; font-weight: 600; color: var(--t4);
  text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: 14px;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: .82rem; font-weight: 500;
  padding: 8px 16px; border-radius: 6px; cursor: pointer;
  border: 1.5px solid; transition: all .15s; letter-spacing: .02em;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: white; border-color: var(--navy); }
.btn-primary:hover:not(:disabled) { background: var(--navy2); }
.btn-blue    { background: var(--blue); color: white; border-color: var(--blue); }
.btn-blue:hover:not(:disabled) { filter: brightness(1.1); }
.btn-ghost   { background: transparent; color: var(--t3); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--t3); color: var(--t1); }
.btn-danger  { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-gold    { background: var(--gold); color: var(--navy); border-color: var(--gold); font-weight: 700; }
.btn-yellow  { background: #eab308; color: #1a1a1a; border-color: #ca8a04; font-weight: 700; }
.btn-yellow:hover:not(:disabled) { background: #ca8a04; border-color: #a16207; }
.btn-sm      { padding: 5px 10px; font-size: .75rem; }
.btn-w       { width: 100%; justify-content: center; }

.inp {
  width: 100%; border: 1.5px solid var(--border); border-radius: 6px;
  padding: 9px 12px; font-family: inherit; font-size: .85rem;
  color: var(--t1); outline: none; transition: border-color .15s;
  background: var(--panel);
}
.inp:focus { border-color: var(--blue); }
.inp::placeholder { color: var(--t5); }

.sel {
  border: 1.5px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-family: inherit; font-size: .82rem;
  color: var(--t2); background: var(--panel); outline: none;
}

/* Tags */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: .68rem; font-weight: 500; border: 1px solid;
}
.tag-blue  { background: var(--blue-lt); color: #1e40af; border-color: #bfdbfe; }
.tag-green { background: var(--green-bg); color: var(--green); border-color: #a7f3d0; }
.tag-red   { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.tag-amber { background: var(--amber-bg); color: var(--amber); border-color: #fde68a; }
.tag-gray  { background: #f7fafc; color: var(--t4); border-color: var(--border); }

/* Spinner */
.spin { display:inline-block;width:14px;height:14px;border:2px solid currentColor;
  border-top-color:transparent;border-radius:50%;animation:rot .6s linear infinite; }
@keyframes rot{to{transform:rotate(360deg)}}

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--navy); color: white;
  padding: 12px 20px; border-radius: 8px;
  font-size: .82rem; z-index: 9999;
  opacity: 0; transform: translateY(8px);
  transition: all .25s; pointer-events: none; max-width: 300px;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* 流程步驟 */
.pipe { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.pipe-row { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--t4); }
.pdot { width:8px;height:8px;border-radius:50%;background:var(--border);flex-shrink:0; }
.pdot.active { background: var(--blue); box-shadow:0 0 6px rgba(43,108,176,.5); }
.pdot.done   { background: var(--green); }

/* ── 新聞卡片 ─────────────────────────────────── */
.news-grid { display: flex; flex-direction: column; gap: 8px; }
.news-card {
  background: var(--panel); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
  transition: border-color .12s; position: relative; overflow: hidden;
}
.news-card:hover { border-color: #b0bfd0; }
.news-card.selected { border-color: var(--blue); background: #f0f7ff; }
.news-card.selected::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--blue);
}
.news-card.analyzed { border-color: var(--green); }
.news-card.analyzed::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--green); }
.news-top { display: flex; align-items: flex-start; gap: 10px; }
.news-ck { margin-top: 3px; accent-color: var(--navy); cursor: pointer; width: 15px; height: 15px; flex-shrink: 0; }
.news-title {
  font-size: .9rem; font-weight: 600; color: var(--t1);
  line-height: 1.5; cursor: pointer; flex: 1;
}
.news-title:hover { color: var(--blue); }
.news-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; padding-left: 25px; }
.news-date { font-size: .68rem; color: var(--t5); }
.news-src  { font-size: .68rem; color: var(--t4); }

/* 快速標記 */
.quick-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; padding-left: 25px; }
.qtag {
  font-size: .65rem; padding: 2px 7px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--t4); cursor: pointer; transition: all .1s;
}
.qtag.on { background: var(--navy); color: white; border-color: var(--navy); }

/* 批次操作列 */
.batch-bar {
  position: sticky; bottom: 0; background: var(--panel);
  border-top: 2px solid var(--navy); padding: 12px 20px;
  display: none; align-items: center; gap: 12px; flex-wrap: wrap;
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  z-index: 50;
}
.batch-bar.show { display: flex; }
.batch-info { font-size: .82rem; color: var(--t3); }
.batch-info strong { color: var(--t1); }
.batch-acts { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── 案例庫 ─────────────────────────────────── */
.case-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; cursor: pointer;
  transition: all .15s; margin-bottom: 10px;
}
.case-card:hover { border-color: var(--blue); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.case-id    { font-size: .68rem; color: var(--t5); font-family: 'DM Mono', monospace; }
.case-title { font-size: .95rem; font-weight: 700; color: var(--navy); margin: 4px 0 8px; }

/* 案例詳情 modal */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 500;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--panel); border-radius: 10px;
  width: 100%; max-width: 920px; max-height: 92vh;
  overflow-y: auto; padding: 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,.2);
}
.modal-hdr { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.modal-title { font-size: 1.05rem; font-weight: 700; color: var(--navy); flex: 1; line-height: 1.4; }
.modal-close {
  background: none; border: none; color: var(--t4);
  cursor: pointer; font-size: 1.2rem; padding: 0 4px;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--t1); }
.modal-body { font-size: .85rem; line-height: 1.9; color: var(--t2); white-space: pre-wrap; }

/* ── 關鍵字管理 ──────────────────────────────── */
.tier-block { margin-bottom: 20px; }
.tier-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--t4); margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.tier-badge {
  font-size: .6rem; padding: 2px 8px; border-radius: 10px;
  background: var(--blue-lt); color: var(--blue); font-weight: 600;
}
.kw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: .78rem;
  border: 1.5px solid;
}
.kw-chip-t1 { background: var(--navy); color: white; border-color: var(--navy); }
.kw-chip-t2 { background: var(--blue-lt); color: #1e40af; border-color: #bfdbfe; }
.kw-chip-t3 { background: var(--bg); color: var(--t3); border-color: var(--border); }
.kw-del-btn {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: .5; font-size: .75rem; padding: 0;
}
.kw-del-btn:hover { opacity: 1; }

.suggest-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--amber-bg);
  border: 1px solid #fde68a; border-radius: 6px; margin-bottom: 6px;
}
.suggest-kw { flex: 1; font-size: .85rem; color: var(--t1); font-weight: 500; }
.suggest-acts { display: flex; gap: 6px; }

/* ── 彙整報告 ─────────────────────────────────── */
.report-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
}
.report-name { flex: 1; font-size: .88rem; color: var(--t1); font-weight: 500; }
.report-meta { font-size: .72rem; color: var(--t4); }

/* ── 公告看板 ─────────────────────────────────── */
.announcement-item {
  border-left: 4px solid var(--blue); padding: 16px 20px;
  background: var(--panel); border-radius: 0 8px 8px 0;
  margin-bottom: 12px;
}
.ann-date  { font-size: .7rem; color: var(--t4); margin-bottom: 4px; font-family: 'DM Mono', monospace; }
.ann-title { font-size: .95rem; font-weight: 700; color: var(--navy); margin-bottom: 10px; }
.ann-body  { font-size: .82rem; line-height: 1.85; color: var(--t2); white-space: pre-wrap; }

/* ── 設定 ─────────────────────────────────────── */
.prompt-ver-item {
  padding: 12px 16px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 8px; display: flex; align-items: flex-start; gap: 12px;
}
.prompt-ver-info { flex: 1; min-width: 0; }
.prompt-ver-name { font-size: .88rem; font-weight: 600; color: var(--t1); }
.prompt-ver-preview { font-size: .72rem; color: var(--t4); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.active-badge { font-size: .65rem; background: var(--green-bg); color: var(--green); border: 1px solid #a7f3d0; padding: 2px 8px; border-radius: 10px; font-weight: 600; }

textarea.inp { min-height: 160px; resize: vertical; font-family: 'DM Mono', monospace; font-size: .78rem; }

/* ── RWD 桌面版（側邊欄固定）──────────────────── */
@media (min-width: 900px) {
  .menu-btn { display: none; }
  .sidebar { transform: translateX(0); }
  .sidebar-overlay { display: none !important; }
  .content { margin-left: var(--sidebar-w); padding: 28px 32px; }
}
@media (max-width: 899px) {
  .content { padding: 16px; }
}

/* 進度條 */
.prog-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.prog-fill { height: 100%; background: var(--blue); border-radius: 2px; transition: width .3s; }

/* ── VP 模式：隱藏側邊欄，內容全寬 ────────────────────── */
.vp-mode .sidebar        { display: none !important; }
.vp-mode .sidebar-overlay{ display: none !important; }
.vp-mode .menu-btn       { display: none !important; }
.vp-mode .content        { margin-left: 0 !important; }

/* 搜尋列 */
.search-bar {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.search-bar .inp { flex: 1; min-width: 200px; }

/* DB selector */
.db-selector { margin-bottom: 12px; }

/* 空狀態 */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--t4);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state h3 { font-size: .95rem; color: var(--t3); margin-bottom: 6px; }
.empty-state p  { font-size: .8rem; line-height: 1.7; }

/* 分隔線 */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* 突發事件快訊 */
.flash-card { padding: 14px 16px; position: relative; overflow: hidden; transition: border-color .12s; }
.flash-card.selected { border-color: var(--blue) !important; background: #f0f7ff; }
.flash-card.selected::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--blue);
}
.flash-section { margin-bottom: 10px; }
.flash-sec-title {
  font-size: .68rem; font-weight: 600; color: var(--t5);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 5px;
}
.flash-person {
  font-size: .8rem; color: var(--t2);
  padding: 3px 0;
  border-bottom: 1px solid rgba(0,0,0,.04);
}
.flash-tag {
  display: inline-block;
  font-size: .78rem; color: var(--t2);
  background: rgba(0,70,160,.07);
  padding: 2px 10px;
  border-radius: 12px;
  margin: 2px 4px 2px 0;
}

/* 時鐘排程 */
.flash-clock {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.flash-hour-btn {
  font-size: .78rem;
  font-family: var(--mono, monospace);
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--t3);
  cursor: pointer;
  transition: all .15s;
  min-width: 58px;
  text-align: center;
}
.flash-hour-btn:hover {
  border-color: var(--navy);
  color: var(--navy);
  background: rgba(0,70,160,.06);
}
.flash-hour-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  font-weight: 700;
}

/* VP 模式：非突發事件頁籤的操作按鈕隱藏 */
body.vp-mode .tab-panel:not(#tab-flash) .btn-primary { display: none !important; }
body.vp-mode .tab-panel:not(#tab-flash) .btn-warning { display: none !important; }
body.vp-mode .tab-panel:not(#tab-flash) input:not([readonly]),
body.vp-mode .tab-panel:not(#tab-flash) textarea:not([readonly]),
body.vp-mode .tab-panel:not(#tab-flash) select {
  pointer-events: none;
  opacity: .65;
}
