:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #16191f;
  --muted: #5f6672;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --danger: #c2410c;
  --focus: #93b4f7;
  --c-reclame: #dc2626;
  --c-nieuwsbrief: #2563eb;
  --c-automatisch: #6b7280;
  --c-klantendienst: #ea8a0c;
  --c-behouden: #15803d;
  --c-beschermd: #7c3aed;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2b313a;
    --text: #e8ebef; --muted: #9aa3ae; --primary: #4f8cff; --danger: #f07a3c; --focus: #35558f;
    --c-reclame: #f05252; --c-nieuwsbrief: #5b93ff; --c-automatisch: #9ca3af;
    --c-klantendienst: #f5a524; --c-behouden: #34c46a; --c-beschermd: #a78bfa;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 6rem;
}
a { color: var(--primary); }
code { font-size: .9em; background: var(--surface-2); padding: .05em .3em; border-radius: 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 650; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--primary); display: inline-block; }
.who { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .9rem; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 1.5rem;
}
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .75rem; }
h2 { font-size: 1.2rem; margin: 0 0 .5rem; }

.hero { max-width: 720px; margin: 2rem auto; padding: 2rem; }
.lead { font-size: 1.08rem; color: var(--muted); margin-top: 0; }
.checks { list-style: none; padding: 0; margin: 1.25rem 0 1.75rem; display: grid; gap: .7rem; }
.checks li { padding-left: 1.75rem; position: relative; }
.checks li::before {
  content: ""; position: absolute; left: 0; top: .3em; width: 1.05rem; height: 1.05rem; border-radius: 50%;
  background: var(--c-behouden); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='10'/%3E%3C/svg%3E");
}
.checks li::after {
  content: ""; position: absolute; left: .33rem; top: .52em; width: .38rem; height: .6rem;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.fine { font-size: .85rem; color: var(--muted); margin-top: 1.25rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 1px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn.ghost { background: transparent; }
.btn.small { padding: .3rem .65rem; font-size: .88rem; }
.btn.large { padding: .75rem 1.3rem; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.setup { max-width: 720px; margin: 1rem auto; display: grid; gap: 1.1rem; }
.field { display: grid; gap: .35rem; border: 0; padding: 0; margin: 0; }
.field.inline { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.label { font-weight: 600; }
.hint { font-size: .86rem; color: var(--muted); margin: 0; }
textarea, input[type="number"], input[type="search"], select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .65rem;
}
textarea { width: 100%; resize: vertical; }
input[type="number"] { width: 6rem; }
.check { display: inline-flex; align-items: center; gap: .45rem; margin-right: 1.25rem; cursor: pointer; }
.ai-box { background: var(--surface-2); border-radius: 10px; padding: .9rem 1rem; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.error { color: var(--danger); margin: 0; }

.job { max-width: 620px; margin: 3rem auto; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 1rem 0 .5rem; }
.bar > div { height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .4s ease; }
.bar.indeterminate > div { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: color-mix(in srgb, var(--c-behouden) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c-behouden) 35%, var(--border));
  border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1rem;
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.cat-card {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: .9rem 1rem; cursor: pointer; font: inherit; color: inherit; box-shadow: var(--shadow);
  border-top: 4px solid var(--cat); display: grid; gap: .1rem;
}
.cat-card:hover { background: var(--surface-2); }
.cat-card.active { outline: 2px solid var(--cat); outline-offset: -1px; }
.cat-card .name { font-weight: 600; font-size: .92rem; }
.cat-card .big { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.cat-card .sub { font-size: .82rem; color: var(--muted); }
.done-line { margin: .75rem 0 0; font-size: .9rem; }

.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: 1.25rem 0 .75rem; }
.toolbar input[type="search"] { flex: 1 1 220px; min-width: 0; }
.spacer { flex: 1; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: clip; }
table.senders { width: 100%; border-collapse: collapse; }
.senders th, .senders td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.senders th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 53px; z-index: 1; }
.senders td.num, .senders th.num { text-align: right; font-variant-numeric: tabular-nums; }
.senders tbody tr:hover { background: var(--surface-2); }
.senders tbody tr.selected { background: color-mix(in srgb, var(--primary) 9%, var(--surface)); }
.col-check { width: 2.2rem; }
.sender-cell { min-width: 0; max-width: 340px; }
.sender-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.sender-addr { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subjects { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .84rem; color: var(--muted); }
.subjects li { overflow: hidden; text-overflow: ellipsis; }
.pill {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--cat); }
.reason { font-size: .84rem; color: var(--muted); max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unsub { font-size: .8rem; color: var(--muted); }
.protected-note { font-size: .8rem; color: var(--c-beschermd); }
.table-foot { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; flex-wrap: wrap; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

.bulkbar {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 10;
  width: min(1150px, calc(100% - 2rem)); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); padding: .75rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
}
.bulk-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

dialog { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--text); width: min(560px, calc(100% - 2rem)); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 14, 20, .45); }
.modal { padding: 1.5rem; display: grid; gap: 1rem; }
.modal ul { margin: 0; padding-left: 1.2rem; }
.modal .warn { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; }
.modal .scroll { max-height: 40vh; overflow: auto; }

.toast {
  position: fixed; right: 1.25rem; top: 4.25rem; z-index: 20; max-width: 28rem;
  background: var(--text); color: var(--bg); padding: .65rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow);
}

@media (max-width: 900px) { .hide-md { display: none; } }
@media (max-width: 640px) {
  main { padding: 1rem; }
  .hide-sm { display: none; }
  .hero { padding: 1.25rem; margin: .5rem auto; }
  .sender-cell { max-width: 170px; }
  .bulkbar { bottom: 0; width: 100%; border-radius: 14px 14px 0 0; }
  .senders th { top: 49px; }
}
