:root {
  --mf-primary: #2b5cff;
  --mf-accent: #06b6d4;
  --mf-bg: #ffffff;
  --mf-fg: #111827;
  --mf-muted: #6b7280;
  --mf-border: #e5e7eb;
}

.mf-roi * {
  box-sizing: border-box;
}

.mf-roi {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--mf-fg);
  background: var(--mf-bg);
  border: 1px solid var(--mf-border);
  border-radius: 12px;
  padding: 16px;
}

.mf-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  /* Ensure grid items can shrink below content size */
  min-width: 0;
}

.mf-row > * {
  min-width: 0; /* Allow grid children to shrink */
}

.mf-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0; /* Allow column to shrink below content size */
  max-width: 100%; /* Prevent overflow */
}

.mf-card {
  border: 1px solid var(--mf-border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}

.mf-card:last-child {
  margin-bottom: 0;
}

.mf-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

.mf-field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.mf-field-row:last-child {
  margin-bottom: 0;
}

.mf-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  align-items: stretch;
}

.mf-field-full {
  flex: 1 1 100%;
  min-width: 100%;
}

.mf-field-half {
  flex: 1 1 calc(50% - 6px);
  min-width: calc(50% - 6px);
}

.mf-field-half-desktop {
  flex: 1 1 calc(50% - 6px);
  min-width: calc(50% - 6px);
}

.mf-field-full-mobile {
  flex: 1 1 100%;
  min-width: 100%;
}

.mf-field label {
  font-size: 12px;
  color: var(--mf-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  min-height: 1.4em;
}

.mf-field input, .mf-field select {
  padding: 10px;
  border: 1px solid var(--mf-border);
  border-radius: 8px;
  width: 100%;
  margin-bottom: 0;
}

.mf-field {
  padding-bottom: 0;
}

.mf-total {
  font-weight: 700;
  font-size: 18px;
}

.mf-total-small {
  font-size: 15px;
}

.mf-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  margin-top: 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid var(--mf-primary);
  background: var(--mf-primary);
  color: #fff;
  cursor: pointer;
  width: 100%;
  justify-content: center;
}

.mf-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.mf-small {
  font-size: 12px;
  color: var(--mf-muted);
}

.mf-field select:disabled + .mf-small,
.mf-field input:disabled + .mf-small,
.mf-field select:disabled ~ .mf-small,
.mf-field input:disabled ~ .mf-small {
  color: #9ca3af;
}

.mf-right {
  text-align: right;
}

.mf-flex {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mf-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  white-space: nowrap;
}

.mf-line-items-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.mf-line-items-table thead {
  background: #f9fafb;
  border-bottom: 2px solid var(--mf-border);
}

.mf-line-items-table th {
  padding: 8px 6px;
  text-align: left;
  font-weight: 600;
  color: var(--mf-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mf-line-items-table th:nth-child(2) {
  min-width: 90px;
  width: 90px;
}

.mf-line-items-table th.mf-right {
  text-align: right;
}

.mf-line-items-table td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--mf-border);
  color: var(--mf-fg);
  font-size: 12px;
}

.mf-line-items-table td:nth-child(2) {
  min-width: 90px;
  width: 90px;
  font-size: 11px;
  white-space: nowrap;
}

.mf-line-items-table td.mf-right {
  text-align: right;
  font-weight: 500;
}

.mf-line-items-table tbody tr:hover {
  background: #f9fafb;
}

.mf-line-items-table tbody tr:last-child td {
  border-bottom: none;
}

.mf-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

.mf-summary-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mf-summary-title {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--mf-fg);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--mf-border);
}

.mf-summary-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--mf-border);
  border-radius: 8px;
  overflow: hidden;
}

.mf-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--mf-border);
  gap: 12px;
}

.mf-summary-row:last-of-type {
  border-bottom: none;
}

.mf-roi-row {
  align-items: flex-start;
}

.mf-roi-row .mf-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.mf-roi-return {
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
}

.mf-summary-note {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--mf-muted);
  border-top: 1px solid var(--mf-border);
  background: #f9fafb;
}

.mf-summary-note:first-of-type {
  border-top: none;
}

.mf-roi-note {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--mf-muted);
  font-style: italic;
}

.mf-deliverables {
  margin-top: 10px;
  display: none;
}

.mf-deliverables.active {
  display: block;
}

.mf-deliverables-container {
  border: 1px solid var(--mf-border);
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
}

.mf-deliverables-content {
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--mf-fg);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.mf-deliverables-content p {
  margin: 0 0 8px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.mf-deliverables-content p span:not(.mf-bullet) {
  flex: 1;
  min-width: 0; /* Allows text to wrap properly */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.mf-deliverables-content p:last-child {
  margin-bottom: 0;
}

.mf-deliverables-content p strong {
  color: var(--mf-primary);
  font-weight: 600;
  flex: 1;
}

.mf-deliverables-content .mf-bullet {
  color: var(--mf-primary);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.mf-deliverables-content p:has(strong) {
  display: block;
}

.mf-deliverables-content p:has(strong) .mf-bullet {
  display: none;
}

.mf-grid-roi {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.mf-badge-revenue {
  background: #d1fae5;
  color: #065f46;
}

.mf-badge-cost {
  background: #fee2e2;
  color: #991b1b;
}

.mf-badge-net {
  background: #dbeafe;
  color: #1e40af;
}

.mf-badge-roi {
  background: #fef3c7;
  color: #92400e;
}

#mf-roi-detail {
  margin-top: 4px;
  font-weight: 500;
}

.mf-cpt-addons-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
  min-width: 0; /* Allow container to shrink */
  max-width: 100%; /* Prevent overflow */
  width: 100%; /* Constrain to parent width */
}

.mf-cpt-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px 12px;
  border: 1px solid var(--mf-border);
  border-radius: 6px;
  transition: background 0.2s, border-color 0.2s;
  background: #fff;
  min-width: 0; /* Allow checkbox to shrink */
  max-width: 100%; /* Prevent overflow */
  width: 100%; /* Constrain to parent width */
}

.mf-cpt-checkbox:hover {
  background: #f9fafb;
  border-color: var(--mf-primary);
}

.mf-cpt-checkbox input[type=checkbox] {
  margin: 0;
  cursor: pointer;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.mf-cpt-checkbox span {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0; /* Allows text to wrap properly in flex container */
}

@media (max-width: 900px) {
  .mf-row {
    grid-template-columns: 1fr;
  }
  .mf-summary-grid {
    grid-template-columns: 1fr;
  }
  .mf-field-half {
    flex: 1 1 100%;
    min-width: 100%;
  }
  .mf-field-half-desktop {
    flex: 1 1 100%;
    min-width: 100%;
  }
  .mf-grid-roi {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  .mf-field label {
    white-space: normal;
    word-wrap: break-word;
    overflow: visible;
    text-overflow: clip;
  }
}
