/* Alpinvest Client Platform — self-contained stylesheet (no CDN dependencies).
   Monochrome identity: black, white and warm greys. Colour is reserved for status (ok / attention / problem).
   To rebrand, change the tokens in :root only. */
:root {
  --bg: #f6f6f4; --panel: #ffffff; --ink: #18181b; --ink-2: #3f3f46; --muted: #71717a; --faint: #a1a1aa;
  --line: #e7e7e4; --line-strong: #d6d6d2; --hover: #f2f2ef; --sunk: #fafaf9;
  --brand: #ffffff; --brand-ink: #18181b; --accent: #18181b; --accent-soft: #f2f2ef;
  --ok: #157f3c; --ok-bg: #eaf6ee; --ok-line: #bfe3cb;
  --warn: #a45a06; --warn-bg: #fdf3e2; --warn-line: #f2d6a6;
  --bad: #b42318; --bad-bg: #fdeceb; --bad-line: #f5c2bd;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 1px 1px rgba(24, 24, 27, .03);
  --shadow-lg: 0 8px 24px rgba(24, 24, 27, .08), 0 2px 6px rgba(24, 24, 27, .04);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sidebar-w: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.55 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; transition: text-decoration-color .15s; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 24px; line-height: 1.25; letter-spacing: -.015em; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 16px; letter-spacing: -.005em; margin: 28px 0 10px; font-weight: 600; }
h3 { font-size: 11.5px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.panel > h3:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
table, .kpi { font-variant-numeric: tabular-nums; }

/* --- shell & sidebar ------------------------------------------------------ */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--brand); color: var(--brand-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); overflow-y: auto; }
.sidebar a.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin: 2px 0 20px; padding: 4px 8px; text-decoration: none; }
.sidebar a.brand:hover { background: none; }
.brand-logo { display: block; width: 168px; height: auto; }
.brand-sub { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.sidebar .nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; padding: 14px 10px 4px; }
.sidebar a { display: flex; align-items: center; gap: 10px; color: var(--ink-2); padding: 7px 10px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 500; transition: background .12s, color .12s; }
.sidebar a svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--muted); transition: color .12s; }
.sidebar a:hover { background: var(--hover); color: var(--ink); }
.sidebar a:hover svg { color: var(--ink); }
.sidebar a.active { background: var(--ink); color: #fff; }
.sidebar a.active svg { color: #fff; }
.sidebar .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 600; text-align: center; line-height: 18px; }
.sidebar a.active .count { background: #fff; color: var(--ink); }
.sidebar-footer { margin-top: auto; padding: 12px 6px 2px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.sidebar-footer .who { min-width: 0; flex: 1; }
.sidebar-footer .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .muted { color: var(--muted); font-size: 11.5px; }
.sidebar-footer form { margin: 0; }
.sidebar-footer button.link { color: var(--muted); font-size: 12px; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.sidebar-footer button.link:hover { color: var(--ink); }
.user-chip { width: 30px; height: 30px; border-radius: 50%; background: var(--hover); border: 1px solid var(--line); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: 11.5px; flex: 0 0 auto; }

.content { flex: 1; min-width: 0; padding: 30px 40px 40px 68px; max-width: 1240px; position: relative; }
.nav-toggle { position: absolute; top: 28px; left: 18px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; box-shadow: var(--shadow); transition: color .12s, border-color .12s; }
.nav-toggle:hover { color: var(--ink); border-color: var(--line-strong); }
html.nav-hidden .sidebar { display: none; }
html.nav-hidden .content { max-width: 1440px; }

/* --- page header, actions, buttons --------------------------------------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; min-height: 34px; }
.page-head h1 .badge { vertical-align: 4px; margin-left: 4px; }
.page-head .muted { margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; font-weight: 500; line-height: 1.4; text-decoration: none; box-shadow: var(--shadow); transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { text-decoration: none; background: var(--sunk); border-color: var(--faint); }
.btn:active { box-shadow: none; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2e2e33; border-color: #2e2e33; }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { padding: 3px 10px; font-size: 12.5px; }
button.link { background: none; border: 0; color: var(--ink); cursor: pointer; padding: 4px 0; font: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 22px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 9px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; font-weight: 500; white-space: nowrap; transition: color .12s, border-color .12s; }
.tabs a.active { color: var(--ink); border-color: var(--ink); font-weight: 600; }
.tabs a:hover { color: var(--ink); }

/* --- panels, grids, facts ------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid > .panel { margin-bottom: 0; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
.grid + .panel { margin-top: 16px; }

dl.facts { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* --- KPI cards ------------------------------------------------------------ */
.stat { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s; }
a.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
.stat .stat-label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat .stat-label svg { width: 16px; height: 16px; }
.stat .stat-foot { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.kpi { font-size: 30px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.stat.attention .kpi { color: var(--warn); }
.stat.problem .kpi { color: var(--bad); }

/* --- tables --------------------------------------------------------------- */
table.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.list th, table.list td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); background: var(--sunk); font-weight: 600; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { transition: background .1s; }
table.list tbody tr:hover td { background: var(--sunk); }
table.list td a { font-weight: 500; text-decoration: none; }
table.list td a:hover { text-decoration: underline; text-decoration-color: var(--ink); }

/* --- badges: neutral by default, colour only for status ------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.6; background: var(--hover); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap; text-transform: none; letter-spacing: normal; vertical-align: 1px; }
.badge.company, .badge.trust, .badge.individual, .badge.investment, .badge.level, .badge.restricted { background: var(--panel); color: var(--ink-2); border-color: var(--line-strong); }
.badge.internal { background: var(--ink); color: #fff; }
/* ok */
.badge.active, .badge.complete, .badge.verified, .badge.clear, .badge.accepted { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
/* attention */
.badge.pending, .badge.onboarding, .badge.prospect, .badge.due_for_review, .badge.incomplete, .badge.received { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
/* problem */
.badge.expired, .badge.overdue, .badge.rejected, .badge.confirmed { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.badge.rejected { text-decoration: line-through; }
/* inactive */
.badge.closed, .badge.dormant { background: var(--hover); color: var(--muted); }
.badge.active::before, .badge.complete::before, .badge.verified::before, .badge.clear::before,
.badge.pending::before, .badge.onboarding::before, .badge.due_for_review::before, .badge.incomplete::before,
.badge.expired::before, .badge.overdue::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* --- forms ---------------------------------------------------------------- */
input[type=text], input[type=email], input[type=date], input[type=number], input[type=password], input[type=search], input[type=url], input[type=tel], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 7px 10px; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(24, 24, 27, .08); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled, select:disabled, textarea:disabled { background: var(--hover); color: var(--faint); cursor: not-allowed; }
.field.is-disabled label, .field.is-disabled .helptext { color: var(--faint); }
form.stack p, form.stack .field { margin: 0 0 14px; }
form.stack label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
form.stack input[type=text], form.stack input[type=email], form.stack input[type=date], form.stack input[type=number], form.stack input[type=password],
form.stack select, form.stack textarea { width: 100%; }
form.stack textarea { min-height: 76px; }
form.stack .helptext { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
form.stack .errorlist { color: var(--bad); margin: 3px 0 0; padding-left: 16px; font-size: 12px; font-weight: 600; }
form.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 16px; box-shadow: var(--shadow); }
.filters input[type=text] { flex: 1 1 240px; }
.formset table { width: 100%; border-collapse: collapse; }
.formset td, .formset th { padding: 4px 6px; font-size: 13px; }
.formset input, .formset select { width: 100%; padding: 6px 8px; }
.formset input[type=checkbox] { width: auto; }

/* --- messages, empty states ---------------------------------------------- */
.messages { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--ink); box-shadow: var(--shadow); }
.msg.success { border-left-color: var(--ok); }
.msg.warning { border-left-color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.msg.error { border-left-color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); font-weight: 500; }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* --- sign-in -------------------------------------------------------------- */
.content.auth { max-width: none; }
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; width: 100%; }
.login { width: 100%; max-width: 400px; padding: 40px 36px 28px; box-shadow: var(--shadow-lg); }
.login .brand { position: relative; margin: 0 0 28px; }
.login .brand-logo { width: 100%; max-width: 320px; display: block; }
/* invisible spot between the N and the V of the logo: opens the administrator sign-in */
.login .logo-spot { position: absolute; left: 55%; width: 6%; top: 0; height: 62%; cursor: default; }
.login-title { font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 22px; }
.login .btn { width: 100%; justify-content: center; padding: 11px 14px; font-size: 14.5px; }
.login .btn.sso svg { width: 18px; height: 18px; }
.login-hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; text-align: center; }
.login .local-login { margin-top: 6px; }
.login-messages { margin: 0 0 16px; }
.login-foot { color: var(--faint); font-size: 11.5px; text-align: center; margin: 26px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.login .divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 18px 0; }
.login .divider::before, .login .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.ended { color: var(--muted); }

/* --- wide forms ----------------------------------------------------------- */
.form-wide .panel { margin-bottom: 14px; }
.form-wide h3 { margin-top: 0; }
.fgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px 16px; }
.fgrid .span-1 { grid-column: span 1; } .fgrid .span-2 { grid-column: span 2; } .fgrid .span-3 { grid-column: span 3; }
.fgrid .span-4 { grid-column: span 4; } .fgrid .span-6 { grid-column: span 6; }
.field .req { color: var(--bad); }
.field .error { display: block; color: var(--bad); font-size: 12px; margin-top: 3px; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }
.field.check label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); margin-right: 12px; }
label.inline input { width: auto; margin: 0; }
label.inline.danger { color: var(--bad); }
.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.row-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--sunk); }
.row-card.deleted { opacity: .5; }
.row-line { display: flex; gap: 10px; align-items: center; }
.row-line .grow { flex: 1; }
.row-line select, .row-line input[type=text] { width: 100%; }
.row-line label.inline { white-space: nowrap; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.panel.internal { border-left: 3px solid var(--warn); }
.savebar { position: sticky; bottom: 0; background: rgba(246, 246, 244, .92); backdrop-filter: blur(6px); padding: 12px 0; display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); margin-top: 4px; z-index: 5; }
.form-wide .errorlist { color: var(--bad); font-size: 12px; margin: 0 0 6px; padding-left: 16px; }

/* --- avatars -------------------------------------------------------------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; vertical-align: middle; background: var(--hover); }
.avatar.lg { width: 72px; height: 72px; }
.avatar.sm { width: 24px; height: 24px; }
.avatar.initials { display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11.5px; color: var(--ink-2); background: var(--hover); border: 1px solid var(--line); letter-spacing: .02em; }
.avatar.initials.lg { font-size: 22px; }
.avatar.initials.organisation { border-radius: 8px; background: var(--ink); color: #fff; border-color: var(--ink); }
.avatar.organisation { border-radius: 8px; }
.with-avatar { display: inline-flex; align-items: center; gap: 10px; }
.photo-field { display: flex; align-items: center; gap: 16px; }

/* --- documents ------------------------------------------------------------ */
.doc-cat { margin-bottom: 20px; }
.doc-cat h3 { margin-bottom: 8px; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 6px; box-shadow: var(--shadow); transition: border-color .12s; }
.doc-row:hover { border-color: var(--line-strong); }
.doc-row .grow { flex: 1; min-width: 0; }
.doc-row .grow > a { font-weight: 500; text-decoration: none; }
.doc-row .grow > a:hover { text-decoration: underline; }
.doc-row .meta { font-size: 12px; color: var(--muted); }
.doc-icon { width: 34px; height: 40px; border: 1px solid var(--line-strong); border-radius: 5px; display: inline-flex; align-items: flex-end; justify-content: center; font-size: 9.5px; font-weight: 700; padding-bottom: 4px; letter-spacing: .04em; flex: 0 0 auto; background: linear-gradient(225deg, var(--hover) 9px, #fff 9px); color: var(--ink-2); }
.preview { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); background: var(--sunk); transition: border-color .12s, background .12s; }
.dropzone.over { border-color: var(--ink); color: var(--ink); background: #fff; }
.dropzone input[type=file] { display: block; margin: 10px auto 0; }
.pdf-preview { background: var(--hover); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; max-height: 78vh; overflow-y: auto; }
.pdf-preview img { display: block; width: 100%; margin: 0 auto 12px; box-shadow: var(--shadow-lg); background: #fff; }
select[multiple] { min-height: 120px; }
.checklist .checklist-filter { width: 100%; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.checklist-box { max-height: 180px; overflow-y: auto; border: 1px solid var(--line-strong); border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: #fff; padding: 4px 10px; }
.checklist-box ul { list-style: none; margin: 0; padding: 0; }
.checklist-box li { padding: 3px 0; }
.checklist-box label { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink); cursor: pointer; }
.checklist-box input { width: auto; margin: 0; }

/* --- small screens -------------------------------------------------------- */
@media (max-width: 900px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 28px 16px; }
  .nav-toggle { position: static; margin-bottom: 14px; }
  .sidebar { --sidebar-w: 210px; }
  .fgrid { grid-template-columns: repeat(2, 1fr); } .fgrid [class*=span-] { grid-column: span 2; }
  dl.facts { grid-template-columns: 1fr; gap: 2px; } dl.facts dd { margin-bottom: 8px; }
  .page-head { flex-wrap: wrap; }
  table.list { display: block; overflow-x: auto; }
}

/* Helpers instead of style="" attributes, which the Content-Security-Policy refuses. */
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; }
.w-480 { max-width: 480px; } .w-560 { max-width: 560px; } .w-640 { max-width: 640px; }
.w-720 { max-width: 720px; } .w-760 { max-width: 760px; } .w-820 { max-width: 820px; }
.inline-form { display: inline; }
.note { text-transform: none; letter-spacing: 0; }
.break-all { word-break: break-all; }
.page-count { text-align: center; padding: 6px; }
.search-wide { min-width: 360px; }
.panel.soft { background: #fafafa; }
.panel.required-panel { border-color: #111; }
