:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1d2630;
  --muted: #647282;
  --line: #dce3ea;
  --nav: #162331;
  --nav-soft: #243445;
  --accent: #2f6f8f;
  --accent-strong: #1f5975;
  --green: #23785b;
  --blue: #326fa8;
  --yellow: #9a7118;
  --red: #a8453d;
  --shadow: 0 18px 40px rgba(22, 35, 49, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  color: #e7edf3;
  background: var(--nav);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #24384c;
  font-weight: 700;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #9eb0c2;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: #c8d3de;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: var(--nav-soft);
}

.icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #d6e4ef;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #b8c7d5;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #63c69d;
}

.status-dot.pending {
  background: var(--yellow);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: 28px;
  font-weight: 760;
}

h2 {
  font-size: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  border: 0;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
}

.compact-button {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.text-button {
  border: 0;
  padding: 0 8px;
  color: var(--accent);
  background: transparent;
  font-weight: 700;
}

.icon-button {
  width: 38px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.metric-card p,
.panel p {
  margin: 8px 0 0;
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.commercial-grid {
  margin-top: 18px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header.tight {
  margin-bottom: 8px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.project-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.project-table th,
.project-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.project-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill.green {
  color: #0f513c;
  background: #dff3ea;
}

.pill.blue {
  color: #184b77;
  background: #e3f0fb;
}

.pill.yellow {
  color: #6b4a00;
  background: #fff1c9;
}

.pill.red {
  color: #7f231b;
  background: #f9dedb;
}

.task-list,
.check-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-list li,
.check-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}

.priority {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.priority.high {
  background: var(--red);
}

.priority.mid {
  background: var(--yellow);
}

.priority.low {
  background: var(--blue);
}

.dropzone {
  display: grid;
  min-height: 280px;
  place-items: center;
  gap: 10px;
  padding: 32px;
  border: 2px dashed #bfd0df;
  border-radius: 8px;
  background: #f8fbfd;
  text-align: center;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: #eaf5fa;
  box-shadow: inset 0 0 0 2px rgba(50, 120, 157, 0.12);
}

.drop-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: #e7f2f8;
  font-size: 28px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.knowledge-form {
  grid-template-columns: minmax(280px, 1.4fr) minmax(180px, 0.7fr);
}

.form-action-slot {
  display: flex;
  align-items: end;
}

.form-action-slot .primary-button {
  width: 100%;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

input:focus,
select:focus {
  border-color: #84b4ca;
  outline: 3px solid #dff0f7;
}

.format-card {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.form-status,
.gate-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #efd28e;
  border-radius: 8px;
  color: #6b4a00;
  background: #fff8e6;
  font-size: 14px;
  font-weight: 700;
}

.form-status.complete {
  border-color: #aed9c9;
  color: #0f513c;
  background: #e7f6ef;
}

.setup-next {
  width: 100%;
  margin-top: 14px;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.gate-banner.unlocked {
  border-color: #aed9c9;
  color: #0f513c;
  background: #e7f6ef;
}

.optional-banner {
  margin-bottom: 14px;
}

.summary-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.summary-grid span,
.summary-grid strong {
  display: block;
}

.summary-grid span {
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  margin-top: 6px;
  font-size: 20px;
}

.mapping-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
}

.chapter-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.chapter {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.chapter.active {
  border-color: #94bdd2;
  background: #edf6fa;
}

.chapter span {
  color: var(--muted);
  font-size: 12px;
}

.source-map {
  display: grid;
  align-content: start;
  gap: 12px;
}

.source-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.dynamic-list {
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.knowledge-list {
  margin-top: 14px;
}

.knowledge-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.knowledge-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.knowledge-title-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.knowledge-item p {
  overflow-wrap: anywhere;
}

.knowledge-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-card,
.job-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.project-card.active {
  border-color: #94bdd2;
  background: #edf6fa;
}

.project-card h3,
.job-card h3 {
  margin: 0;
  font-size: 15px;
}

.project-meta,
.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.job-card.failed {
  border-color: #efc0bc;
  background: #fff7f6;
}

.job-card.completed {
  border-color: #bfe2d3;
}

.job-card.running {
  border-color: #b7d5e7;
  background: #f4fbff;
}

.job-card.canceled {
  border-color: #e1d1a6;
  background: #fffaf0;
}

.job-status-stack {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.job-actions button {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.job-progress {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe8ef;
}

.job-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.knowledge-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.commercial-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.system-message {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.system-message.ready {
  border-color: #aed9c9;
  color: #0f513c;
  background: #e7f6ef;
}

.system-settings-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.llm-preflight-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.llm-preflight-panel h3 {
  margin: 0;
  font-size: 16px;
}

.llm-preflight-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.preflight-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid #e4edf3;
  border-radius: 8px;
  background: #fbfcfd;
}

.preflight-row strong {
  display: block;
  font-size: 14px;
}

.preflight-row p,
.preflight-empty {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.preflight-empty.error {
  color: var(--danger);
}

.preflight-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: #d6e3eb;
}

.preflight-row.passed .preflight-dot {
  background: var(--good);
}

.preflight-row.warning .preflight-dot {
  background: var(--warn);
}

.preflight-row.failed .preflight-dot {
  background: var(--danger);
}

.preflight-row.info .preflight-dot {
  background: var(--accent);
}

.command-box {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.command-row,
.command-ready {
  padding: 10px;
  border-radius: 8px;
  background: #eef5fa;
  color: var(--ink);
  font-size: 13px;
}

.command-row {
  display: grid;
  gap: 5px;
}

.command-row code {
  display: block;
  padding: 8px;
  border-radius: 6px;
  background: #142231;
  color: #eef7ff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.deployment-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 18px;
  align-items: center;
}

.deployment-hero h2 {
  margin: 0;
  font-size: 26px;
}

.deployment-score-card {
  display: grid;
  min-width: 112px;
  justify-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.deployment-score-card span {
  color: var(--accent-strong);
  font-size: 30px;
  font-weight: 800;
}

.deployment-score-card strong {
  margin-top: 2px;
  font-size: 14px;
}

.deployment-report-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.deployment-grid {
  margin-top: 18px;
}

.deployment-checklist,
.deployment-actions {
  display: grid;
  gap: 12px;
}

.deployment-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.deployment-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.deployment-section-title h3 {
  margin: 0;
  font-size: 16px;
}

.deployment-section-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.deployment-section.blocked {
  border-color: #efc6c3;
}

.deployment-section.warning {
  border-color: #f3deaa;
}

.action-hint {
  color: var(--accent-strong) !important;
  font-weight: 700;
}

.release-checklist {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.release-checklist li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.release-checklist .check-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #d6e3eb;
}

.release-checklist .passed .check-dot {
  background: var(--good);
}

.release-checklist .warning .check-dot {
  background: var(--warn);
}

.official-source-list {
  margin-top: 10px;
}

.official-source-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.official-source-item p {
  overflow-wrap: anywhere;
}

.schedule-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
}

.source-row .pill {
  align-self: start;
  justify-content: center;
}

.qa-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
}

.qa-score {
  display: grid;
  justify-items: center;
  text-align: center;
}

.score-ring {
  display: grid;
  width: 126px;
  height: 126px;
  margin-bottom: 14px;
  place-items: center;
  border: 10px solid #dfeff4;
  border-top-color: var(--accent);
  border-radius: 50%;
  color: var(--accent-strong);
  font-size: 34px;
  font-weight: 800;
}

.check-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  flex: 0 0 24px;
}

.check-icon.ok {
  background: var(--green);
}

.check-icon.warn {
  background: var(--yellow);
}

.export-list {
  display: grid;
  gap: 12px;
}

.pipeline-log {
  min-height: 48px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  white-space: pre-wrap;
}

.pipeline-log.compact {
  min-height: 40px;
  margin-top: 14px;
  margin-bottom: 0;
}

.export-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .nav-list {
    display: flex;
    min-width: max-content;
  }

  .sidebar-footer {
    display: none;
  }

  .metric-grid,
  .content-grid,
  .mapping-layout,
  .qa-grid,
  .summary-grid,
  .system-settings-grid,
  .form-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .deployment-hero,
  .export-item {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .deployment-report-actions {
    justify-content: stretch;
  }

  .deployment-report-actions button {
    flex: 1 1 160px;
  }
}
