:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #65717f;
  --line: #d9e0e7;
  --ok: #16784b;
  --bad: #b42318;
  --warn: #9a5b00;
  --accent: #2251a4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

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

main {
  padding: 24px 32px 40px;
}

.summary,
.jobs,
.trade-panel,
.test-trade-panel {
  display: grid;
  gap: 14px;
}

.summary {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.metric,
.job,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.trade-panel,
.test-trade-panel {
  margin-bottom: 18px;
}

.warning-panel {
  border-color: #efc46a;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

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

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

h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  font-size: 12px;
}

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

th {
  color: var(--muted);
  background: #f8fafc;
  font-weight: 700;
}

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

.metric .label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric .value {
  font-size: 20px;
  font-weight: 700;
}

.job {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
}

.job-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--warn);
  background: #fff3d8;
  font-size: 11px;
  font-weight: 750;
}

.running {
  color: var(--ok);
  background: #e7f5ee;
}

.stopped {
  color: var(--bad);
  background: #fdecea;
}

.project {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.command {
  margin-top: 10px;
  padding: 9px 10px;
  background: #f1f4f7;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.command-editor {
  margin-top: 10px;
}

.command-editor label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 6px;
}

.command-editor textarea {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.preset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

.test-trade-form {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr auto 0.8fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.test-trade-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: start;
  justify-content: flex-end;
  max-width: 320px;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 7px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 650;
}

button.primary {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

button.danger {
  color: white;
  background: var(--bad);
  border-color: var(--bad);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.log {
  grid-column: 1 / -1;
  display: none;
  white-space: pre-wrap;
  height: 360px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 7px;
  background: #101820;
  color: #dbe7f2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.log.open {
  display: block;
}

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

input,
select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

.hidden {
  display: none;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 420px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 18px 0 0;
}

@media (max-width: 720px) {
  .topbar,
  .job,
  .trade-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .section-title,
  .preset-row,
  .test-trade-form {
    grid-template-columns: 1fr;
    display: grid;
  }

  main {
    padding: 16px;
  }

  .actions {
    flex-wrap: wrap;
  }
}
