:root {
  --purple: #5b2a86;
  --purple-dark: #431f63;
  --bg: #f4f5f8;
  --card: #ffffff;
  --border: #e1e3ea;
  --text: #202230;
  --text-dim: #6b6f80;
  --green: #1a9e5c;
  --green-bg: #e6f7ee;
  --red: #c23b3b;
  --red-bg: #fdecec;
  --yellow: #a3760a;
  --yellow-bg: #fff6df;
  --radius: 10px;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--purple);
  color: white;
  padding: 14px 24px;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; }
.brand-mark { display: block; width: 34px; height: 34px; flex-shrink: 0; }
.local-badge {
  font-size: 12px; opacity: 0.85; background: rgba(255,255,255,0.15);
  padding: 4px 10px; border-radius: 999px;
}
.user-chrome { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 13px; opacity: 0.9; }
.user-chrome .btn.secondary.small {
  background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.3); color: white;
}
.inline-form { display: inline; margin: 0; }

.shell { max-width: 980px; margin: 0 auto; padding: 24px; }
.shell.narrow { max-width: 420px; padding-top: 60px; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid #f0d3a0; background: var(--yellow-bg); color: #6b4e05;
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 14px;
}
.banner code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; }
.banner.banner-error { border-color: #e8b4b4; background: var(--red-bg); color: var(--red); }
.banner.banner-success { border-color: #a8ddc0; background: var(--green-bg); color: var(--green); }
.banner.hidden { display: none; }

.centered-card { text-align: left; }
.centered-card h2 { text-align: center; margin-bottom: 16px; }
.btn.full-width { width: 100%; margin-top: 4px; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  padding: 10px 18px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.tab.active { background: var(--purple); color: white; border-color: var(--purple); }

.panel { display: none; }
.panel.active { display: block; }

.panel-desc {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; font-size: 14px; color: var(--text-dim); margin-bottom: 16px;
}
.panel-desc.warn { border-color: #f0d3a0; background: var(--yellow-bg); color: #6b4e05; }

.section-divider { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.card.hidden { display: none; }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card h3 { margin: 18px 0 10px; font-size: 14px; }

.hint { font-size: 13px; color: var(--text-dim); margin: 0 0 12px; }
.hint-inline { font-weight: 400; color: var(--text-dim); font-size: 12px; }

.field-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 12px; }
.field-row label {
  display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600;
}
.field-row label.grow { flex: 1; min-width: 260px; }
.field-row input[type=file],
.field-row input[type=date],
.field-row input[type=text],
.field-row input[type=password] {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  min-width: 220px;
}
.checkbox-label { display: flex !important; flex-direction: row !important; align-items: center; gap: 6px !important; }
.field-row textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  min-width: 260px; resize: vertical;
}

.btn {
  font: inherit; font-weight: 600; font-size: 14px; border: none; border-radius: 7px;
  padding: 10px 18px; cursor: pointer;
}
.btn.primary { background: var(--purple); color: white; }
.btn.primary:hover { background: var(--purple-dark); }
.btn.secondary { background: #eee; color: var(--text); }
.btn.danger { background: var(--red); color: white; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; margin: 10px 0; max-height: 420px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th { position: sticky; top: 0; background: #fafafc; z-index: 1; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.done, .badge.submitted { background: var(--green-bg); color: var(--green); }
.badge.pending, .badge.error, .badge.needs-review { background: var(--red-bg); color: var(--red); }
.badge.skipped, .badge.other { background: var(--yellow-bg); color: var(--yellow); }

.run-status { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.status-pill {
  text-transform: uppercase; font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
  padding: 4px 10px; border-radius: 999px; background: #eee; color: var(--text-dim);
}
.status-pill.running { background: #e5edff; color: #2b4fc2; }
.status-pill.done { background: var(--green-bg); color: var(--green); }
.status-pill.stopped, .status-pill.paused_for_confirm { background: var(--yellow-bg); color: var(--yellow); }
.status-pill.error { background: var(--red-bg); color: var(--red); }

.counts { display: flex; gap: 16px; font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.counts b { color: var(--text); }

.mode-choice { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.mode-card {
  display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; cursor: pointer; flex: 1; min-width: 230px;
}
.mode-card:has(input:checked) { border-color: var(--purple); background: #f8f3fc; }
.mode-title { font-weight: 700; font-size: 13px; }
.mode-desc { font-size: 12px; color: var(--text-dim); margin-top: 3px; }

.confirm-box {
  border: 2px solid var(--purple); border-radius: 8px; padding: 14px 16px; margin: 10px 0 16px;
  background: #f8f3fc;
}
.confirm-box.hidden { display: none; }
.confirm-box h3 { margin-top: 0; }
.preview-fields { width: auto; }
.preview-fields th { color: var(--text-dim); font-weight: 600; padding-right: 16px; white-space: nowrap; }
.confirm-actions { display: flex; gap: 10px; margin-top: 12px; }

a.btn { text-decoration: none; display: inline-block; }
