:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #64717a;
  --line: #d7e0e5;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --good: #14803d;
  --bad: #b42318;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
}

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

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

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

.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
}

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

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #aeb8be;
}

.dot.ok {
  background: var(--good);
}

.dot.bad {
  background: var(--bad);
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
}

.wide {
  margin-bottom: 16px;
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: #33414a;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input:not([type]),
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

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

input[readonly] {
  background: #eef3f5;
  color: #33414a;
}

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

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 500;
  color: var(--text);
}

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

.autoExecuteOption {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-weight: 600;
  color: #33414a;
}

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

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

.secretSetup small {
  display: block;
  margin-top: 6px;
}

.notice {
  margin-top: 14px;
  border: 1px solid #e0d4b6;
  border-radius: 6px;
  background: #fff8e6;
  color: #6a4a00;
  padding: 10px;
}

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

.metrics div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

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

.metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  word-break: break-word;
}

.output {
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  color: #26343c;
  padding: 12px;
  white-space: pre-wrap;
}

.planList,
.queueList {
  display: grid;
  gap: 10px;
}

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

.plan {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.plan strong,
.plan em,
.plan code {
  display: block;
}

.plan em {
  color: var(--muted);
  font-style: normal;
  margin-top: 3px;
}

.plan code {
  margin-top: 5px;
  color: #3b4a53;
  word-break: break-all;
}

.queueItem {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.queueItem div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.queueItem span,
.queueItem small,
.queueItem p {
  color: var(--muted);
}

.executorSummary {
  margin-top: 6px;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modalBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 38, 0.52);
}

.modalPanel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  box-shadow: 0 20px 60px rgba(23, 32, 38, 0.24);
}

.modalGrid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(340px, 1.1fr);
  gap: 16px;
}

.modalGrid h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

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

.walletChoice {
  display: grid;
  gap: 4px;
  width: 100%;
  height: auto;
  min-height: 76px;
  padding: 10px;
  text-align: left;
}

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

.walletChoice code {
  color: #3b4a53;
  font-size: 12px;
  word-break: break-all;
}

@media (max-width: 900px) {
  .layout,
  .checks,
  .modalGrid {
    grid-template-columns: 1fr;
  }

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