:root {
  --bg: #0b101b;
  --bg-elev: #111827;
  --bg-card: #161f33;
  --bg-hover: #1e2942;
  --bg-input: #0d1424;
  --border: #26334d;
  --border-light: #334466;
  --text: #e5ecf6;
  --text-muted: #8fa1bd;
  --text-dim: #627491;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.16);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.16);
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

a {
  color: #60a5fa;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}

input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 500;
  transition: all 0.15s;
}
button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-light);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}
.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

/* Top Navbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 54px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.3px;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.nav-tabs {
  display: flex;
  gap: 4px;
}
.nav-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 15px 14px;
  color: var(--text-muted);
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-tab:hover {
  background: transparent;
  color: var(--text);
}
.nav-tab.active {
  color: #fff;
  border-bottom-color: var(--accent);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: #34d399; border-color: rgba(16, 185, 129, 0.3); }
.badge-amber { background: var(--amber-soft); color: #fbbf24; border-color: rgba(245, 158, 11, 0.3); }
.badge-red   { background: var(--red-soft); color: #f87171; border-color: rgba(239, 68, 68, 0.3); }
.badge-blue  { background: var(--accent-soft); color: #60a5fa; border-color: rgba(59, 130, 246, 0.3); }
.badge-purple { background: var(--purple-soft); color: #c084fc; border-color: rgba(168, 85, 247, 0.3); }
.mono { font-family: var(--font-mono); font-size: 12px; }

/* Layout Containers */
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-label {
  color: var(--text-muted);
  font-size: 12.5px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.alert-amber { background: var(--amber-soft); border-color: rgba(245, 158, 11, 0.35); color: #fde68a; }
.alert-red   { background: var(--red-soft); border-color: rgba(239, 68, 68, 0.35); color: #fecaca; }
.alert-blue  { background: var(--accent-soft); border-color: rgba(59, 130, 246, 0.35); color: #bfdbfe; }

/* Split Panes (Issues & Docs) */
.split-2 {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  align-items: start;
}
.split-docs {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 960px) {
  .split-2, .split-docs {
    grid-template-columns: 1fr;
  }
}

.list-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
}
.list-panel-head {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-scroll {
  overflow-y: auto;
  flex: 1;
}
.list-item {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.list-item:hover {
  background: var(--bg-hover);
}
.list-item.active {
  background: rgba(59, 130, 246, 0.14);
  border-left: 3px solid var(--accent);
}
.list-item-title {
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 4px;
  word-break: break-word;
}
.list-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Kanban / Work Items */
.work-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.work-row {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 15px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.work-row:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.work-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.work-row-note {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Markdown Viewer & Editor */
.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
}
@media (max-width: 1200px) {
  .doc-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
.md-body {
  line-height: 1.7;
  color: var(--text);
  overflow-wrap: break-word;
}
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin-top: 1.3em;
  margin-bottom: 0.5em;
  color: #f8fafc;
  scroll-margin-top: 72px;
}
.md-body h1 { font-size: 1.55rem; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.md-body h2 { font-size: 1.25rem; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.md-body h3 { font-size: 1.08rem; }
.md-body p, .md-body ul, .md-body ol { margin: 0.65em 0; }
.md-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(148, 163, 184, 0.15);
  padding: 2px 5px;
  border-radius: 4px;
}
.md-body pre {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  overflow-x: auto;
}
.md-body pre code {
  background: none;
  padding: 0;
  font-size: 12.5px;
}
.md-body blockquote {
  margin: 0.8em 0;
  padding: 6px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-muted);
}
.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.md-body th, .md-body td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
}
.md-body th {
  background: var(--bg-elev);
}

.toc-box {
  position: sticky;
  top: 72px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.toc-link {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 0;
  cursor: pointer;
}
.toc-link:hover {
  color: #fff;
}

.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 1024px) {
  .editor-split {
    grid-template-columns: 1fr;
  }
}
.md-textarea {
  width: 100%;
  min-height: 520px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  padding: 12px;
}

/* Diff view */
.diff-box {
  font-family: var(--font-mono);
  font-size: 12px;
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  padding: 8px 0;
}
.diff-line {
  padding: 1px 12px;
  white-space: pre-wrap;
  word-break: break-all;
}
.diff-add { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; }
.diff-del { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.diff-hdr { color: #60a5fa; background: rgba(59, 130, 246, 0.1); }

/* Comments & Logs */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.timeline-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.timeline-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Auth Card & Modal */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.form-row label {
  font-size: 12.5px;
  color: var(--text-muted);
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 80;
}
.modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 20px;
}
.code-snippet {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: #cbd5e1;
}

/* CI/CD Console */
.ci-pipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.ci-split {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 960px) {
  .ci-split {
    grid-template-columns: 1fr;
  }
}
.ci-job-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.ci-job-item:hover {
  background: var(--bg-hover);
}
.ci-job-item.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.09);
}
.ci-log-terminal {
  background: #060911;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: #d1fae5;
  max-height: 520px;
  min-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.btn-danger {
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.btn-danger:hover:not(:disabled) {
  background: var(--red);
  color: #fff;
}
