/* ─────────────────────────────────────────────────────────────────────────
   SBIR 查詢工具 - 全域樣式
   深色主題 · 玻璃元素 · 現代卡片 UI
───────────────────────────────────────────────────────────────────────── */

/* ── CSS 變數 ────────────────────────────────────────────────────────────── */
:root {
  --bg-base:      #0d1117;
  --bg-surface:   #161b22;
  --bg-elevated:  #1c2433;
  --bg-hover:     #21293a;

  --accent:       #3b82f6;
  --accent-light: #60a5fa;
  --accent-dim:   rgba(59,130,246,.15);

  --green:  #22c55e;
  --yellow: #f59e0b;
  --red:    #ef4444;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --border:       rgba(255,255,255,.08);
  --border-hover: rgba(59,130,246,.4);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-card: 0 4px 24px rgba(0,0,0,.4);
  --shadow-glow: 0 0 20px rgba(59,130,246,.25);

  --font-body: 'Noto Sans TC', 'Inter', system-ui, sans-serif;
}

/* ── 重置 ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59,130,246,.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(99,102,241,.08), transparent);
}

/* ── 頂部標題列 ───────────────────────────────────────────────────────────── */
.site-header {
  background: rgba(22,27,34,.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.logo-icon { font-size: 2rem; }

.logo h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo p { font-size: .75rem; color: var(--text-secondary); }

.header-badge {
  padding: .25rem .75rem;
  background: var(--accent-dim);
  color: var(--accent-light);
  border: 1px solid rgba(59,130,246,.3);
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 500;
}

/* ── 分頁導覽 ─────────────────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: .25rem;
  padding: .75rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  font-size: .88rem;
  font-weight: 500;
  font-family: var(--font-body);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}

.tab-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--accent-dim);
  color: var(--accent-light);
  border-color: rgba(59,130,246,.3);
}

/* ── 主內容區 ─────────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-header { margin-bottom: 1.5rem; }
.panel-header h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem; }
.panel-header p  { font-size: .9rem; color: var(--text-secondary); }

/* ── 搜尋框 ───────────────────────────────────────────────────────────────── */
.search-box-wrap { margin-bottom: 1.5rem; }

.search-box {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .75rem 1rem;
  transition: border-color .2s, box-shadow .2s;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.search-icon { font-size: 1.1rem; flex-shrink: 0; }

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--text-primary);
}

.search-box input::placeholder { color: var(--text-muted); }

.search-clear {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .9rem;
  padding: .2rem .4rem;
  border-radius: var(--radius-sm);
  transition: color .2s;
}

.search-clear:hover { color: var(--text-primary); }

.search-hints {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .75rem;
}

.hint-label { font-size: .8rem; color: var(--text-muted); }

.hint-chip {
  padding: .3rem .7rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .8rem;
  font-family: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
}

.hint-chip:hover {
  background: var(--accent-dim);
  border-color: var(--border-hover);
  color: var(--accent-light);
}

.search-status {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-bottom: .75rem;
  min-height: 1.4em;
}

/* ── 搜尋結果卡片 ──────────────────────────────────────────────────────────── */
.results-grid {
  display: grid;
  gap: .75rem;
}

.result-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  transition: border-color .2s, transform .15s;
  cursor: default;
}

.result-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.result-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .4rem;
}

.result-category {
  font-size: .72rem;
  padding: .15rem .55rem;
  background: var(--accent-dim);
  color: var(--accent-light);
  border-radius: 99px;
  font-weight: 500;
}

.result-file {
  font-size: .72rem;
  color: var(--text-muted);
}

.result-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--text-primary);
}

.result-excerpt {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.55;
  white-space: pre-wrap;
}

.result-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: .95rem;
}

/* ── FAQ ──────────────────────────────────────────────────────────────────── */
.faq-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .6rem;
  margin-bottom: 1.5rem;
}

.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: .85rem .75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: .85rem;
  font-family: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}

.cat-btn:hover, .cat-btn.active {
  background: var(--accent-dim);
  border-color: var(--border-hover);
  color: var(--accent-light);
}

.cat-icon { font-size: 1.4rem; }

.faq-list { display: grid; gap: .6rem; }

.faq-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color .2s;
}

.faq-item:hover { border-color: var(--border-hover); }

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .9rem 1.1rem;
  cursor: pointer;
  font-weight: 500;
  font-size: .95rem;
  gap: 1rem;
  user-select: none;
}

.faq-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform .25s;
}

.faq-item.open .faq-arrow { transform: rotate(180deg); }

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, padding .3s;
  font-size: .88rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.faq-item.open .faq-answer {
  max-height: 600px;
  padding: 0 1.1rem 1rem;
  white-space: pre-wrap;
}

/* ── 檢核清單 ─────────────────────────────────────────────────────────────── */
.checklist-tabs {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.cl-tab {
  padding: .45rem .9rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .82rem;
  font-family: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
}

.cl-tab:hover, .cl-tab.active {
  background: var(--accent-dim);
  border-color: var(--border-hover);
  color: var(--accent-light);
}

.checklist-score-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .9rem 1.1rem;
  margin-bottom: 1.2rem;
}

.score-info {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  color: var(--text-secondary);
  margin-bottom: .5rem;
}

#score-count, #score-total { color: var(--accent-light); font-weight: 700; }
#score-pct { font-weight: 700; color: var(--green); }

.score-track {
  background: var(--bg-base);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width .4s ease;
  width: 0%;
}

.checklist-content { display: grid; gap: .75rem; margin-bottom: 1rem; }

.cl-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.cl-section-title {
  padding: .7rem 1rem;
  font-weight: 600;
  font-size: .9rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.cl-items { padding: .5rem 0; }

.cl-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .5rem 1rem;
  cursor: pointer;
  transition: background .15s;
}

.cl-item:hover { background: var(--bg-hover); }

.cl-item input[type="checkbox"] { display: none; }

.cl-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-hover);
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  font-size: .7rem;
}

.cl-item.checked .cl-checkbox {
  background: var(--green);
  border-color: var(--green);
}

.cl-item.checked .cl-checkbox::after { content: '✓'; color: #fff; }

.cl-item-text {
  font-size: .88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.cl-item.checked .cl-item-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.checklist-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
}

/* ── 計畫書生成器 ─────────────────────────────────────────────────────────── */
.generator-form { max-width: 700px; margin: 0 auto; }

.gen-progress-wrap { margin-bottom: 1.5rem; }

.gen-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  color: var(--text-secondary);
  margin-bottom: .4rem;
}

#gen-pct { color: var(--accent-light); font-weight: 600; }

.gen-progress-track {
  background: var(--bg-surface);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}

.gen-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 99px;
  transition: width .4s ease;
}

.question-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow-card);
}

.q-badge {
  display: inline-block;
  padding: .2rem .65rem;
  background: var(--accent-dim);
  color: var(--accent-light);
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
  margin-bottom: .9rem;
}

.q-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

#q-input-wrap textarea,
#q-input-wrap input[type="text"],
#q-input-wrap input[type="number"] {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .95rem;
  padding: .7rem 1rem;
  outline: none;
  transition: border-color .2s;
  resize: vertical;
}

#q-input-wrap textarea:focus,
#q-input-wrap input:focus {
  border-color: var(--accent);
}

#q-input-wrap .radio-group {
  display: grid;
  gap: .5rem;
}

.radio-opt {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all .15s;
  font-size: .9rem;
}

.radio-opt:hover, .radio-opt.selected {
  border-color: var(--border-hover);
  background: var(--accent-dim);
  color: var(--accent-light);
}

.radio-opt input { display: none; }

.q-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  gap: .75rem;
}

/* 生成結果 */
.proposal-result { max-width: 900px; margin: 0 auto; }

.hidden { display: none !important; }

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: .5rem;
}

.result-header h3 { font-size: 1.2rem; }

.proposal-text {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  font-size: .88rem;
  font-family: var(--font-body);
  color: var(--text-secondary);
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
}

/* ── 快速指南 ─────────────────────────────────────────────────────────────── */
.guide-tabs {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.guide-tab {
  padding: .5rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .85rem;
  font-family: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
}

.guide-tab:hover, .guide-tab.active {
  background: var(--accent-dim);
  border-color: var(--border-hover);
  color: var(--accent-light);
}

.guide-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  line-height: 1.75;
  color: var(--text-secondary);
  white-space: pre-wrap;
  font-size: .9rem;
  max-height: 75vh;
  overflow-y: auto;
}

/* ── 按鈕 ─────────────────────────────────────────────────────────────────── */
.btn-primary {
  padding: .55rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: .9rem;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.btn-primary:hover  { background: #2563eb; }
.btn-primary:active { transform: scale(.97); }

.btn-ghost {
  padding: .55rem 1.2rem;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: .9rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all .15s;
}

.btn-ghost:hover { border-color: var(--border-hover); color: var(--text-primary); }
.btn-ghost:disabled { opacity: .35; cursor: default; }

/* ── 問卷表單 ─────────────────────────────────────────────────────────────── */
.guide-form { animation: fadeIn .2s ease; }

.form-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  overflow: hidden;
}

.form-section-title {
  padding: .7rem 1rem;
  font-weight: 600;
  font-size: .9rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: .75rem;
  align-items: center;
  padding: .65rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
}

.form-row:last-child { border-bottom: none; }

.form-row label {
  font-size: .88rem;
  color: var(--text-secondary);
}

.form-row select,
.form-row input[type="text"],
.form-row input[type="number"] {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .88rem;
  padding: .45rem .7rem;
  outline: none;
  width: 100%;
  transition: border-color .2s;
}

.form-row select:focus,
.form-row input:focus { border-color: var(--accent); }

.form-row textarea {
  grid-column: 1 / -1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .88rem;
  padding: .6rem .8rem;
  outline: none;
  width: 100%;
  resize: vertical;
  transition: border-color .2s;
}

.form-row textarea:focus { border-color: var(--accent); }

.guide-submit { margin-top: .5rem; width: 100%; padding: .75rem; font-size: 1rem; }

/* ── 報告輸出 ─────────────────────────────────────────────────────────────── */
.guide-report { animation: fadeIn .25s ease; }

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: .5rem;
}

.report-header h3 { font-size: 1.15rem; }

.report-body { display: grid; gap: .75rem; }

.result-banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: .95rem;
  border: 1px solid;
}

.result-icon { font-size: 1.4rem; flex-shrink: 0; }

.result-ok   { background: rgba(34,197,94,.12);  border-color: rgba(34,197,94,.3);  color: #4ade80; }
.result-warn { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #fbbf24; }
.result-fail { background: rgba(239,68,68,.12);  border-color: rgba(239,68,68,.3);  color: #f87171; }

.report-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.report-section-title {
  padding: .6rem 1rem;
  font-weight: 600;
  font-size: .85rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.report-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: .88rem;
  gap: 1rem;
}

.report-row:last-child { border-bottom: none; }
.report-row > span:first-child { color: var(--text-secondary); }

.report-list {
  padding: .5rem 1rem .75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.report-list li { font-size: .88rem; color: var(--text-secondary); line-height: 1.55; }

.report-quote {
  margin: .5rem 1rem;
  padding: .6rem .9rem;
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .88rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Badge */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-ok   { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge-warn { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-fail { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-muted{ background: var(--bg-elevated);   color: var(--text-muted); }

/* 評分摘要 */
.score-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .5rem;
  margin-bottom: .25rem;
}

.score-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .7rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.score-item span { font-size: .78rem; color: var(--text-muted); }
.score-item b    { font-size: 1.15rem; color: var(--accent-light); }

/* 市場試算 */
.market-calc {
  padding: .5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.market-calc > div {
  display: flex;
  justify-content: space-between;
  font-size: .88rem;
  padding: .3rem 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}

.market-calc > div:last-child { border: none; }
.market-calc span { color: var(--text-secondary); }
.market-calc b    { color: var(--accent-light); }

/* 每日行程表 */
.schedule-table { font-size: .85rem; }

.schedule-header {
  display: grid;
  grid-template-columns: 90px 100px 1fr;
  gap: .5rem;
  padding: .5rem 1rem;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .8rem;
  border-bottom: 1px solid var(--border);
}

.schedule-row {
  display: grid;
  grid-template-columns: 90px 100px 1fr;
  gap: .5rem;
  padding: .55rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  align-items: center;
}

.schedule-row:last-child { border: none; }

.schedule-day   { color: var(--accent-light); font-weight: 600; }
.schedule-focus { color: var(--text-primary); font-weight: 500; }
.schedule-tasks { color: var(--text-secondary); }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.site-footer a { color: var(--accent-light); text-decoration: none; }

/* ── 捲軸 ─────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Modal 彈窗 ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn .2s ease;
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  animation: slideUp .25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header > div { display: flex; flex-direction: column; gap: .35rem; }
.modal-header h3    { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }

.modal-close {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: .85rem;
  flex-shrink: 0;
  transition: all .15s;
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-file {
  padding: .4rem 1.5rem .6rem;
  font-size: .72rem;
  color: var(--text-muted);
  font-family: monospace;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  font-size: .9rem;
  color: var(--text-secondary);
  line-height: 1.75;
  white-space: pre-wrap;
  flex: 1;
}

/* 讓搜尋卡片可點擊 */
.result-card {
  cursor: pointer;
}

.result-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(59,130,246,.15);
}

.result-card::after {
  content: '點擊查看完整內容 →';
  display: block;
  margin-top: .5rem;
  font-size: .75rem;
  color: var(--accent-light);
  opacity: 0;
  transition: opacity .2s;
}

.result-card:hover::after { opacity: 1; }

/* ── 市場數據分頁 ─────────────────────────────────────────────────────────── */
.market-industry-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: 1.25rem;
}

.market-ind-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .9rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .84rem;
  font-family: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
}

.market-ind-btn:hover, .market-ind-btn.active {
  background: var(--accent-dim);
  border-color: var(--border-hover);
  color: var(--accent-light);
}

.market-content { display: grid; gap: 1rem; margin-bottom: 1.25rem; min-height: 80px; }

.market-placeholder {
  color: var(--text-muted);
  font-size: .9rem;
  padding: .5rem;
  align-self: center;
}

/* 數字數據表 */
.market-key-data {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.market-key-data-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: .5rem;
  padding: .5rem 1rem;
  background: var(--bg-elevated);
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.market-key-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: .5rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  align-items: center;
  font-size: .88rem;
}

.market-key-row:last-child { border: none; }
.market-key-metric { color: var(--text-secondary); }
.market-key-value  { color: var(--accent-light); font-weight: 600; text-align: right; }
.market-key-source { color: var(--text-muted); font-size: .75rem; text-align: right; }

/* 數據來源卡片 */
.market-sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .6rem;
}

.market-source-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  transition: border-color .15s;
  text-decoration: none;
}

.market-source-card:hover { border-color: var(--border-hover); }

.ms-name { font-weight: 600; font-size: .9rem; color: var(--accent-light); }
.ms-note { font-size: .78rem; color: var(--text-muted); line-height: 1.4; }

/* 計算機 */
.market-calc-section {
  margin-bottom: 1rem;
}

.market-calc-section h3 { margin-bottom: .3rem; font-size: 1rem; }
.market-calc-desc { font-size: .83rem; color: var(--text-muted); margin-bottom: 1rem; }

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
  margin-bottom: .75rem;
}

.calc-input-block {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.calc-input-block label {
  font-size: .82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.calc-input-block input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .9rem;
  padding: .5rem .75rem;
  outline: none;
  transition: border-color .2s;
}

.calc-input-block input:focus { border-color: var(--accent); }
.calc-hint { font-size: .73rem; color: var(--text-muted); }

.calc-result {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: .25rem;
}

.calc-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: .88rem;
}

.calc-result-row:last-of-type { border: none; }

.calc-result-note {
  padding: .5rem 1.1rem .7rem;
  font-size: .78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.market-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* 免費資源 */
.market-free-sources h3 { margin-bottom: .75rem; font-size: 1rem; }

.free-sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .6rem;
}

.free-source-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  text-decoration: none;
  transition: all .15s;
  text-align: center;
  cursor: pointer;
}

.free-source-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  background: var(--accent-dim);
}

.fs-icon { font-size: 1.5rem; }
.fs-name { font-size: .85rem; font-weight: 600; color: var(--accent-light); }
.fs-note { font-size: .73rem; color: var(--text-muted); line-height: 1.35; }

/* ── 補助查詢分頁 ─────────────────────────────────────────────────────────── */
.subsidy-update-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .55rem 1rem;
  font-size: .82rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: .5rem;
}

.subsidy-update-bar.stale { border-color: rgba(245,158,11,.5); color: #fbbf24; }

.subsidy-refresh-btn {
  padding: .3rem .75rem;
  font-size: .78rem;
}

.subsidy-toolbar {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-bottom: 1rem;
}

.subsidy-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.subsidy-search-wrap .search-icon {
  position: absolute;
  left: .85rem;
  pointer-events: none;
  font-size: .95rem;
}

#subsidy-q {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .9rem;
  padding: .6rem 1rem .6rem 2.5rem;
  outline: none;
  transition: border-color .2s;
}

#subsidy-q:focus { border-color: var(--accent); }

.subsidy-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.subsidy-filters select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: .82rem;
  padding: .4rem .65rem;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}

.subsidy-filters select:focus { border-color: var(--accent); }

.subsidy-show-closed {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .82rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.subsidy-count {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

/* Card grid */
.subsidy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: .85rem;
}

.subsidy-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  cursor: pointer;
}

.subsidy-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(59,130,246,.12);
}

/* Status flag */
.subsidy-flag {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  font-weight: 600;
  justify-content: space-between;
}

.flag-badge {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}

.flag-open     { background: rgba(34,197,94,.15);  color: #4ade80; }
.flag-closing  { background: rgba(245,158,11,.15); color: #fbbf24; }
.flag-ongoing  { background: rgba(96,165,250,.15); color: #60a5fa; }
.flag-unknown  { background: var(--bg-elevated);   color: var(--text-muted); }
.flag-closed   { background: rgba(100,116,139,.1); color: #94a3b8; }

.subsidy-countdown {
  font-size: .75rem;
  color: var(--text-muted);
}

.subsidy-card-name {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.subsidy-card-org {
  font-size: .78rem;
  color: var(--text-muted);
}

.subsidy-card-desc {
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.subsidy-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.subsidy-meta-pill {
  padding: .18rem .55rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .72rem;
  color: var(--text-secondary);
}

.subsidy-card-actions {
  display: flex;
  gap: .5rem;
  margin-top: .25rem;
}

.subsidy-detail-btn {
  flex: 1;
  padding: .45rem .75rem;
  background: var(--accent-dim);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  color: var(--accent-light);
  font-size: .82rem;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  text-align: center;
}

.subsidy-detail-btn:hover { background: rgba(59,130,246,.25); }

.subsidy-url-btn {
  padding: .45rem .75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .82rem;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .3rem;
  transition: border-color .15s;
  white-space: nowrap;
}

.subsidy-url-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }

.subsidy-empty {
  color: var(--text-muted);
  font-size: .9rem;
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
}

/* Subsidy modal */
.subsidy-modal-meta {
  padding: .75rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sm-meta-item {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.sm-meta-label {
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sm-meta-value {
  font-size: .85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.subsidy-modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.sm-section-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: .4rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--border);
}

.sm-tag-wrap { display: flex; flex-wrap: wrap; gap: .3rem; }

.sm-tag {
  padding: .2rem .55rem;
  background: var(--accent-dim);
  border-radius: 99px;
  font-size: .73rem;
  color: var(--accent-light);
}

.sm-list { display: flex; flex-direction: column; gap: .3rem; }

.sm-list-item {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.sm-list-item::before { content: '•'; color: var(--accent-light); flex-shrink: 0; }

.sm-url-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: .88rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
  align-self: flex-start;
}

.sm-url-btn:hover { background: #2563eb; }

/* ── 響應式 ───────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner { padding: .7rem 1rem; }
  .tab-nav      { padding: .5rem 1rem; }
  .main-content { padding: .75rem 1rem 2rem; }
  .faq-categories { grid-template-columns: repeat(2, 1fr); }
  .q-nav { flex-direction: column-reverse; }
}
