/*
  ledger/static/ledger/erp.css
  ─────────────────────────────────────────────────────────────────────────────
  Oricred Enterprise Lending & Risk Operations Design System.
  World-Class Fintech & SME Banking UI with dynamic Light & Dark mode support.
  Brand Palette inspired by oricred.co.za:
    - Primary Slate Teal / Navy: #043141, #07384a, #0b5563
    - Vibrant Accent Teal: #278189, #1ba3ab, #36b4bf
    - Warm Prestige Gold: #daa24e, #ca8a2a, #edd3ab, #f9f1e5
  ─────────────────────────────────────────────────────────────────────────────
*/

:root,
[data-theme="light"] {
  /* Surfaces & Grounds */
  --ground: #f4f7f8;
  --raised: #ffffff;
  --raised-card: #ffffff;
  --raised-hover: #f8fbfb;
  
  /* Text & Inks */
  --ink: #072a37;
  --ink-heading: #041f29;
  --muted: #4e6772;
  --faint: #7994a0;
  
  /* Borders & Dividers */
  --rule: #dfe7ea;
  --rule-strong: #c8d6db;
  --rule-subtle: #edf2f4;

  /* Brand Accents */
  --accent: #0b5563;
  --accent-hover: #07414d;
  --accent-vibrant: #278189;
  --accent-soft: #eaf3f5;
  --accent-gradient: linear-gradient(135deg, #0b5563 0%, #278189 100%);

  /* Prestige Gold */
  --gold: #daa24e;
  --gold-deep: #ca8a2a;
  --gold-soft: #fcf6ec;
  --gold-badge: #edd3ab;
  --gold-gradient: linear-gradient(135deg, #daa24e 0%, #ca8a2a 100%);

  /* Semantics */
  --high: #d93829;
  --high-soft: #feebe8;
  --high-border: #f8b4ad;
  --medium: #c27d14;
  --medium-soft: #fef5e7;
  --medium-border: #f7d49e;
  --ok: #15803d;
  --ok-soft: #eaf8f0;
  --ok-border: #a7e3be;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --info-border: #bae6fd;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(4, 49, 65, 0.04);
  --shadow-sm: 0 2px 4px rgba(4, 49, 65, 0.05), 0 1px 2px rgba(4, 49, 65, 0.03);
  --shadow-md: 0 6px 16px -2px rgba(4, 49, 65, 0.07), 0 2px 6px -1px rgba(4, 49, 65, 0.04);
  --shadow-lg: 0 14px 30px -4px rgba(4, 49, 65, 0.1), 0 4px 10px -2px rgba(4, 49, 65, 0.05);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --gutter: 28px;
}

[data-theme="dark"] {
  /* Surfaces & Grounds */
  --ground: #05161e;
  --raised: #08212c;
  --raised-card: #0b2936;
  --raised-hover: #103444;
  
  /* Text & Inks */
  --ink: #eaf2f5;
  --ink-heading: #ffffff;
  --muted: #8faeb8;
  --faint: #5d7e8b;
  
  /* Borders & Dividers */
  --rule: #133948;
  --rule-strong: #1b4b5e;
  --rule-subtle: #0d2a35;

  /* Brand Accents */
  --accent: #2dc4cf;
  --accent-hover: #45d4de;
  --accent-vibrant: #278189;
  --accent-soft: #0c3340;
  --accent-gradient: linear-gradient(135deg, #105b62 0%, #2dc4cf 100%);

  /* Prestige Gold */
  --gold: #f5ba58;
  --gold-deep: #e5a43b;
  --gold-soft: #2d2412;
  --gold-badge: #4d3c19;
  --gold-gradient: linear-gradient(135deg, #f5ba58 0%, #ca8a2a 100%);

  /* Semantics */
  --high: #f87171;
  --high-soft: #381a1a;
  --high-border: #592828;
  --medium: #fbbf24;
  --medium-soft: #382910;
  --medium-border: #5a421a;
  --ok: #34d399;
  --ok-soft: #103322;
  --ok-border: #1a5938;
  --info: #38bdf8;
  --info-soft: #0f2d42;
  --info-border: #174b6e;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --ground: #05161e;
    --raised: #08212c;
    --raised-card: #0b2936;
    --raised-hover: #103444;
    --ink: #eaf2f5;
    --ink-heading: #ffffff;
    --muted: #8faeb8;
    --faint: #5d7e8b;
    --rule: #133948;
    --rule-strong: #1b4b5e;
    --rule-subtle: #0d2a35;
    --accent: #2dc4cf;
    --accent-hover: #45d4de;
    --accent-vibrant: #278189;
    --accent-soft: #0c3340;
    --accent-gradient: linear-gradient(135deg, #105b62 0%, #2dc4cf 100%);
    --gold: #f5ba58;
    --gold-deep: #e5a43b;
    --gold-soft: #2d2412;
    --gold-badge: #4d3c19;
    --gold-gradient: linear-gradient(135deg, #f5ba58 0%, #ca8a2a 100%);
    --high: #f87171;
    --high-soft: #381a1a;
    --high-border: #592828;
    --medium: #fbbf24;
    --medium-soft: #382910;
    --medium-border: #5a421a;
    --ok: #34d399;
    --ok-soft: #103322;
    --ok-border: #1a5938;
    --info: #38bdf8;
    --info-soft: #0f2d42;
    --info-border: #174b6e;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.6);
  }
}

/* ──────────────────────────────────────────────────────────────── Base CSS */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--ink-heading);
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mono,
.figure,
td.num,
th.num {
  font-family: 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, monospace;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ──────────────────────────────────────────────────────────── Header Topbar */

.topbar {
  background: var(--raised);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Brand Group */
.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand-link:hover {
  text-decoration: none;
}

.brand-badge-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--gold-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #043141;
  font-weight: 800;
  font-family: 'Poppins', sans-serif;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(218, 162, 78, 0.35);
}

.brand-text {
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink-heading);
}
.brand-text span {
  color: var(--gold);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid var(--ok-border);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.5);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Global Search */
.find {
  flex: 1;
  max-width: 440px;
  margin: 0;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 13px;
  opacity: 0.6;
  pointer-events: none;
}

.find input {
  width: 100%;
  padding: 8px 36px 8px 36px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  background: var(--ground);
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  transition: all 0.2s ease;
}

.find input::placeholder {
  color: var(--faint);
}

.find input:focus {
  outline: none;
  background: var(--raised);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-kbd {
  position: absolute;
  right: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--rule);
  color: var(--muted);
  border: 1px solid var(--rule-strong);
}

/* Topbar Actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-topbar-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--accent-gradient);
  color: #ffffff !important;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none !important;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.btn-topbar-action:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.08);
}

.theme-toggle-btn {
  background: var(--ground);
  border: 1px solid var(--rule);
  color: var(--ink);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
}
.theme-toggle-btn:hover {
  background: var(--rule-subtle);
  border-color: var(--accent);
  transform: scale(1.05);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 5px;
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: 999px;
}

.avatar-initial {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12.5px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-heading);
}
.user-role {
  font-size: 10.5px;
  color: var(--muted);
}

.btn-logout {
  border: 0;
  font-family: inherit;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--high) !important;
  margin-left: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--high-soft);
}
.btn-logout:hover {
  text-decoration: none;
  filter: brightness(0.95);
}

/* Navigation Strip */
.nav-strip {
  background: var(--raised-card);
  border-top: 1px solid var(--rule-subtle);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
}

.nav-strip-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 4px var(--gutter);
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--rule);
}

.nav-item {
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none !important;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.nav-item-admin {
  color: var(--gold-deep) !important;
  background: var(--gold-soft);
}
.nav-item-admin:hover {
  background: var(--gold-badge);
}

.nav-item .count {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--medium);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
}

/* ──────────────────────────────────────────────────────────── Main Layout */

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px var(--gutter) 72px;
}

/* Page Head Hero */
.page-head {
  margin-bottom: 30px;
}

.dashboard-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.dashboard-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--rule-strong);
  padding: 3px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.page-head h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink-heading);
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  max-width: 72ch;
  line-height: 1.5;
}

.dashboard-actions {
  display: flex;
  gap: 10px;
}
.btn-hero-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  transition: all 0.2s ease;
}
.btn-hero-action.primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}
.btn-hero-action.primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.btn-hero-action.secondary {
  background: var(--raised);
  border: 1px solid var(--rule-strong);
  color: var(--ink);
}
.btn-hero-action.secondary:hover {
  background: var(--ground);
}

/* ──────────────────────────────────────────────────────── Metric KPI Tiles */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.tile {
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--rule-strong);
}

/* Distinctive top border accent colors */
.tile-funded { border-top: 3.5px solid var(--accent-vibrant); }
.tile-outstanding { border-top: 3.5px solid var(--info); }
.tile-arrears { border-top: 3.5px solid var(--gold); }
.tile-arrears.is-high { border-top: 3.5px solid var(--high); }
.tile-clients { border-top: 3.5px solid var(--gold-deep); }
.tile-health { border-top: 3.5px solid var(--ok); }
.tile-health.is-high { border-top: 3.5px solid var(--high); }
.tile-health.is-medium { border-top: 3.5px solid var(--medium); }

.tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tile .label {
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.tile-icon {
  font-size: 18px;
  opacity: 0.85;
}

.tile .value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: var(--ink-heading);
}

.tile.is-high .value { color: var(--high); }
.tile.is-medium .value { color: var(--medium); }
.tile.is-ok .value { color: var(--ok); }

.tile .sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.4;
}

.sub-highlight {
  font-weight: 600;
  color: var(--ink);
}
.sub-alert {
  color: var(--high);
  font-weight: 600;
}
.sub-clean {
  color: var(--ok);
  font-weight: 600;
}
.tile-link {
  font-weight: 600;
  text-decoration: underline;
}

/* ───────────────────────────────────────────────────────── Panels & Grids */

.cols-3,
.cols-2 {
  display: grid;
  gap: 20px;
  align-items: start;
}

.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .cols-3,
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
}

.panel {
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

.panel > h2 {
  margin: 0;
  padding: 14px 18px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--rule);
  background: var(--raised-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-title-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-heading);
}

.p-icon {
  font-size: 15px;
}

.panel > h2 .of {
  color: var(--faint);
  font-weight: 500;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0;
}

.panel-body {
  padding: 18px 20px;
}

/* ─────────────────────────────────────────────────────── Funnel Pipelines */

.funnel {
  display: grid;
  gap: 12px;
}

.funnel-row {
  display: grid;
  grid-template-columns: minmax(100px, auto) 1fr 48px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.funnel-row:hover {
  background: var(--accent-soft);
}

.funnel-row .name {
  color: var(--ink);
  font-weight: 500;
}

.bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar {
  flex: 1;
  height: 10px;
  background: var(--rule);
  border-radius: 999px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.share-percent {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--faint);
  min-width: 28px;
  text-align: right;
}

.funnel-row .n {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink-heading);
}

/* ───────────────────────────────────────────────────────────────── Tables */

.scroll {
  overflow-x: auto;
}

.scroll > table.data {
  width: max-content;
  min-width: 100%;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.data th {
  width: 1%;
  white-space: nowrap;
  text-align: left;
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 16px;
  border-bottom: 1.5px solid var(--rule);
  background: var(--raised-card);
}

table.data td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  white-space: nowrap;
  transition: background 0.15s ease;
}

table.data th.grow { width: auto; }
table.data td.grow { white-space: normal; }

table.data tr:hover td {
  background: var(--raised-hover);
}

table.data tr:last-child td {
  border-bottom: 0;
}

/* Table links & identifiers */
.deal-ref-link,
.lead-ref-link {
  font-weight: 600;
  color: var(--accent);
}

.issue-link {
  font-weight: 600;
  color: var(--ink-heading);
}
.issue-money {
  font-size: 12px;
  color: var(--high);
  margin-top: 2px;
  font-weight: 600;
}

.stage-tag {
  font-weight: 500;
  color: var(--ink);
}

.product-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--ground);
  border: 1px solid var(--rule);
  color: var(--muted);
}

/* ────────────────────────────────────────────────────────────────── Pills */

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-transform: uppercase;
}

.pill.high {
  background: var(--high-soft);
  color: var(--high);
  border: 1px solid var(--high-border);
}
.pill.medium {
  background: var(--medium-soft);
  color: var(--medium);
  border: 1px solid var(--medium-border);
}
.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid var(--ok-border);
}
.pill.low,
.pill.info {
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid var(--info-border);
}
.pill.unknown {
  background: var(--rule);
  color: var(--muted);
}

/* Row highlights */
tr.row-high > td:first-child { box-shadow: inset 3.5px 0 0 var(--high); }
tr.row-medium > td:first-child { box-shadow: inset 3.5px 0 0 var(--medium); }

/* ────────────────────────────────────────────────────────────────── Forms */

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-family: 'Poppins', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-heading);
}

.field select,
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="date"] {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}

.field select:focus,
.field input:focus {
  outline: none;
  background: var(--raised);
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

.field small.quiet {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

button[type="submit"],
.submit-btn {
  font-family: 'Poppins', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  padding: 10px 22px;
  color: #ffffff;
  background: var(--accent-gradient);
  border: 1px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

button[type="submit"]:hover,
.submit-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ──────────────────────────────────────────────────────── Flash & Alerts */

.flash {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Gatebars */
.gatebar {
  display: inline-flex;
  gap: 3px;
  vertical-align: middle;
  margin-right: 8px;
}
.gatebar i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: block;
}
.gatebar .g-ok { background: var(--ok); }
.gatebar .g-high { background: var(--high); }
.gatebar .g-info { background: var(--rule-strong); }
.gatebar .g-medium { background: var(--medium); }

/* ──────────────────────────────────────────────────────────────── Footer */

footer.note {
  border-top: 1px solid var(--rule);
  padding: 24px var(--gutter) 48px;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.6;
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-tag {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 12px;
}

/* ─────────────────────────────────────────────────── Utility: Layout Grids */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
  margin-top: 18px;
}

@media (max-width: 840px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ───────────────────────────────────────────────────── Progress / Meter Bar */

.meter {
  display: inline-flex;
  align-items: center;
  width: 80px;
  height: 8px;
  background: var(--rule);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 6px;
}

.meter-fill {
  display: block;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 2px;
}

/* ─────────────────────────────────────────────────── Action / CTA Link Btn */

.act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  color: #ffffff !important;
  text-decoration: none !important;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.act:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  text-decoration: none !important;
}
.act.secondary {
  background: var(--raised);
  color: var(--ink) !important;
  border: 1px solid var(--rule-strong);
}
.act.secondary:hover {
  background: var(--ground);
}

/* ───────────────────────────────────────────────────── Text Utility Classes */

.clip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.quiet,
.faint {
  color: var(--muted);
  font-size: 12.5px;
}

.faint {
  color: var(--faint);
}

.bad {
  color: var(--high);
  font-weight: 600;
}

.mono {
  font-family: 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* ─────────────────────────────────────────────────────── Need / Gate Tags */

.need {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--medium-soft);
  color: var(--medium);
  border: 1px solid var(--medium-border);
  margin: 1px 2px;
  white-space: nowrap;
}

/* ──────────────────────────────────────────────────────── Empty State */

.empty {
  display: block;
  text-align: center;
  padding: 28px 16px;
  color: var(--faint);
  font-size: 13.5px;
  font-style: italic;
}

/* ──────────────────────────────────────────────────── Breadcrumb Crumb */

.crumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.crumb a {
  color: var(--accent);
  font-weight: 500;
}

/* ────────────────────────────────────── Pairs: Key-Value Detail Tables */

table.data.pairs th {
  width: 45%;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  background: transparent;
  padding: 9px 14px;
}
table.data.pairs td {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  padding: 9px 14px;
}

/* ────────────────────────────────────────────── Page Head Breadcrumb Line */

.page-head .crumb {
  font-size: 12.5px;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

/* ────────────────────────────── Deal/Client Link within Data Tables */

a.deal-ref-link,
a.lead-ref-link {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  color: var(--accent);
}
a.deal-ref-link:hover,
a.lead-ref-link:hover {
  text-decoration: underline;
}

/* ─────────────────────────────────────────────────── Company Column */

.company-col strong {
  display: block;
  font-size: 13.5px;
  color: var(--ink-heading);
}

/* ────────────────────────────────────── Nav Icon display fixes */

.nav-icon {
  font-size: 13px;
  display: inline-block;
}

/* ──────────────────────────────────── Panel attention / moved accents */

.panel-attention > h2 {
  border-left: 3.5px solid var(--high);
}

.panel-moved > h2 {
  border-left: 3.5px solid var(--accent-vibrant);
}

.panel-leads > h2 {
  border-left: 3.5px solid var(--gold);
}

.panel-funnel > h2 {
  border-left: 3.5px solid var(--info);
}

/* ──────────────────────────────── Count column */
.count-col {
  font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--ink-heading);
}

/* ──────────────────────────────────────────────── Section Spacing */

section + section,
section + div,
div + section {
  margin-top: 20px;
}

/* ─────────────────────────────────────────────────── Scroll-area x overflow */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ──────────────────────────────────────────────── Responsive adjustments */

@media (max-width: 700px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 10px;
  }
  .find {
    order: 3;
    max-width: 100%;
    flex: 1 1 100%;
  }
  main {
    padding: 20px 16px 60px;
  }
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-hero {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  .tiles {
    grid-template-columns: minmax(0, 1fr);
  }
  .user-meta { display: none; }
}

/* ──────────────────────────────────── Data Health Check Cards */

.check {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: start;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--rule);
  transition: background 0.15s ease;
}

.check:last-child {
  border-bottom: 0;
}

.check:hover {
  background: var(--raised-hover);
}

.check.is-high { border-left: 4px solid var(--high); }
.check.is-medium { border-left: 4px solid var(--medium); }
.check.is-ok { border-left: 4px solid var(--ok); }
.check.is-info { border-left: 4px solid var(--info); }
.check.is-broken { border-left: 4px solid var(--faint); }

.check .count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  color: var(--ink-heading);
  line-height: 1;
  padding-top: 4px;
}

.check.is-high .count { color: var(--high); }
.check.is-medium .count { color: var(--medium); }
.check.is-ok .count { color: var(--ok); font-size: 20px; }
.check.is-broken .count { color: var(--faint); font-size: 20px; }

.check h3 {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink-heading);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.check .why {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 72ch;
}

.check .money {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--high);
  background: var(--high-soft);
  border: 1px solid var(--high-border);
  padding: 2px 10px;
  border-radius: 6px;
  margin-top: 4px;
}

.check .err {
  margin: 6px 0 0;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--high);
  background: var(--high-soft);
  border: 1px solid var(--high-border);
  padding: 6px 10px;
  border-radius: 6px;
}

.check .go a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--rule-strong);
  border-radius: 7px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s;
}
.check .go a:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* ──────────────────────────────────── Inline code */
code.mono {
  background: var(--ground);
  border: 1px solid var(--rule);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}

/* ──────────────────────────────── Tile icon size fix */
.tile-icon {
  font-size: 20px;
  line-height: 1;
}

/* ────────────────────────────────── Tile top-border accented variants */
.tile-funded  { border-top: 3.5px solid var(--accent-vibrant); }
.tile-outstanding { border-top: 3.5px solid var(--info); }
.tile-arrears { border-top: 3.5px solid var(--gold); }
.tile-clients { border-top: 3.5px solid var(--gold-deep); }
.tile-health  { border-top: 3.5px solid var(--ok); }

/* ──────────────────────────────── Client / Department page head */
.page-head-main {
  flex: 1;
}

.page-head-main h1 {
  margin: 4px 0 6px;
}

/* ─────────────────────────────── Work page department panel highlight */
.dept-panel > h2 {
  border-left: 3.5px solid var(--accent);
}

/* ─────────────────────────────── Inline table form controls (assign page) */

.pool-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-soft);
  color: var(--gold-deep);
  border: 1px solid var(--gold-badge);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

table.data select {
  padding: 5px 8px;
  border: 1.5px solid var(--rule);
  border-radius: 7px;
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  min-width: 150px;
  transition: border-color 0.2s;
}
table.data select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

table.data button[type="submit"] {
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent-hover);
  cursor: pointer;
  transition: all 0.2s;
}
table.data button[type="submit"]:hover {
  filter: brightness(1.1);
}

/* Extra pill variants */
.pill.warn {
  background: var(--medium-soft);
  color: var(--medium);
  border: 1px solid var(--medium-border);
}
.pill.ok { border: 1px solid var(--ok-border); }
.pill.info { border: 1px solid var(--info-border); }
.pill.high { border: 1px solid var(--high-border); }



/* ═════════════════════════════════════════════════════════════════════════
   Dashboard layer (2026-10): scenic hero, KPI cards, server-drawn charts.
   Charts come from executive/templatetags/charts.py (inline SVG, no CDN).
   ═════════════════════════════════════════════════════════════════════════ */

/* Top bar: secondary links neutral, sign-out readable */
a.btn-logout {
  color: var(--muted) !important;
  background: var(--accent-soft) !important;
}
a.btn-logout:hover { color: var(--accent) !important; }
.logout-form .btn-logout,
.logout-form button.btn-logout {
  color: var(--high) !important;
  background: var(--high-soft) !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 4px 10px !important;
  font-size: 11.5px !important;
}

/* Hero: a landscape banner - deep teal sky, gold sun, layered hills */
.dashboard-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 6px;
  margin: 0 0 22px;
  padding: 26px 30px 34px;
  border-radius: 18px;
  overflow: hidden;
  color: #e9f6f7;
  background-color: #06303d;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Ccircle cx='80' cy='80' r='78' fill='%23f5c66b' fill-opacity='.10'/%3E%3Ccircle cx='80' cy='80' r='52' fill='%23f5c66b' fill-opacity='.14'/%3E%3Ccircle cx='80' cy='80' r='32' fill='%23f5c66b' fill-opacity='.9'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 220' preserveAspectRatio='none'%3E%3Cpath d='M0 150 C 180 100 300 170 470 130 S 760 70 930 120 S 1120 150 1200 110 V220 H0Z' fill='%23278189' fill-opacity='.45'/%3E%3Cpath d='M0 180 C 200 140 380 200 600 160 S 950 130 1200 170 V220 H0Z' fill='%230b5563' fill-opacity='.75'/%3E%3Cpath d='M0 205 C 260 180 520 215 820 195 S 1100 190 1200 200 V220 H0Z' fill='%23043141'/%3E%3C/svg%3E"),
    linear-gradient(135deg, #062a36 0%, #0b5563 55%, #1b7f87 100%);
  background-size: 150px 150px, 100% 100%, cover;
  background-position: right 9% top 14px, bottom, center;
  background-repeat: no-repeat;
  box-shadow: 0 18px 40px -18px rgba(4, 49, 65, .55);
}
.dashboard-hero:has(> .page-head-main) {
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
}
.dashboard-hero > * { position: relative; z-index: 1; }
.dashboard-hero .dashboard-badge {
  color: #fbe3b5;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 4px;
}
.dashboard-hero h1,
.dashboard-hero .dashboard-title {
  margin: 2px 0 2px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #ffffff;
  text-align: left;
}
.dashboard-hero p,
.dashboard-hero .dashboard-subtitle {
  margin: 0;
  max-width: 78ch;
  color: rgba(233, 246, 247, .82);
  font-size: 14.5px;
  line-height: 1.55;
  text-align: left;
}
.dashboard-hero a:not(.btn-hero-action) {
  color: #fbe3b5;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed rgba(251, 227, 181, .5);
}
.dashboard-hero a:not(.btn-hero-action):hover { color: #fff; border-bottom-color: #fff; }
.dashboard-hero .btn-hero-action,
.dashboard-hero .btn-hero-action.primary {
  background: linear-gradient(135deg, #f5c66b 0%, #daa24e 100%) !important;
  color: #2b1d05 !important;
  border: 0 !important;
  border-radius: 10px !important;
  padding: 9px 16px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  box-shadow: 0 6px 16px -6px rgba(218, 162, 78, .8);
}
.dashboard-hero .btn-hero-action.secondary {
  background: rgba(255, 255, 255, .12) !important;
  color: #fff !important;
  box-shadow: none;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 12px; align-items: center; }
[data-theme="dark"] .dashboard-hero { box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .8); }

/* Panels: softer, rounder */
.panel { border-radius: 14px; }
.panel > h2 {
  font-size: 14px;
  padding: 14px 20px;
  background: linear-gradient(180deg, var(--raised-card) 0%, var(--raised) 100%);
}
.panel .empty,
.panel-body > .empty,
p.empty {
  padding: 12px 16px;
  margin: 0;
  font-size: 13px;
}
.panel-body:has(> .empty:only-child) { padding: 6px 12px; }
.panel .empty::before { content: "\2713\00a0\00a0"; font-style: normal; color: var(--ok); }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin: 0 0 22px;
}
a.kpi, .kpi {
  position: relative;
  display: block;
  padding: 16px 18px 15px 20px;
  border-radius: 14px;
  background: var(--raised);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--rule-strong); text-decoration: none; }
.kpi::after {
  content: "";
  position: absolute;
  right: -28px; top: -28px;
  width: 92px; height: 92px;
  border-radius: 50%;
  background: var(--kpi-tone, var(--accent));
  opacity: .09;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--kpi-tone, var(--accent));
}
.kpi-icon { font-size: 18px; line-height: 1; margin-bottom: 8px; display: inline-block; }
.kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  margin-top: 4px;
  font-family: 'Poppins', sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-heading);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.kpi-value small { font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi-value .bad { color: var(--high); }
.kpi-sub { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.kpi-go { margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.kpi.tone-gold { --kpi-tone: var(--gold); }
.kpi.tone-info { --kpi-tone: var(--info); }
.kpi.tone-ok { --kpi-tone: var(--ok); }
.kpi.tone-high { --kpi-tone: var(--high); }
.kpi.tone-medium { --kpi-tone: var(--medium); }
.kpi.tone-vibrant { --kpi-tone: var(--accent-vibrant); }

/* Chart cards */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin: 0 0 22px;
}
.chart-grid.wide-first { grid-template-columns: 1.35fr 1fr; }
@media (max-width: 980px) { .chart-grid.wide-first { grid-template-columns: minmax(0, 1fr); } }
.chart-card {
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 16px 20px 18px;
  min-width: 0;
}
.chart-card h3 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-heading);
}
.chart-card .chart-sub { margin: 0 0 14px; font-size: 12.5px; color: var(--faint); }
a.chart-link { color: inherit; text-decoration: none; display: block; border-radius: 8px; }
a.chart-link:hover { background: var(--accent-soft); text-decoration: none; }

.chart-donut { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-svg circle { transition: stroke-width .15s ease; }
.donut-svg circle:hover { stroke-width: 22; }
.donut-total { font-family: 'Poppins', sans-serif; font-size: 24px; font-weight: 700; fill: var(--ink-heading); }
.donut-unit { font-size: 10.5px; fill: var(--faint); text-transform: uppercase; letter-spacing: .08em; }
.chart-legend { flex: 1; min-width: 170px; display: grid; gap: 2px; }
.chart-legend a.chart-link { display: block; padding: 0; }
.chart-legend .lg-item { display: flex; align-items: center; gap: 9px; padding: 5px 8px; }
.chart-legend .lg-label { flex: 1; font-size: 13px; color: var(--ink); }
.chart-legend .lg-val { font-size: 13px; font-weight: 700; color: var(--ink-heading); font-variant-numeric: tabular-nums; }
.chart-legend .lg-val small { font-weight: 500; color: var(--faint); margin-left: 4px; }
.lg-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg-empty { font-size: 13px; color: var(--faint); font-style: italic; }

.chart-cols {
  position: relative;
  display: flex; align-items: stretch; gap: 6px;
  padding-top: 18px;
  background: repeating-linear-gradient(to top, transparent 0, transparent calc(var(--h) / 4 - 1px),
              var(--rule-subtle) calc(var(--h) / 4 - 1px), var(--rule-subtle) calc(var(--h) / 4));
  background-size: 100% var(--h);
  background-repeat: no-repeat;
  background-position: 0 18px;
}
.cc { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cc-bars {
  height: var(--h);
  display: flex; align-items: flex-end; justify-content: center; gap: 4px;
  border-bottom: 1px solid var(--rule-strong);
}
.cb {
  position: relative; width: min(30px, 40%);
  border-radius: 6px 6px 2px 2px;
  transition: opacity .15s ease, transform .15s ease;
}
.cb:hover { opacity: .85; }
.cb-a { background: linear-gradient(180deg, var(--accent-vibrant), var(--accent)); }
.cb-b { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); }
.cb em {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  margin-bottom: 3px; font-style: normal; font-size: 11px; font-weight: 700;
  color: var(--ink-heading); white-space: nowrap;
}
.cc-label { text-align: center; font-size: 12px; color: var(--muted); padding-top: 6px; }
.cc-empty {
  position: absolute; left: 0; right: 0; top: calc(var(--h) / 2);
  text-align: center; font-size: 13px; font-style: italic; color: var(--faint);
}
.chart-key { display: flex; gap: 16px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.chart-key i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.chart-hbars { display: grid; gap: 4px; }
.hb-row { display: grid; grid-template-columns: minmax(110px, 34%) 1fr auto; gap: 12px; align-items: center; padding: 6px 8px; }
.hb-label { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-track { height: 10px; border-radius: 99px; background: var(--rule-subtle); overflow: hidden; }
.hb-fill { display: block; height: 100%; border-radius: 99px; }
.hb-val { font-size: 13px; font-weight: 700; color: var(--ink-heading); font-variant-numeric: tabular-nums; text-align: right; min-width: 3ch; }
.hb-val small { font-weight: 500; color: var(--faint); }

.chart-funnel { display: grid; gap: 8px; }
.fn-step { display: flex; align-items: center; gap: 12px; padding: 2px; }
.fn-bar {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  color: #fff; min-width: 150px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08);
}
.fn-bar b { font-family: 'Poppins', sans-serif; font-size: 20px; }
.fn-bar span { font-size: 13px; opacity: .92; }
.fn-step small { font-size: 12px; color: var(--faint); white-space: nowrap; }

.section-label {
  margin: 26px 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  display: flex; align-items: center; gap: 10px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

/* Empty worklist boxes: one slim line instead of a tall card */
.panel:has(> .panel-body > .empty:only-child) > h2 { border-bottom: 0; background: var(--raised); }
.panel:has(> .panel-body > .empty:only-child) > .panel-body { padding: 0 20px 12px; }
.panel:has(> .panel-body > .empty:only-child) .empty { text-align: left; padding: 0; }
.panel:has(> .panel-body > .empty:only-child) { box-shadow: var(--shadow-xs); }

/* ═════════════════════════════════════════════════════════════════════════
   2026-10-16: Take it, documents, recorded details (grouped + editable)
   ═════════════════════════════════════════════════════════════════════════ */

/* Take it */
.take-btn {
  background: linear-gradient(135deg, #f5c66b 0%, #daa24e 100%) !important;
  color: #2b1d05 !important;
  border: 0 !important;
  border-radius: 999px !important;
  padding: 4px 12px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  cursor: pointer;
  box-shadow: 0 3px 8px -3px rgba(218, 162, 78, .7);
  white-space: nowrap;
}
.take-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }

/* Documents */
.doc-block { display: grid; gap: 10px; }
.doc-head { display: flex; align-items: center; gap: 8px; }
.doc-list { display: grid; gap: 8px; }
.doc-row {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: 12px; background: var(--raised);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.doc-row:hover { border-color: var(--rule-strong); box-shadow: var(--shadow-sm); }
.doc-icon {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 18px;
  background: var(--accent-soft);
}
.doc-title { font-weight: 650; font-size: 13.5px; color: var(--ink-heading); }
.doc-meta { font-size: 12px; color: var(--faint); margin-top: 2px; word-break: break-all; }
.doc-actions { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
.doc-btn, a.doc-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--rule-strong); background: var(--raised); color: var(--accent) !important;
  font-size: 12.5px; font-weight: 600; text-decoration: none !important; cursor: pointer; list-style: none;
}
.doc-btn:hover { background: var(--accent-soft); }
.doc-more { position: relative; }
/* an open document card lets its replace / delete menu float over what follows instead of cutting it off */
.doc-grid .rf2-card[open] { overflow: visible; }
.doc-grid .rf2-card[open] > .rf2-card-head { border-radius: 14px 14px 0 0; }
.doc-more[open] { z-index: 40; }
.doc-more summary::-webkit-details-marker { display: none; }
.doc-more[open] .doc-form {
  position: absolute; right: 0; top: 34px; z-index: 30; width: 280px; display: grid; gap: 8px;
  padding: 12px; background: var(--raised); border: 1px solid var(--rule-strong); border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.doc-form button.secondary { background: var(--high-soft) !important; color: var(--high) !important; border: 0 !important; }
.doc-add {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 12px;
  border: 1.5px dashed var(--rule-strong); border-radius: 12px; background: var(--accent-soft);
}
.doc-add input[name="document_type"] { flex: 1; min-width: 200px; }

/* Recorded details */
.rf-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.rf-tab {
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--rule); background: var(--raised);
  font-size: 12.5px; font-weight: 600; color: var(--ink) !important; text-decoration: none !important;
}
.rf-tab small { color: var(--faint); font-weight: 500; margin-left: 2px; }
.rf-tab:hover { border-color: var(--accent); background: var(--accent-soft); }
.rf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.rf-group {
  border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; background: var(--raised);
  scroll-margin-top: 90px;
}
.rf-group:target { box-shadow: 0 0 0 3px var(--gold); }
.rf-group-head {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent-soft), var(--raised)); font-weight: 700; font-size: 13.5px;
  color: var(--ink-heading); border-bottom: 1px solid var(--rule);
}
.rf-group-head small { color: var(--faint); font-weight: 500; font-size: 11.5px; }
.rf-row {
  display: grid; grid-template-columns: 42% 1fr; gap: 10px; align-items: start; padding: 7px 14px;
  border-bottom: 1px solid var(--rule-subtle); font-size: 13px;
}
.rf-row:last-child { border-bottom: 0; }
.rf-row.rf-empty .rf-label { color: var(--faint); }
.rf-label { color: var(--muted); font-size: 12.5px; padding-top: 2px; }
.rf-sync { color: var(--gold-deep); font-weight: 700; cursor: help; }
.rf-value-ro { color: var(--ink); word-break: break-word; }
.rf-lock { font-size: 11px; opacity: .5; cursor: help; }
.rf-edit summary {
  list-style: none; display: flex; justify-content: space-between; gap: 8px; cursor: pointer;
  border-radius: 6px; padding: 2px 4px; margin: -2px -4px;
}
.rf-edit summary::-webkit-details-marker { display: none; }
.rf-edit summary:hover { background: var(--accent-soft); }
.rf-value { color: var(--ink); word-break: break-word; }
.rf-pencil { color: var(--accent); opacity: .55; font-size: 13px; }
.rf-edit summary:hover .rf-pencil { opacity: 1; }
.rf-edit[open] summary .rf-value { display: none; }
.rf-form { display: flex; gap: 6px; margin-top: 4px; }
.rf-form input, .rf-form select { flex: 1; min-width: 0; padding: 5px 8px; font-size: 13px; }
.rf-form button { padding: 5px 12px; font-size: 12.5px; }

/* General polish */
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:hover { background: var(--raised-hover); }
.panel { margin-bottom: 18px; }
.flash { border-radius: 12px !important; box-shadow: var(--shadow-sm); }

/* ═════════════════════════════════════════════════════════════════════════
   UX pass (16 Oct): one look for every form, button, message and table
   ═════════════════════════════════════════════════════════════════════════ */
main input[type="text"], main input:not([type]), main input[type="email"], main input[type="tel"],
main input[type="number"], main input[type="date"], main input[type="datetime-local"], main input[type="search"],
main input[type="password"], main select, main textarea {
  font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--raised); border: 1px solid var(--rule-strong); border-radius: 9px;
  padding: 7px 10px; min-height: 36px; box-sizing: border-box;
  transition: border-color .15s ease, box-shadow .15s ease;
}
main textarea { min-height: 70px; }
main input:focus, main select:focus, main textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
main input[type="file"] { font-size: 13px; padding: 5px; border: 1px dashed var(--rule-strong); border-radius: 9px;
  background: var(--raised); }
main input[type="checkbox"], main input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }
main label { font-size: 13px; color: var(--muted); }

main button, main input[type="submit"], main .button {
  font: inherit; font-size: 13.5px; font-weight: 650; letter-spacing: .01em;
  border-radius: 10px; padding: 8px 16px; min-height: 36px; cursor: pointer;
  background: var(--accent-gradient); color: #fff; border: 0;
  box-shadow: 0 4px 12px -6px rgba(11, 85, 99, .7);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
main button:hover, main input[type="submit"]:hover { filter: brightness(1.06); transform: translateY(-1px);
  box-shadow: 0 8px 18px -8px rgba(11, 85, 99, .8); }
main button:active { transform: translateY(0); }
main button.secondary, main .secondary > button {
  background: var(--raised); color: var(--accent); border: 1px solid var(--rule-strong); box-shadow: none;
}
main button[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* Messages: green done, red refused, amber warning, blue information */
.flash-stack { display: grid; gap: 8px; margin: 0 0 18px; }
.flash { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px !important; margin: 0 !important;
  border-radius: 12px !important; border: 1px solid var(--rule) !important; background: var(--raised) !important;
  box-shadow: var(--shadow-sm); font-size: 13.5px; line-height: 1.5; }
.flash-icon { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: #fff; background: var(--info); }
.flash-success { border-color: var(--ok-border) !important; background: var(--ok-soft) !important; }
.flash-success .flash-icon { background: var(--ok); }
.flash-error { border-color: var(--high-border) !important; background: var(--high-soft) !important; }
.flash-error .flash-icon { background: var(--high); }
.flash-warning { border-color: var(--medium-border) !important; background: var(--medium-soft) !important; }
.flash-warning .flash-icon { background: var(--medium); }

/* Tables: calmer headers, room to breathe, sticky heads in long lists */
table.data th { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--faint);
  background: var(--raised-card); position: sticky; top: 0; z-index: 1; }
table.data td { font-size: 13.5px; }
table.data td a { font-weight: 600; }

/* Section headings inside panels */
.panel > h2 { font-family: 'Poppins', sans-serif; }

/* Footer */
footer.note { border-top: 1px solid var(--rule); background: var(--raised); }
footer.note .footer-inner { font-size: 12.5px; color: var(--faint); }

/* Small screens */
@media (max-width: 760px) {
  .dashboard-hero { padding: 20px 18px 26px; }
  .dashboard-hero h1, .dashboard-hero .dashboard-title { font-size: 24px; }
  .rf-grid { grid-template-columns: minmax(0, 1fr); }
  .doc-row { grid-template-columns: 32px 1fr; }
  .doc-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* A closed deal (completed, rejected, stale) reads as finished: no workflow buttons */
.closed-banner { display: flex; gap: 14px; align-items: center; margin: 0 0 18px; padding: 14px 18px;
  border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--rule-strong); font-size: 14px; }
.closed-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: #fff; font-weight: 800; }
.closed-deal .panel form:not(.doc-add):not(.doc-form):not(.rf-form) { display: none !important; }
.closed-deal .doc-add, .closed-deal .doc-more { display: none; }

/* Lists: filter box and sortable headings (base.html script) */
.tbl-tools { display: flex; align-items: center; gap: 10px; padding: 10px 16px 6px; }
.tbl-tools input[type="search"] { flex: 0 1 340px; padding: 7px 12px 7px 32px !important; border-radius: 999px !important;
  background: var(--raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237994a0' stroke-width='2.4'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") no-repeat 11px center !important; }
.tbl-count { font-size: 12px; color: var(--faint); }
table.data th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.data th.sortable:hover { color: var(--accent); }
table.data th.sortable::after { content: " \2195"; opacity: .25; font-size: 10px; }
table.data th[data-sort="asc"]::after { content: " \2191"; opacity: .9; }
table.data th[data-sort="desc"]::after { content: " \2193"; opacity: .9; }

/* Detail pages (a breadcrumb above the banner): a compact banner, so the work is on screen */
.crumb + .dashboard-hero, .crumb ~ .dashboard-hero { padding: 16px 26px 22px; gap: 4px; margin-bottom: 16px;
  background-size: 96px 96px, 100% 100%, cover; background-position: right 6% top 10px, bottom, center; }
.crumb + .dashboard-hero h1, .crumb + .dashboard-hero .dashboard-title { font-size: 24px; }
.crumb + .dashboard-hero p, .crumb + .dashboard-hero .dashboard-subtitle { font-size: 13.5px; }

/* Pills: stale / stand-by amber */
.pill.warn { background: var(--medium-soft); color: var(--medium); border: 1px solid var(--medium-border); }
.scroll { overflow-x: auto; }

/* Phones: nothing wider than the screen */
@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  .topbar-inner { flex-wrap: wrap; gap: 8px; }
  .topbar .find { order: 3; flex: 1 1 100%; }
  .user-chip .user-meta, .user-chip a.btn-logout { display: none; }
  .btn-topbar-action { padding: 6px 10px; font-size: 12px; }
  .nav-strip-inner, .nav-group { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
  .kpi-grid, .chart-grid, .chart-grid.wide-first, .tiles { grid-template-columns: minmax(0, 1fr) !important; }
  .chart-card, .kpi, .panel { min-width: 0; }
  .chart-donut { justify-content: center; }
  .hero-actions { gap: 8px 12px; }
  main { padding-left: 12px !important; padding-right: 12px !important; }
  .tbl-tools input[type="search"] { flex: 1 1 auto; }
  .rf-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
@media (max-width: 760px) {
  main { width: 100%; max-width: 100vw; box-sizing: border-box; overflow-x: hidden; }
  main > *, .dashboard-hero, .panel, .kpi, .chart-card { max-width: 100%; box-sizing: border-box; }
  .topbar .find, .search-input-wrap { min-width: 0; width: 100%; box-sizing: border-box; }
  .search-input-wrap input { min-width: 0; width: 100%; }
  .check-layout { display: block !important; }
  table.data { font-size: 12.5px; }
}

/* Directory tabs: the chosen one stands out */
.dir-tab { display: inline-block; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--rule-strong); background: var(--raised); color: var(--ink) !important; text-decoration: none !important; }
.dir-tab:hover { border-color: var(--accent); background: var(--accent-soft); }
.dir-tab.on { background: var(--accent-gradient); color: #fff !important; border-color: transparent; box-shadow: var(--shadow-sm); }
/* Clickable rows */
table.data tr.row-link { cursor: pointer; }
table.data tr.row-link:hover td { background: var(--accent-soft); }

/* ═══ Record details: closed section cards, a status bar, empty fields tucked away ═══ */
.rf2 { margin-top: 22px; background: var(--raised); border: 1px solid var(--rule); border-radius: 18px;
  box-shadow: var(--shadow-sm); padding: 20px 22px 22px; scroll-margin-top: 80px; }
.rf2-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.rf2-title { margin: 0; font-family: 'Poppins', sans-serif; font-size: 18px; color: var(--ink-heading); }
.rf2-sub { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.rf2-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rf2-link { background: none !important; border: 0 !important; box-shadow: none !important; color: var(--accent) !important;
  font-weight: 600 !important; font-size: 13px !important; padding: 2px 0 !important; min-height: 0 !important; cursor: pointer; }
.rf2-link:hover { text-decoration: underline; transform: none !important; }
.rf2-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.rf2-switch input { display: none; }
.rf2-switch span { width: 34px; height: 20px; border-radius: 999px; background: var(--rule-strong); position: relative; transition: background .2s; }
.rf2-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.rf2-switch input:checked + span { background: var(--accent); }
.rf2-switch input:checked + span::after { transform: translateX(14px); }

.rf2-status { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 16px;
  border-radius: 14px; background: linear-gradient(135deg, var(--accent-soft), var(--raised)); border: 1px solid var(--rule); }
.rf2-status-label { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.rf2-pill { display: inline-block; padding: 5px 14px; border-radius: 999px; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 13.5px; }
.rf2-status-form { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.rf2-status-form select { min-width: 220px; }
.rf2-locked-note { margin-left: auto; font-size: 12.5px; color: var(--faint); }

.rf2-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; align-items: start; }
.rf2-card { border: 1px solid var(--rule); border-radius: 14px; background: var(--raised); overflow: hidden;
  transition: box-shadow .15s ease, border-color .15s ease; }
.rf2-card:hover { border-color: var(--rule-strong); box-shadow: var(--shadow-sm); }
.rf2-card[open] { box-shadow: var(--shadow-md); border-color: var(--accent); }
.rf2-card-head { list-style: none; display: flex; align-items: center; gap: 12px; padding: 13px 14px; cursor: pointer; user-select: none; }
.rf2-card-head::-webkit-details-marker { display: none; }
.rf2-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px;
  background: var(--accent-soft); }
.rf2-card-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.rf2-card-title { font-weight: 700; font-size: 14.5px; color: var(--ink-heading); }
.rf2-card-meta { font-size: 12px; color: var(--faint); }
.rf2-can { color: var(--accent); font-weight: 600; }
.rf2-bar { display: block; height: 4px; border-radius: 99px; background: var(--rule-subtle); overflow: hidden; }
.rf2-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-vibrant), var(--accent)); }
.rf2-chevron { flex: none; font-size: 22px; color: var(--faint); transition: transform .2s ease; line-height: 1; }
.rf2-card[open] .rf2-chevron { transform: rotate(90deg); color: var(--accent); }
.rf2-body { padding: 4px 14px 12px; border-top: 1px solid var(--rule-subtle); }
.rf2-row { display: grid; grid-template-columns: 42% 1fr; gap: 10px; align-items: start; padding: 9px 0;
  border-bottom: 1px dashed var(--rule-subtle); font-size: 13.5px; }
.rf2-row:last-of-type { border-bottom: 0; }
.rf2-empty { display: none; }
.rf2-show-all .rf2-empty, .rf2-card-all .rf2-empty { display: grid; }
.rf2-label { color: var(--muted); font-size: 13px; padding-top: 2px; }
.rf2-sync { color: var(--gold-deep); font-weight: 700; cursor: help; }
.rf2-value, .rf2-value-ro { color: var(--ink); word-break: break-word; }
.rf2-lock { font-size: 11px; opacity: .55; cursor: help; }
.rf2-edit summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; }
.rf2-edit summary::-webkit-details-marker { display: none; }
.rf2-edit-btn { flex: none; font-size: 12px; font-weight: 700; color: var(--accent); padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--rule-strong); background: var(--raised); }
.rf2-edit summary:hover .rf2-edit-btn { background: var(--accent); color: #fff; border-color: var(--accent); }
.rf2-edit[open] summary { display: none; }
.rf2-form { display: grid; gap: 8px; }
.rf2-form input, .rf2-form select { width: 100%; }
.rf2-form-actions { display: flex; gap: 8px; }
.rf2-form-actions button { padding: 6px 14px !important; min-height: 32px !important; font-size: 13px !important; }
.rf2 .rf2-show-empty { margin-top: 8px; }
@media (max-width: 760px) {
  .rf2 { padding: 16px 14px; }
  .rf2-grid { grid-template-columns: minmax(0, 1fr); }
  .rf2-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .rf2-status-form { margin-left: 0; width: 100%; }
  .rf2-status-form select { min-width: 0; flex: 1; }
}
.closed-deal .rf2 form.rf2-form { display: grid !important; }
.closed-deal .rf2 form.rf2-status-form { display: flex !important; }

/* Detail pages: panels fold by their heading */
.panel.foldable > h2 { cursor: pointer; user-select: none; }
.panel.foldable > h2:hover { background: var(--accent-soft); }
.fold-chev { margin-left: 8px; font-size: 20px; line-height: 1; color: var(--faint); transform: rotate(90deg);
  transition: transform .2s ease; display: inline-block; }
.panel.folded > h2 .fold-chev { transform: rotate(0deg); }
.panel.folded > *:not(h2) { display: none !important; }
.panel.folded > h2 { border-bottom: 0; }
.panel.folded { box-shadow: var(--shadow-xs); }

/* ═══ Deal journey: the road travelled, the road ahead, and why it stopped ═══ */
.jr { margin-top: 22px; background: var(--raised); border: 1px solid var(--rule); border-radius: 18px;
  box-shadow: var(--shadow-sm); padding: 20px 22px 22px; scroll-margin-top: 80px; display: grid; gap: 14px; }
.jr .rf2-head { margin-bottom: 0; }
.jr-facts { display: flex; gap: 10px; flex-wrap: wrap; }
.jr-facts > div { display: grid; padding: 8px 14px; border-radius: 12px; background: var(--accent-soft); min-width: 96px; }
.jr-facts b { font-family: 'Poppins', sans-serif; font-size: 16px; color: var(--ink-heading); }
.jr-facts span { font-size: 11.5px; color: var(--muted); }
.jr-facts .jr-fact-esc { background: var(--high-soft); } .jr-facts .jr-fact-esc b { color: var(--high); }
.jr-facts .jr-fact-wait { background: var(--medium-soft); } .jr-facts .jr-fact-wait b { color: var(--medium); }
.jr-bar { height: 6px; border-radius: 99px; background: var(--rule-subtle); overflow: hidden; }
.jr-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-vibrant), var(--accent)); }
.jr-alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--rule); font-size: 14px; }
.jr-alert-icon { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; }
.jr-alert-stop { background: var(--high-soft); border-color: var(--high-border); } .jr-alert-stop .jr-alert-icon { background: var(--high); }
.jr-alert-esc { background: var(--medium-soft); border-color: var(--medium-border); } .jr-alert-esc .jr-alert-icon { background: var(--medium); }
.jr-alert-done { background: var(--ok-soft); border-color: var(--ok-border); } .jr-alert-done .jr-alert-icon { background: var(--ok); }
.jr-alert-now { background: var(--info-soft); border-color: var(--info-border); } .jr-alert-now .jr-alert-icon { background: var(--info); }
.jr-why { margin-top: 4px; font-style: italic; color: var(--ink); }
.jr-muted { color: var(--muted); font-size: 12.5px; }

.jr-road { list-style: none; margin: 0; padding: 4px 2px 8px; display: flex; overflow-x: auto; gap: 0; scrollbar-width: thin; }
.jr-stop { flex: 1 0 74px; min-width: 74px; display: grid; justify-items: center; text-align: center; gap: 4px; position: relative; padding-top: 2px; }
.jr-stop::before { content: ""; position: absolute; top: 15px; left: -50%; width: 100%; height: 3px; background: var(--rule); z-index: 0; }
.jr-stop:first-child::before { display: none; }
.jr-dot { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 800; border: 2px solid var(--rule-strong); background: var(--raised); color: var(--faint); }
.jr-name { font-size: 12px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.jr-dept { font-size: 10.5px; color: var(--faint); }
.jr-stop.jr-done .jr-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.jr-stop.jr-done::before, .jr-stop.jr-current::before { background: var(--ok); }
.jr-stop.jr-current .jr-dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 5px var(--accent-soft); animation: jrpulse 2s infinite; }
.jr-stop.jr-current .jr-name { color: var(--accent); font-weight: 800; }
.jr-stop.jr-current .jr-dept { color: var(--accent); font-weight: 700; }
.jr-stop.jr-ahead .jr-name, .jr-stop.jr-never .jr-name { color: var(--muted); font-weight: 500; }
.jr-stop.jr-never { opacity: .45; }
.jr-stop.jr-skipped .jr-dot { border-style: dashed; }
.jr-stop.jr-detour .jr-dot { background: var(--medium); border-color: var(--medium); color: #fff; }
.jr-stop.jr-detour.jr-current .jr-dot { box-shadow: 0 0 0 5px var(--medium-soft); }
.jr-stop.jr-stopped .jr-dot { background: var(--high); border-color: var(--high); color: #fff; }
.jr-stop.jr-stopped .jr-name { color: var(--high); font-weight: 800; }
@keyframes jrpulse { 50% { box-shadow: 0 0 0 9px transparent; } }
.jr-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--muted); margin-top: -6px; }
.jr-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; border: 2px solid var(--rule-strong); }
.jr-legend .jr-done i { background: var(--ok); border-color: var(--ok); } .jr-legend .jr-current i { background: var(--accent); border-color: var(--accent); }
.jr-legend .jr-detour i { background: var(--medium); border-color: var(--medium); } .jr-legend .jr-stopped i { background: var(--high); border-color: var(--high); }

.jr-case { border-color: var(--medium-border); }
.jr-timeline { list-style: none; margin: 0; padding: 6px 16px 14px 34px; border-top: 1px solid var(--rule-subtle); position: relative; }
.jr-timeline::before { content: ""; position: absolute; left: 21px; top: 14px; bottom: 18px; width: 2px; background: var(--rule); }
.jr-ev { position: relative; padding: 10px 0 10px; border-bottom: 1px dashed var(--rule-subtle); }
.jr-ev:last-child { border-bottom: 0; }
.jr-ev::before { content: ""; position: absolute; left: -18px; top: 15px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--ok); border: 2px solid var(--raised); box-shadow: 0 0 0 1px var(--ok); }
.jr-ev-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.jr-ev-stage { font-weight: 700; color: var(--ink-heading); font-size: 14px; }
.jr-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok); }
.jr-tag-now { background: var(--accent); color: #fff; }
.jr-ev-meta { font-size: 12px; color: var(--faint); margin-top: 2px; }
.jr-ev-why { margin-top: 6px; padding: 7px 10px; border-left: 3px solid var(--rule-strong); background: var(--rule-subtle); border-radius: 0 8px 8px 0; font-size: 13px; color: var(--ink); }
.jr-ev-note { margin-top: 5px; font-size: 12.5px; color: var(--ink); }
.jr-ev-stopped::before { background: var(--high); box-shadow: 0 0 0 1px var(--high); }
.jr-ev-stopped .jr-tag { background: var(--high-soft); color: var(--high); } .jr-ev-stopped .jr-ev-why { border-color: var(--high); background: var(--high-soft); }
.jr-ev-escalated::before, .jr-ev-waiting::before, .jr-ev-back::before { background: var(--medium); box-shadow: 0 0 0 1px var(--medium); }
.jr-ev-escalated .jr-tag, .jr-ev-waiting .jr-tag, .jr-ev-back .jr-tag { background: var(--medium-soft); color: var(--medium); }
.jr-ev-escalated .jr-ev-why, .jr-ev-waiting .jr-ev-why, .jr-ev-back .jr-ev-why { border-color: var(--medium); background: var(--medium-soft); }
.jr-ev-current::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.jr-ev-start::before { background: var(--info); box-shadow: 0 0 0 1px var(--info); }
@media (max-width: 760px) {
  .jr { padding: 16px 14px; }
  .jr-facts > div { min-width: 0; flex: 1 1 40%; }
  .jr-stop { flex-basis: 86px; }
}

/* Finance: the parties the Finance Manager keeps */
.fin-parties { margin-top: 18px; }
.party-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.party-card { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center; padding: 14px;
  border: 1px solid var(--rule); border-radius: 14px; background: var(--raised); transition: box-shadow .15s, border-color .15s; }
.party-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.party-card-text { display: grid; gap: 2px; } .party-card-text b { color: var(--ink-heading); font-size: 14.5px; }
.party-card-text span { font-size: 12px; color: var(--faint); }
.party-card-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.party-card-actions .party-add { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ═══ Team presence (hybrid work) ═══ */
.tm-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--rule-strong); border: 2px solid var(--raised); vertical-align: middle; flex: none; }
.tm-dot.tm-online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.tm-dot.tm-away { background: #f59e0b; }
.tm-dot.tm-offline { background: #9ca3af; }
.tm-dot.tm-off { background: #8b5cf6; }
.tm-pick { position: relative; margin-right: 6px; }
.tm-pick > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tm-pick > summary::-webkit-details-marker { display: none; }
.tm-pick.tm-ask > summary { border-color: var(--gold-deep) !important; color: var(--gold-deep) !important; animation: tmask 2.4s ease-in-out 3; }
@keyframes tmask { 50% { box-shadow: 0 0 0 4px var(--gold-soft); } }
.tm-pick-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 250px; padding: 10px; border-radius: 14px;
  background: var(--raised); border: 1px solid var(--rule); box-shadow: var(--shadow-lg); display: grid; gap: 6px; }
.tm-pick-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 2px 4px 4px; }
.tm-pick-menu form { display: grid; gap: 4px; }
.tm-pick-opt { text-align: left; background: transparent !important; color: var(--ink) !important; border: 1px solid transparent !important;
  box-shadow: none !important; padding: 8px 10px !important; border-radius: 10px !important; font-weight: 500 !important; min-height: 0 !important; }
.tm-pick-opt:hover { background: var(--accent-soft) !important; transform: none !important; }
.tm-pick-opt.on { border-color: var(--accent) !important; background: var(--accent-soft) !important; font-weight: 700 !important; }
.tm-pick-team { padding: 8px 10px; border-top: 1px solid var(--rule-subtle); font-weight: 600; font-size: 13px; color: var(--accent); text-decoration: none; }
.tm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 18px; }
.tm-kpi { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 14px 16px; border-radius: 16px; background: var(--raised); border: 1px solid var(--rule); box-shadow: var(--shadow-xs); }
.tm-kpi .tm-dot, .tm-kpi .tm-big { grid-row: 1 / 3; } .tm-kpi .tm-dot { width: 14px; height: 14px; }
.tm-big { font-size: 22px; }
.tm-kpi b { font-family: 'Poppins', sans-serif; font-size: 22px; color: var(--ink-heading); line-height: 1.1; }
.tm-kpi span:last-child { font-size: 12px; color: var(--muted); }
.tm-me { margin-top: 18px; }
.tm-mode-form { display: grid; gap: 12px; }
.tm-modes { display: flex; flex-wrap: wrap; gap: 8px; }
.tm-mode { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--rule-strong);
  cursor: pointer; font-size: 14px; background: var(--raised); }
.tm-mode input { display: none; } .tm-mode span { font-size: 18px; }
.tm-mode:has(input:checked), .tm-mode-on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; box-shadow: 0 0 0 3px var(--accent-soft); }
.tm-note { display: flex; gap: 8px; flex-wrap: wrap; } .tm-note input { flex: 1; min-width: 220px; }
.tm-dept { margin-top: 14px; }
.tm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; padding: 4px 14px 14px; }
.tm-person { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; padding: 12px; border-radius: 14px; border: 1px solid var(--rule); background: var(--raised); }
.tm-person.tm-online { border-color: rgba(34,197,94,.45); }
.tm-person.tm-offline, .tm-person.tm-off { opacity: .8; }
.tm-avatar { position: relative; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  color: #fff; background: linear-gradient(135deg, var(--accent-vibrant), var(--accent)); }
.tm-avatar .tm-dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; }
.tm-who { display: grid; gap: 1px; min-width: 0; }
.tm-who b { color: var(--ink-heading); font-size: 14.5px; }
.tm-role { font-size: 11.5px; color: var(--faint); }
.tm-status { font-size: 13px; color: var(--ink); margin-top: 3px; }
.tm-pnote { font-size: 12.5px; font-style: italic; color: var(--muted); }
.tm-seen { font-size: 11.5px; color: var(--faint); }
.tm-week { grid-column: 1 / -1; display: flex; gap: 4px; align-items: stretch; margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--rule-subtle); }
.tm-day { flex: 1; display: grid; justify-items: center; gap: 1px; padding: 4px 2px; border-radius: 8px; background: var(--rule-subtle); font-size: 14px; }
.tm-day i { font-style: normal; font-size: 10px; font-weight: 700; color: var(--faint); text-transform: uppercase; }
.tm-day em { font-style: normal; font-size: 10px; color: var(--muted); }
.tm-day.tm-today { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tm-weektotal { flex: 1.3; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--accent); }
@media (max-width: 760px) { .tm-pick-text { display: none; } .tm-grid { grid-template-columns: minmax(0, 1fr); padding: 4px 8px 10px; } }

.tm-depts { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; margin-top: 14px; align-items: start; }
.tm-depts .tm-dept { margin-top: 0; }
.tm-depts .tm-grid { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 760px) { .tm-depts { grid-template-columns: minmax(0, 1fr); } }

.tm-pick > summary.btn-logout { background: var(--accent-soft) !important; color: var(--ink) !important; border: 1px solid var(--rule) !important; }
.tm-pick > summary.btn-logout:hover { border-color: var(--accent) !important; }

/* Delete / deactivate card */
.remove-card { border-color: var(--high-border) !important; }
.remove-card > h2 { color: var(--high); }
.remove-body { display: grid; gap: 12px; }
.remove-actions { display: flex; gap: 10px; flex-wrap: wrap; }
button.danger { background: var(--high) !important; border-color: var(--high) !important; color: #fff !important; }
button.danger:hover { filter: brightness(1.08); }

/* Folding card groups: facts and linked records */
.fold-group { margin-top: 18px; }
.rc-list { display: grid; gap: 10px; }
.rc-card .rf2-card-meta b { color: var(--ink); }
.rc-count { flex: none; min-width: 30px; height: 26px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 800; background: var(--accent-soft); color: var(--accent); }
.rc-body { border-top: 1px solid var(--rule-subtle); padding: 6px 8px 10px; }
.rc-body table.data { margin: 0; }
.rc-empty { margin: 12px 2px 0; font-size: 12.5px; color: var(--faint); }

/* Deal pulse: moved today, stuck past the stage's time */
.pulse-grid { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.pulse-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 4px; border-bottom: 1px dashed var(--rule-subtle);
  text-decoration: none; color: var(--ink); border-left: 3px solid transparent; padding-left: 8px; }
.pulse-row:hover { background: var(--accent-soft); }
.pulse-row:last-of-type { border-bottom: 0; }
.pulse-main { font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pulse-move { font-size: 12.5px; text-align: right; white-space: nowrap; }
.pulse-meta { grid-column: 1 / -1; font-size: 11.5px; color: var(--faint); }
.pulse-row.pulse-bad { border-left-color: var(--high); }
.pulse-alert { border-color: var(--high-border); }
.pulse-alert .rc-count { background: var(--high-soft); color: var(--high); }
@media (max-width: 760px) { .pulse-grid { grid-template-columns: minmax(0, 1fr); } }

/* A deal's documents, by department */
.doc-groups { margin-top: 20px; }
.doc-generate { padding: 12px 14px; border: 1px dashed var(--rule); border-radius: 12px; margin-bottom: 12px; }
.doc-groups .rf2-body.doc-list, .doc-block .rf2-body.doc-list { padding: 6px 12px 10px; gap: 0; }

/* Documents, in the same cards as At a glance */
.doc-groups .gen-grid, .doc-groups .doc-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
/* a record's documents (lead, application, client): the same cards, even in a narrow column */
.doc-block .doc-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.doc-block .doc-head { margin-bottom: 2px; }
.doc-block .doc-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px;
  border: 1px dashed var(--rule); border-radius: 12px; }
.doc-block .doc-add input[name=document_type], .doc-block .doc-add select { flex: 1 1 200px; min-width: 0; }
.doc-block .doc-add input[type=file] { flex: 1 1 200px; min-width: 0; }
.gen-card { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--rule);
  border-radius: 14px; background: var(--raised); }
.gen-card.gen-wait { opacity: .62; border-style: dashed; }
.gen-actions { margin-left: auto; display: flex; gap: 6px; }
.doc-count { display: inline-block; min-width: 20px; padding: 0 7px; margin-left: 4px; border-radius: 999px; font-size: 11.5px;
  font-weight: 800; line-height: 19px; text-align: center; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.doc-groups .doc-grid .rf2-card[open], .doc-block .doc-grid .rf2-card[open] { grid-column: 1 / -1; }
.doc-line { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 9px 2px;
  border-bottom: 1px dashed var(--rule-subtle); }
.doc-line:last-child { border-bottom: 0; }
.doc-line-icon { font-size: 18px; }
.doc-line-text { display: grid; gap: 1px; min-width: 0; }
.doc-line-text b { font-size: 13.5px; color: var(--ink-heading); font-weight: 600; }
.doc-line-text small { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-line-actions { display: flex; gap: 6px; align-items: center; }
.doc-line-actions .doc-btn { min-width: 34px; text-align: center; }

/* Accountability: who processed a lead / application at each stage */
.trail { margin-top: 18px; }
.trail-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.trail-who { font-size: 13.5px; font-weight: 700; color: var(--accent); }

/* What the current stage still needs, under the stage tracker (27 Oct) */
.jr-todo { margin-top: 14px; border: 1px solid var(--accent); border-radius: 14px; background: var(--raised); overflow: hidden; }
.jr-todo-head { display: flex; align-items: center; gap: 12px; padding: 13px 14px; }
.jr-todo-list { list-style: none; margin: 0; padding: 4px 14px 12px; display: grid; gap: 2px; border-top: 1px solid var(--rule-subtle); }
.jr-todo-list li { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center; padding: 8px 2px;
  border-bottom: 1px dashed var(--rule-subtle); font-size: 13.5px; }
.jr-todo-list li:last-child { border-bottom: 0; }
.jr-todo-mark { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--rule-strong); display: grid;
  place-items: center; font-size: 12px; font-weight: 800; }
.jr-todo-list li.is-done .jr-todo-mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.jr-todo-list li.is-done .jr-todo-what { color: var(--faint); text-decoration: line-through; }
.jr-todo-go { font-size: 12.5px; font-weight: 600; white-space: nowrap; }

/* A form's result shown in the section it was sent from (27 Oct) */
.flash-here { margin: 12px 16px !important; }
details.rf2-card > .flash-here, .jr-todo > .flash-here { margin: 8px 14px !important; }
.just-acted { box-shadow: 0 0 0 2px var(--accent), var(--shadow-md) !important; transition: box-shadow .4s ease; }

/* KYC done by Oricred: the checklist that writes the KYC record (27 Oct) */
.kyc-check { display: grid; gap: 8px; margin: 10px 0 14px; padding: 14px; border: 1px solid var(--accent); border-radius: 12px; background: var(--accent-soft); }
.kyc-check-head { font-size: 13.5px; }
.kyc-item { display: flex; gap: 10px; align-items: center; font-size: 13.5px; }
.kyc-check-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kyc-row { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(260px, 1.2fr); gap: 10px; align-items: center;
  padding: 8px 0; border-top: 1px dashed var(--rule-subtle); }
.kyc-docs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kyc-doc { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--rule-strong); background: var(--raised); text-decoration: none; }
.kyc-none { font-size: 12px; color: var(--faint); }
.kyc-up { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.kyc-up input[type=file] { max-width: 210px; font-size: 12px; }
.kyc-up button { padding: 5px 10px !important; font-size: 12px !important; }
@media (max-width: 760px) { .kyc-row { grid-template-columns: 1fr; } }

/* Marking a party as a government / public-sector body (27 Oct) */
.inline-mark { display: inline; margin: 0 0 0 6px; }
.link-btn { background: none !important; border: 0 !important; padding: 0 !important; box-shadow: none !important;
  color: var(--accent) !important; font-size: 12.5px !important; font-weight: 600; cursor: pointer; text-decoration: underline; }

/* The client's consent to credit checks (27 Oct) */
.consent-box { margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; display: grid; gap: 8px; }
.consent-box.is-ok { border: 1px solid var(--ok-border); background: var(--ok-soft); }
.consent-box.is-wait { border: 1px solid var(--gold); background: var(--gold-soft); }
.consent-link input { width: min(100%, 520px); font-size: 12px; padding: 5px 8px !important; }
.consent-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.consent-actions form { margin: 0; }
.consent-paper { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }

/* What a repeat credit review is waiting for (27 Oct) */
.cond-wait { margin: 10px 0 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--gold); background: var(--gold-soft); font-size: 13px; }

/* The notification bell (27 Oct) */
.bell { position: relative; }
.bell > summary { list-style: none; position: relative; }
.bell > summary::-webkit-details-marker { display: none; }
.bell-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; }
.bell-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 380px; max-height: 70vh; overflow: auto;
  padding: 10px; border-radius: 14px; background: var(--raised); border: 1px solid var(--rule-strong); box-shadow: var(--shadow-lg); }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 8px; }
.bell-read { background: none !important; border: 0 !important; color: var(--accent) !important; font-size: 12px !important;
  padding: 0 !important; box-shadow: none !important; cursor: pointer; }
.bell-section { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 10px 6px 4px; }
.bell-n { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.bell-item { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 8px 6px; border-radius: 10px;
  text-decoration: none; color: var(--ink); }
.bell-item:hover { background: var(--raised-hover); }
.bell-item.is-new { background: var(--accent-soft); }
.bell-tx { display: grid; gap: 1px; min-width: 0; }
.bell-tx b { font-size: 13px; font-weight: 600; }
.bell-tx small { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bell-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.bell-empty { margin: 6px; font-size: 12.5px; color: var(--faint); }
@media (max-width: 600px) { .bell-menu { position: fixed; left: 12px; right: 12px; width: auto; top: 70px; } }

/* In-page jumps ("Do it", section links) stop below the sticky header, and the place jumped to lights up (27 Oct) */
[id] { scroll-margin-top: 130px; }
:target { animation: target-glow 2.4s ease-out 1; }
@keyframes target-glow {
  0%, 35% { box-shadow: 0 0 0 3px var(--accent, #2dc4cf), 0 0 28px rgba(45, 196, 207, .45); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.jr-todo-who { margin-left: auto; font-size: 12px; color: var(--muted, #8faeb8); white-space: nowrap; }
.sign-links { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--rule, #1b4b5e); border-radius: 12px; font-size: 13px; }
.sign-link { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.sign-link > span { min-width: 220px; }
.sign-link input { flex: 1; min-width: 260px; font-size: 12px; }

/* 27 Oct: lists in recorded details (every contact, bank account, supplier) and each document card's own "+ Add" */
.rf2-lines div { padding: 2px 0; border-bottom: 1px dashed var(--border-color, #e3e8ea); }
.rf2-lines div:last-of-type { border-bottom: 0; }
.rf2-lines small { display: block; margin-top: 4px; }
.client-contacts { margin: 0 0 10px; font-size: 13px; }
.client-contacts ul { margin: 4px 0 0; padding-left: 18px; }
.doc-add-here { margin-top: 8px; }
.doc-add-here > summary { cursor: pointer; font-size: 12.5px; }
.doc-add-here .doc-form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.doc-add-here .doc-form input[name=document_type] { flex: 1; min-width: 180px; }

/* 27 Oct: the in-app document viewer (ledger/base.html) - every preview opens on the page, not in a new tab */
.docv { position: fixed; inset: 0; z-index: 2000; background: rgba(5, 22, 30, .62); display: flex;
        align-items: center; justify-content: center; padding: 24px; }
.docv[hidden] { display: none; }
.docv-box { width: min(1100px, 100%); height: min(92vh, 100%); background: var(--raised); color: var(--ink); border-radius: 14px;
            box-shadow: 0 24px 60px rgba(0, 0, 0, .35); display: flex; flex-direction: column; overflow: hidden; }
.docv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px;
             border-bottom: 1px solid var(--rule); background: var(--raised); }
.docv-title { color: var(--ink-heading); }
.docv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docv-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.docv-dl { font-size: 13px; font-weight: 600; text-decoration: none; color: var(--accent-vibrant); }
.docv-close { border: 0; background: transparent; font-size: 18px; line-height: 1; padding: 6px 8px; cursor: pointer;
              color: inherit; }
.docv-body { position: relative; flex: 1; background: #525659; }
.docv-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.docv-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff;
             font-size: 14px; z-index: 1; pointer-events: none; background: #525659; }
.docv-wait[hidden] { display: none; }
body.docv-open { overflow: hidden; }
@media (max-width: 640px) { .docv { padding: 0; } .docv-box { height: 100%; border-radius: 0; } }

/* 27 Oct: the record's hero is frozen under the top bar (deal, application, lead), with the record at a glance on
   its right; once the page scrolls it slims to the title, the department links and the glance. */
.dashboard-hero.hero-frozen { position: sticky; top: var(--stick-top, 64px); z-index: 60; padding-right: 340px;
               background-size: 0 0, 100% 100%, cover; }   /* no sun: the glance sits there */
.hero-glance { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); width: 290px;
               background: rgba(255, 255, 255, .10); border: 1px solid rgba(255, 255, 255, .18); border-radius: 14px;
               padding: 12px 14px; backdrop-filter: blur(6px); color: #e9f6f7; }
.hg-customer b { display: block; font-size: 17px; line-height: 1.25; color: #fff; font-weight: 800; }
.hg-customer span { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: #fbe3b5; }
.hg-facts { margin: 8px 0 0; display: grid; gap: 4px; }
.hg-facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.hg-facts dt { color: rgba(233, 246, 247, .72); }
.hg-facts dd { margin: 0; font-weight: 700; color: #fff; text-align: right; overflow: hidden; text-overflow: ellipsis;
               white-space: nowrap; max-width: 170px; }
/* the deal ledger page keeps its department buttons on the right: its glance sits under the title */
.page-head-main .hero-glance { position: static; transform: none; margin-top: 12px; width: auto; max-width: 520px; }
.dashboard-hero.hero-frozen.page-head { padding-right: 30px; }

.dashboard-hero.hero-frozen.is-stuck { padding: 10px 20px 12px; padding-right: 20px; gap: 2px; border-radius: 0 0 14px 14px;
                        flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 16px; }
.hero-frozen.is-stuck .dashboard-badge,
.hero-frozen.is-stuck > p,
.hero-frozen.is-stuck > .dashboard-subtitle,
.hero-frozen.is-stuck > div:not(.hero-glance):not(.page-head-main):not(:has(a)),
.hero-frozen.is-stuck .page-head-main > p,
.hero-frozen.page-head.is-stuck > div:not(.page-head-main) { display: none !important; }
.hero-frozen.is-stuck h1, .hero-frozen.is-stuck .dashboard-title { font-size: 19px !important; margin: 0 !important; }
.hero-frozen.is-stuck > div:has(a) { margin-top: 0 !important; }
.hero-frozen.is-stuck .hero-glance { order: 5; position: static; transform: none; width: auto; margin-left: auto; padding: 6px 12px;
                                     display: flex; align-items: center; gap: 16px; flex-wrap: wrap; max-width: 100%; }
.hero-frozen.is-stuck .page-head-main { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; width: 100%; }
.hero-frozen.is-stuck .hg-customer b { font-size: 14.5px; }
.hero-frozen.is-stuck .hg-customer span { display: none; }
.hero-frozen.is-stuck .hg-facts { margin: 0; display: flex; gap: 14px; flex-wrap: wrap; }
.hero-frozen.is-stuck .hg-facts div { gap: 5px; font-size: 12.5px; }

@media (max-width: 900px) {
  .dashboard-hero.hero-frozen { position: relative; top: auto; padding-right: 26px; }     /* a phone keeps its screen */
  .hero-glance { position: static; transform: none; width: 100%; margin-top: 10px; }
}

/* 27 Oct: the Oricred scorecard (dealmgmt/_scorecard.html) */
.sc-table th, .sc-table td { vertical-align: top; }
.sc-table .num { text-align: right; white-space: nowrap; }
.sc-table .sc-cat { width: 150px; font-weight: 700; vertical-align: middle; border-right: 1px solid var(--rule); }
.sc-table .sc-comment { min-width: 220px; border-left: 1px solid var(--rule); }
.sc-table .sc-comment textarea { width: 100%; min-height: 64px; resize: vertical; }
.sc-table tbody.sc-group { border-top: 2px solid var(--rule-strong); }
.sc-table .sc-sub td { background: var(--raised-hover); }
.sc-table .sc-total th, .sc-table .sc-total td { background: var(--accent-soft); }
.sc-score { width: 64px; text-align: right; padding: 4px 6px; }
.sc-score.is-bad { border-color: var(--high) !important; background: var(--high-soft); }
.sc-rec { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 12.5px; }
.sc-ok { background: var(--ok-soft); color: var(--ok); }
.sc-warn { background: var(--gold-soft); color: var(--gold-deep); }
.sc-bad { background: var(--high-soft); color: var(--high); }
.sc-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; }

/* 27 Oct: a waiver waiting for an Executive (governance/_waiver.html) */
.waiver-box { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: center;
              padding: 12px 14px; margin: 0 0 14px; border-radius: 12px; border: 1px solid var(--gold-badge);
              background: var(--gold-soft); color: var(--ink); }
.waiver-decide { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.waiver-decide input { min-width: 200px; }
/* the DD item's own section of the scorecard (27 Oct) */
.sc-table tbody.sc-focus td, .sc-table tbody.sc-focus th { background: var(--gold-soft); }
.sc-table tbody.sc-focus { outline: 2px solid var(--gold-badge); outline-offset: -2px; }

/* 28 Oct: the Credit Committee's review pack (dealmgmt/deal.html, section 6) */
.review-pack { border: 1px solid var(--rule); border-radius: 12px; padding: 12px 14px; margin-bottom: 6px; background: var(--raised-hover); }
.rp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 18px; }
.rp-grid > div { display: flex; flex-direction: column; gap: 2px; }
.rp-k { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.rp-v { font-size: 13.5px; color: var(--ink); }
.rp-docs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* 28 Oct: the COO's pricing row (finance/_pricing_row.html) and the overdue flag */
.pricing-row { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 10px; }
.pr-box { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--rule);
          border-radius: 10px; background: var(--raised); min-width: 0; }
.pr-box.pr-system { background: var(--raised-hover); border-style: dashed; }
.pr-k { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.pr-v { font-size: 16px; color: var(--ink-heading); }
.pr-box small { font-size: 11.5px; line-height: 1.35; }
.pr-box select, .pr-box input { width: 100%; }
.pr-pair { display: flex; gap: 6px; align-items: center; }
.pr-pair input { flex: 1; min-width: 0; }
.pr-pair select { width: auto; }
.pr-unit { color: var(--muted); font-size: 13px; }
.pr-manage { font-size: 11.5px; }
@media (max-width: 900px) { .pricing-row { grid-template-columns: 1fr 1fr; } }
.od-flag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
           font-style: normal; white-space: nowrap; }
.od-green { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); }
.od-amber { background: var(--medium-soft); color: var(--medium); border: 1px solid var(--medium-border); }
.od-red { background: var(--high-soft); color: var(--high); border: 1px solid var(--high-border); }
.od-due { background: var(--raised-hover); color: var(--muted); border: 1px solid var(--rule); }
/* 28 Oct: real-time progress - a short note when the journey redraws itself */
.live-pulse { position: fixed; right: 18px; bottom: 18px; z-index: 1500; padding: 8px 14px; border-radius: 999px;
              background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-xs); }

/* What the deal is waiting for, every lane, with a shortcut to each (29 Oct) */
.waiting { margin: 0 0 18px; border: 1px solid var(--accent); border-radius: 14px; background: var(--raised); overflow: hidden; }
.waiting-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 12px 14px; border-bottom: 1px solid var(--rule-subtle); }
.waiting-head .quiet { font-size: 12px; }
.waiting-lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0; }
.waiting-lane { padding: 10px 14px 12px; border-right: 1px dashed var(--rule-subtle); border-bottom: 1px dashed var(--rule-subtle); }
.waiting-lane-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13.5px; margin-bottom: 4px; }
.waiting-who { margin-left: auto; font-size: 12px; color: var(--muted, #8faeb8); }
.waiting-lane ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.waiting-lane li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; align-items: baseline; }
.waiting-note { margin: 6px 0 0; font-size: 12px; }
