/* 股票資訊頁面樣式（復刻示意）：使用2空格縮排，語義化、可交互 */
:root {
  --bg: #fafafa;
  --card: #ffffff;
  --muted: #6b7280;
  --primary: #f5b300;
  --primary-weak: #fde68a;
  --tab-bg: #f3f4f6;
  --tab-active: #f5b300;
  --tab-active-text: #fff;
  --table-row: #f7f7f7;
  --shadow: 0 6px 18px rgba(0,0,0,.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial; background: var(--bg); color: #0f172a; }

.si-header { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
.si-title h1 { margin: 0 0 4px; font-size: 28px; }
.muted { color: var(--muted); margin: 0; }

.si-main { max-width: 1200px; margin: 0 auto; padding: 0 16px 40px; }

.tabs, .subtabs { display: flex; gap: 12px; padding: 10px; background: var(--tab-bg); border-radius: var(--radius); box-shadow: var(--shadow); }
.subtabs { margin-top: 16px; }
.tab, .subtab {
  appearance: none; border: 0; background: var(--card); padding: 10px 16px; border-radius: 999px; font-weight: 700;
  cursor: pointer; color: #111827; box-shadow: inset 0 0 0 1px #e5e7eb; transition: .2s ease;
}
.tab:hover, .subtab:hover { transform: translateY(-1px); }
.tab.is-active, .subtab.is-active { background: var(--tab-active); color: var(--tab-active-text); box-shadow: none; }

.panel { display: none; margin-top: 16px; }
.panel.is-active { display: block; }
.status { margin: 10px 0; color: var(--muted); font-size: 14px; }

.table-scroll { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.ipo-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.ipo-table thead th { text-align: left; padding: 16px 14px; font-weight: 800; background: #fff; position: sticky; top: 0; z-index: 1; cursor: pointer; }
.ipo-table tbody td { padding: 16px 14px; border-top: 1px solid #f0f0f0; }
.ipo-table tbody tr:nth-child(even) { background: var(--table-row); }

.files-empty { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; color: var(--muted); }

@media (max-width: 768px) {
  .ipo-table { min-width: 720px; }
}


/* 市場新聞樣式 */
.news-container { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0; overflow: hidden; }
.news-iframe { width: 100%; height: 70vh; border: 0; display: block; background: #fff; }
.news-list { padding: 12px 16px; }
.news-item { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 10px 8px; border-bottom: 1px solid #f0f0f0; }
.news-item:last-child { border-bottom: 0; }
.news-time { color: var(--muted); font-size: 12px; align-self: center; }
.news-title { font-weight: 600; line-height: 1.5; }


/* Topdata 表格樣式 */
.news-topdata { padding: 12px 0 16px; }
.news-topdata-header { display: flex; gap: 8px; padding: 10px 12px; }
.news-tab { appearance: none; border: 0; background: var(--card); padding: 8px 12px; border-radius: 999px; cursor: pointer; box-shadow: inset 0 0 0 1px #e5e7eb; }
.news-tab.is-active { background: var(--tab-active); color: var(--tab-active-text); box-shadow: none; font-weight: 700; }
.news-table { width: 100%; border-collapse: collapse; min-width: 720px; background: #fff; }
.news-table thead th { text-align: left; padding: 12px 12px; background: #fff; position: sticky; top: 0; z-index: 1; }
.news-table tbody td { padding: 12px 12px; border-top: 1px solid #f0f0f0; }
.news-updated { color: var(--muted); font-size: 12px; padding: 8px 12px; }

.news-exotic { padding: 12px 16px; }
.news-section-title { font-weight: 800; margin: 6px 0 10px; }
.news-top20 { padding: 12px 0 16px; }




/* 檔案室（ipo-archive）樣式 */
.archive-list { padding: 12px 16px; }
.archive-item { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 10px 8px; border-bottom: 1px solid #f0f0f0; }
.archive-item:last-child { border-bottom: 0; }
.archive-time { color: var(--muted); font-size: 12px; align-self: center; }
.archive-title a { font-weight: 600; line-height: 1.5; color: inherit; text-decoration: none; }
.archive-title a:hover { text-decoration: underline; }


/* ========== AI 功能增強樣式 ========== */

/* 打字機光標動畫 */
.typing::after {
  content: '|';
  animation: blink 1s infinite;
  margin-left: 2px;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Markdown 渲染樣式 */
.result h1, .result h2, .result h3, .bubble .content h1, .bubble .content h2, .bubble .content h3 { 
  margin: 12px 0 8px; 
  font-weight: 700;
}
.result h1, .bubble .content h1 { font-size: 20px; }
.result h2, .bubble .content h2 { font-size: 18px; }
.result h3, .bubble .content h3 { font-size: 16px; }
.result p, .bubble .content p { margin: 8px 0; line-height: 1.6; }
.result ul, .result ol, .bubble .content ul, .bubble .content ol { 
  margin: 8px 0; 
  padding-left: 24px; 
}
.result li, .bubble .content li { margin: 4px 0; }
.result code, .bubble .content code { 
  background: #f3f4f6; 
  padding: 2px 6px; 
  border-radius: 4px; 
  font-family: 'Fira Code', 'Courier New', monospace; 
  font-size: 13px;
  color: #be123c;
}
.result pre, .bubble .content pre { 
  background: #1e293b; 
  color: #e2e8f0; 
  padding: 12px; 
  border-radius: 8px; 
  overflow-x: auto;
  margin: 10px 0;
}
.result pre code, .bubble .content pre code { 
  background: none; 
  color: inherit; 
  padding: 0; 
}
.result table, .bubble .content table { 
  border-collapse: collapse; 
  width: 100%; 
  margin: 10px 0; 
}
.result table th, .result table td, .bubble .content table th, .bubble .content table td { 
  border: 1px solid #e5e7eb; 
  padding: 8px 12px; 
  text-align: left; 
}
.result table th, .bubble .content table th { 
  background: #f3f4f6; 
  font-weight: 700; 
}
.result blockquote, .bubble .content blockquote { 
  border-left: 4px solid var(--primary); 
  padding-left: 12px; 
  margin: 10px 0; 
  color: var(--muted); 
  font-style: italic;
}
.result a, .bubble .content a { 
  color: #3b82f6; 
  text-decoration: none; 
}
.result a:hover, .bubble .content a:hover { 
  text-decoration: underline; 
}

/* 情緒標籤 */
.sentiment-positive { color: #10b981; font-weight: 700; }
.sentiment-neutral { color: #6b7280; }
.sentiment-negative { color: #ef4444; font-weight: 700; }

/* 評分星星 */
.rating { color: #f59e0b; }
.rating::before { content: '★'; margin-right: 2px; }

/* 來源標註 */
.source-ref { 
  color: #3b82f6; 
  cursor: pointer; 
  font-size: 11px; 
  vertical-align: super;
  text-decoration: none;
}
.source-ref:hover { text-decoration: underline; }

/* AI 思考過程 */
.thinking-process { 
  color: var(--muted); 
  font-size: 13px; 
  font-style: italic; 
  margin: 8px 0;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 8px;
}

/* 聊天操作按鈕 */
.chat-toolbar { 
  display: flex; 
  gap: 8px; 
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.chat-toolbar button { 
  padding: 6px 12px; 
  border: 0; 
  background: var(--primary); 
  color: var(--tab-active-text); 
  border-radius: 8px; 
  font-size: 12px; 
  font-weight: 700; 
  cursor: pointer;
  transition: all 0.2s ease;
}
.chat-toolbar button:hover { 
  opacity: 0.9; 
  transform: translateY(-1px);
}

/* 結果操作按鈕 */
.result-actions { 
  margin-top: 8px; 
  display: flex; 
  gap: 8px; 
  flex-wrap: wrap; 
}
.result-actions button { 
  padding: 6px 12px; 
  border: 0; 
  background: var(--primary); 
  color: var(--tab-active-text); 
  border-radius: 8px; 
  font-size: 12px; 
  font-weight: 700; 
  cursor: pointer;
  transition: all 0.2s ease;
}
.result-actions button:hover { 
  opacity: 0.9; 
}

/* 表格控制區域 */
.table-controls { 
  display: flex; 
  gap: 12px; 
  margin-bottom: 16px; 
  align-items: center;
  flex-wrap: wrap;
}
.table-search { 
  flex: 1; 
  min-width: 200px;
  padding: 10px 14px; 
  border: 1px solid #e5e7eb; 
  border-radius: 10px; 
  font-size: 14px;
  transition: border-color 0.2s ease;
}
.table-search:focus { 
  outline: none; 
  border-color: var(--primary); 
}
.table-export-btn { 
  padding: 10px 16px; 
  border: 0; 
  background: var(--primary); 
  color: var(--tab-active-text); 
  border-radius: 10px; 
  font-size: 14px; 
  font-weight: 700; 
  cursor: pointer; 
  white-space: nowrap;
  transition: all 0.2s ease;
}
.table-export-btn:hover { 
  opacity: 0.9; 
  transform: translateY(-1px);
}

/* 排序指示器 */
.sort-indicator { 
  color: var(--primary); 
  font-weight: 700; 
  margin-left: 4px;
  font-size: 12px;
}

/* 表格行過濾狀態 */
tr.filtered-out { 
  display: none; 
}

/* AI 市場案例試試看按鈕 */
.try-it-btn { 
  margin-top: 12px; 
  padding: 8px 16px; 
  border: 0; 
  background: var(--primary); 
  color: var(--tab-active-text); 
  border-radius: 8px; 
  font-size: 13px; 
  font-weight: 700; 
  cursor: pointer; 
  width: 100%; 
  transition: all 0.2s ease;
}
.try-it-btn:hover { 
  opacity: 0.9; 
  transform: translateY(-2px);
}

/* 響應式調整 */
@media (max-width: 768px) {
  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .table-search {
    min-width: unset;
  }
  .chat-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .chat-toolbar button {
    width: 100%;
  }
}

/* ========== Markdown 渲染樣式 ========== */
.result h1, .bubble h1 { 
  font-size: 20px; 
  margin: 16px 0 12px; 
  color: #111827; 
  border-bottom: 2px solid var(--primary); 
  padding-bottom: 6px; 
}

.result h2, .bubble h2 { 
  font-size: 18px; 
  margin: 14px 0 10px; 
  color: #1f2937; 
}

.result h3, .bubble h3 { 
  font-size: 16px; 
  margin: 12px 0 8px; 
  color: #374151; 
}

.result ul, .bubble ul,
.result ol, .bubble ol { 
  margin: 8px 0; 
  padding-left: 24px; 
}

.result li, .bubble li { 
  margin: 4px 0; 
  line-height: 1.6; 
}

.result p, .bubble p { 
  margin: 8px 0; 
  line-height: 1.6; 
}

.result code, .bubble code { 
  background: #f3f4f6; 
  padding: 2px 6px; 
  border-radius: 4px; 
  font-family: 'Courier New', monospace; 
  font-size: 0.9em; 
}

.result pre, .bubble pre { 
  background: #1f2937; 
  color: #f9fafb; 
  padding: 12px; 
  border-radius: 8px; 
  overflow-x: auto; 
  margin: 12px 0; 
}

.result pre code, .bubble pre code { 
  background: none; 
  padding: 0; 
  color: inherit; 
}

.result blockquote, .bubble blockquote { 
  border-left: 4px solid var(--primary); 
  padding-left: 12px; 
  margin: 12px 0; 
  color: #6b7280; 
  font-style: italic; 
}

.result table, .bubble table { 
  border-collapse: collapse; 
  width: 100%; 
  margin: 12px 0; 
}

.result th, .bubble th,
.result td, .bubble td { 
  border: 1px solid #e5e7eb; 
  padding: 8px 12px; 
  text-align: left; 
}

.result th, .bubble th { 
  background: #f9fafb; 
  font-weight: 600; 
}

.result hr, .bubble hr { 
  border: none; 
  border-top: 1px solid #e5e7eb; 
  margin: 16px 0; 
}

/* 思考中動畫 */
.thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  color: #6b7280;
  font-size: 14px;
}

.thinking::after {
  content: '...';
  animation: thinking-dots 1.5s infinite;
}

@keyframes thinking-dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* 錯誤樣式 */
.error {
  color: #dc2626;
  padding: 12px;
  background: #fee2e2;
  border-radius: 8px;
  border-left: 4px solid #dc2626;
}

/* ========== AI 市場案例樣式 ========== */
.ai-intro, .assistant-intro, .finance-intro { 
  color: var(--muted); 
  margin: 10px 0 16px; 
  font-size: 14px; 
}

.ai-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
  gap: 16px; 
}

.ai-card { 
  background: var(--card); 
  border-radius: var(--radius); 
  box-shadow: var(--shadow); 
  padding: 16px; 
  transition: transform 0.2s ease;
}

.ai-card:hover { 
  transform: translateY(-2px); 
}

.ai-card h3 { 
  margin: 0 0 12px; 
  font-size: 18px; 
  color: #111827; 
}

.ai-list { 
  margin: 0; 
  padding-left: 18px; 
  font-size: 14px; 
  line-height: 1.6; 
}

.ai-list li { 
  margin: 6px 0; 
}

.ai-metrics { 
  margin-top: 12px; 
  display: flex; 
  gap: 8px; 
  flex-wrap: wrap; 
}

.ai-metrics span { 
  background: #f3f4f6; 
  padding: 4px 10px; 
  border-radius: 999px; 
  font-size: 12px; 
  font-weight: 600; 
  color: #374151; 
}

/* ========== AI 助手樣式 ========== */
.chat-settings { 
  display: flex; 
  gap: 16px; 
  margin-bottom: 16px; 
  padding: 12px; 
  background: var(--card); 
  border-radius: var(--radius); 
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.chat-settings label { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  font-size: 14px; 
}

.chat-settings input[type="text"],
.chat-settings input[type="number"] { 
  padding: 6px 10px; 
  border: 1px solid #e5e7eb; 
  border-radius: 8px; 
  font-size: 14px; 
}

.chat-settings input[type="number"] { 
  width: 60px; 
}

/* 大型快速體驗按鈕 */
.quick-examples-large {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.example-btn-large {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  border: 2px solid #e2e8f0;
  background: white;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.example-btn-large:hover {
  border-color: var(--primary);
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.example-btn-large:active {
  transform: translateY(-2px);
}

.example-btn-large .btn-icon {
  font-size: 36px;
  margin-bottom: 4px;
}

.example-btn-large .btn-title {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 4px;
}

.example-btn-large .btn-desc {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
}

/* 簡化的輸入框 */
.simple-input-wrapper {
  margin-top: 16px;
}

.chat-form-simple {
  display: flex;
  gap: 8px;
  background: white;
  padding: 8px;
  border-radius: 24px;
  border: 2px solid #e5e7eb;
  transition: border-color 0.2s ease;
}

.chat-form-simple:focus-within {
  border-color: var(--primary);
}

.chat-form-simple input {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
}

.chat-form-simple button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-form-simple button:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
}

.chat-form-simple button:active {
  transform: scale(0.95);
}

.chat-form-simple button svg {
  transform: translateX(1px);
}

.chat-wrap { 
  background: var(--card); 
  border-radius: var(--radius); 
  box-shadow: var(--shadow); 
  padding: 16px; 
  max-height: 500px; 
  overflow-y: auto; 
  margin-bottom: 16px; 
}

#chat-list { 
  list-style: none; 
  margin: 0; 
  padding: 0; 
}

.msg { 
  display: flex; 
  gap: 12px; 
  margin-bottom: 16px; 
  align-items: flex-start; 
}

.msg.user { 
  flex-direction: row-reverse; 
}

.avatar { 
  width: 36px; 
  height: 36px; 
  border-radius: 50%; 
  background: var(--primary); 
  flex-shrink: 0; 
}

.msg.assistant .avatar { 
  background: #6366f1; 
}

.bubble { 
  background: #f3f4f6; 
  padding: 10px 14px; 
  border-radius: 12px; 
  max-width: 70%; 
}

.msg.user .bubble { 
  background: var(--primary); 
  color: var(--tab-active-text); 
}

.bubble .content { 
  margin: 0; 
  font-size: 14px; 
  line-height: 1.6; 
}

.chat-form { 
  display: flex; 
  gap: 12px; 
  background: var(--card); 
  padding: 12px; 
  border-radius: var(--radius); 
  box-shadow: var(--shadow); 
}

.chat-form textarea { 
  flex: 1; 
  padding: 10px 12px; 
  border: 1px solid #e5e7eb; 
  border-radius: 10px; 
  font-size: 14px; 
  font-family: inherit; 
  resize: vertical; 
}

.chat-form button { 
  padding: 10px 20px; 
  border: 0; 
  background: var(--primary); 
  color: var(--tab-active-text); 
  border-radius: 10px; 
  font-weight: 700; 
  cursor: pointer; 
  white-space: nowrap;
  transition: all 0.2s ease;
}

.chat-form button:hover { 
  opacity: 0.9; 
}

.chat-hint { 
  margin-top: 8px; 
  font-size: 12px; 
}

/* ========== AI 金融分析樣式 ========== */
.finance-grid { 
  display: grid; 
  grid-template-columns: repeat(2, 1fr); 
  gap: 16px; 
}

.finance-module { 
  background: var(--card); 
  border-radius: var(--radius); 
  box-shadow: var(--shadow); 
  padding: 16px; 
}

.finance-module h3 { 
  margin: 0 0 12px; 
  font-size: 18px; 
  color: #111827; 
}

.finance-module form { 
  display: grid; 
  gap: 10px; 
}

.finance-module label { 
  display: flex; 
  flex-direction: column; 
  gap: 4px; 
  font-size: 13px; 
  font-weight: 600; 
}

.finance-module input,
.finance-module select,
.finance-module textarea { 
  padding: 8px 10px; 
  border: 1px solid #e5e7eb; 
  border-radius: 8px; 
  font-size: 14px; 
  font-family: inherit; 
}

.finance-module button[type="submit"] { 
  padding: 10px; 
  border: 0; 
  background: var(--primary); 
  color: var(--tab-active-text); 
  border-radius: 10px; 
  font-weight: 700; 
  cursor: pointer; 
  margin-top: 6px;
  transition: all 0.2s ease;
}

.finance-module button[type="submit"]:hover { 
  opacity: 0.9; 
}

.finance-module .result { 
  margin-top: 12px; 
  padding: 12px; 
  background: #f8fafc; 
  border-radius: 8px; 
  min-height: 60px; 
  font-size: 13px; 
  line-height: 1.6; 
  white-space: pre-wrap; 
}

.checkbox-group { 
  display: flex; 
  gap: 12px; 
}

.checkbox-group label { 
  flex-direction: row; 
  align-items: center; 
  gap: 6px; 
}

/* ========== 結果操作按鈕 ========== */
.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

.result-actions button {
  padding: 6px 14px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #334155;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.result-actions button:hover {
  background: #f8fafc;
  border-color: var(--primary);
  color: var(--primary);
}

/* ========== 新聞項目樣式 ==========  */
.news-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.news-item:hover {
  transform: translateY(-2px);
}

.news-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 8px 0;
  line-height: 1.5;
}

.news-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #6b7280;
}

.news-source {
  font-weight: 500;
}

.news-time {
  color: #9ca3af;
}

.news-summary {
  font-size: 14px;
  color: #4b5563;
  line-height: 1.6;
  margin: 0;
}

/* ========== 空白狀態樣式 ========== */
.empty-state {
  text-align: center;
  padding: 0 !important;
}

.empty-content {
  padding: 60px 20px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-content h3 {
  font-size: 18px;
  color: #374151;
  margin: 0 0 8px 0;
}

.empty-content p {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 20px 0;
}

.btn-reload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  background: white;
  color: #374151;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reload:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fef3f2;
}

.btn-reload svg {
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .finance-grid { 
    grid-template-columns: 1fr; 
  }
  .ai-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}