:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d8dee8;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #182230;
  color: #fff;
  padding: 24px 18px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 28px;
}

.sidebar a {
  display: block;
  color: #cbd5e1;
  text-decoration: none;
  padding: 10px 8px;
  border-radius: 6px;
}

.sidebar a:hover {
  background: #263548;
  color: #fff;
}

.main {
  padding: 24px;
}

.topbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.topbar div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

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

.topbar strong {
  display: block;
  font-size: 28px;
  margin-top: 6px;
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.phase-grid button,
.section-head button,
.actions button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  text-align: left;
  padding: 14px;
  cursor: pointer;
}

.phase-grid button:hover,
.section-head button:hover,
.actions button:hover {
  border-color: var(--accent);
}

.phase-grid button.running {
  background: #ecfdf3;
  border-color: var(--accent);
}

.phase-grid b,
.phase-grid span {
  display: block;
}

.phase-grid span {
  color: var(--muted);
  margin-top: 6px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h1 {
  font-size: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

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

.actions button {
  padding: 10px 12px;
}

.source-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}

.source-summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #344054;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: span 4;
}

.comment-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.comment-summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
}

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

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

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.comment-text {
  line-height: 1.5;
}

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

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

th {
  background: #f8fafc;
  color: #334155;
}

td {
  color: #344054;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #ecfdf3;
  color: var(--accent-dark);
}

.badge.off {
  background: #fef3f2;
  color: var(--danger);
}

#logBox {
  min-height: 360px;
  max-height: 560px;
  overflow: auto;
  background: #101828;
  color: #d1fadf;
  border-radius: 8px;
  padding: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .topbar,
  .phase-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: span 1;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
