:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --ink: #172033;
  --muted: #637083;
  --line: #dfe4ea;
  --line-strong: #cbd5e1;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #dc2626;
  --green: #15803d;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  background: #101827;
  color: #dbeafe;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  padding: 4px 8px 20px;
}

.brand-mark {
  align-items: center;
  background: #14b8a6;
  color: #062421;
  display: grid;
  font-weight: 900;
  height: 42px;
  place-items: center;
  width: 42px;
}

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

.brand span {
  color: #9fb1c7;
  font-size: 12px;
  margin-top: 4px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  align-items: center;
  background: transparent;
  color: #b6c5d8;
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  width: 100%;
}

.nav button svg,
.top-actions svg,
.icon-btn svg,
.copy-grid svg,
.row-actions svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.nav button.active,
.nav button:hover {
  background: rgba(20, 184, 166, 0.14);
  color: #f8fafc;
}

.sidebar-footer {
  align-items: center;
  border-top: 1px solid rgba(203, 213, 225, 0.16);
  color: #9fb1c7;
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding: 16px 8px 0;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto 20px;
  max-width: 1480px;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 8px;
}

.topbar p {
  color: var(--muted);
  margin: 0;
}

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

.view {
  margin: 0 auto;
  max-width: 1480px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel.compact {
  box-shadow: none;
  padding: 14px;
}

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

.panel-header h2,
.panel-header h3 {
  font-size: 17px;
  line-height: 1.3;
  margin: 0;
}

.panel-header p {
  color: var(--muted);
  margin: 4px 0 0;
}

.stat {
  min-height: 130px;
}

.stat span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.stat strong {
  display: block;
  font-size: 31px;
  line-height: 1;
  margin: 16px 0 10px;
}

.stat small {
  color: var(--muted);
}

.status {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  min-height: 26px;
  padding: 4px 8px;
}

.status::before {
  background: currentColor;
  border-radius: 999px;
  content: "";
  height: 7px;
  width: 7px;
}

.status.healthy,
.status.completed,
.status.running {
  background: #e8f5ee;
  color: var(--green);
}

.status.degraded,
.status.completed_with_errors,
.status.queued {
  background: #fff7ed;
  color: var(--amber);
}

.status.failed,
.status.disabled {
  background: #fef2f2;
  color: var(--red);
}

.table-wrap {
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field label {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.field small {
  color: var(--muted);
}

input,
textarea,
select {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  min-height: 40px;
  outline: none;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  line-height: 1.55;
  min-height: 118px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

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

.span-2 {
  grid-column: span 2;
}

.primary,
.secondary,
.ghost,
.danger,
.icon-btn {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
}

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

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

.secondary {
  background: #e9f7f5;
  color: var(--brand-strong);
}

.ghost {
  background: #f1f5f9;
  color: #334155;
}

.danger {
  background: #fee2e2;
  color: var(--red);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.12);
  color: currentColor;
  height: 38px;
  padding: 0;
  width: 38px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: #edf2f7;
  color: #475569;
  display: inline-flex;
  font-size: 12px;
  min-height: 26px;
  padding: 5px 8px;
}

.chip.brand {
  background: #dff7f3;
  color: var(--brand-strong);
}

.studio-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(360px, 0.88fr) minmax(520px, 1.12fr);
}

.tabs {
  background: #eef2f7;
  display: inline-flex;
  padding: 4px;
}

.tabs button {
  background: transparent;
  color: var(--muted);
  min-height: 34px;
  padding: 7px 11px;
}

.tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.editor-shell {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(420px, 0.95fr) minmax(460px, 1.05fr);
}

.editor-tools {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px -4px 12px;
  padding: 0 4px 12px;
}

.editor-tools button {
  background: #f1f5f9;
  color: #334155;
  min-height: 34px;
  min-width: 36px;
  padding: 6px 10px;
}

.markdown-editor {
  font-family: Consolas, "SFMono-Regular", monospace;
  min-height: 660px;
}

.preview {
  background: #fff;
  border: 1px solid var(--line);
  line-height: 1.76;
  min-height: 660px;
  overflow: auto;
  padding: 28px;
}

.preview h1 {
  color: #0f172a;
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 18px;
}

.preview h2 {
  border-left: 5px solid var(--brand);
  font-size: 23px;
  margin: 32px 0 12px;
  padding-left: 12px;
}

.preview h3 {
  font-size: 18px;
  margin: 24px 0 10px;
}

.preview p {
  margin: 12px 0;
}

.preview strong {
  background: linear-gradient(transparent 58%, #fef08a 58%);
  color: #111827;
  padding: 0 2px;
}

.preview blockquote {
  background: #f0fdfa;
  border-left: 5px solid var(--brand);
  color: #115e59;
  margin: 18px 0;
  padding: 14px 18px;
}

.preview img {
  display: block;
  height: auto;
  margin: 18px 0 8px;
  max-width: 100%;
}

.preview table {
  min-width: 0;
}

.preview table th {
  background: #f8fafc;
}

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

.copy-grid button {
  background: #f8fafc;
  border: 1px solid var(--line);
  color: #334155;
  min-height: 50px;
}

.article-list {
  display: grid;
  gap: 10px;
}

.article-card {
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 14px;
}

.article-card.active {
  border-color: var(--brand);
  box-shadow: inset 4px 0 0 var(--brand);
}

.article-card h3 {
  font-size: 16px;
  margin: 0;
}

.article-card p {
  color: var(--muted);
  margin: 0;
}

.progress {
  background: #e2e8f0;
  height: 9px;
  overflow: hidden;
}

.progress span {
  background: var(--brand);
  display: block;
  height: 100%;
  transition: width 0.25s ease;
}

.toast {
  background: #111827;
  box-shadow: var(--shadow);
  color: #fff;
  max-width: 520px;
  padding: 12px 14px;
  position: fixed;
  right: 24px;
  top: 24px;
  z-index: 20;
}

.empty {
  align-items: center;
  color: var(--muted);
  display: grid;
  gap: 10px;
  min-height: 180px;
  place-items: center;
}

.empty-icon {
  align-items: center;
  background: #edf2f7;
  color: #94a3b8;
  display: grid;
  font-size: 28px;
  height: 54px;
  place-items: center;
  width: 54px;
}

.two-pane {
  display: grid;
  gap: 16px;
  grid-template-columns: 360px minmax(0, 1fr);
}

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

.mini-chart {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(7, minmax(24px, 1fr));
  height: 160px;
  padding-top: 12px;
}

.mini-chart div {
  align-items: center;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.mini-chart span {
  background: #14b8a6;
  display: block;
  min-height: 8px;
  width: 100%;
}

.mini-chart small {
  color: var(--muted);
  font-size: 11px;
}

.login-page {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 42%),
    var(--bg);
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 30px;
  width: min(100%, 420px);
}

.login-brand {
  color: var(--ink);
  padding: 0 0 24px;
}

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

.login-panel h1 {
  font-size: 26px;
  line-height: 1.2;
  margin: 0 0 8px;
}

.login-panel p {
  color: var(--muted);
  margin: 0 0 22px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
}

.login-form label span {
  color: var(--muted);
  font-size: 13px;
}

.login-form input {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

.login-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.14);
  outline: none;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--red);
  margin-bottom: 16px;
  padding: 10px 12px;
}

.logout-link {
  align-items: center;
  display: inline-flex;
  min-height: 40px;
}

@media (max-width: 1180px) {
  .grid.cols-4,
  .grid.cols-3,
  .studio-layout,
  .editor-shell,
  .two-pane {
    grid-template-columns: 1fr;
  }

  .markdown-editor,
  .preview {
    min-height: 480px;
  }
}

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

  .sidebar {
    height: auto;
    position: static;
  }

  .main {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    display: grid;
    gap: 14px;
  }

  .form-grid,
  .grid.cols-2,
  .copy-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}
