:root {
  --bg: #1e1e1e;
  --panel: #282a2e;
  --text: #c5c8c6;
  --muted: #8abeb7;
  --accent: #5f819d;
  --border: #373b41;
  --danger: #cc6666;
  --ok: #8abeb7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 14px;
}

a { color: var(--muted); }

button, input, select, textarea {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 8px 12px;
  font: inherit;
}

button {
  cursor: pointer;
}

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

.auth-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

.card h1 { margin: 0 0 8px; font-size: 22px; }
.card p { color: #999; }
.card form { display: grid; gap: 12px; }
.msg { min-height: 1.4em; color: var(--ok); }
.msg.error { color: var(--danger); }

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #232428;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 16px;
  margin: 0 12px 0 0;
  font-weight: 600;
}

.grow { flex: 1; }

.workspace {
  display: grid;
  grid-template-columns: 320px 6px 1fr;
  min-height: 0;
}

#tree {
  overflow: auto;
  padding: 12px;
  background: var(--panel);
}

.resizer {
  cursor: col-resize;
  background: var(--border);
}

.editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.editor-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

.editor-body {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

#jsonEditor, .CodeMirror {
  height: 100%;
  font-size: 13px;
}

.split-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 280px;
  border-top: 1px solid var(--border);
}

.split-preview textarea {
  width: 100%;
  height: 100%;
  border: 0;
  resize: none;
}

.split-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.hidden { display: none !important; }

.status {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  min-height: 36px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  width: min(520px, 92vw);
  display: grid;
  gap: 10px;
}

.merchant-list {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
}

.merchant-list button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

.user-chip { color: #999; font-size: 12px; }
