/* Outer wrapper */
.dce-estimator-wrapper {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 14px;
  max-width: 450px; /* Reduced from 720px */
  margin: 0 auto;
  box-sizing: border-box;
  overflow: hidden;
}


/* Title */
.dce-title {
  margin-top: 0;
  font-size: 20px;
  line-height: 1.3;
}

/* Form grid */
.dce-estimate-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden; /* no children exceed */
}

/* Field cell must allow shrink */
.dce-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0; /* allow child to shrink */
}

/* Clamp inner control width via wrapper */
.dce-control-clamp {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}

/* Labels */
.dce-label-text {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  margin: 0;
}

/* Inputs and selects */
.dce-estimate-form select,
.dce-estimate-form input[type="number"],
.dce-estimate-form input[type="text"] {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  background: #fff;
  box-sizing: border-box;
  margin: 0;
  min-width: 0; /* prevent intrinsic overflow */
}

/* Treatment select specific */
.dce-estimate-form select.dce-treatment {
  width: 100% !important;
  max-width: 100% !important;
}

/* Checkbox */
.dce-estimate-form input[type="checkbox"] { transform: translateY(1px); }

/* Buttons */
.dce-btn-primary {
  appearance: none; border: 0; background: #2563eb; color: #fff;
  padding: 10px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; margin-top: 8px;
}
.dce-btn-primary:hover { background: #1d4ed8; }
.dce-btn-primary:focus { outline: 2px solid #1d4ed8; outline-offset: 2px; }

/* Result */
.dce-result { margin-top: 12px; font-weight: 700; font-size: 16px; }

/* Mobile one-column */
@media (max-width: 640px) {
  .dce-estimate-form { grid-template-columns: 1fr; }

  .dce-estimate-form select,
  .dce-estimate-form select.dce-treatment {
    width: 100% !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    text-overflow: ellipsis !important;
  }

  .dce-estimate-form select option { white-space: normal; }
}

/* Hard containment */
.dce-estimator-wrapper *,
.dce-estimator-wrapper *::before,
.dce-estimator-wrapper *::after {
  box-sizing: border-box;
}

/* Custom arrow to avoid native overflow quirks */
.dce-estimator-wrapper select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #6b7280 50%),
    linear-gradient(135deg, #6b7280 50%, transparent 50%),
    linear-gradient(to right, #d1d5db, #d1d5db);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px),
    calc(100% - 2.3em) 50%;
  background-size:
    6px 6px,
    6px 6px,
    1px 1.8em;
  background-repeat: no-repeat;
  padding-right: 2.7em; /* space for arrow without overflow */
}

/* If any theme adds margins to selects, neutralize them in estimator */
.dce-estimator-wrapper select { margin-right: 0 !important; margin-left: 0 !important; }

/* If a specific container causes overflow, clamp it */
.dce-estimator-wrapper .dce-estimate-form,
.dce-estimator-wrapper .dce-form-field,
.dce-estimator-wrapper .dce-form-field .dce-control-clamp {
  max-width: 100%;
  overflow: hidden;
}

/* Ensure checkbox sits inline with its label on mobile and desktop */
.dce-form-field[data-type="checkbox"] {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.dce-form-field[data-type="checkbox"] .dce-label-text {
  margin: 0;
}

.dce-estimate-form input[type="checkbox"] {
  margin: 0;
}

