:root {
  color-scheme: light;
  --bg: #edf1f5;
  --sidebar: #16202e;
  --sidebar-soft: #202d3d;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --text: #152033;
  --muted: #657387;
  --line: #d8e0ea;
  --primary: #116074;
  --primary-dark: #0b4656;
  --ok: #167a46;
  --warn: #9a5b00;
  --err: #b42318;
  --code-bg: #0e1420;
  --code-text: #e7edf7;
  --shadow: 0 18px 45px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

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

.sidebar {
  min-height: 100vh;
  padding: 20px 16px;
  background: var(--sidebar);
  color: #e8eef7;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #e6f2f5;
  color: var(--primary-dark);
  font-weight: 900;
}

h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 18px; line-height: 1.2; letter-spacing: 0; }
h2 { font-size: 22px; letter-spacing: 0; }
h3 { font-size: 15px; letter-spacing: 0; }
h4 { font-size: 14px; }
.brand p { margin-top: 4px; color: #9fb0c4; font-size: 13px; }

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b7c5d8;
  font-size: 15px;
  font-weight: 800;
  text-align: left;
  padding: 0 14px;
  cursor: pointer;
}

.tab:hover {
  background: var(--sidebar-soft);
  color: #fff;
}

.tab.active {
  background: #e6f2f5;
  color: var(--primary-dark);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  display: grid;
  gap: 6px;
}

.sidebar-footer span {
  color: #9fb0c4;
  font-size: 12px;
}

.sidebar-footer strong {
  font-size: 13px;
  line-height: 1.4;
}

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

.page-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  overflow: hidden;
}

.page-head p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.build-head {
  height: 76px;
}

.status-group {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.status-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge {
  min-width: 104px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  font-size: 14px;
  font-weight: 800;
}

.badge.running { color: var(--warn); border-color: #e7bd7a; background: #fff7e8; }
.badge.done { color: var(--ok); border-color: #8ec7a1; background: #effaf2; }
.badge.failed { color: var(--err); border-color: #f0a39c; background: #fff1f0; }

.tab-page { display: none; }
.tab-page.active { display: block; }

.build-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.control-panel { grid-column: 1; grid-row: 1; }
.terminal-panel { grid-column: 2; grid-row: 1 / span 2; }
.artifact-panel { grid-column: 1; grid-row: 2; }

.panel-head {
  height: 50px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fbfcfe;
}

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

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: calc(100vh - 180px);
  resize: vertical;
  padding: 15px;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 96, 116, .12);
}

button,
a {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  min-height: 42px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
a:hover {
  background: var(--primary-dark);
}

button:disabled {
  opacity: .58;
  cursor: wait;
}

.drop {
  min-height: 138px;
  border: 1px dashed #aebccd;
  border-radius: 8px;
  background: var(--panel-soft);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-align: center;
  padding: 16px;
}

.drop:hover {
  border-color: var(--primary);
  background: #eef7f9;
}

.drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-kicker,
.drop-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.drop strong {
  max-width: 100%;
  color: var(--text);
  font-size: 18px;
  overflow-wrap: anywhere;
}

.ghost {
  min-height: 32px;
  padding: 0 10px;
  color: var(--primary);
  background: #e6f2f5;
}

.ghost:hover {
  color: #fff;
}

.metric-list {
  border-top: 1px solid var(--line);
  display: grid;
}

.metric-list div {
  min-height: 52px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.metric-list div + div {
  border-top: 1px solid var(--line);
}

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

.metric-list strong {
  font-size: 13px;
}

.terminal-panel {
  min-height: calc(100vh - 114px);
  display: grid;
  grid-template-rows: 50px minmax(0, 1fr);
}

pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  background: var(--code-bg);
  color: var(--code-text);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.artifacts {
  padding: 14px;
}

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

.empty-state.compact {
  min-height: 150px;
}

.empty-icon {
  width: 58px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-soft);
  color: var(--primary);
  font-weight: 900;
}

.artifact {
  display: grid;
  gap: 8px;
}

.artifact a {
  width: 100%;
}

.artifact span {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  word-break: break-all;
}

.source-panel textarea {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

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

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

.doc-card ul {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

.template-links {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.template-links a {
  min-height: 40px;
  justify-content: flex-start;
  color: var(--primary);
  background: #e6f2f5;
  overflow-wrap: anywhere;
}

.template-links a:hover {
  color: #fff;
  background: var(--primary);
}

.history-box {
  overflow: hidden;
}

.history {
  display: grid;
}

.job-row {
  width: 100%;
  min-height: 74px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 12px 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  text-align: left;
}

.job-row:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.job-title {
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.job-meta {
  color: var(--muted);
  font-size: 12px;
}

.job-status {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  min-width: 72px;
  padding: 6px 9px;
  border-radius: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.job-status.done {
  color: var(--ok);
  background: #effaf2;
}

.job-status.failed {
  color: var(--danger);
  background: #fff1f1;
}

.job-status.running {
  color: var(--primary-dark);
  background: #e6f2f5;
}

.job-status.expired {
  color: var(--muted);
  background: #f2f4f7;
}

.job-actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
}

.job-actions a {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.job-expired {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.empty-action {
  min-height: 34px;
  padding: 0 12px;
}

code {
  color: var(--primary-dark);
  background: #e6f2f5;
  border-radius: 5px;
  padding: 2px 5px;
}

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

  .sidebar {
    min-height: auto;
  }

  .build-layout,
  .info-grid,
  .template-library {
    grid-template-columns: 1fr;
  }

  .control-panel,
  .terminal-panel,
  .artifact-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .terminal-panel {
    min-height: 420px;
  }
}
