:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #657083;
  --line: #dfe5ee;
  --brand: #1f6feb;
  --brand-dark: #164ea8;
  --green: #0f766e;
  --orange: #b45309;
  --red: #b91c1c;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

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

button {
  border: 0;
  border-radius: 7px;
  padding: 9px 14px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

button:hover { background: var(--brand-dark); }

.secondary, .ghost-btn {
  background: #edf2f7;
  color: #243044;
}

.secondary:hover, .ghost-btn:hover { background: #dfe7f1; }

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

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: #edf2f7;
  color: #243044;
  font-size: 22px;
}

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

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: #2563eb;
  font-weight: 800;
}

.brand strong { display: block; font-size: 15px; }
.brand span { display: block; margin-top: 3px; color: #9aa8bc; font-size: 12px; line-height: 1.3; }

nav {
  display: grid;
  gap: 5px;
}

.nav-item {
  padding: 10px 11px;
  border-radius: 7px;
  color: #cbd5e1;
  cursor: pointer;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.login-card {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 9px;
  color: #cbd5e1;
  font-size: 13px;
}

.login-card button {
  width: 100%;
  margin-top: 10px;
}

main {
  min-width: 0;
  padding: 26px 30px 54px;
}

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

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

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

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

.top-actions input,
.top-actions button {
  height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
  line-height: 1.2;
}

.top-actions input {
  width: 220px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 98px;
  resize: vertical;
}

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

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

.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 28px; }

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 6px 20px rgba(17, 24, 39, 0.05);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 { margin: 0; font-size: 18px; }
.panel-body { padding: 18px; }

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: #42506a;
  background: #f8fafc;
  white-space: nowrap;
}

td.actions {
  white-space: nowrap;
}

td.actions button {
  margin-right: 6px;
  padding: 6px 9px;
  font-size: 13px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-controls button {
  height: 32px;
  padding: 5px 10px;
}

.page-controls select {
  width: 130px;
  height: 32px;
  padding: 4px 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #334155;
  font-size: 12px;
  white-space: nowrap;
}

.badge.high, .badge.critical { background: #fee2e2; color: #991b1b; }
.badge.medium { background: #fff7ed; color: #9a3412; }
.badge.approved, .badge.active { background: #dcfce7; color: #166534; }
.badge.pending_review, .badge.draft { background: #dbeafe; color: #1d4ed8; }
.badge.rejected, .badge.deprecated, .badge.inactive { background: #f1f5f9; color: #475569; }

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

.detail-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.detail-item strong { display: block; margin-bottom: 4px; color: #475569; font-size: 12px; }

.detail-item.full { grid-column: 1 / -1; }

.detail-item pre {
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border-radius: 6px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

.relation-block {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.relation-block h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 15px;
}

.relation-block ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
}

.relation-block li {
  color: #334155;
  line-height: 1.45;
}

.lifecycle-stack {
  display: grid;
  gap: 16px;
}

.execution-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.timeline {
  display: grid;
  align-content: start;
  gap: 8px;
}

.timeline-item {
  width: 100%;
  min-height: 52px;
  justify-content: space-between;
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  text-align: left;
}

.timeline-item strong,
.timeline-item span {
  display: block;
}

.timeline-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-item.completed { border-color: #86efac; background: #f0fdf4; }
.timeline-item.running { border-color: #93c5fd; background: #eff6ff; }
.timeline-item.failed,
.timeline-item.partial_failed { border-color: #fecaca; background: #fef2f2; }
.timeline-item.skipped { background: #f8fafc; }

.execution-detail {
  min-width: 0;
}

dialog {
  width: min(920px, calc(100vw - 28px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
}

dialog::backdrop { background: rgba(15, 23, 42, 0.45); }

.dialog-form {
  padding: 20px;
}

.dialog-form.narrow { max-width: 420px; }

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

.dialog-head h2 { margin: 0; }

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

label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

label.full { grid-column: 1 / -1; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  main { padding: 18px 14px 40px; }
  nav, .cards, .filters, .form-grid, .detail-grid, .execution-layout, .relation-grid { grid-template-columns: 1fr; }
  .topbar { align-items: stretch; flex-direction: column; }
  .top-actions { flex-direction: column; }
}
