:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --text: #16191f;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1d232c;
    --border: #2d333b;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #4f8ff7;
    --accent-soft: #172a4d;
    --ok: #3fb950;
    --ok-soft: #12291a;
    --warn: #d29922;
    --warn-soft: #2e2410;
    --bad: #f85149;
    --bad-soft: #3a1618;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 17px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; gap: 8px; align-items: center; }
p { margin: 0 0 10px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.pre { white-space: pre-line; }

input, select, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; }
.step-body { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
input[type="checkbox"] { width: auto; }
input[type="range"] { padding: 0; }

.button {
  font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap;
}
.button:hover { background: var(--surface-2); }
.button:disabled { opacity: .6; cursor: progress; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { filter: brightness(1.08); }
.button.danger { color: var(--bad); }
.button.ghost { border-color: transparent; background: transparent; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.check { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.check.big { font-weight: 600; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.spacer { flex: 1; }
.hint { font-size: 12px; color: var(--muted); }
.error-text { color: var(--bad); min-height: 1em; }
.notice, .warning { padding: 8px 12px; border-radius: 8px; margin: 8px 0; font-size: 13px; }
.notice { background: var(--accent-soft); }
.warning { background: var(--warn-soft); color: var(--warn); }

/* Login */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card .button { width: 100%; }

/* Layout */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; margin-bottom: 12px; }
.topbar .brand { margin: 0; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #7c3aed); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 4px; }
.tab { font: inherit; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.view { padding: 16px 20px 40px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-sidebar { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.prose li { margin-bottom: 8px; line-height: 1.5; }

/* Pills & badges */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.failed { background: var(--bad-soft); color: var(--bad); }
.pill.searching, .pill.enriching, .pill.queued { background: var(--accent-soft); color: var(--accent); }
.fit { display: inline-grid; place-items: center; min-width: 34px; height: 24px; border-radius: 6px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.fit.high { background: var(--ok-soft); color: var(--ok); }
.fit.mid { background: var(--warn-soft); color: var(--warn); }
.fit.low { background: var(--bad-soft); color: var(--bad); }
.nis2 { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; text-transform: none; letter-spacing: 0; background: var(--surface-2); color: var(--muted); }
.nis2-essentieel { background: var(--bad-soft); color: var(--bad); }
.nis2-belangrijk { background: var(--warn-soft); color: var(--warn); }
.nis2-toeleverancier { background: var(--accent-soft); color: var(--accent); }
.stage { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); }
.stage-gereageerd, .stage-interesse { background: var(--accent-soft); color: var(--accent); }
.stage-demo, .stage-klant { background: var(--ok-soft); color: var(--ok); }
.stage-afgewezen, .stage-uitgeschreven { color: var(--muted); }

/* Pipeline */
.stage-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stage-card {
  font: inherit; text-align: left; cursor: pointer; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; display: grid; gap: 2px; color: var(--text);
}
.stage-card span { font-size: 12px; color: var(--muted); font-weight: 600; }
.stage-card strong { font-size: 22px; }
.stage-card.active { border-color: var(--accent); background: var(--accent-soft); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar input[type="search"] { width: 260px; }
.toolbar select { width: auto; }
.bulkbar {
  display: none; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; margin-bottom: 10px;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius);
}
.bulkbar.visible { display: flex; }
.bulkbar select { width: auto; min-width: 200px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 250px); }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.active { background: var(--accent-soft); }
.col-check { width: 34px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.detail {
  position: sticky; top: 70px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; max-height: calc(100vh - 90px); overflow: auto;
}
.detail-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.detail-head h2 { margin-bottom: 2px; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 12px 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.block { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.block.reply { background: var(--ok-soft); border: 0; border-radius: 8px; padding: 12px; }
.enrollment { font-size: 13px; }
.enrollment.failed { color: var(--bad); }
.timeline { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.timeline li { padding: 4px 0; }
.timeline span { color: var(--muted); margin-right: 8px; }

/* Research */
.job-list { display: grid; gap: 10px; }
.job { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: grid; gap: 4px; }
.job-head { display: flex; justify-content: space-between; gap: 8px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }

/* Sequences */
.sequence-list { display: grid; gap: 6px; }
.sequence-item { font: inherit; text-align: left; cursor: pointer; background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: grid; gap: 2px; }
.sequence-item.active { border-color: var(--accent); background: var(--accent-soft); }
.title-input { font-size: 17px; font-weight: 700; border-color: transparent; padding-left: 0; }
.ai-box { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.ai-box summary { cursor: pointer; font-weight: 600; }
.ai-box textarea { margin: 10px 0; font-family: inherit; }
.step { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; display: grid; gap: 8px; }
.step-head { display: flex; align-items: center; gap: 12px; }
.step-head .step-remove { margin-left: auto; }
.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.inline input { width: 64px; }
.preview-box { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; display: grid; gap: 10px; }
.preview-box .field { margin: 0; }
.preview-subject { font-weight: 700; }
.preview-body iframe { width: 100%; height: 320px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* Modal & toast */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(0, 0, 0, .4); }
.modal-card { padding: 22px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; max-width: min(560px, calc(100vw - 32px));
  transition: opacity .2s, transform .2s; z-index: 20;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .workspace, .grid-2, .grid-sidebar { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
  .stage-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .view { padding: 12px 16px 32px; }
  .toolbar input[type="search"] { width: 100%; }
  .stage-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
