/* Financial Benchmarks Phase 4B: account-balance analysis */

.bm4-analysis {
  display: grid;
  max-width: 1100px;
  margin: 0 auto 32px;
  padding: 0 20px;
  gap: 18px;
}

.bm4-view-stack {
  display: grid;
  min-width: 0;
  gap: 18px;
}

.bm4-view-stack[hidden] {
  display: none !important;
}

.bm4-view {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 16px 38px rgba(7, 14, 30, 0.14);
}

.bm4-view[data-bm4-view="national-peers"] {
  padding: clamp(22px, 4vw, 34px);
  border-color: rgba(119, 215, 204, 0.24);
  background:
    radial-gradient(
      circle at 8% 4%,
      rgba(42, 157, 143, 0.18),
      transparent 34%
    ),
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.055),
      rgba(13, 24, 47, 0.7)
    );
}

.bm4-view-header {
  max-width: 820px;
  margin-bottom: 20px;
}

.bm4-view-header > p:first-child {
  margin: 0 0 8px;
  color: #8ce8dd;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.bm4-view-header h2,
.bm4-view > h2 {
  margin: 0;
  color: #f3f7fb;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  line-height: 1.2;
}

.bm4-view-header > p:last-child,
.bm4-view > p {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.88rem;
  line-height: 1.62;
}

.bm4-cohort-status {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(119, 215, 204, 0.28);
  border-left: 4px solid #2a9d8f;
  border-radius: 9px;
  background: rgba(42, 157, 143, 0.09);
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.84rem;
  line-height: 1.55;
}

.bm4-cohort-status[data-state="unavailable"],
.bm4-cohort-status[data-state="rejected"] {
  border-color: rgba(230, 149, 58, 0.4);
  border-left-color: #e6953a;
  background: rgba(230, 149, 58, 0.09);
}

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

.bm4-module-grid[hidden] {
  display: none !important;
}

.bm4-module {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(7, 15, 31, 0.48);
}

.bm4-module[data-state="matched"],
.bm4-module[data-state="partially_matched"] {
  border-color: rgba(119, 215, 204, 0.44);
}

.bm4-module[data-state="unsupported"],
.bm4-module[data-state="invalid_input"] {
  border-color: rgba(230, 149, 58, 0.4);
}

.bm4-module-header {
  padding: 22px 22px 0;
}

.bm4-module-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.bm4-module-kicker > span:first-child {
  color: #8ce8dd;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bm4-quality-badge {
  padding: 4px 8px;
  border: 1px solid rgba(119, 215, 204, 0.32);
  border-radius: 999px;
  color: #baf3ec;
  font-size: 0.66rem;
  white-space: nowrap;
}

.bm4-module h3 {
  margin: 0;
  color: #f3f7fb;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.bm4-module-header > p {
  margin: 7px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  line-height: 1.55;
}

.bm4-key-result {
  margin: 18px 22px 0;
  padding: 18px;
  border: 1px solid rgba(42, 157, 143, 0.28);
  border-radius: 13px;
  background: linear-gradient(
    135deg,
    rgba(42, 157, 143, 0.15),
    rgba(42, 157, 143, 0.04)
  );
}

.bm4-key-result > span {
  display: block;
  color: rgba(255, 255, 255, 0.73);
  font-size: 0.75rem;
  line-height: 1.52;
}

.bm4-key-result > span:first-child {
  color: rgba(255, 255, 255, 0.84);
  font-weight: 700;
}

.bm4-key-result > strong {
  display: block;
  margin: 5px 0 4px;
  color: #f4fbfa;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.bm4-scope {
  margin: 12px 22px 0;
  padding-left: 11px;
  border-left: 3px solid rgba(140, 232, 221, 0.55);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  line-height: 1.55;
}

.bm4-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 22px 0;
}

.bm4-meta div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.bm4-meta dt {
  margin-bottom: 3px;
  color: #8ce8dd;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bm4-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.72rem;
  line-height: 1.42;
}

.bm4-table-region {
  max-width: 100%;
  overflow-x: auto;
  margin-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  scrollbar-color: rgba(119, 215, 204, 0.55) rgba(255, 255, 255, 0.05);
}

.bm4-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.bm4-table caption {
  padding: 15px 22px 11px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.7rem;
  line-height: 1.5;
  text-align: left;
}

.bm4-table th,
.bm4-table td {
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  text-align: right;
}

.bm4-table th:first-child,
.bm4-table td:first-child {
  padding-left: 22px;
  text-align: left;
}

.bm4-table th:last-child,
.bm4-table td:last-child {
  padding-right: 22px;
}

.bm4-table thead th {
  color: #baf3ec;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.bm4-table tbody tr[aria-current="true"] {
  background: rgba(42, 157, 143, 0.16);
  box-shadow: inset 4px 0 #2a9d8f;
}

.bm4-table tbody tr[aria-current="true"] th {
  color: #d9faf6;
}

.bm4-method {
  margin: 16px 22px 0;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}

.bm4-method summary {
  color: #baf3ec;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 800;
}

.bm4-method p {
  margin: 9px 0 0;
  color: rgba(255, 255, 255, 0.67);
  font-size: 0.72rem;
  line-height: 1.55;
}

.bm4-module-footer {
  padding: 16px 22px 20px;
}

.bm4-module-footer p {
  margin: 0;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.71rem;
  line-height: 1.5;
}

.bm4-module-footer a,
.bm4-tool-group a {
  color: #8ce8dd;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.bm4-view[data-bm4-view="planning-targets"],
.bm4-view[data-bm4-view="community"] {
  padding: clamp(20px, 3vw, 28px);
}

.bm4-view[data-bm4-view="planning-targets"] {
  border-color: rgba(230, 149, 58, 0.24);
  background: rgba(230, 149, 58, 0.045);
}

.bm4-view[data-bm4-view="community"] {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.16);
}

.bm4-view[data-bm4-view="planning-targets"] h2,
.bm4-view[data-bm4-view="community"] h2 {
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
}

.bm4-tool-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.bm4-tool-group {
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.bm4-tool-group h3 {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.83rem;
}

.bm4-tool-group ul {
  display: grid;
  margin: 11px 0 0;
  padding: 0;
  gap: 7px;
  list-style: none;
}

.bm4-tool-group li {
  font-size: 0.76rem;
}

.bm4-cohort-status:focus-visible,
.bm4-table-region:focus-visible,
.bm4-method summary:focus-visible,
.bm4-module-footer a:focus-visible,
.bm4-tool-group a:focus-visible {
  outline: 3px solid #8ce8dd;
  outline-offset: 3px;
}

@media (max-width: 820px) {
  .bm4-module-grid,
  .bm4-tool-groups {
    grid-template-columns: 1fr;
  }

  .bm4-analysis {
    padding: 0 14px;
  }

  .bm4-view[data-bm4-view="national-peers"] {
    padding: 20px 14px;
  }

  .bm4-module-kicker {
    align-items: flex-start;
    flex-direction: column;
  }

  .bm4-meta {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .bm4-module-header,
  .bm4-module-footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .bm4-key-result,
  .bm4-meta,
  .bm4-method {
    margin-right: 16px;
    margin-left: 16px;
  }

  .bm4-scope {
    margin-right: 16px;
    margin-left: 16px;
  }

  .bm4-table {
    min-width: 470px;
  }

  .bm4-table caption,
  .bm4-table th:first-child,
  .bm4-table td:first-child {
    padding-left: 16px;
  }

  .bm4-table th:last-child,
  .bm4-table td:last-child {
    padding-right: 16px;
  }
}

@media (forced-colors: active) {
  .bm4-view,
  .bm4-module,
  .bm4-key-result,
  .bm4-meta div,
  .bm4-method,
  .bm4-tool-group,
  .bm4-cohort-status {
    border: 1px solid CanvasText;
    background: Canvas;
    box-shadow: none;
    color: CanvasText;
  }

  .bm4-table tbody tr[aria-current="true"] {
    outline: 3px solid Highlight;
    background: Canvas;
    box-shadow: none;
  }
}

@media print {
  .bm4-analysis {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
    color: #000;
  }

  .bm4-view,
  .bm4-module,
  .bm4-key-result,
  .bm4-meta div,
  .bm4-method,
  .bm4-tool-group {
    break-inside: avoid;
    border-color: #777;
    background: #fff;
    box-shadow: none;
  }

  .bm4-view {
    margin-bottom: 14px;
  }

  .bm4-module-grid,
  .bm4-tool-groups {
    grid-template-columns: 1fr;
  }

  .bm4-view-header h2,
  .bm4-view > h2,
  .bm4-module h3,
  .bm4-key-result > strong,
  .bm4-meta dd,
  .bm4-table,
  .bm4-method p,
  .bm4-module-footer p,
  .bm4-view p {
    color: #000;
  }

  .bm4-view-header > p:first-child,
  .bm4-module-kicker > span:first-child,
  .bm4-quality-badge,
  .bm4-meta dt,
  .bm4-table thead th,
  .bm4-method summary,
  .bm4-module-footer a,
  .bm4-tool-group a {
    color: #075f56;
  }

  .bm4-table-region {
    overflow: visible;
  }

  .bm4-table {
    min-width: 0;
  }

  .bm4-method:not([open]) > :not(summary) {
    display: block;
  }

  .bm4-cohort-status {
    display: none;
  }
}
