.bfroi-root {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(80, 94, 125, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff 0%, #f7f9fc 100%);
  box-shadow: 0 16px 40px rgba(21, 31, 52, 0.1);
  color: #172033;
}

.bfroi-controls {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  border-bottom: 1px solid rgba(80, 94, 125, 0.13);
}

.bfroi-section {
  padding: 1rem;
  border-right: 1px solid rgba(80, 94, 125, 0.11);
}

.bfroi-section:last-child {
  border-right: 0;
}

.bfroi-section h3 {
  margin: 0 0 0.8rem;
  font-size: 0.95rem;
  letter-spacing: 0;
}

.bfroi-field {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.7rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #42506a;
}

.bfroi-field input,
.bfroi-menu-button {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(80, 94, 125, 0.22);
  border-radius: 8px;
  background: #fff;
  color: #172033;
  padding: 0 0.75rem;
  font: inherit;
}

.bfroi-menu {
  position: relative;
}

.bfroi-menu-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 800;
}

.bfroi-menu-button::after {
  content: "";
  width: 0.58rem;
  height: 0.58rem;
  margin-left: 1rem;
  border-right: 2px solid currentcolor;
  border-bottom: 2px solid currentcolor;
  opacity: 0.62;
  transform: translateY(-2px) rotate(45deg);
}

.bfroi-menu-list {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  display: none;
  overflow: hidden;
  border: 1px solid rgba(80, 94, 125, 0.2);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(21, 31, 52, 0.18);
}

.bfroi-menu[data-open="true"] .bfroi-menu-list {
  display: grid;
}

.bfroi-menu-list button {
  min-height: 38px;
  border: 0;
  border-bottom: 1px solid rgba(80, 94, 125, 0.1);
  background: transparent;
  color: #172033;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-align: left;
  padding: 0 0.75rem;
}

.bfroi-menu-list button:last-child {
  border-bottom: 0;
}

.bfroi-menu-list button:hover,
.bfroi-menu-list button:focus-visible {
  background: #eef5f6;
  outline: 0;
}

.bfroi-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  min-height: 42px;
  padding: 0.25rem;
  border: 1px solid rgba(80, 94, 125, 0.22);
  border-radius: 8px;
  background: #edf2f7;
}

.bfroi-segment button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #42506a;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.bfroi-segment button[aria-pressed="true"] {
  background: #fff;
  color: #172033;
  box-shadow: 0 4px 10px rgba(21, 31, 52, 0.1);
}

.bfroi-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(80, 94, 125, 0.22);
  border-radius: 8px;
  background: #fff;
}

.bfroi-input input {
  border: 0;
}

.bfroi-input b {
  padding: 0 0.75rem;
  color: #65718a;
}

.bfroi-results {
  display: grid;
  gap: 0;
}

.bfroi-hero {
  padding: 1rem;
  background: linear-gradient(135deg, #10243a 0%, #195f72 54%, #23a36f 100%);
  color: #fff;
}

.bfroi-hero span {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  opacity: 0.85;
}

.bfroi-hero strong {
  display: block;
  margin-top: 0.2rem;
  font-size: clamp(2.2rem, 8vw, 4.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.bfroi-meter {
  height: 10px;
  margin-top: 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.bfroi-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #fff;
}

.bfroi-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border-bottom: 1px solid rgba(80, 94, 125, 0.13);
}

.bfroi-kpis div {
  padding: 1rem;
  border-right: 1px solid rgba(80, 94, 125, 0.12);
}

.bfroi-kpis div:last-child {
  border-right: 0;
}

.bfroi-kpis span {
  display: block;
  color: #65718a;
  font-size: 0.76rem;
  font-weight: 700;
}

.bfroi-kpis b {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.05rem;
  color: #172033;
}

#bfroi-viability[data-state="profitable"] {
  color: #0c8b5f;
}

#bfroi-viability[data-state="neutral"] {
  color: #8a6400;
}

#bfroi-viability[data-state="poor"] {
  color: #b72f3c;
}

.bfroi-table-card {
  overflow-x: auto;
  border-bottom: 1px solid rgba(80, 94, 125, 0.13);
}

.bfroi-table-card table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.bfroi-table-card th,
.bfroi-table-card td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(80, 94, 125, 0.13);
  text-align: left;
}

.bfroi-table-card th {
  color: #65718a;
  font-size: 0.78rem;
}

.bfroi-table-card td {
  font-weight: 750;
}

.bfroi-warning {
  padding: 1rem;
  background: #fff5f4;
}

.bfroi-warning[data-risk="low"] {
  background: #f0fff8;
}

.bfroi-warning b {
  display: block;
  color: #b72f3c;
}

.bfroi-warning[data-risk="low"] b {
  color: #0c8b5f;
}

.bfroi-warning p {
  margin: 0.35rem 0 0;
  color: #4e5a70;
}

.theme-dark .bfroi-root {
  border-color: rgba(174, 190, 216, 0.18);
  background: linear-gradient(180deg, #182033 0%, #101827 100%);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
  color: #e7edf8;
}

.theme-dark .bfroi-controls,
.theme-dark .bfroi-section,
.theme-dark .bfroi-kpis,
.theme-dark .bfroi-table-card,
.theme-dark .bfroi-kpis div,
.theme-dark .bfroi-table-card th,
.theme-dark .bfroi-table-card td {
  border-color: rgba(174, 190, 216, 0.14);
}

.theme-dark .bfroi-field,
.theme-dark .bfroi-kpis span,
.theme-dark .bfroi-table-card th,
.theme-dark .bfroi-input b {
  color: #aebad1;
}

.theme-dark .bfroi-field input,
.theme-dark .bfroi-menu-button,
.theme-dark .bfroi-input {
  border-color: rgba(174, 190, 216, 0.2);
  background: #0d1421;
  color: #e7edf8;
}

.theme-dark .bfroi-menu-list {
  border-color: rgba(174, 190, 216, 0.22);
  background: #111a2a;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.36);
}

.theme-dark .bfroi-menu-list button {
  border-color: rgba(174, 190, 216, 0.12);
  color: #e7edf8;
}

.theme-dark .bfroi-menu-list button:hover,
.theme-dark .bfroi-menu-list button:focus-visible {
  background: #1d2b43;
}

.theme-dark .bfroi-segment {
  border-color: rgba(174, 190, 216, 0.2);
  background: #0d1421;
}

.theme-dark .bfroi-segment button {
  color: #aebad1;
}

.theme-dark .bfroi-segment button[aria-pressed="true"] {
  background: #26354f;
  color: #fff;
  box-shadow: none;
}

.theme-dark .bfroi-kpis b,
.theme-dark .bfroi-table-card td {
  color: #e7edf8;
}

.theme-dark .bfroi-warning {
  border-color: rgba(255, 123, 125, 0.35);
  background: #2a161b;
}

.theme-dark .bfroi-warning[data-risk="low"] {
  border-color: rgba(64, 205, 140, 0.32);
  background: #10251d;
}

.theme-dark .bfroi-warning p {
  color: #d3dbea;
}

@media (max-width: 720px) {
  .bfroi-controls {
    grid-template-columns: 1fr;
  }

  .bfroi-section {
    border-right: 0;
    border-bottom: 1px solid rgba(80, 94, 125, 0.12);
  }

  .bfroi-section:last-child {
    border-bottom: 0;
  }

  .bfroi-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bfroi-kpis div {
    border-bottom: 1px solid rgba(80, 94, 125, 0.12);
  }
}
