/* E×Impeccable — Production design system */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;1,14..32,400&display=swap');

:root {
  --bg:       oklch(97.5% 0.007 55);
  --surface:  oklch(99.5% 0.003 55);
  --hdr:      oklch(14% 0.022 260);
  --red:      oklch(52% 0.22 27);
  --gold:     oklch(72% 0.13 76);
  --green:    oklch(50% 0.15 145);
  --blue:     oklch(48% 0.18 255);
  --text:     oklch(16% 0.012 255);
  --mid:      oklch(46% 0.015 255);
  --dim:      oklch(66% 0.012 255);
  --border:   oklch(90% 0.008 255);
  --hdr-text: oklch(97% 0.005 255);

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;

  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Header ─────────────────────────────────────────────────────── */

.site-header {
  background: var(--hdr);
  color: var(--hdr-text);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .brand { position: absolute; left: 2rem; }

.brand {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--hdr-text);
  text-decoration: none;
  white-space: nowrap;
}

.brand span { color: var(--red); }

.site-nav { display: flex; list-style: none; }

.site-nav a {
  display: block;
  padding: 0 1.125rem;
  height: 56px;
  line-height: 56px;
  font-size: 0.875rem;
  font-weight: 500;
  color: oklch(68% 0.012 255);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.site-nav a:hover { color: var(--hdr-text); }
.site-nav a.active {
  color: var(--hdr-text);
  border-bottom-color: var(--red);
}

/* ── Layout ─────────────────────────────────────────────────────── */

.page-main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 2rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.5rem;
}

.sidebar { display: flex; flex-direction: column; gap: 1.5rem; }

/* ── KPI row ─────────────────────────────────────────────────────── */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.25rem 1.5rem;
}

.kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi-value.accent { color: var(--red); }

.kpi-hint {
  font-size: 0.7rem;
  color: var(--dim);
  margin-top: 0.5rem;
  line-height: 1.4;
}

a.kpi-card:hover {
  border-color: oklch(78% 0.012 255);
  box-shadow: 0 2px 8px oklch(0% 0 0 / 0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* ── Section titles ──────────────────────────────────────────────── */

.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 1rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border);
}

/* ── Score dots ──────────────────────────────────────────────────── */

.score-dots { display: flex; gap: 3px; align-items: center; }

.score-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.score-dot.pain      { background: var(--red); }
.score-dot.product   { background: var(--blue); }
.score-dot.market    { background: var(--gold); }
.score-dot.innovation{ background: var(--green); }

/* ── Signal table ────────────────────────────────────────────────── */

.signal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.signal-table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.signal-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.signal-table tr:hover td { background: oklch(96.5% 0.006 55); }

.signal-table .title-cell a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.signal-table .title-cell a:hover { color: var(--red); }
.signal-table .title-cell span { font-weight: 500; }

.tag-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: oklch(93% 0.01 255);
  color: var(--mid);
  white-space: nowrap;
}

/* ── Keyword cloud ───────────────────────────────────────────────── */

.keyword-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.keyword-pill {
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--mid);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}

.keyword-pill:hover,
.keyword-pill.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ── Bar chart ───────────────────────────────────────────────────── */

.bar-chart { display: flex; flex-direction: column; gap: 0.625rem; }

.bar-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.75rem;
}

.bar-label { font-size: 0.78rem; color: var(--mid); text-align: right; }
.bar-track  { background: var(--border); border-radius: 2px; height: 7px; overflow: hidden; }
.bar-fill   { height: 100%; background: var(--red); border-radius: 2px; transition: width 0.7s cubic-bezier(0.16,1,0.3,1); width: 0; }
.bar-count  { font-size: 0.78rem; color: var(--dim); font-variant-numeric: tabular-nums; }

/* ── Pagination ──────────────────────────────────────────────────── */

.pagination {
  display: flex;
  gap: 0.375rem;
  margin-top: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.pagination button {
  height: 30px;
  padding: 0 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--mid);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.pagination button:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.pagination button.active { background: var(--red); border-color: var(--red); color: #fff; }
.pagination button:disabled { opacity: 0.35; cursor: default; }
.pagination .page-info { font-size: 0.78rem; color: var(--dim); margin-left: 0.25rem; }

/* ── Forms ───────────────────────────────────────────────────────── */

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mid);
}

.form-control {
  height: 38px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.form-control:focus { border-color: var(--red); }
.form-control.wide { min-width: 260px; }

.btn {
  height: 38px;
  padding: 0 1.125rem;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s;
  white-space: nowrap;
}

.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: oklch(46% 0.22 27); }
.btn-primary:disabled { opacity: 0.45; cursor: default; }

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--mid);
}

.btn-ghost:hover { border-color: var(--mid); color: var(--text); }

/* ── Status / spinner ────────────────────────────────────────────── */

.status-bar {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--mid);
}

.spinner {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Gap result ──────────────────────────────────────────────────── */

.gap-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.75rem;
  margin-top: 1.25rem;
}

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

.gap-result-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
}

.opp-score {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: oklch(96% 0.025 145);
  border: 1px solid var(--green);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--green);
}

.gap-section { margin-bottom: 1.125rem; }

.gap-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.3rem;
}

.gap-section-content {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.65;
}

/* ── Report ──────────────────────────────────────────────────────── */

.report-wrapper { max-width: 840px; }

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

.report-path { font-size: 0.78rem; color: var(--dim); }

.report-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2.5rem 3rem;
  line-height: 1.8;
}

.report-content h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.report-content h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 2rem 0 0.625rem;
  color: var(--text);
}

.report-content h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 1.25rem 0 0.375rem;
  color: var(--mid);
}

.report-content p {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  max-width: 72ch;
}

.report-content ul,
.report-content ol {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.report-content li {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  max-width: 72ch;
}

.report-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 1rem 0;
}

.report-content th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: oklch(95% 0.007 55);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.8rem;
}

.report-content td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
}

/* ── Page heading ────────────────────────────────────────────────── */

.page-heading { margin-bottom: 2rem; }
.page-heading h1 { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.375rem; }
.page-heading p  { font-size: 0.875rem; color: var(--mid); max-width: 60ch; }

/* ── 使用情境：浮動按鈕 + modal（三頁共用）────────── */

.uc-btn {
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .14);
  color: oklch(78% .012 255);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: .35rem .8rem .35rem .65rem;
  border-radius: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: inherit;
  transition: all .18s ease;
}
.uc-btn::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: oklch(70% .15 255);
  box-shadow: 0 0 6px oklch(70% .15 255 / .55);
}
.uc-btn:hover {
  color: var(--hdr-text);
  background: rgba(255, 255, 255, .1);
  border-color: oklch(70% .15 255);
  transform: translateY(calc(-50% - 1px));
}

@media (max-width: 700px) {
  .uc-btn { right: 1rem; padding: .3rem .65rem .3rem .55rem; font-size: .68rem; }
}

.uc-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 18, 22, .35);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 1rem 1rem;
  backdrop-filter: blur(2px);
  animation: ucFadeIn .15s ease-out;
}
.uc-modal-backdrop.open { display: flex; }

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

.uc-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid oklch(55% .15 255);
  border-radius: 12px;
  width: 100%;
  max-width: 880px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(15,18,22,.18);
  animation: ucSlideUp .22s ease-out;
}

.uc-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem .85rem;
  border-bottom: 1px solid var(--border);
}
.uc-modal-title {
  font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; gap: .5rem;
}
.uc-modal-title .uc-tag {
  font-size: .65rem; font-weight: 600;
  color: oklch(55% .15 255);
  background: oklch(96% .025 255);
  padding: .15rem .55rem;
  border-radius: 12px;
  letter-spacing: .04em;
}
.uc-modal-close {
  background: none; border: none;
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  color: var(--dim); padding: 0 .25rem;
  font-family: inherit; transition: color .15s;
}
.uc-modal-close:hover { color: var(--text); }

.uc-modal-body {
  padding: 1rem 1.25rem 1.25rem;
}
.ucc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}
.ucc-cell {
  display: flex; flex-direction: column; gap: .35rem;
  padding: .65rem .85rem;
  background: oklch(98% .005 255);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.ucc-cell-head {
  display: flex; align-items: center; gap: .35rem;
  font-size: .72rem; font-weight: 700;
  color: var(--text);
  letter-spacing: .03em;
}
.ucc-cell-head .icon { font-size: .95rem; }
.ucc-cell-body {
  font-size: .8rem; color: var(--mid); line-height: 1.6;
}
.ucc-cell-body strong { color: var(--text); font-weight: 700; }
.ucc-cell-body ul { padding-left: 1rem; margin: .25rem 0 0; }
.ucc-cell-body li { margin-bottom: .2rem; }
.role-chip {
  display: inline-block;
  font-size: .7rem;
  background: var(--surface);
  color: var(--mid);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .15rem .5rem;
  margin: .1rem .2rem .1rem 0;
}

.ucc-tech {
  padding: .75rem .9rem;
  background: oklch(20% .02 255);
  color: oklch(92% .005 255);
  border-radius: var(--r-sm);
  font-size: .76rem;
  line-height: 1.6;
}
.ucc-tech strong { color: oklch(82% .14 60); font-weight: 700; }
.ucc-tech code {
  background: oklch(28% .02 255);
  border-radius: 3px; padding: .05rem .35rem;
  font-family: ui-monospace, monospace; font-size: .9em;
  color: oklch(86% .08 255);
}

@media (max-width: 700px) {
  .ucc-grid { grid-template-columns: 1fr; }
  .uc-btn { top: auto; bottom: 1rem; right: 1rem; }
}

/* ── （舊版 inline 卡片殘餘樣式，保留避免破版）──── */

.use-case-card {
  background: linear-gradient(180deg, oklch(98% .005 255), var(--surface));
  border: 1px solid var(--border);
  border-left: 3px solid oklch(55% .15 255);
  border-radius: var(--r-md);
  margin-bottom: 1.25rem;
  overflow: hidden;
  transition: box-shadow .18s ease;
}
.use-case-card:hover { box-shadow: 0 2px 10px rgba(15,18,22,.04); }

.ucc-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: .65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: inherit;
  text-align: left;
  color: var(--text);
}
.ucc-toggle:hover { background: oklch(98% .008 255); }

.ucc-title {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.ucc-title::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: oklch(55% .15 255);
}
.ucc-tag {
  font-size: .65rem; font-weight: 600;
  color: var(--mid); padding: .15rem .5rem;
  border: 1px solid var(--border); border-radius: 20px;
  margin-left: .5rem;
  letter-spacing: .04em;
}

.ucc-chevron {
  font-size: .75rem; color: var(--dim);
  transition: transform .2s ease;
}
.use-case-card.collapsed .ucc-chevron { transform: rotate(-90deg); }

.ucc-body {
  padding: 0 1rem 1rem;
  border-top: 1px dashed var(--border);
  display: block;
}
.use-case-card.collapsed .ucc-body { display: none; }

.ucc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  padding-top: .85rem;
}
.ucc-cell {
  display: flex; flex-direction: column; gap: .3rem;
  padding: .55rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  min-width: 0;
}
.ucc-cell-head {
  display: flex; align-items: center; gap: .35rem;
  font-size: .7rem; font-weight: 700;
  color: var(--text);
  letter-spacing: .03em;
}
.ucc-cell-head .icon { font-size: .9rem; }
.ucc-cell-body {
  font-size: .76rem; color: var(--mid); line-height: 1.55;
}
.ucc-cell-body strong { color: var(--text); font-weight: 700; }
.ucc-cell-body ul { padding-left: 1rem; margin: .2rem 0 0; }
.ucc-cell-body li { margin-bottom: .15rem; }
.ucc-cell .role-chip {
  display: inline-block;
  font-size: .68rem;
  background: oklch(95% .015 255);
  color: var(--mid);
  border-radius: 4px;
  padding: .1rem .45rem;
  margin: .1rem .2rem .1rem 0;
}

.ucc-tech {
  margin-top: .85rem;
  padding: .55rem .75rem;
  background: oklch(96% .008 255);
  border-radius: var(--r-sm);
  font-size: .72rem;
  color: var(--mid);
  line-height: 1.55;
}
.ucc-tech::before {
  content: "⚙ "; color: oklch(55% .15 255); font-weight: 700;
}
.ucc-tech strong { color: var(--text); font-weight: 700; }
.ucc-tech code {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 3px; padding: .05rem .35rem;
  font-family: ui-monospace, monospace; font-size: .92em;
}

@media (max-width: 1100px) {
  .ucc-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .ucc-grid { grid-template-columns: 1fr; }
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ── 響應式 header（避免 nav 跟 brand 撞在一起）──────────────────── */
@media (max-width: 1100px) {
  .site-header { padding: 0 1rem; }
  .site-header .brand { left: 1rem; }
  .site-nav a { padding: 0 0.7rem; font-size: 0.82rem; }
}

@media (max-width: 880px) {
  /* brand 改為內聯，header 容器改為左右排版 */
  .site-header {
    justify-content: space-between;
    padding: 0 1rem;
  }
  .site-header .brand { position: static; }
  .site-nav { gap: 0; }
  .site-nav a { padding: 0 0.55rem; font-size: 0.78rem; }
  .brand { font-size: 0.82rem; }
  /* AI 助手 / 缺口圖譜頁的「歷史紀錄」按鈕在這邊不放 header，避免再擠 */
  .uc-btn { display: none; }
}

@media (max-width: 720px) {
  /* nav 自行可橫向 scroll，brand 永遠看得到 */
  .site-header {
    flex-wrap: wrap;
    height: auto;
    padding: .5rem 1rem;
    align-items: center;
  }
  .site-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    max-width: 100%;
  }
  .site-nav a {
    white-space: nowrap;
    height: 44px; line-height: 44px;
    padding: 0 .65rem;
  }
}

@media (max-width: 540px) {
  .page-main { padding: 1rem; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.25rem; }
  .kpi-value { font-size: 1.75rem; }
  .report-content { padding: 1.5rem; }
}
