* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --teal: #0d9488;
  --teal-dark: #0b7d73;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
}
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

.center-box { flex: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 360px; box-shadow: 0 10px 30px rgba(2, 6, 23, .08); }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }

.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; }
.brand em { color: var(--teal); font-style: normal; font-weight: 600; }
.shield { width: 22px; height: 22px; background: var(--teal); display: inline-block;
  clip-path: path("M11 0L2 4.6V11c0 4.6 3.7 8.3 9 9.2 5.3-.9 9-4.6 9-9.2V4.6L11 0z"); }

button, .button {
  font: inherit; border: 1px solid var(--border); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .button:hover { border-color: #cbd5e1; background: #f8fafc; }
button.primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--teal-dark); }
button.danger { color: var(--danger); }
button.mini { padding: 2px 8px; font-size: 12px; border-radius: 6px; }
button.mini.active { background: var(--teal); color: #fff; border-color: var(--teal); }
button.mini.danger { color: var(--danger); }

.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.spacer { flex: 1; }
.editor-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.design-tag { background: #ccfbf1; color: #115e59; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.save-state { color: var(--muted); font-size: 12px; font-weight: 400; }

.list-main { max-width: 860px; margin: 32px auto; width: 100%; padding: 0 16px; }
.campaign-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.campaign-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); }
.campaign-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.campaign-table tr:last-child td { border-bottom: none; }
.slug-cell { font-weight: 600; }
.right { text-align: right; white-space: nowrap; }
.right > * { margin-left: 6px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.badge.live { background: #dcfce7; color: #166534; }
.badge.dirty { background: #fef3c7; color: #92400e; }
.badge.draft { background: #e2e8f0; color: #475569; }

.editor { flex: 1; display: grid; grid-template-columns: minmax(420px, 44%) 1fr; min-height: 0; }
.form-pane { overflow-y: auto; padding: 18px; max-height: calc(100vh - 54px); }
.preview-pane { border-left: 1px solid var(--border); display: flex; flex-direction: column; max-height: calc(100vh - 54px); background: #e2e8f0; }
.preview-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--card); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--muted); }
.preview-frame-wrap { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 14px; }
.preview-frame-wrap iframe { border: 1px solid var(--border); border-radius: 10px; background: #fff; height: 100%; min-height: 600px; }
.preview-frame-wrap.mobile iframe { width: 390px; }
.preview-frame-wrap.desktop iframe { width: 100%; }

fieldset.group { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 16px; background: var(--card); }
fieldset.group legend { font-weight: 700; font-size: 13px; padding: 0 6px; color: var(--ink); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field textarea, .field select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; width: 100%;
  background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; }
.field .mono, textarea.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid #99f6e4; border-color: var(--teal); }

.array-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 10px; background: #f8fafc; }
.array-item-bar { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.array-item-title { font-weight: 700; color: var(--muted); margin-right: auto; }
.add-item { width: 100%; border-style: dashed; color: var(--muted); }

.error-msg { color: var(--danger); font-size: 13px; min-height: 1em; }
.error-box { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.error-box ul { margin: 6px 0 0 18px; }
.error-box code { background: #fee2e2; padding: 1px 4px; border-radius: 4px; }

.overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, .45); display: flex; align-items: center; justify-content: center; z-index: 20; }
.dialog { background: var(--card); border-radius: 12px; padding: 24px; width: 420px; box-shadow: 0 20px 50px rgba(2, 6, 23, .25); }
.dialog h2 { font-size: 17px; margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 30; box-shadow: 0 8px 20px rgba(2, 6, 23, .3); }
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
  .preview-pane { display: none; }
}
