
/* =========================================================
   DYNASTY — RISK ANALYSIS
   Scoped styles to avoid conflicts with other pages
========================================================= */

.risk-page {
  --risk-gold: #c9a227;
  --risk-bg: #0a0a0a;
  --risk-panel: #141414;
  --risk-border: #292929;
  --risk-text: #f5f5f0;
  --risk-muted: #a5a5a0;

  width: 100%;
  min-width: 0;
  color: var(--risk-text);
  font-family: inherit;
  box-sizing: border-box;
}

.risk-page *,
.risk-page *::before,
.risk-page *::after {
  box-sizing: border-box;
}

.risk-page [hidden] {
  display: none !important;
}

.risk-page h1,
.risk-page h2,
.risk-page p {
  margin-top: 0;
}

.risk-page h1 {
  margin-bottom: 8px;
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.risk-page h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.4;
  font-weight: 600;
}

.risk-page p {
  line-height: 1.6;
}

.risk-page .risk-panel__head {
  margin-bottom: 18px;
}

.risk-page .risk-panel__head h2 {
  flex: 0 1 auto;
  min-width: 0;
}

.risk-page .risk-panel__head > * {
  max-width: 100%;
  overflow-wrap: anywhere;
}

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

.risk-small {
  font-size: 0.8rem;
}

.risk-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.risk-page-head__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.risk-panel {
  min-width: 0;
  margin-bottom: 18px;
  padding: 20px;
  background: var(--risk-panel);
  border: 1px solid var(--risk-border);
  border-radius: 14px;
}

.risk-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.risk-btn {
  min-height: 42px;
  padding: 10px 16px;
  color: #0a0a0a;
  background: var(--risk-gold);
  border: 1px solid var(--risk-gold);
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.risk-btn:hover {
  filter: brightness(1.08);
}

.risk-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}


/* Buttons created by the risk-analysis JavaScript */
.risk-page .btn {
  min-height: 42px;
  padding: 10px 16px;
  color: var(--risk-text);
  background: #171717;
  border: 1px solid var(--risk-border);
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.risk-page .btn--primary {
  color: #0a0a0a;
  background: var(--risk-gold);
  border-color: var(--risk-gold);
}

.risk-page .btn--ghost {
  background: transparent;
  border-color: var(--risk-border);
}

.risk-page .btn--sm {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.risk-page .btn--icon {
  width: 36px;
  min-height: 36px;
  padding: 6px;
}

.risk-page .btn:hover {
  filter: brightness(1.15);
}

.risk-page .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}


.risk-btn--ghost {
  color: var(--risk-text);
  background: transparent;
  border-color: var(--risk-border);
}

.risk-status {
  margin-bottom: 14px;
  color: var(--risk-muted);
  font-size: 0.9rem;
}

.risk-status[hidden] {
  display: none !important;
}


.risk-app {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  min-width: 0;
}

.risk-app > section,
.risk-app > .risk-split {
  width: 100%;
  min-width: 0;
}

.risk-app > section.risk-panel {
  margin-bottom: 0;
}

.risk-app .risk-split > .risk-panel {
  margin-bottom: 0;
}



.risk-stats {
  display: grid;
  grid-template-columns: repeat( auto-fit, minmax(min(100%, 190px), 1fr) );
  gap: 14px;
  margin: 0 0 22px;
  align-items: stretch;
}

.stat {
  min-width: 0;
  padding: 18px;
  background: linear-gradient(
    180deg,
    #19170f 0%,
    #111111 38%,
    #0d0d0d 100%
  );
  border: 1px solid #39301a;
  border-top: 2px solid #c9a227;
  border-radius: 14px;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.28);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.stat:hover {
  border-color: #6b5620;
  border-top-color: #e0b735;
  background: linear-gradient(
    180deg,
    #211c0e 0%,
    #131313 42%,
    #0d0d0d 100%
  );
}


.stat__label {
  margin: 0 0 12px;
  color: #b8b5aa;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.4;
  text-transform: uppercase;
}

.stat__value {
  margin: 0;
  color: #f5f5f0;
  font-size: clamp(1.8rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat__sub {
  margin: 12px 0 0;
  color: #85857f;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.5;
}


.risk-dist-bar {
  display: flex;
  min-height: 12px;
  overflow: hidden;
  background: #252525;
  border-radius: 8px;
}

.risk-legend,
.risk-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  margin: 16px 0 0;
  list-style: none;
}





/* Separate risk heading and horizontal count bar */
.risk-page .risk-legend,
.risk-page #legend {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.risk-page .legend__row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  list-style: none;
}

.risk-page .legend__label {
  color: var(--risk-text);
  font-size: 0.85rem;
  font-weight: 600;
}

.risk-page .legend__item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  color: var(--risk-text);
  background: #141414;
  border: 1px solid rgba(201, 162, 39, 0.6);
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
}

.risk-page .legend__fill {
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  border-radius: 3px;
  pointer-events: none;
}

.risk-page .legend__fill.lv-green {
  background: linear-gradient(90deg, rgba(74, 222, 128, 0.55), rgba(74, 222, 128, 0.08));
}

.risk-page .legend__fill.lv-yellow {
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.55), rgba(250, 204, 21, 0.08));
}

.risk-page .legend__fill.lv-orange {
  background: linear-gradient(90deg, rgba(251, 146, 60, 0.55), rgba(251, 146, 60, 0.08));
}

.risk-page .legend__fill.lv-purple {
  background: linear-gradient(90deg, rgba(192, 132, 252, 0.55), rgba(192, 132, 252, 0.08));
}

.risk-page .legend__fill.lv-red {
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.55), rgba(248, 113, 113, 0.08));
}

.risk-page .legend__count {
  position: relative;
  z-index: 1;
  font-size: 0.82rem;
  font-weight: 600;
}

.risk-page .legend__item:hover {
  border-color: var(--risk-gold);
}

.risk-page .legend__item:focus-visible {
  outline: 2px solid var(--risk-gold);
  outline-offset: 2px;
}


/* Luxury gold borders with individual risk-color fills */
.risk-page .risk-legend .lv-green {
  background: linear-gradient(90deg, rgba(74, 222, 128, 0.18), rgba(74, 222, 128, 0.025));
}

.risk-page .risk-legend .lv-yellow {
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.18), rgba(250, 204, 21, 0.025));
}

.risk-page .risk-legend .lv-orange {
  background: linear-gradient(90deg, rgba(251, 146, 60, 0.18), rgba(251, 146, 60, 0.025));
}

.risk-page .risk-legend .lv-purple {
  background: linear-gradient(90deg, rgba(192, 132, 252, 0.18), rgba(192, 132, 252, 0.025));
}

.risk-page .risk-legend .lv-red {
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.18), rgba(248, 113, 113, 0.025));
}



.risk-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.risk-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--risk-border);
  border-radius: 999px;
  font-size: 0.8rem;
}



/* Risk level badges */
.risk-page .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--risk-border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.risk-page .badge--lg {
  padding: 8px 12px;
  font-size: 0.95rem;
}

.risk-page .badge__dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
}


/* Risk level colors */
.risk-page .lv-green {
  color: #4ade80;
  border-color: #4ade80;
}

.risk-page .lv-yellow {
  color: #facc15;
  border-color: #facc15;
}

.risk-page .lv-orange {
  color: #fb923c;
  border-color: #fb923c;
}

.risk-page .lv-purple {
  color: #c084fc;
  border-color: #c084fc;
}

.risk-page .lv-red {
  color: #f87171;
  border-color: #f87171;
}

/* Apply each level's color to its score bar */
.risk-page .meter.lv-green .meter__fill {
  background: #4ade80;
}

.risk-page .meter.lv-yellow .meter__fill {
  background: #facc15;
}

.risk-page .meter.lv-orange .meter__fill {
  background: #fb923c;
}

.risk-page .meter.lv-purple .meter__fill {
  background: #c084fc;
}

.risk-page .meter.lv-red .meter__fill {
  background: #f87171;
}

/* Risk score meter */
.risk-page .meter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  font-size: 0.85rem;
}

.risk-page .meter__track {
  display: block;
  flex: 1;
  min-width: 40px;
  height: 6px;
  overflow: hidden;
  background: #292929;
  border-radius: 999px;
}

.risk-page .meter__fill {
  display: block;
  height: 100%;
  background: var(--risk-gold);
  border-radius: inherit;
}

.risk-changes {
  display: grid;
  gap: 10px;
}



/* Client risk trend indicators */
.risk-page .trend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--risk-border);
  border-radius: 999px;
  color: var(--risk-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}


.risk-page .trend--worse {
  color: #f87171;
  border-color: #f87171;
}

.risk-page .trend--better {
  color: #4ade80;
  border-color: #4ade80;
}

.risk-page .trend--steady {
  color: var(--risk-muted);
  border-color: var(--risk-border);
}



/* Follow-up and note records */
.risk-page .records {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.risk-page .record {
  min-width: 0;
  padding: 14px;
  background: #101010;
  border: 1px solid var(--risk-border);
  border-radius: 10px;
}

.risk-page .record__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.risk-page .record__title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.risk-page .record__meta {
  margin: 8px 0 0;
  color: var(--risk-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.risk-page .record__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.risk-page .record.is-excluded {
  opacity: 0.65;
  border-style: dashed;
}

/* Note and follow-up status indicators */
.risk-page .state {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--risk-border);
  border-radius: 999px;
  color: var(--risk-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.risk-page .state--overdue {
  color: #f87171;
  border-color: #f87171;
}

.risk-page .state--ok {
  color: #4ade80;
  border-color: #4ade80;
}


.risk-filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.risk-field {
  display: grid;
  flex: 1 1 140px;
  min-width: 0;
  gap: 6px;
}

/* Payment promise and note form fields */
.risk-page .field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.risk-page .field label {
  display: block;
  color: var(--risk-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.risk-page .input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--risk-text);
  background: #0a0a0a;
  border: 1px solid var(--risk-border);
  border-radius: 8px;
  font: inherit;
  box-sizing: border-box;
}

.risk-page textarea.input {
  min-height: 80px;
  resize: vertical;
}

.risk-page .input::placeholder {
  color: #85857f;
  opacity: 1;
}

.risk-page .input:focus {
  outline: 2px solid var(--risk-gold);
  outline-offset: 1px;
  border-color: var(--risk-gold);
}

.risk-page select.input,
.risk-page input.input {
  color-scheme: dark;
}

.risk-field--grow {
  flex-grow: 2;
}

.risk-field label {
  color: var(--risk-muted);
  font-size: 0.85rem;
}

.risk-input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--risk-text);
  background: #0a0a0a;
  border: 1px solid var(--risk-border);
  border-radius: 8px;
  font: inherit;
}

.risk-input:focus {
  outline: 2px solid var(--risk-gold);
  outline-offset: 2px;
}

.risk-table-scroll {
  width: 100%;
  overflow-x: auto;
}

.risk-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.risk-table th,
.risk-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--risk-border);
  vertical-align: top;
}

.risk-table th {
  color: var(--risk-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.risk-num {
  text-align: right;
  white-space: nowrap;
}

.risk-col-optional {
  white-space: nowrap;
}

.risk-empty {
  padding: 20px 0;
  color: var(--risk-muted);
  text-align: center;
}

.risk-disclaimer {
  margin: 18px 0;
  color: var(--risk-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.risk-drawer {
  width: min(560px, 95vw);
  max-height: 85vh;
  padding: 0;
  overflow: auto;
  color: var(--risk-text);
  background: var(--risk-panel);
  border: 1px solid var(--risk-border);
  border-radius: 14px;
}

.risk-drawer::backdrop {
  background: rgb(0 0 0 / 70%);
}

.risk-profile {
  padding: 22px;
}


/* Client risk profile sections */
.risk-page .profile__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.risk-page .profile-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--risk-border);
}

.risk-page .profile__level {
  margin-bottom: 12px;
}

.risk-page .profile__level-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}



.risk-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  max-width: min(360px, calc(100vw - 40px));
  padding: 14px 18px;
  color: var(--risk-text);
  background: var(--risk-panel);
  border: 1px solid var(--risk-gold);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 35%);
}

.risk-page button:focus-visible {
  outline: 2px solid var(--risk-gold);
  outline-offset: 3px;
}

@media (max-width: 700px) {
  .risk-page-head {
    flex-direction: column;
  }

  .risk-page-head__actions {
    width: 100%;
  }

  .risk-split {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .risk-panel {
    padding: 14px;
  }

  .risk-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .risk-field {
    width: 100%;
  }

  .risk-col-optional {
    display: none;
  }

  .risk-table th,
  .risk-table td {
    padding: 10px 8px;
  }
}


/* Broken payment promise warning */
.risk-page .risk-warning {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin: 12px 0;
  padding: 16px;
  color: var(--risk-text);
  background: linear-gradient(135deg, #1b1414 0%, #111111 100%);
  border: 1px solid #633535;
  border-left: 4px solid #d64545;
  border-radius: 10px;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}

.risk-page .risk-warning strong {
  display: block;
  margin: 0;
  color: #ff7777;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.5;
}

.risk-page .risk-warning p {
  margin: 0;
  color: #d8d0d0;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.risk-page .risk-warning p:last-child {
  padding-top: 10px;
  border-top: 1px solid #3c2929;
  color: var(--risk-text);
  font-weight: 600;
}


/* Payment behavior — metric cards */
.risk-page .facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  min-width: 0;
  margin: 0;
}

.risk-page .facts > div {
  min-width: 0;
  padding: 14px;
  background: #101010;
  border: 1px solid var(--risk-border);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.risk-page .facts dt {
  margin: 0 0 8px;
  color: var(--risk-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.risk-page .facts dd {
  margin: 0;
  color: var(--risk-text);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.risk-page .muted.small {
  margin: 12px 0 0;
  padding: 10px 12px;
  color: var(--risk-muted);
  background: #101010;
  border-left: 3px solid var(--risk-gold);
  border-radius: 4px;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (max-width: 360px) {
  .risk-page .facts > div {
    padding: 10px;
  }

  .risk-page .facts dd {
    font-size: 1rem;
  }
}


/* Risk history — audit timeline */
.risk-page .timeline {
  position: relative;
  display: grid;
  gap: 14px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 0 0 22px;
  list-style: none;
}

.risk-page .timeline li {
  position: relative;
  min-width: 0;
  padding: 14px;
  background: #101010;
  border: 1px solid var(--risk-border);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.risk-page .timeline li::before {
  content: "";
  position: absolute;
  top: 20px;
  left: -22px;
  width: 10px;
  height: 10px;
  background: var(--risk-gold);
  border: 2px solid var(--risk-bg);
  border-radius: 50%;
}

.risk-page .timeline li::after {
  content: "";
  position: absolute;
  top: 32px;
  bottom: -16px;
  left: -18px;
  width: 2px;
  background: #383838;
}

.risk-page .timeline li:last-child::after {
  display: none;
}

.risk-page .timeline__title {
  margin: 0;
  color: var(--risk-text);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.risk-page .timeline__detail {
  margin: 8px 0 0;
  color: #d0d0ca;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.risk-page .timeline__time {
  margin: 10px 0 0;
  padding-top: 9px;
  color: var(--risk-muted);
  border-top: 1px solid #292929;
  font-size: 0.75rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* Match timeline markers to the recorded risk level */
.risk-page .timeline li.lv-green::before {
  background: #4ade80;
}

.risk-page .timeline li.lv-yellow::before {
  background: #facc15;
}

.risk-page .timeline li.lv-orange::before {
  background: #fb923c;
}

.risk-page .timeline li.lv-purple::before {
  background: #c084fc;
}

.risk-page .timeline li.lv-red::before {
  background: #f87171;
}

@media (max-width: 360px) {
  .risk-page .timeline {
    padding-left: 18px;
  }

  .risk-page .timeline li {
    padding: 11px;
  }

  .risk-page .timeline li::before {
    left: -18px;
  }

  .risk-page .timeline li::after {
    left: -14px;
  }
}


/* Compact, responsive form field groups */
.risk-page -grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.risk-page .form-grid > .field {
  min-width: 0;
}

.risk-page .form-grid .input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 480px) {
  .risk-page .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
}


/* Dynasty Risk Analysis — Dropdown Accordion Cards */
.risk-page .form-card {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 12px 0;
  border: 1px solid #333;
  border-radius: 12px;
  background: #141414;
  overflow: hidden;
}

.risk-page .form-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  color: #f5f5f0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.risk-page .form-card > summary::-webkit-details-marker {
  display: none;
}

.risk-page .form-card > summary::after {
  content: "+";
  color: #c9a227;
  font-size: 20px;
  line-height: 1;
}

.risk-page .form-card[open] > summary {
  border-bottom: 1px solid #333;
  color: #c9a227;
}

.risk-page .form-card[open] > summary::after {
  content: "\2212";
}

.risk-page .form-card > form {
  padding: 16px;
}

/* Dynasty Risk Analysis — Last 30 Days */
.risk-page .change-group {
  margin-top: 14px;
  padding: 16px;
  background: #141414;
  border: 1px solid #333;
  border-radius: 12px;
  min-width: 0;
}

.risk-page .change-group h3 {
  margin: 0 0 12px;
  color: #f5f5f0;
  font-size: 15px;
  font-weight: 600;
}

.risk-page .change-group .empty {
  margin: 0;
  padding: 12px;
  background: #0a0a0a;
  border: 1px dashed #383838;
  border-radius: 8px;
  color: #a7a7a0;
  font-size: 13px;
  line-height: 1.5;
}

.risk-page .change-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.risk-page .change-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #292929;
}

.risk-page .change-list li:last-child {
  border-bottom: 0;
}

.risk-page .change-list .link {
  min-width: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

.risk-page #clientRows tr,
.risk-page #clientRows th,
.risk-page #clientRows td {
  background-color: #141414 !important;
  color: #e8e0ce;
}


/* Dynasty Risk Intelligence */
.risk-page .risk-intelligence__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.risk-page .risk-intelligence__item {
  min-width: 0;
  padding: 16px;
  background: #141414;
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 8px;
}

.risk-page .risk-intelligence__number {
  color: var(--risk-gold, #c9a227);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.risk-page .risk-intelligence__item h3 {
  margin: 8px 0;
  color: var(--risk-text, #f5f0e5);
  font-size: 1rem;
}

.risk-page .risk-intelligence__item p {
  margin: 0 0 12px;
  color: var(--risk-muted, #b8b2a5);
  font-size: 0.85rem;
  line-height: 1.5;
}

.risk-page .risk-intelligence__tag {
  display: inline-block;
  color: var(--risk-gold, #c9a227);
  font-size: 0.72rem;
  font-weight: 600;
}

@media (max-width: 520px) {
  .risk-page .risk-intelligence__grid {
    grid-template-columns: 1fr;
  }
}
.risk-page .risk-intelligence__item {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.risk-page .risk-intelligence__item:hover,
.risk-page .risk-intelligence__item:focus-visible {
  border-color: var(--risk-gold, #c9a227);
}

.risk-page .risk-intelligence__item:focus-visible {
  outline: 2px solid var(--risk-gold, #c9a227);
  outline-offset: 2px;
}


/* FIX: Center the Risk Intelligence overview */
.risk-page .risk-intelligence__detail[hidden] {
  display: none !important;
}

.risk-page .risk-intelligence__detail {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 10001 !important;
  width: calc(100% - 32px) !important;
  max-width: 620px !important;
  max-height: 80vh !important;
  overflow-y: auto;
  margin: 0 !important;
  background: #141414 !important;
  border: 1px solid #c9a227 !important;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.97);
  transition: opacity 220ms ease, transform 220ms ease;
}

.risk-page .risk-intelligence__detail.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

body:has(.risk-intelligence__detail:not([hidden]))::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .risk-page .risk-intelligence__detail {
    transition: none;
  }
}


/* =========================================================
   DYNASTY — RISK INSIGHTS, AGING & PATTERN DETECTION
========================================================= */

/* Insights panel */
.risk-page #insights-panel {
  border-color: rgba(201, 162, 39, 0.4);
}

.risk-page #insights {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.risk-page #insights li {
  position: relative;
  padding: 14px 16px 14px 20px;
  color: var(--risk-text);
  background: linear-gradient(135deg, #1b190f, #101010);
  border: 1px solid #39301a;
  border-left: 3px solid var(--risk-gold);
  border-radius: 9px;
  font-size: 0.88rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* Receivables aging */
.risk-page #aging {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.risk-page #aging > div {
  min-width: 0;
  padding: 16px;
  background: #101010;
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 10px;
}

.risk-page #aging h3 {
  margin: 0 0 12px;
  color: var(--risk-gold);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
}

.risk-page #aging .record__meta {
  margin: 8px 0 0;
  padding: 9px 10px;
  color: #d0d0ca;
  background: #171717;
  border: 1px solid #292929;
  border-radius: 7px;
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* Pattern Detection */
.risk-page .factors {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.risk-page .factor {
  min-width: 0;
  padding: 15px;
  background: linear-gradient(135deg, #1b1710, #101010);
  border: 1px solid rgba(201, 162, 39, 0.4);
  border-left: 3px solid var(--risk-gold);
  border-radius: 10px;
}

.risk-page .factor__body {
  min-width: 0;
}

.risk-page .factor__label {
  margin: 0 0 8px;
  color: var(--risk-gold);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.risk-page .factor__detail {
  margin: 0;
  color: #d0d0ca;
  font-size: 0.85rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

/* Empty and upgrade messages */
.risk-page #insights-panel .empty,
.risk-page .risk-app .empty {
  padding: 14px;
  color: var(--risk-muted);
  background: #101010;
  border: 1px dashed #393939;
  border-radius: 9px;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Mobile layout */
@media (max-width: 520px) {
  .risk-page #aging {
    grid-template-columns: minmax(0, 1fr);
  }

  .risk-page #aging > div {
    padding: 13px;
  }

  .risk-page .factor {
    padding: 13px;
  }
}

