:root {
  --bg: #FEE2D7;
  --panel: #FFF8F5;
  --card: #FFFFFF;
  --text: #1F1F1F;
  --muted: #756B68;
  --accent: #F83C4D;
  --accent-dark: #D92F40;
  --border: rgba(248, 60, 77, 0.22);
  --line: rgba(248, 60, 77, 0.12);
  --shadow: 0 18px 50px rgba(81, 34, 34, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(247, 60, 78, 0.12), transparent 30rem),
    linear-gradient(90deg, #fff1eb 0%, var(--bg) 100%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
  display: grid;
  grid-template-columns: minmax(390px, 0.9fr) minmax(520px, 1.1fr);
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.hero-card {
  min-height: 630px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 42px;
  box-shadow: none;
  overflow: hidden;
}

.brand-logo {
  display: block;
  width: min(62%, 260px);
  height: auto;
  margin: 0 auto;
}

h2 {
  margin: 8px 0 12px;
  line-height: 1.05;
}

h2 {
  font-size: 1.55rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(285px, 0.98fr) minmax(300px, 1.02fr);
  gap: 18px;
  align-content: start;
}

.form {
  grid-column: 1 / -1;
  background: rgba(255, 250, 247, 0.76);
  border: 1px solid rgba(243, 181, 170, 0.76);
  border-radius: 8px;
  padding: 30px 34px;
  display: grid;
  grid-template-columns: minmax(250px, 320px) auto auto;
  gap: 18px;
  align-items: end;
  justify-content: start;
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 10px;
  min-width: 0;
}

label {
  font-weight: 700;
  margin-top: 0;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 18px;
  font-size: 1.08rem;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(247, 60, 78, 0.14);
}

.money-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  min-height: 62px;
}

.money-input span {
  padding-left: 18px;
  padding-right: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 1.08rem;
  background: transparent;
}

.money-input input {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding-left: 8px;
  appearance: textfield;
}

.money-input input::-webkit-outer-spin-button,
.money-input input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

button {
  margin-top: 0;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  padding: 18px 20px;
  font-size: 1rem;
  cursor: pointer;
  min-height: 62px;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  margin-top: 0;
  background: #ffe2d7;
  color: var(--accent-dark);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: #ffd2c4;
}

.result {
  grid-column: 1 / -1;
  margin-top: 0;
  padding: 34px 40px 38px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  border: 0;
  min-height: 188px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.is-hidden {
  display: none;
}

.label {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}

.final-price {
  margin: 18px 0 0;
  font-size: clamp(3.4rem, 6vw, 5.2rem);
  font-weight: 900;
  color: #fff;
  line-height: 1;
  width: 100%;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  text-align: left;
}

.details {
  grid-column: 1 / -1;
  align-self: start;
  min-height: auto;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.details h2 {
  grid-column: 1 / -1;
  margin-bottom: 8px;
}

.details .row {
  min-height: 108px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 28px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.details .row span {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.25;
}

.details .row strong {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 1.08rem;
}

.details .row.highlight {
  color: var(--accent-dark);
}

.details .row.highlight span,
.details .row.highlight strong {
  color: var(--accent-dark);
  font-weight: 900;
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
    padding: 24px 0;
  }

  .hero-card {
    min-height: 220px;
    padding: 26px 18px;
  }

.brand-logo {
  width: min(48%, 180px);
}

  .workspace {
    grid-template-columns: 1fr;
  }

  .form {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .result {
    min-height: 180px;
  }

  .label {
    white-space: normal;
  }

  .final-price {
    font-size: clamp(2.8rem, 12vw, 4.6rem);
    white-space: normal;
  }

  .details {
    grid-template-columns: 1fr;
  }

  .money-input {
    grid-column: auto;
  }

  .card {
    padding: 22px;
    border-radius: 8px;
  }

  .row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .row strong {
    text-align: left;
  }
}


/* UX OLVERA V2 */

/* Botones de cálculo más compactos */
.form > button {
  min-height: 48px;
  padding: 12px 16px;
  font-size: 0.92rem;
  justify-self: start;
}

/* Precio + copiar */
.price-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.price-row .final-price {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.copy-price {
  width: 46px;
  height: 46px;
  min-height: 46px;
  flex: 0 0 46px;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.copy-price:hover {
  background: rgba(255, 255, 255, 0.24);
}

.copy-price:disabled {
  opacity: 0.38;
  cursor: default;
}

.copy-price svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.copy-feedback {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.86rem;
  font-weight: 700;
}

/* Desglose colapsable */
.details {
  display: block;
  padding: 0;
  overflow: hidden;
}

.details summary {
  list-style: none;
  cursor: pointer;
  padding: 22px 28px;
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.details summary::-webkit-details-marker {
  display: none;
}

.details summary::after {
  content: "⌄";
  font-size: 1.4rem;
  line-height: 1;
  transition: transform 160ms ease;
}

.details[open] summary::after {
  transform: rotate(180deg);
}

.details-content {
  padding: 0 28px 28px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 960px) {
  .form > button {
    min-height: 46px;
    padding: 11px 15px;
    font-size: 0.9rem;
  }

  .result {
    min-height: auto;
    padding: 26px 22px 22px;
  }

  .price-row {
    gap: 10px;
  }

  .copy-price {
    width: 44px;
    height: 44px;
    min-height: 44px;
    flex-basis: 44px;
  }

  .details summary {
    padding: 18px 20px;
  }

  .details-content {
    padding: 0 20px 20px;
    grid-template-columns: 1fr;
  }
}


/* Precio final: número protagonista, moneda discreta */
.price-row {
  margin-top: 0;
}

.final-currency {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.46em;
  font-weight: 800;
  letter-spacing: 0;
  opacity: 0.82;
  vertical-align: baseline;
}


/* MXN pequeño blanco */
.final-currency {
  color: #FFFFFF;
}


/* UX OLVERA V3 */

/* Resultado principal 30% */
.result {
  position: relative;
}

.main-margin-label {
  color: #FFFFFF;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.price-row {
  margin-top: 0;
}

.final-currency {
  color: #FFFFFF;
  font-size: 0.46em;
  font-weight: 800;
  margin-left: 8px;
  opacity: 0.86;
}

/* El formulario ahora solo contiene el input */
.form {
  grid-template-columns: minmax(0, 1fr);
}

.form .field {
  width: 100%;
}

/* Márgenes alternativos */
.margin-options {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.mini-margin-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(81, 34, 34, 0.06);
}

.mini-margin-percent {
  display: block;
  color: var(--accent);
  font-weight: 900;
  font-size: 0.78rem;
  margin-bottom: 5px;
}

.mini-price {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

.mini-price span {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
  color: var(--text);
}

.mini-price small {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
}

.mini-copy {
  width: 40px;
  height: 40px;
  min-height: 40px;
  flex: 0 0 40px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
}

.mini-copy:hover {
  background: var(--bg);
}

.mini-copy:disabled {
  opacity: 0.35;
  cursor: default;
}

.mini-copy svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

/* Dropdowns */
.utility-details {
  grid-column: 1 / -1;
  display: block;
  padding: 0;
  overflow: hidden;
}

.utility-details summary {
  list-style: none;
  cursor: pointer;
  padding: 19px 22px;
  font-size: 1rem;
  font-weight: 850;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.utility-details summary::-webkit-details-marker {
  display: none;
}

.utility-details summary::after {
  content: "⌄";
  font-size: 1.35rem;
  line-height: 1;
  transition: transform 160ms ease;
}

.utility-details[open] summary::after {
  transform: rotate(180deg);
}

/* Historial */
.history-content {
  padding: 0 18px 18px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 13px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: left;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.9);
}

.history-item strong {
  color: var(--accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-empty {
  color: var(--muted);
  margin: 4px 4px 12px;
  font-size: 0.9rem;
}

.clear-history {
  min-height: 0;
  margin-top: 12px;
  padding: 9px 11px;
  background: transparent;
  color: var(--muted);
  border: 0;
  font-size: 0.82rem;
  font-weight: 750;
}

.clear-history:hover {
  background: transparent;
  color: var(--accent);
}

/* Tabla de desglose */
.breakdown-content {
  padding: 0 14px 18px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.breakdown-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.breakdown-table th,
.breakdown-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.breakdown-table th:first-child,
.breakdown-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 1;
}

.breakdown-table th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.breakdown-table td {
  font-weight: 650;
}

.breakdown-table .suggested-row td {
  color: var(--accent);
  font-weight: 900;
}

/* Toast de copiado */
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  z-index: 999;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(31, 31, 31, 0.92);
  color: #FFFFFF;
  font-size: 0.86rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  white-space: nowrap;
}

.copy-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 960px) {
  .margin-options {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .mini-margin-card {
    padding: 13px 14px;
  }

  .mini-price span {
    font-size: 1.35rem;
  }

  .utility-details summary {
    padding: 17px 18px;
  }

  .history-content {
    padding: 0 14px 14px;
  }

  .result {
    padding-top: 22px;
  }
}
