/* Harvey bellijst — layout and components. Self-contained: every colour,
   font, radius and shadow comes from the custom properties in theme.css
   (no raw colour values here), so the brand can change without touching
   layout. Phone-first: below 600px the list table becomes one card per
   company; tap targets are at least 44px. No inline styles anywhere
   (strict CSP). */

[hidden] { display: none !important; }

:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, p, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; }

body.crm {
  min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--text-muted); }

/* Small uppercase, letter-spaced section label ("KOUDE LIJST · 41"). */
.crm-label {
  display: block; font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted);
}
.crm-title, .crm-company {
  font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;
}
.crm-title { font-size: 32px; margin-bottom: 20px; }

/* ── Top bar ─────────────────────────────────────────────────── */

.crm-top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px; min-height: 64px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.crm-brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.crm-brand-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.crm-brand-sub { font-size: 12px; color: var(--text-muted); }
.crm-top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.crm-top-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  background: none; border: 0; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text); text-decoration: none;
}
.crm-top-link:hover { background: var(--surface-2); }
.crm-user { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.crm-user-name { font-weight: 600; }

.crm-main { max-width: 1180px; margin: 0 auto; padding: 24px 24px 96px; }

/* ── Cards, buttons, badges, chips, forms ────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 14px;
}
.card > .crm-label { margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 22px; border-radius: 999px;
  border: 1.5px solid transparent; background: var(--surface-2); color: var(--text);
  font-size: 15px; font-weight: 600; line-height: 1.2; text-decoration: none;
  cursor: pointer; user-select: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-primary::after { content: "\2192"; margin-left: 2px; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { min-height: 36px; padding: 6px 16px; font-size: 14px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 10px; }

.badge, .tag {
  display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 2px 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  background: var(--surface-2); color: var(--text);
}
.tag { font-weight: 500; }
.badge.track-a { background: var(--track-a); color: var(--on-tile); }
.badge.track-b { background: var(--track-b); color: var(--on-tile); }
.badge.track-unknown { background: var(--track-unknown); color: var(--on-tile); }
.badge.t-good { background: var(--success); color: var(--on-tile); }
.badge.t-waiting { background: var(--warning); color: var(--on-tile); }
.badge.t-bad { background: var(--danger); color: var(--on-danger); }
.badge.t-active { background: var(--accent); color: var(--accent-contrast); }
.badge.t-note { background: var(--track-b); color: var(--on-tile); }
.badge.t-idle { background: var(--surface-2); color: var(--text-muted); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  border-radius: 999px; border: 0; background: var(--track-unknown); color: var(--on-tile);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip .n { font-family: var(--font-mono); font-size: 12px; color: inherit; opacity: 0.7; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }
/* An active chip is marked by shape as well as colour: a check before the text. */
.chip[aria-pressed="true"]::before { content: "\2713"; font-weight: 700; }
/* Removable chip in the "Gefilterd op" strip: the x after the text. */
.chip.chip-x { background: var(--surface); color: var(--text); border: 1.5px solid var(--text); }
.chip.chip-x::after { content: "\00d7"; font-weight: 700; font-size: 16px; line-height: 1; }
.chip:disabled { opacity: 0.45; cursor: default; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.form-input {
  width: 100%; min-height: 44px; padding: 8px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
textarea.form-input { resize: vertical; min-height: 88px; }
.form-input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.form-row > .form-input { flex: 1 1 160px; width: auto; }

/* ── Login ───────────────────────────────────────────────────── */

.crm-login { max-width: 400px; margin: 56px auto; padding: 32px; }
.crm-wide { width: 100%; min-height: 52px; }
.crm-error { color: var(--danger); font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.crm-login-help { margin-top: 16px; text-align: center; font-size: 14px; }

/* ── Banners ─────────────────────────────────────────────────── */

.crm-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 14px; font-weight: 500;
}
.crm-banner.t-bad { background: var(--danger-soft); color: var(--on-tile); border-color: var(--danger); }
.crm-banner.t-waiting { background: var(--warning); color: var(--on-tile); border-color: transparent; }
.crm-banner.t-note { background: var(--track-b); color: var(--on-tile); border-color: transparent; }
.crm-banner.t-idle { background: var(--surface-2); color: var(--text); }
#offline-banner { position: sticky; top: 0; z-index: 10; margin: 0; border-radius: 0; }

/* ── List: tabs, counts, filters ─────────────────────────────── */

.crm-tabs {
  display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 16px;
  background: var(--surface-2); border-radius: 999px; max-width: 100%;
}
.crm-tabs button {
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent;
  color: var(--text-muted); font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.crm-tabs button.on { background: var(--accent); color: var(--accent-contrast); }

.crm-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.crm-counts .tag .n { font-family: var(--font-mono); }

.crm-filters {
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px 20px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.crm-filter-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.crm-filter-count, .crm-more-count {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 9px;
  border-radius: 999px; background: var(--accent); color: var(--accent-contrast);
  font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0;
  text-transform: none;
}
.crm-filter-hint { font-size: 13px; }
.crm-more-count { margin-left: 8px; }
/* The strip above the list that names every active filter, each removable. */
.crm-active {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 12px 16px; margin-bottom: 14px;
  background: var(--warning); color: var(--on-tile); border-radius: var(--radius-sm);
}
.crm-active > .crm-label { color: var(--on-tile); }
.crm-active-chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; }
.crm-active .crm-link { color: var(--on-tile); }
.crm-chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.crm-chip-row > .crm-label { min-width: 64px; }
.crm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.crm-filter-line { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.crm-field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.crm-field-grow { flex: 1 1 240px; }
.crm-link {
  min-height: 44px; padding: 0 6px; background: none; border: 0; cursor: pointer;
  color: var(--text); font-size: 14px; font-weight: 600; text-decoration: underline;
  text-underline-offset: 3px;
}
.crm-more > summary {
  display: inline-flex; align-items: center; min-height: 44px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-muted);
}
.crm-filter-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; padding-top: 8px;
}
.crm-list-title { margin-bottom: 10px; }

/* ── List: table / cards ─────────────────────────────────────── */

.table-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.crm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.crm-table th {
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap;
}
.crm-table td { padding: 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table tbody tr { cursor: pointer; }
.crm-table tbody tr:hover td { background: var(--surface-2); }
.crm-table .num { text-align: right; }
.crm-row-name { display: block; font-weight: 700; font-size: 15px; }
.crm-row-why {
  display: block; margin-top: 4px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; max-width: 46ch;
}
.crm-score { display: inline-flex; align-items: center; gap: 8px; }
.crm-score-bar {
  position: relative; display: inline-block; width: 56px; height: 4px;
  background: var(--surface-2); border-radius: 999px; overflow: hidden;
}
.crm-score-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 999px; }
.crm-score-n { font-family: var(--font-mono); font-size: 13px; min-width: 2ch; text-align: right; }
.crm-empty { padding: 32px 20px; text-align: center; color: var(--text-muted); }
.crm-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px 0; }

/* ── Detail ──────────────────────────────────────────────────── */

.crm-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.crm-company { font-size: 34px; overflow-wrap: anywhere; }
.crm-head-card .muted { margin-top: 6px; }
.crm-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 0; }
.crm-review {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--warning); color: var(--on-tile); font-size: 14px; font-weight: 500;
}

.crm-dial { margin: 20px 0 8px; }
.crm-dial-btn { width: 100%; min-height: 60px; font-size: 19px; }
.crm-dial-reason { margin-top: 8px; color: var(--danger); font-size: 14px; font-weight: 600; }

.crm-openers { padding-left: 1.3em; display: flex; flex-direction: column; gap: 10px; font-size: 16px; }
.crm-openers .src { font-size: 13px; color: var(--text-muted); margin-left: 6px; white-space: nowrap; }
.crm-owner-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.crm-owner { font-size: 15px; overflow-wrap: anywhere; }
.crm-owner .badge { margin-left: 6px; vertical-align: 1px; }
.crm-owner-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
/* Full-size tap targets even though these sit in a dense card. */
.crm-owner-actions .btn { min-height: 44px; padding: 8px 16px; font-size: 14px; }
.crm-owner-actions a.btn::after { content: "\2197"; margin-left: 2px; }
.crm-owner-form {
  margin-top: 12px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.crm-owner-fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px;
}

.crm-outcomes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.crm-outcomes .btn { min-height: 48px; white-space: normal; text-align: center; }
.crm-outcomes .btn.on { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.crm-callback { margin-bottom: 16px; }
.crm-callback .form-row { margin-top: 6px; }
.crm-callback .muted { margin-top: 6px; font-size: 13px; }
.crm-hint { font-size: 13px; margin-top: 12px; }

.crm-stop { background: var(--danger-soft); border: 1.5px solid var(--danger); color: var(--on-tile); }
.crm-stop-title { font-family: var(--font-sans); font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.crm-stop-guidance { font-size: 15px; margin-bottom: 14px; max-width: 68ch; }
.crm-stop-btn {
  width: 100%; min-height: 54px; font-size: 16px; font-weight: 700;
  background: var(--danger); color: var(--on-danger); border-color: var(--danger);
}
.crm-stop-btn:disabled { opacity: 0.5; }

details.card { padding: 0 22px; }
details.card > summary.crm-summary {
  display: flex; align-items: center; min-height: 56px; cursor: pointer; list-style: none;
  font-weight: 600; font-size: 15px;
}
details.card > summary.crm-summary::-webkit-details-marker { display: none; }
details.card > summary.crm-summary::before {
  content: "+"; display: inline-block; width: 1.2em; font-family: var(--font-mono); color: var(--text-muted);
}
details.card[open] > summary.crm-summary::before { content: "\2212"; }
details.card[open] { padding-bottom: 18px; }
details.card .muted { margin-bottom: 10px; }

.crm-list { list-style: none; display: flex; flex-direction: column; }
.crm-list li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.crm-list li:last-child { border-bottom: none; }
.crm-list .meta { color: var(--text-muted); font-size: 13px; }
.crm-list .note { white-space: pre-wrap; overflow-wrap: anywhere; }
.crm-list .btn { margin-top: 6px; }
.crm-list + .crm-list { margin-top: 8px; border-top: 1px solid var(--border); }

/* ── Help page ───────────────────────────────────────────────── */

.crm-help { max-width: 760px; margin: 0 auto; }
.crm-help .card h2 { font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; margin-bottom: 10px; }
.crm-help p + p, .crm-help p + ul, .crm-help ul + p { margin-top: 10px; }
.crm-help ul { padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.crm-help dl { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 8px 16px; margin: 0; }
.crm-help dt { font-weight: 700; }
.crm-help dd { margin: 0; }
.crm-help dd > p { margin-top: 8px; }
.crm-help .crm-stop { margin-top: 12px; }
.crm-help code { font-family: var(--font-mono); font-size: 0.92em; }
.crm-help-intro { font-size: 17px; color: var(--text-muted); margin-bottom: 20px; }

/* Phone: the list table becomes one card per company. */
@media (max-width: 600px) {
  .crm-top { padding: 8px 16px; }
  .crm-brand-sub { display: none; }
  .crm-user-name { display: none; }
  .crm-main { padding: 16px 16px 96px; }
  .crm-tabs { display: flex; width: 100%; }
  .crm-tabs button { flex: 1 1 0; padding: 0 8px; font-size: 14px; }
  .crm-filters { padding: 14px; }
  .crm-chip-row > .crm-label { width: 100%; }
  .crm-field { min-width: 0; flex: 1 1 100%; }
  .crm-table thead { display: none; }
  .crm-table, .crm-table tbody, .crm-table tr, .crm-table td { display: block; width: 100%; }
  .table-card { background: none; border: 0; overflow: visible; }
  .crm-table tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 12px; padding: 8px 16px;
  }
  .crm-table tbody tr:hover td { background: none; }
  .crm-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    min-height: 44px; padding: 8px 0; border-bottom: 1px solid var(--border); text-align: right;
  }
  .crm-table tbody tr td:last-child { border-bottom: none; }
  .crm-table td::before {
    content: attr(data-label); color: var(--text-muted); font-size: 12px; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase; text-align: left;
  }
  .crm-table td.crm-cell-main { display: block; text-align: left; }
  .crm-table td.crm-cell-main::before { content: none; }
  .crm-row-why { max-width: none; }
  .crm-table td.num { text-align: right; }
  .crm-company { font-size: 28px; }
  .crm-owner-actions .btn { flex: 1 1 auto; }
  .crm-owner-form { padding: 12px; }
  .card { padding: 18px; }
  details.card { padding: 0 18px; }
  .crm-help dl { grid-template-columns: 1fr; }
  .crm-help dd { margin-bottom: 8px; }
}
