/* Haria Investments CRM — dense, desktop-first financial UI on top of Bootstrap 5. */

:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --surface: #ffffff;
  --canvas: #f6f7f9;
  --brand: #0b2545;
  --brand-soft: #13315c;
  --accent: #0d7c66;
  --accent-soft: #e6f4f1;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 10px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip { position: absolute; top: .5rem; left: .5rem; z-index: 1080; }

/* ---------------------------------------------------------------- layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--brand);
  color: #cbd5e1;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-offcanvas .sidebar { height: 100%; position: static; width: 100%; }
@media (max-width: 991.98px) { .shell > .sidebar { display: none; } }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-name { color: #fff; font-weight: 600; line-height: 1.15; }
.brand-name small { display: block; color: #94a3b8; font-weight: 400; font-size: 11px; }

.nav-group { margin-bottom: 14px; }
.nav-label {
  font-size: 10px; letter-spacing: .11em; text-transform: uppercase;
  color: #64748b; padding: 6px 10px;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px; color: #cbd5e1; font-weight: 500;
  cursor: pointer; user-select: none;
}
.sidebar .nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.sidebar .nav-item.active { background: rgba(255,255,255,.13); color: #fff; }
.sidebar .nav-item.sub {
  /* Indent rail, aligned under the parent's icon. */
  margin-left: 18px; padding-left: 18px; border-left: 1px solid rgba(255, 255, 255, .12);
  border-radius: 0 8px 8px 0; font-weight: 400; font-size: 13px; color: #9fb0c4;
}
.sidebar .nav-item.sub:hover { color: #fff; }
.sidebar .nav-item.sub.active { color: #fff; border-left-color: #60a5fa; }

.nav-ico, .nav-caret {
  flex: none; width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: .8;
}
.nav-item.active .nav-ico { opacity: 1; }

/* Collapsible group — plain <details>, no JavaScript. */
.nav-collapse > summary { list-style: none; }
.nav-collapse > summary::-webkit-details-marker { display: none; }
.nav-collapse > summary:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
.nav-caret { width: 14px; height: 14px; margin-left: auto; opacity: .55; transition: transform .16s ease; }
.nav-collapse[open] > summary .nav-caret { transform: rotate(90deg); }

.nav-count { margin-left: auto; font-size: 11px; color: #94a3b8; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.crumbs { font-size: 13px; color: var(--ink-faint); flex: 1; min-width: 0; }
.crumbs a { color: var(--ink-soft); }
.crumbs .sep { padding: 0 6px; color: var(--line); }
.topsearch { width: min(360px, 40vw); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 600;
}

.page { padding: 22px; max-width: 1500px; width: 100%; }

/* ------------------------------------------------------------- typography */

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-faint); font-weight: 600; margin: 0 0 10px;
}

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ------------------------------------------------------------------ cards */

.card-crm {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 16px;
}
.card-crm > header {
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px;
}
.card-crm > header h2 { font-size: 13px; font-weight: 650; margin: 0; }
.card-crm > header .spacer { margin-left: auto; }
.card-body-crm { padding: 14px 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); font-weight: 600; }
.stat .value { font-size: 23px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.stat.accent { border-left: 3px solid var(--accent); }
.stat.warn { border-left: 3px solid var(--warn); }

/* ----------------------------------------------------------------- tables */

.table-crm { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-crm th {
  text-align: left; font-weight: 600; font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfcfd;
}
.table-crm td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table-crm tbody tr:hover { background: #fafbfc; }
.table-crm tbody tr:last-child td { border-bottom: 0; }
.table-crm .r { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.sort-link { color: inherit; }
.sort-link:hover { color: var(--brand-soft); }

.name-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.chip {
  width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 650;
}
.name-cell .meta { color: var(--ink-faint); font-size: 11.5px; }

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.badge-ok { background: var(--accent-soft); color: #08604e; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--line-soft); color: var(--ink-soft); }
.badge-risk-low { background: #e0f2fe; color: #075985; }
.badge-risk-mid { background: #ede9fe; color: #5b21b6; }
.badge-risk-high { background: #ffe4e6; color: #9f1239; }
.badge-info { background: #e0e7ff; color: #3730a3; }

/* ------------------------------------------------------------------ misc */

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filters .form-control, .filters .form-select { min-width: 140px; }

.empty { text-align: center; padding: 44px 16px; color: var(--ink-soft); }
.empty .icon { font-size: 26px; opacity: .35; }
.empty h3 { font-size: 15px; font-weight: 600; margin: 8px 0 4px; color: var(--ink); }

.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--ink-faint); font-weight: 500; }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }

.bar { height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.form-section { border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 14px; }
.form-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
label.form-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 3px; }
.form-control, .form-select { font-size: 13px; }
.form-text { font-size: 11.5px; }

.btn { font-size: 13px; }
.btn-brand { background: var(--brand); color: #fff; border: 1px solid var(--brand); }
.btn-brand:hover { background: var(--brand-soft); color: #fff; }

.row-error { background: #fff7f7 !important; }
.row-warn { background: #fffdf5 !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; background: var(--brand); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 30px; }

@media print {
  .sidebar, .topbar, .actions { display: none !important; }
  .page { padding: 0; }
}

/* Django's built-in auth forms render bare inputs — style them without touching the views. */
form input:not([class]), form select:not([class]), form textarea:not([class]) {
  display: block; width: 100%; padding: .375rem .75rem; font-size: 13px;
  border: 1px solid #ced4da; border-radius: 6px; background: #fff;
}

/* ------------------------------------------------------------------ brand */

.brand-mark { width: 34px; height: 34px; object-fit: contain; }

/* The mark is deep blue on transparent, so on the navy sidebar it sits on a
   light tile — the way the logo is designed to be read. */
.sidebar .brand-mark {
  width: 38px; height: 38px; padding: 5px;
  background: #fff; border-radius: 9px;
}
.brand-mark-lg { width: 54px; height: 54px; }

/* --------------------------------------------------------------- loaders */

@property --sweep { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

/* The tree "grows": leaves light up around the sweep while the mark breathes. */
.logo-spinner {
  display: inline-block; line-height: 0;
  animation: logo-sweep 1.5s linear infinite;
  -webkit-mask-image: conic-gradient(from var(--sweep),
    rgba(0, 0, 0, .24) 0deg, rgba(0, 0, 0, .24) 40deg, #000 130deg, #000 250deg, rgba(0, 0, 0, .24) 340deg);
  mask-image: conic-gradient(from var(--sweep),
    rgba(0, 0, 0, .24) 0deg, rgba(0, 0, 0, .24) 40deg, #000 130deg, #000 250deg, rgba(0, 0, 0, .24) 340deg);
}
.logo-spinner img { animation: logo-breathe 1.8s ease-in-out infinite; }

@keyframes logo-sweep { to { --sweep: 360deg; } }
@keyframes logo-breathe {
  0%, 100% { transform: scale(.94); opacity: .82; }
  50%      { transform: scale(1.04); opacity: 1; }
}

.loader-overlay {
  position: fixed; inset: 0; z-index: 1090;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(246, 247, 249, .82);
  backdrop-filter: blur(3px);
}
.loader-overlay.is-active { display: flex; animation: loader-fade .18s ease-out; }
@keyframes loader-fade { from { opacity: 0; } to { opacity: 1; } }

.loader-mark {
  line-height: 0;
  animation: logo-sweep 1.5s linear infinite;
  -webkit-mask-image: conic-gradient(from var(--sweep),
    rgba(0, 0, 0, .22) 0deg, rgba(0, 0, 0, .22) 40deg, #000 130deg, #000 250deg, rgba(0, 0, 0, .22) 340deg);
  mask-image: conic-gradient(from var(--sweep),
    rgba(0, 0, 0, .22) 0deg, rgba(0, 0, 0, .22) 40deg, #000 130deg, #000 250deg, rgba(0, 0, 0, .22) 340deg);
}
.loader-mark img { width: 88px; height: auto; animation: logo-breathe 1.8s ease-in-out infinite; }

.loader-text {
  margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-faint);
}

/* Inline spinner for buttons / htmx targets. */
.logo-spinner-sm img { width: 22px; height: auto; }

@media (prefers-reduced-motion: reduce) {
  .loader-mark, .logo-spinner, .loader-mark img, .logo-spinner img { animation: none; }
  .loader-overlay.is-active { animation: none; }
}

.nav-badge {
  margin-left: auto; margin-right: 6px; min-width: 20px; text-align: center;
  padding: 1px 6px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: #b45309; color: #fff;
}

/* ------------------------------------------------------------------ leads */

.pipeline { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
.pipeline-step {
  flex: 1 1 130px; min-width: 120px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  position: relative; text-decoration: none; color: inherit;
}
.pipeline-step:hover { border-color: var(--brand-soft); text-decoration: none; }
.pipeline-step .n { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pipeline-step .s { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); font-weight: 600; }
.pipeline-step::after {
  content: '→'; position: absolute; right: -13px; top: 50%; transform: translateY(-50%);
  color: var(--line); font-size: 15px; z-index: 1;
}
.pipeline-step:last-child::after { content: none; }
@media (max-width: 700px) { .pipeline-step::after { content: none; } }

/* ------------------------------------------------- requirement picker
   Two accent-coded lanes of instrument tiles. Each asset class carries its own
   glyph so eight options read as eight things, not eight identical boxes.
   Real <input type=checkbox> underneath — the tile is only its skin.          */

.req-picker header .req-summary {
  font-size: 12px; color: var(--ink-faint); text-align: right;
  max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.req-picker header .req-summary.has-selection { color: var(--accent); font-weight: 600; }

.req-lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 26px; }

.req-lane { border: 0; margin: 0; padding: 0; min-width: 0; --lane: var(--accent); }
.req-lane--insurance { --lane: #4f46e5; }
.req-lane > legend {
  float: none; width: 100%; display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; padding: 0;
}
.req-lane-name {
  font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--lane);
}
.req-lane-rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

.req-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 460px) { .req-tiles { grid-template-columns: 1fr; } }

.req-tile {
  position: relative; display: grid;
  grid-template-columns: 34px 1fr 18px; align-items: center; gap: 11px;
  padding: 12px 13px 12px 15px; min-height: 62px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
  cursor: pointer; overflow: hidden;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
  animation: req-rise .32s cubic-bezier(.2, .7, .3, 1) backwards;
}
.req-tile:nth-child(1) { animation-delay: .02s; }
.req-tile:nth-child(2) { animation-delay: .06s; }
.req-tile:nth-child(3) { animation-delay: .10s; }
.req-tile:nth-child(4) { animation-delay: .14s; }

@keyframes req-rise { from { opacity: 0; transform: translateY(6px); } }

/* The filling rail on the left edge is the primary "on" signal. */
.req-tile::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--lane); transform: scaleY(0); transform-origin: center;
  transition: transform .2s cubic-bezier(.2, .7, .3, 1);
}

.req-tile input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;  /* focusable, unseen */
}

.req-glyph {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--line-soft); color: var(--ink-soft);
  transition: background .16s ease, color .16s ease;
}
.req-glyph svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

.req-name { font-size: 13.5px; line-height: 1.25; color: var(--ink); text-wrap: balance; }

.req-mark { width: 18px; height: 18px; color: var(--lane); opacity: 0; transform: scale(.5); }
.req-mark svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 26; stroke-dashoffset: 26;
}

.req-tile:hover { border-color: color-mix(in srgb, var(--lane) 45%, var(--line)); }
.req-tile:hover .req-glyph { background: color-mix(in srgb, var(--lane) 12%, #fff); color: var(--lane); }

.req-tile:has(input:checked) {
  border-color: var(--lane);
  background: color-mix(in srgb, var(--lane) 6%, #fff);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--lane) 22%, transparent);
}
.req-tile:has(input:checked)::before { transform: scaleY(1); }
.req-tile:has(input:checked) .req-glyph { background: var(--lane); color: #fff; }
.req-tile input:checked ~ .req-name { font-weight: 600; }
.req-tile input:checked ~ .req-mark { opacity: 1; transform: scale(1); transition: opacity .12s ease, transform .22s cubic-bezier(.2, 1.5, .4, 1); }
.req-tile input:checked ~ .req-mark svg { animation: req-draw .28s ease forwards .04s; }

@keyframes req-draw { to { stroke-dashoffset: 0; } }

.req-tile:active { transform: scale(.985); }
.req-tile:has(input:focus-visible) { outline: 2px solid var(--lane); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .req-tile, .req-tile::before, .req-mark, .req-mark svg { animation: none; transition: none; }
  .req-mark svg { stroke-dashoffset: 0; }
}

/* Fallback for engines without :has() — selection still reads clearly. */
@supports not selector(:has(*)) {
  .req-tile input:checked ~ .req-glyph { background: var(--lane); color: #fff; }
  .req-tile input:checked ~ .req-name { color: var(--lane); }
}

.quick-dates { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.quick-dates .btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* <details> styled as a card, matching .card-crm headers. */
.details-card > .card-summary {
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  list-style: none; cursor: pointer;
}
.details-card > .card-summary::-webkit-details-marker { display: none; }
.details-card > .card-summary h2 { font-size: 13px; font-weight: 650; margin: 0; }
.details-card > .card-summary .nav-caret { margin-left: auto; color: var(--ink-faint); opacity: 1; }
.details-card[open] > .card-summary { border-bottom: 1px solid var(--line-soft); }
.details-card[open] > .card-summary .nav-caret { transform: rotate(90deg); }
.details-card > .card-summary:focus-visible { outline: 2px solid var(--brand-soft); outline-offset: -2px; }

.lead-form { max-width: 940px; }

.req-line { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.req-line .tick { width: 16px; font-weight: 700; }
.req-line.on .tick { color: var(--accent); }
.req-line.off { color: var(--ink-faint); }

.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 1px; background: var(--line);
}
.timeline-item { position: relative; padding: 0 0 16px; }
.timeline-item::before {
  content: ''; position: absolute; left: -20px; top: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
}
.timeline-item.muted::before { border-color: var(--line); }
.timeline-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.timeline-head .when { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.timeline-body { font-size: 13px; margin-top: 2px; white-space: pre-line; }
.timeline-meta { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; }

.next-action {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 12px 14px; border-radius: 8px;
}
.next-action.overdue { border-left-color: var(--danger); background: var(--danger-soft); }
.next-action.today { border-left-color: var(--warn); background: var(--warn-soft); }
.next-action .when { font-size: 17px; font-weight: 650; }

/* ------------------------------------------------------------------ drawer
   Listing rows open their detail panel in a native <dialog>: Esc, focus trap
   and backdrop come from the platform.                                       */

.table-rows-clickable tbody tr[role="button"] { cursor: pointer; }
.table-rows-clickable tbody tr[role="button"]:focus-visible {
  outline: 2px solid var(--brand-soft); outline-offset: -2px;
}
.table-rows-clickable .row-title { font-weight: 600; color: var(--brand-soft); }
.table-rows-clickable tbody tr:hover .row-title { text-decoration: underline; }

dialog.drawer {
  margin: 0 0 0 auto; height: 100%; max-height: 100%;
  width: min(440px, 100vw); max-width: 100vw;
  border: 0; border-left: 1px solid var(--line); padding: 0;
  background: var(--surface); color: var(--ink);
  box-shadow: -18px 0 40px rgba(15, 23, 42, .14);
}
/* Only the open dialog is a flex column — leaving `display` unscoped would
   override the UA's display:none and leave a ghost panel on the page. */
dialog.drawer[open] { display: flex; flex-direction: column; }
dialog.drawer::backdrop { background: rgba(15, 23, 42, .32); backdrop-filter: blur(2px); }
dialog.drawer[open] { animation: drawer-in .22s cubic-bezier(.2, .7, .3, 1); }
dialog.drawer[open]::backdrop { animation: drawer-fade .22s ease; }

@keyframes drawer-in { from { transform: translateX(24px); opacity: .4; } }
@keyframes drawer-fade { from { opacity: 0; } }

dialog.drawer > div { display: flex; flex-direction: column; min-height: 0; height: 100%; }

.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 16px; font-weight: 650; margin: 0; }
.drawer-close {
  margin-left: auto; border: 0; background: none; font-size: 22px; line-height: 1;
  color: var(--ink-faint); cursor: pointer; padding: 0 4px;
}
.drawer-close:hover { color: var(--ink); }

.drawer-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.drawer-body .kv { grid-template-columns: minmax(110px, 42%) 1fr; }
.drawer-foot {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--line); background: #fbfcfd;
}

@media (prefers-reduced-motion: reduce) {
  dialog.drawer[open], dialog.drawer[open]::backdrop { animation: none; }
}

/* ------------------------------------------- requirement chips (listings)
   The same glyphs as the picker, shrunk to table scale. Hovering one names it. */

.req-chips { display: flex; gap: 5px; flex-wrap: wrap; }

.req-chip {
  position: relative; width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center; flex: none;
  background: var(--line-soft); color: var(--ink-soft);
  transition: background .14s ease, color .14s ease;
  --lane: var(--accent);
}
.req-chip--inv { background: var(--accent-soft); color: #0b6b57; }
.req-chip--ins { background: #eef0ff; color: #4338ca; --lane: #4f46e5; }
.req-chip svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.req-chip:hover { background: var(--lane); color: #fff; }

/* Name on hover. Rendered above the chip; the table wrapper opens its overflow
   on desktop so the label is not clipped (narrow screens do not hover anyway). */
.req-chip::after {
  content: attr(data-label);
  position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .01em;
  opacity: 0; pointer-events: none; z-index: 30;
  transition: opacity .12s ease, transform .12s ease;
}
.req-chip::before {
  content: ''; position: absolute; bottom: calc(100% + 1px); left: 50%;
  transform: translateX(-50%); border: 4px solid transparent; border-top-color: var(--ink);
  opacity: 0; pointer-events: none; z-index: 30; transition: opacity .12s ease;
}
.req-chip:hover::after { opacity: 1; transform: translateX(-50%); }
.req-chip:hover::before { opacity: 1; }

@media (min-width: 992px) {
  .table-wrap--tooltips { overflow: visible; }
}
@media (prefers-reduced-motion: reduce) {
  .req-chip, .req-chip::after { transition: none; }
}

/* ================================================================== dossier
   Add / edit customer. A KYC record being assembled: the sections on the
   right, a sticky ledger on the left that shows the record taking shape.   */

.dossier { max-width: 1180px; }
.dossier-grid { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1100px) { .dossier-grid { grid-template-columns: 1fr; } }

/* The rail must span the row for its sticky child to travel with the scroll. */
.ledger { align-self: stretch; }
.ledger-inner { position: sticky; top: 78px; display: grid; gap: 14px; }
@media (max-width: 1100px) { .ledger { align-self: auto; } .ledger-inner { position: static; } }

/* --- the record as it will appear once saved --- */
.record-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(13, 124, 102, .07), transparent 60%),
    var(--surface);
  padding: 14px 15px;
}
.record-card-top { display: flex; align-items: center; gap: 11px; }
.record-initials { width: 38px; height: 38px; border-radius: 10px; font-size: 13px; }
.record-name {
  font-size: 15px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.record-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.record-meta {
  margin-top: 11px; padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: 11.5px; color: var(--ink-soft); display: flex; gap: 6px; flex-wrap: wrap;
}
.record-meta .dot { color: var(--line); }
.min-w-0 { min-width: 0; }

/* --- progress ledger --- */
.ledger-steps { display: grid; gap: 2px; }
.ledger-step {
  --fill: 0;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px; color: var(--ink-soft); font-size: 13px;
}
.ledger-step:hover { background: var(--surface); color: var(--ink); text-decoration: none; }
.ledger-step.is-started { color: var(--ink); }

.ledger-ring {
  /* A real progress donut: filled arc over a visible track. */
  flex: none; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--accent) calc(var(--fill) * 360deg), var(--line) 0);
  transition: background .25s ease;
}
.ledger-ring i {
  width: 12px; height: 12px; border-radius: 50%; background: var(--canvas); display: block;
}
.ledger-step.is-complete .ledger-ring i { background: var(--accent); }
.ledger-step.is-complete .ledger-ring i::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 5px; height: 2.5px; border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translate(0, -1px);
}
.ledger-label { display: flex; align-items: baseline; gap: 6px; width: 100%; }
.ledger-count {
  margin-left: auto; font-style: normal; font-size: 11px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.ledger-step.is-complete .ledger-count { color: var(--accent); }

.ledger-note {
  margin: 0; padding: 11px 12px; border-left: 2px solid var(--line);
  font-size: 11.5px; line-height: 1.55; color: var(--ink-faint);
}

/* --- section sheets --- */
.dossier-sections { display: grid; gap: 16px; }
.sheet { margin: 0; animation: sheet-in .34s cubic-bezier(.2, .7, .3, 1) backwards; animation-delay: calc(var(--i) * .05s); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } }

.sheet-head {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
}
.sheet-index {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; font-weight: 600; color: var(--ink-faint);
  padding-top: 2px; letter-spacing: .04em;
}
.sheet-head h2 { font-size: 14px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.sheet-head p { margin: 2px 0 0; font-size: 12px; color: var(--ink-faint); }
.sheet-progress {
  margin-left: auto; font-size: 11px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums; padding: 2px 8px;
  border: 1px solid var(--line); border-radius: 999px; white-space: nowrap;
}

/* Identifiers are data, so they get the data face. */
.mono-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em; font-size: 13px;
}
#id_pan { text-transform: uppercase; }

.field-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 4px; min-height: 15px; }
.field-hint.is-ok { color: var(--accent); font-weight: 600; }
.field-hint.is-warn { color: var(--warn); }

/* --- segmented control (risk profile) --- */
.segmented-label { display: block; }
.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  background: var(--line-soft); border-radius: 10px;
}
.segmented-option { position: relative; }
.segmented-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented-option span {
  display: block; padding: 7px 15px; border-radius: 7px; font-size: 13px;
  color: var(--ink-soft); cursor: pointer; white-space: nowrap;
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}
.segmented-option:hover span { color: var(--ink); }
.segmented-option input:checked + span {
  background: var(--surface); color: var(--brand); font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
}
.segmented-option input:focus-visible + span { outline: 2px solid var(--brand-soft); outline-offset: 1px; }

/* --- sticky actions --- */
.dossier-actions {
  position: sticky; bottom: 0; z-index: 15;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin-top: 2px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.dossier-dirty {
  margin-left: auto; font-size: 12px; color: var(--warn); font-weight: 600;
}
.dossier-dirty::before { content: '● '; }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}

/* ========================================== customer relationship sheet
   The one page in the app that opens on the brand ground: identity and the
   money in a single band, then the record's depth behind tabs.            */

.sheet-page { display: grid; gap: 16px; }

.masthead {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr) auto;
  gap: 22px; align-items: center;
  padding: 20px 22px; border-radius: 14px;
  background:
    radial-gradient(90% 140% at 100% 0%, rgba(13, 124, 102, .35), transparent 62%),
    linear-gradient(180deg, var(--brand-soft), var(--brand));
  color: #e6eefb;
}
@media (max-width: 1080px) { .masthead { grid-template-columns: 1fr; gap: 16px; } }

.masthead-identity { display: flex; align-items: center; gap: 15px; min-width: 0; }
.monogram {
  width: 54px; height: 54px; flex: none; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18);
  color: #fff; font-size: 17px; font-weight: 650; letter-spacing: .02em;
}
.masthead h1 {
  margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.02em; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.masthead-meta { font-size: 12.5px; color: #a9bcd8; margin-top: 3px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.masthead-meta a { color: #cfe0f7; text-decoration: underline; text-underline-offset: 2px; }
.masthead-meta .muted { color: #7f93b3; }
.sep-dot { width: 3px; height: 3px; border-radius: 50%; background: #56698a; display: inline-block; }
.masthead-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }

.masthead-money { min-width: 0; }
.money-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #8ba4c7;
}
.money-figure {
  font-size: 30px; font-weight: 650; letter-spacing: -.025em; color: #fff;
  font-variant-numeric: tabular-nums; line-height: 1.15; margin: 2px 0 9px;
}
.money-figure .cur { font-size: 19px; font-weight: 500; color: #9fb6d6; margin-right: 3px; }

.alloc-bar {
  display: flex; height: 8px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, .12);
}
.alloc-seg { display: block; height: 100%; animation: alloc-grow .5s cubic-bezier(.2, .7, .3, 1) backwards; }
@keyframes alloc-grow { from { width: 0 !important; } }
.alloc-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 9px; font-size: 11.5px; color: #a9bcd8; }
.alloc-key, .alloc-name { display: inline-flex; align-items: center; gap: 6px; }
.alloc-key b { color: #fff; font-weight: 600; }
.alloc-key i, .alloc-name i { width: 8px; height: 8px; border-radius: 2px; flex: none; }

/* One colour per asset class, used by the bar, the legend and the rows. */
.alloc-MUTUAL_FUND { background: #2dd4a7; }
.alloc-EQUITY { background: #60a5fa; }
.alloc-FIXED_INCOME { background: #fbbf24; }
.alloc-OTHER { background: #a78bfa; }
.alloc-empty { background: rgba(255, 255, 255, .1); }

.masthead-actions { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 1080px) { .masthead-actions { flex-direction: row; flex-wrap: wrap; } }
.masthead-actions .btn-light {
  background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .16); color: #eaf1fb;
  white-space: nowrap;
}
.masthead-actions .btn-light:hover { background: rgba(255, 255, 255, .2); color: #fff; }

/* --- tabs --- */
.sheet-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.sheet-tab {
  padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.sheet-tab:hover { color: var(--ink); text-decoration: none; }
.sheet-tab em {
  font-style: normal; font-size: 11px; margin-left: 6px; padding: 1px 6px;
  border-radius: 999px; background: var(--line-soft); color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.has-tabs .sheet-tab.is-active { color: var(--brand); font-weight: 650; border-bottom-color: var(--accent); }
.has-tabs .sheet-tab.is-active em { background: var(--accent-soft); color: var(--accent); }

/* Without JS every panel shows; with it, only the selected one. */
.has-tabs .sheet-panel { display: none; }
.has-tabs .sheet-panel.is-active { display: block; animation: panel-in .22s ease; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } }

/* --- overview --- */
.review-strip {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 16px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); background: var(--surface);
}
.review-strip.is-due { border-left-color: var(--warn); background: #fffdf6; }
.review-date { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.review-facts { display: flex; gap: 20px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); align-items: center; }
.review-strip .btn { margin-left: auto; }

/* Four fact cards read best as a balanced 2x2 rather than 3 + 1 orphan. */
.facts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .facts-grid { grid-template-columns: 1fr; } }
.facts-grid .card-crm { margin-bottom: 0; }
.kv-wide { grid-template-columns: minmax(120px, 26%) 1fr; }

.kin-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.kin {
  display: flex; align-items: center; gap: 9px; padding: 9px 13px 9px 9px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: inherit;
}
.kin:hover { border-color: var(--brand-soft); text-decoration: none; }
.kin.is-self { border-color: var(--accent); background: var(--accent-soft); }
.kin b { display: block; font-size: 13px; font-weight: 600; }
.kin span:last-child { font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* --- allocation rows (holdings tab) --- */
.alloc-rows { display: grid; gap: 9px; }
.alloc-row {
  display: grid; grid-template-columns: minmax(130px, 1fr) minmax(90px, 2fr) 120px 62px;
  gap: 12px; align-items: center; font-size: 13px;
}
@media (max-width: 700px) { .alloc-row { grid-template-columns: 1fr auto; } .alloc-track { display: none; } }
.alloc-name i { width: 9px; height: 9px; border-radius: 3px; }
.alloc-track { height: 7px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.alloc-track i { display: block; height: 100%; border-radius: 999px; }
.alloc-amount { text-align: right; }
.alloc-pct { text-align: right; color: var(--ink-faint); font-size: 12px; }

.danger-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; border: 1px dashed var(--line); border-radius: var(--radius);
}
.danger-row .btn { margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  .alloc-seg, .has-tabs .sheet-panel.is-active { animation: none; }
}

/* --------------------------------------------------------- filter chips
   A list should say what is filtering it, and let you drop one thing. */

.filter-chips {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 11px 16px; border-top: 1px solid var(--line-soft);
}
.filter-chips-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint);
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 10px; border-radius: 999px; font-size: 12px;
  background: var(--accent-soft); color: #08604e; border: 1px solid transparent;
}
.filter-chip:hover { border-color: var(--accent); text-decoration: none; }
.filter-chip-key { color: #0b6b57; opacity: .72; }
.filter-chip-value { font-weight: 600; }
.filter-chip-x { font-size: 14px; line-height: 1; opacity: .55; }
.filter-chip:hover .filter-chip-x { opacity: 1; }
.filter-chips-clear { font-size: 12px; color: var(--ink-faint); margin-left: 2px; }
.filter-chips-clear:hover { color: var(--danger); }

/* Rows that navigate. The whole row is the target, not a 12px link. */
tr[data-href] { cursor: pointer; }
tr[data-href]:focus-visible { outline: 2px solid var(--brand-soft); outline-offset: -2px; }
tr[data-href] .row-title { font-weight: 600; color: var(--brand-soft); }
tr[data-href]:hover .row-title { text-decoration: underline; }

/* ----------------------------------------------------------- search */

.topsearch { position: relative; }
.topsearch input { padding-right: 30px; }
.topsearch-key {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; line-height: 1; padding: 2px 5px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--line-soft); color: var(--ink-faint);
  pointer-events: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.topsearch input:focus + .topsearch-key { opacity: 0; }

.search-hero { display: flex; gap: 10px; }
.search-hero input { flex: 1; }

/* Share-of-family column. */
.share-track {
  display: inline-block; width: 46px; height: 5px; border-radius: 999px;
  background: var(--line-soft); overflow: hidden; vertical-align: middle; margin-right: 6px;
}
.share-track i { display: block; height: 100%; background: var(--accent); }
.share-pct { font-size: 11.5px; color: var(--ink-faint); }

/* ------------------------------------------------------------ wizard
   Upload → Preview → Result. The same rail on all three import screens. */

.wizard {
  display: flex; gap: 0; list-style: none; margin: 0 0 16px; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  overflow-x: auto;
}
.wizard-step { display: flex; align-items: center; gap: 10px; padding-right: 26px; position: relative; flex: none; }
.wizard-step + .wizard-step { padding-left: 26px; }
.wizard-step + .wizard-step::before {
  content: ''; position: absolute; left: 0; top: 50%; width: 18px; height: 1px;
  background: var(--line); transform: translateX(-22px);
}
.wizard-dot {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--line-soft); color: var(--ink-faint);
  font-size: 12px; font-weight: 650; flex: none;
}
.wizard-text b { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); line-height: 1.2; }
.wizard-text em { font-style: normal; font-size: 11.5px; color: var(--ink-faint); }

.wizard-step.is-current .wizard-dot { background: var(--brand); color: #fff; }
.wizard-step.is-current .wizard-text b { color: var(--ink); }
.wizard-step.is-done .wizard-dot { background: var(--accent-soft); color: var(--accent); }
.wizard-step.is-done .wizard-dot::after { content: '✓'; }
.wizard-step.is-done .wizard-dot { font-size: 0; }
.wizard-step.is-done .wizard-dot::after { font-size: 12px; }

/* The book total on the investments page. */
.book-total {
  font-size: 27px; font-weight: 650; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; margin-bottom: 11px;
}
.book-total .cur { font-size: 18px; font-weight: 500; color: var(--ink-faint); margin-right: 2px; }
.book-total em {
  font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-faint); margin-left: 10px;
}
.alloc-bar--light { background: var(--line-soft); height: 10px; }

/* One-click type filters. */
.type-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.type-chip {
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
}
.type-chip:hover { border-color: var(--brand-soft); color: var(--ink); text-decoration: none; }
.type-chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* Single-purpose forms sit on a comfortable measure rather than full bleed. */
.form-card { max-width: 860px; }
.form-card > .card-body-crm { padding: 18px 20px; }

/* ------------------------------------------------- sub-page forms
   Adding a holding, a policy or a document always happens *to* someone. */

.stack-form { max-width: 900px; }

.context-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
  padding: 11px 15px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); background: var(--surface); color: inherit;
}
.context-header:hover { border-color: var(--accent); text-decoration: none; }
.context-header b { display: block; font-size: 14px; font-weight: 650; }
.context-header > div > span { font-size: 12px; color: var(--ink-faint); }
.context-back { margin-left: auto; font-size: 12px; color: var(--brand-soft); white-space: nowrap; }

.doc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 9px; }
.doc-tile { grid-template-columns: 1fr 18px; --lane: var(--brand-soft); min-height: 52px; }

/* ------------------------------------------------------- the book strip
   Totals belong on one line so the holdings are the page, not the chrome. */

.book-strip {
  display: flex; align-items: center; gap: 30px; flex-wrap: wrap;
  padding: 15px 20px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.book-strip-figure { flex: none; }
.book-strip-alloc { flex: 1; min-width: 260px; }
.book-strip .money-label { color: var(--ink-faint); }
.book-strip .book-total { font-size: 24px; margin: 2px 0 0; }
.book-return { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.book-return.is-up { color: #0b7a4b; }
.book-return.is-down { color: var(--danger); }
.book-strip-note { font-size: 11px; color: var(--ink-faint); }

.alloc-legend--light { color: var(--ink-soft); gap: 4px 16px; }
.alloc-legend--light .alloc-key { color: inherit; }
.alloc-legend--light .alloc-key:hover { text-decoration: none; color: var(--brand); }
.alloc-legend--light .alloc-key b { color: var(--ink); }
.alloc-legend--light .alloc-key em {
  font-style: normal; color: var(--ink-faint); font-size: 11px; margin-left: 2px;
}

.type-search { margin-left: auto; min-width: 210px; }
.holding-name { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; }
.holding-name i { width: 8px; height: 8px; border-radius: 2px; flex: none; }

.gain-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.gain-chip.is-up { background: var(--accent-soft); color: #0b6b57; }
.gain-chip.is-down { background: var(--danger-soft); color: var(--danger); }

/* A lead masthead leads with the next action rather than a balance. */
.masthead--lead {
  background:
    radial-gradient(90% 140% at 100% 0%, rgba(96, 165, 250, .3), transparent 62%),
    linear-gradient(180deg, var(--brand-soft), var(--brand));
}
.masthead-note { font-size: 12.5px; color: #a9bcd8; margin-top: 7px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead-cta { display: inline-block; margin-top: 6px; color: #cfe0f7; font-size: 13px; }
.btn-convert { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-convert:hover { background: #0a6a57; border-color: #0a6a57; color: #fff; }

/* --------------------------------------------------------- lead pipeline */

.worklist-band {
  display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.worklist-cell {
  flex: 1 1 150px; padding: 15px 18px; color: inherit;
  border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 1px;
}
.worklist-cell:last-child { border-right: 0; }
.worklist-cell:hover { background: #fafbfc; text-decoration: none; }
.worklist-n { font-size: 27px; font-weight: 650; letter-spacing: -.025em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.worklist-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.worklist-note { font-size: 11.5px; color: var(--ink-faint); }
.worklist-cell.is-urgent { background: var(--danger-soft); }
.worklist-cell.is-urgent .worklist-n { color: var(--danger); }
.worklist-cell.is-due { background: var(--warn-soft); }
.worklist-cell.is-due .worklist-n { color: var(--warn); }
.worklist-cell.is-quiet .worklist-n { color: var(--ink-soft); font-size: 22px; }
.worklist-split { width: 1px; background: var(--line); }

/* The pipeline as a rail: each stage is a step you can click into, with the
   drop-off legible from the numbers rather than from bar widths — at these
   volumes proportional bars say nothing. */
.stages {
  display: flex; align-items: stretch; margin-bottom: 16px; overflow-x: auto;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.stage {
  flex: 1 1 0; min-width: 130px; padding: 13px 16px; color: inherit; position: relative;
  display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line-soft);
}
.stage:last-child { border-right: 0; }
.stage::after {
  content: ''; position: absolute; right: -6px; top: 50%; z-index: 1;
  width: 10px; height: 10px; transform: translateY(-50%) rotate(45deg);
  border-top: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft);
  background: var(--surface);
}
.stage:last-child::after { content: none; }
.stage:hover { background: #fafbfc; text-decoration: none; }
.stage-n {
  font-size: 22px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--ink-faint);
}
.stage.has-leads .stage-n { color: var(--ink); }
.stage-label { font-size: 11.5px; color: var(--ink-soft); line-height: 1.25; }
.stage-label em { display: block; font-style: normal; font-size: 10.5px; color: var(--ink-faint); }
.stage--out { background: var(--accent-soft); }
.stage--out .stage-n { color: var(--accent); }
.stage--out::after { background: var(--accent-soft); }


/* A deactivated account stays visible but reads as switched off. */
tr.is-inactive td { opacity: .55; }
tr.is-inactive .row-title { text-decoration: line-through; }
