:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-line: #d9e1e8;
  --text: #1f2933;
  --text-soft: #667085;
  --text-faint: #8a97a6;
  --blue: #1f6feb;
  --blue-dark: #1558c8;
  --green: #168a5b;
  --amber: #b7791f;
  --red: #c2410c;
  --radius: 8px;
  --shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
  --mono: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.console-shell {
  min-height: 100vh;
}

.console-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(160px, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 64px;
  border-bottom: 1px solid var(--surface-line);
  background: rgba(255, 255, 255, 0.94);
  padding: 0 28px;
  backdrop-filter: blur(10px);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border: 3px solid var(--blue);
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.12);
}

.nav-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 4px;
}

.nav-tab {
  min-width: 96px;
  border-radius: 999px;
  color: var(--text-soft);
  padding: 8px 14px;
  text-align: center;
  text-decoration: none;
}

.nav-tab.active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.08);
}

.mode-pill,
.status-pill,
.count-pill,
.state-badge,
.metric-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-soft);
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.mode-pill {
  justify-self: end;
}

.portal-page,
.admin-page {
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.compact-head {
  align-items: center;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 5px;
  font-size: 21px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.page-subtitle,
.muted {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.head-actions,
.editor-header-actions,
.editor-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-text-button,
.command-copy {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button,
.icon-text-button,
.command-copy {
  border-color: var(--surface-line);
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover,
.icon-text-button:hover,
.command-copy:hover {
  border-color: rgba(31, 111, 235, 0.5);
  color: var(--blue);
}

.danger-button {
  border-color: rgba(194, 65, 12, 0.35);
  background: #fff7ed;
  color: var(--red);
}

.danger-button:hover {
  border-color: var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.search-input,
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  border: 1px solid var(--surface-line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  padding: 9px 11px;
}

.search-input:focus,
.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
  border-color: rgba(31, 111, 235, 0.75);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

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

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

.metric-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 25px;
}

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

.list-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  padding: 12px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 4px;
}

.segmented.compact {
  width: 100%;
  justify-content: space-between;
}

.segment {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  min-height: 30px;
  padding: 5px 11px;
}

.segmented.compact .segment {
  flex: 1;
  padding-inline: 6px;
}

.segment.active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.08);
}

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

.project-row {
  display: grid;
  grid-template-columns: minmax(250px, 0.9fr) minmax(300px, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(31, 41, 51, 0.05);
  padding: 13px 15px;
}

.project-main-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
}

.project-main-title strong {
  font-size: 16px;
}

.state-badge.published {
  border-color: rgba(22, 138, 91, 0.28);
  background: #ecfdf5;
  color: var(--green);
}

.state-badge.draft {
  border-color: rgba(183, 121, 31, 0.28);
  background: #fffbeb;
  color: var(--amber);
}

.state-badge.archived {
  background: #eef2f7;
  color: var(--text-faint);
}

.project-slug,
.mono-link {
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 12px;
}

.project-desc {
  color: var(--text-soft);
  line-height: 1.55;
  margin: 0;
}

.project-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 330px;
  flex-wrap: wrap;
}

.empty-state {
  border: 1px dashed var(--surface-line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px;
  text-align: center;
}

.admin-head {
  align-items: center;
}

.admin-workbench {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 14px;
  min-height: 680px;
}

.project-sidebar,
.editor-surface {
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.project-sidebar {
  overflow: hidden;
}

.sidebar-tools {
  display: grid;
  gap: 10px;
  border-bottom: 1px solid var(--surface-line);
  padding: 12px;
}

.project-sidebar-list {
  max-height: 650px;
  overflow-y: auto;
  padding: 8px;
}

.admin-graph-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  margin-bottom: 6px;
  padding: 10px 11px;
  text-align: left;
}

.admin-graph-item:hover,
.admin-graph-item.active {
  border-color: rgba(31, 111, 235, 0.32);
  background: #f8fbff;
}

.admin-graph-name {
  margin-bottom: 5px;
  font-weight: 700;
}

.admin-graph-meta {
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.editor-surface {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--surface-line);
  padding: 18px;
}

.editor-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--surface-line);
  background: var(--surface-soft);
  padding: 8px 12px 0;
}

.editor-tab {
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  min-height: 40px;
  padding: 8px 14px;
}

.editor-tab.active {
  border-color: var(--surface-line);
  background: var(--surface);
  color: var(--blue);
}

.admin-form {
  flex: 1;
  padding: 18px;
}

.tab-panel {
  min-height: 360px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two-col,
.data-metrics-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.data-metrics-form {
  display: grid;
  gap: 14px;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: #fbfdff;
  padding: 11px;
}

.workflow-step strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
}

.workflow-step span {
  color: var(--text-soft);
  font-size: 13px;
}

.process-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.process-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 13px;
}

.process-card h3,
.process-card p {
  margin-bottom: 0;
}

.process-card p {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.55;
}

.process-kicker {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.command-copy {
  width: 100%;
  margin-top: 2px;
}

.import-panel {
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: #fbfdff;
  margin-top: 16px;
  padding: 14px;
}

.import-panel p {
  color: var(--text-soft);
  line-height: 1.7;
}

.import-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.import-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.import-actions .muted {
  min-width: min(100%, 280px);
}

.import-review {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.review-card {
  border: 1px solid var(--surface-line);
  border-left: 4px solid var(--green);
  border-radius: 7px;
  background: var(--surface);
  padding: 11px 12px;
}

.review-card.warn {
  border-left-color: var(--amber);
}

.review-card div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.review-card span {
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}

.review-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: 13px;
}

.form-wide {
  grid-column: 1 / -1;
}

.admin-form textarea {
  resize: vertical;
}

.publish-note {
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: #fbfdff;
  margin-top: 16px;
  padding: 14px;
}

.publish-note p {
  color: var(--text-soft);
  line-height: 1.7;
}

.note-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.note-head h3,
.note-head p {
  margin-bottom: 0;
}

.command-preview {
  overflow-x: auto;
  border-radius: 6px;
  background: #111827;
  color: #e5edf7;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  margin: 12px 0 0;
  padding: 12px;
  white-space: pre;
}

.publish-note code {
  display: block;
  overflow-x: auto;
  border-radius: 6px;
  background: #edf2f7;
  color: #334155;
  font-family: var(--mono);
  margin-top: 10px;
  padding: 10px;
}

.editor-footer {
  border-top: 1px solid var(--surface-line);
  padding: 14px 18px;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .console-nav {
    grid-template-columns: 1fr;
    padding: 12px 16px;
  }

  .mode-pill {
    justify-self: start;
  }

  .portal-page,
  .admin-page {
    width: min(100vw - 24px, 1280px);
  }

  .page-head,
  .list-toolbar,
  .editor-header {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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

  .workflow-strip,
  .process-board,
  .import-grid {
    grid-template-columns: 1fr;
  }

  .project-row,
  .admin-workbench {
    grid-template-columns: 1fr;
  }

  .project-actions {
    justify-content: flex-start;
    min-width: 0;
  }

  .note-head,
  .review-card div {
    align-items: stretch;
    flex-direction: column;
  }

  .review-card span {
    white-space: normal;
  }
}

@media (max-width: 560px) {
  .metric-strip,
  .form-grid.two-col,
  .data-metrics-form {
    grid-template-columns: 1fr;
  }

  .nav-tabs,
  .segmented {
    width: 100%;
    justify-content: space-between;
  }
}
