:root {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --surface: #ffffff;
  --surface-muted: #f7f7f6;
  --surface-hover: #f0f0ef;
  --border: rgba(0,0,0,.08);
  --border-strong: rgba(0,0,0,.14);
  --text: #1a1a1a;
  --text-muted: #717171;
  --text-faint: #a0a0a0;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-width: 210px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-muted);
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 20px;
  font-weight: 700;
  font-size: 14px;
}
.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.02em;
  flex-shrink: 0;
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group-label {
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 6px 10px 4px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  transition: background .12s, color .12s;
}
.nav-item i { font-size: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-muted); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 10%, white); color: var(--accent); font-weight: 600; }
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 15%, white);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Main ── */
.main { flex: 1; min-width: 0; }
.page { padding: 24px 32px 56px; max-width: 1200px; }

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.crumb { color: var(--text-muted); text-decoration: none; font-weight: 500; display: flex; align-items: center; gap: 4px; }
.crumb-back-icon { font-size: 13px; }
a.crumb:hover { color: var(--text); }
.crumb.current { color: var(--text); font-weight: 700; }
.crumb-sep { color: var(--text-faint); margin: 0 2px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 7px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn[hidden] { display: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-dashed { border-style: dashed; background: transparent; width: 100%; justify-content: center; margin-top: 12px; color: var(--text-muted); }
.btn-dashed:hover { background: var(--surface-muted); color: var(--text); }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn-logout { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 4px; margin-left: auto; font-size: 16px; display: flex; align-items: center; border-radius: var(--radius); }
.btn-logout:hover { color: var(--text); background: var(--surface-muted); }

/* ── Spin animation ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin .7s linear infinite; }

/* ── Stats ── */
.stats-row { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
  flex: 1;
  min-width: 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.stat-icon { width: 36px; height: 36px; border-radius: 9px; background: color-mix(in srgb, var(--accent) 10%, white); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.stat-value { font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ── Configurator cards ── */
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.config-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow .15s, transform .15s, border-color .15s;
  box-shadow: var(--shadow-sm);
}
.config-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent-color, var(--accent)) 50%, transparent); }
.config-card-accent { height: 4px; background: var(--accent-color, var(--accent)); }
.config-card-body { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.config-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.config-card-icon { width: 40px; height: 40px; border-radius: 10px; background: color-mix(in srgb, var(--accent-color, var(--accent)) 12%, white); color: var(--accent-color, var(--accent)); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.config-card-name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.config-card-client { color: var(--text-muted); font-size: 12px; }
.config-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.config-card-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.config-card-arrow { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: var(--radius); background: var(--surface-muted); color: var(--text-muted); font-size: 13px; transition: background .12s, color .12s; flex-shrink: 0; }
.config-card:hover .config-card-arrow { background: var(--accent-color, var(--accent)); color: #fff; }
.config-card-live { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--radius); border: 1px solid var(--border-strong); color: var(--text-muted); cursor: pointer; background: var(--surface); transition: background .12s, color .12s; }
.config-card-live:hover { background: var(--surface-hover); color: var(--text); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-orange { background: #fef3c7; color: #b45309; }
.badge-grey { background: #f1f1f0; color: #666; }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted); }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.card:last-child { margin-bottom: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.card-body { padding: 18px; }

/* ── Hero block ── */
.hero-block { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.hero-icon { width: 52px; height: 52px; border-radius: 12px; background: color-mix(in srgb, var(--accent-color, var(--accent)) 12%, white); color: var(--accent-color, var(--accent)); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.hero-info h1 { margin: 0; font-size: 17px; font-weight: 700; }
.hero-client { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.hero-badges { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.hero-url { font-size: 11.5px; color: var(--text-muted); text-decoration: none; display: flex; align-items: center; gap: 3px; }
.hero-url:hover { color: var(--accent); }

/* ── Two-col layout ── */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; align-items: start; }
.side-col { display: flex; flex-direction: column; gap: 14px; }

/* ── Field rows ── */
.field-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.field-row:last-child { border-bottom: none; }
.field-label { color: var(--text); font-weight: 500; }
.field-input { text-align: right; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 5px 9px; width: 150px; font-size: 13px; font-family: inherit; transition: border-color .12s; outline: none; }
.field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent); }
.field-input[type="checkbox"] { width: auto; }

/* ── Info list ── */
.info-list .info-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); gap: 12px; font-size: 13px; }
.info-list .info-row:last-child { border-bottom: none; }
.info-list .info-row span:first-child { color: var(--text-muted); }

/* ── Textarea ── */
.notes-area { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 9px 10px; font: inherit; resize: vertical; outline: none; transition: border-color .12s; }
.notes-area:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent); }

/* ── Forms ── */
.form-grid { display: flex; flex-direction: column; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  font: inherit;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}
.slug-field { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.slug-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent); }
.slug-prefix { padding: 8px 10px; background: var(--surface-muted); color: var(--text-muted); font-size: 12px; white-space: nowrap; border-right: 1px solid var(--border-strong); }
.slug-field input { border: none; border-radius: 0; flex: 1; box-shadow: none !important; }

/* ── Type cards ── */
.type-cards { display: flex; gap: 8px; }
.type-card { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; font: inherit; font-size: 12px; font-weight: 500; color: var(--text-muted); transition: border-color .12s, background .12s, color .12s; }
.type-card i { font-size: 18px; }
.type-card:hover { background: var(--surface-muted); color: var(--text); }
.type-card.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, white); color: var(--accent); }

/* ── Wizard ── */
.wizard { display: flex; flex-direction: column; gap: 16px; }
.wizard-steps { display: flex; gap: 20px; margin-bottom: 4px; }
.wizard-step { color: var(--text-faint); font-weight: 600; font-size: 12px; display: flex; align-items: center; gap: 4px; }
.wizard-step.active { color: var(--accent); }
.wizard-step.done { color: var(--text-muted); }
.wizard-card { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.wizard-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; }

/* ── Field rows (settings/detected) ── */
.detected-field-row, .settings-field-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.detected-field-row:last-child, .settings-field-row:last-child { border-bottom: none; }
.detected-field-row input, .settings-field-row input, .settings-field-row select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color .12s;
}
.detected-field-row input:focus, .settings-field-row input:focus, .settings-field-row select:focus {
  border-color: var(--accent);
}
.df-key { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; }
.sf-toggle { display: flex; align-items: center; }
.sf-delete-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: none; background: none; color: var(--text-faint); cursor: pointer; border-radius: var(--radius); flex-shrink: 0; font-size: 14px; }
.sf-delete-btn:hover { background: #fee2e2; color: #dc2626; }

/* ── Abonnementen ── */
.abon-list { display: flex; flex-direction: column; }
.abon-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.abon-row:last-child { border-bottom: none; }
.abon-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.abon-info { flex: 1; min-width: 0; }
.abon-name { font-weight: 600; }
.abon-client { color: var(--text-muted); font-size: 12px; }
.abon-amount { font-weight: 600; white-space: nowrap; }
.abon-freq { color: var(--text-muted); font-weight: 400; font-size: 12px; }

/* ── Inzendingen ── */
.submission-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.submission-row:last-of-type { border-bottom: none; }
.sub-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; min-width: 150px; display: flex; align-items: center; gap: 4px; }
.sub-preview { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.sub-preview-item { font-size: 12px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-preview-key { color: var(--text-muted); margin-right: 4px; font-weight: 500; }
.sub-more { font-size: 12px; color: var(--text-faint); padding: 2px 4px; align-self: center; }
.sub-actions { display: flex; gap: 6px; flex-shrink: 0; }
.sub-delete-btn { color: var(--text-faint) !important; border-color: var(--border) !important; }
.sub-delete-btn:hover { color: #dc2626 !important; border-color: #fca5a5 !important; background: #fff5f5 !important; }
.submission-detail { padding: 10px 0 14px 154px; border-bottom: 1px solid var(--border); background: var(--surface-muted); margin: 0 -18px; padding-left: calc(154px + 18px); padding-right: 18px; }
.sub-table { border-collapse: collapse; width: 100%; font-size: 13px; max-width: 600px; }
.sub-table td { padding: 4px 16px 4px 0; vertical-align: top; }
.sub-key { color: var(--text-muted); white-space: nowrap; min-width: 140px; font-weight: 500; font-size: 12px; }

/* ── Login ── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--surface-muted); width: 100%; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 20px; box-shadow: var(--shadow-md); }
.login-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.login-error { color: #dc2626; font-size: 13px; background: #fff5f5; border: 1px solid #fca5a5; border-radius: var(--radius); padding: 8px 12px; }

/* ── Danger zone ── */
.card-danger { border-color: #fca5a5; }
.danger-text { margin: 0 0 12px; color: var(--text-muted); font-size: 13px; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; margin-top: 14px; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* ── States ── */
.success-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 32px; text-align: center; }
.success-state i { font-size: 44px; }
.loading { padding: 40px; text-align: center; color: var(--text-muted); display: flex; align-items: center; justify-content: center; gap: 8px; }
.empty-state { padding: 36px; text-align: center; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; }
.error-state { padding: 36px; text-align: center; color: #dc2626; display: flex; flex-direction: column; align-items: center; }

/* ── Responsive ── */
@media (max-width: 960px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; overflow-x: auto; padding: 10px; }
  .sidebar-nav { flex-direction: row; gap: 4px; }
  .sidebar-footer { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .detected-field-row, .settings-field-row { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .submission-detail { padding-left: 18px; }
}
