:root {
  --accent: #FF9814;
  --accent-2: #000805;
  --bg: #ffffff;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #000805;
  --muted: #475569;
}

* { box-sizing: border-box; }
.wrap { max-width: 1100px; margin: 32px auto; padding: 0 16px 64px; }
.hero { display:flex; align-items:center; justify-content:space-between; gap:14px; background:linear-gradient(180deg,#f8fafc 0%,#fff 100%); border:1px solid var(--border); border-radius:16px; padding:16px; }
h1 { font-size:1.6rem; margin:0 0 6px 0; color: var(--text); }
.sub { color:var(--muted); font-size:.95rem; }

.pill { padding:10px 14px; border-radius:12px; background:#f8fafc; border:1px solid var(--border); }
.highlight { background:#FFE3C2; border-color:#FF9814; }
.cdt { font-size:clamp(26px,5vw,40px); font-weight:800; color:#000805; letter-spacing:-.02em; }

.grid { display:grid; grid-template-columns:repeat(12,1fr); gap:16px; }
.card { background:var(--card-bg); border:1px solid var(--border); border-radius:14px; padding:16px; box-shadow:0 1px 2px rgba(0,0,0,.04); }
.section-title { font-weight:700; margin:0 0 8px 0; color: var(--text); }
label { display:block; font-size:.9rem; margin: 0 0 6px 0; color:#334155; }
input[type="number"], select { width:100%; padding:10px 12px; border-radius:10px; border:1px solid #cbd5e1; background:#fff; font-size:1rem; }
input[type="number"]:focus, select:focus { outline:2px solid var(--accent); border-color: var(--accent); }

table { width:100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size:.95rem; color: var(--text); }
th { background:#f8fafc; position:sticky; top:0; z-index:1; }
.total-row td { font-weight:700; }

.badge { display:inline-block; padding:6px 10px; border-radius:999px; background:#FFE3C2; color:#000805; font-weight:700; }
.muted { color:var(--muted); }
.small { font-size:.9rem; }
.right { text-align:right; }
.scroll { max-height: 360px; overflow:auto; }
.hr { height:1px; background:var(--border); margin: 8px 0 16px; }
footer { font-size:.85rem; color:var(--muted); margin-top: 8px; }


/* ===== Responsive enhancements ===== */

/* Fluid type for titles */
h1 { font-size: clamp(1.25rem, 1rem + 1.2vw, 1.8rem); line-height: 1.2; }

/* Make the hero stack on smaller screens */
@media (max-width: 1024px) {
  .hero { gap: 16px; }
}
@media (max-width: 768px) {
  .hero { flex-direction: column; align-items: stretch; text-align: left; }
  .hero .pill { width: 100%; order: 2; }
  .hero > div:first-child { order: 1; }
}

/* Grid: fall back to single column on small screens */
@media (max-width: 1024px) {
  .grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
}
@media (max-width: 768px) {
  .grid { grid-template-columns: 1fr; }
  .grid > * { grid-column: auto !important; }
}

/* Cards spacing on mobile */
@media (max-width: 768px) {
  .card { padding: 14px; }
  .section-title { margin: 8px 0 12px 0; }
}

/* Inputs & selects: comfortable tap targets on touch */
@media (max-width: 768px) {
  input[type="number"], select { padding: 12px 14px; font-size: 1.05rem; }
  label { font-size: .95rem; }
}

/* Tables: enable horizontal scroll when needed and compact cells */
.table-wrap { width: 100%; overflow-x: auto; }
.table-wrap table { min-width: 640px; } /* prevents squishing too much on phones */

@media (max-width: 480px) {
  th, td { padding: 8px; font-size: .9rem; }
}

/* Utility: stack pills nicely */
@media (max-width: 768px) {
  .pill { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
}

/* Improve contrast for muted text on mobile */
@media (max-width: 480px) {
  .muted { color: #64748b; }
}

/* Reduce overall margins on very small devices */
@media (max-width: 400px) {
  .wrap { padding: 0 12px 48px; }
}

/* Print: keep result prominent and hide interactive controls */
@media print {
  .hero { border: none; }
  input, select { border: 1px solid #e2e8f0; }
}


/* Force all sections full width on tablet and mobile */
@media (max-width: 1024px) {
  .grid > section { grid-column: 1 / -1 !important; }
}


/* ===== Force full-width stacking on tablets & mobiles ===== */
@media (max-width: 1024px) {
  /* Hero: stack and stretch to 100% width */
  .hero { flex-direction: column; align-items: stretch; gap: 16px; }
  .hero > * { width: 100% !important; }
  .hero .pill { width: 100% !important; }

  /* Grid: always one column and items spanning full width */
  .grid { grid-template-columns: 1fr !important; }
  .grid > * { grid-column: 1 / -1 !important; width: 100% !important; }

  /* Cards, pills, wrappers: full width */
  .card, .pill, .table-wrap, .scroll, .section-title { width: 100% !important; }

  /* Inputs stretch nicely */
  input[type="number"], select { width: 100% !important; }

  /* Tighten overall paddings for neat presentation */
  .wrap { max-width: 900px; }
}

/* Extra-small phones: even tighter */
@media (max-width: 480px) {
  .wrap { max-width: 100%; }
  .card { padding: 12px; }
  .pill { padding: 10px 12px; }
}


/* ===== Uniform vertical layout for desktop ===== */
.wrap { max-width: 900px; margin: 24px auto; }

/* Always stack blocks vertically */
.grid { grid-template-columns: 1fr !important; }
.grid > * { grid-column: 1 / -1 !important; width: 100% !important; }

.hero { flex-direction: column; align-items: stretch; gap: 16px; }
.hero > * { width: 100% !important; }

.card, .pill, .table-wrap, .scroll { width: 100% !important; }

/* Make all cards uniform in appearance */
.card { margin-bottom: 20px; }
.pill { margin-bottom: 12px; }

/* Headings consistent */
.section-title { font-size: 1.1rem; margin: 0 0 10px; }

/* Ensure inputs span full width */
input[type="number"], select { width: 100% !important; }


/* ===== Vertical layout & uniform blocks on DESKTOP ===== */
/* Force a single vertical column and full-width blocks even on large screens */
.hero { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
.hero > * { width: 100% !important; }

.grid { display: grid; grid-template-columns: 1fr !important; gap: 16px; }
.grid > * { grid-column: 1 / -1 !important; width: 100% !important; }

/* Make cards/pills consistent and uniform */
.card, .pill, .section-title, .table-wrap, .scroll { width: 100% !important; }
.card, .pill { border-radius: 16px; padding: 16px; }

/* Optional: equal visual rhythm */
.section-title { margin: 8px 0 12px 0; }

/* Keep result "pill" visually prominent but same width as others */
.highlight { box-shadow: 0 1px 0 rgba(0,0,0,.02); }


/* ===== Uniform width for all blocks on mobile & tablet ===== */
@media (max-width: 1024px) {
  .wrap { max-width: 100% !important; }
  .hero, .card, .pill, .table-wrap, .scroll { width: 100% !important; margin-left: auto; margin-right: auto; }
  .grid { grid-template-columns: 1fr !important; }
  .grid > * { grid-column: 1 / -1 !important; width: 100% !important; }
}


/* ===== Consistent narrower column on mobiles & tablets ===== */
:root {
  --mobile-content-max: 520px;  /* adjust if you want narrower/wider */
}

@media (max-width: 1024px) {
  /* Center a uniform column so all blocks share the same width as the title area */
  .wrap .hero > *, 
  .wrap .section-title,
  .wrap .card, 
  .wrap .pill, 
  .wrap .table-wrap, 
  .wrap .scroll {
    width: 100%;
    max-width: var(--mobile-content-max);
    margin-left: auto;
    margin-right: auto;
  }

  /* Keep inner inputs full width inside the constrained blocks */
  .wrap input[type="number"], 
  .wrap select, 
  .wrap table {
    width: 100%;
  }
}

/* Slightly tighter option for very small phones */
@media (max-width: 400px) {
  :root { --mobile-content-max: 92vw; } /* use viewport-based max for tiny screens */
}


/* ===== Better organization of "3) Resultados detallados" on mobile/tablet ===== */
@media (max-width: 1024px) {
  /* Force resultados pills to be stacked vertically with consistent spacing */
  .grid .pill {
    display: block;
    text-align: left;
    margin-bottom: 12px;
  }
  .grid .pill > div { margin: 4px 0; }
  .grid .pill strong { display: inline-block; min-width: 60px; }
}

@media (max-width: 480px) {
  .grid .pill {
    padding: 12px;
    font-size: 0.95rem;
  }
}


/* ===== Mobile/Tablet organization for '3) Resultados detallados' ===== */
@media (max-width: 1024px) {
  #resultsDetail .grid { display: block; }
  #resultsDetail .pill {
    display: block;
    width: 100% !important;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 12px;
  }
  #resultsDetail .pill:last-child { margin-bottom: 0; }

  /* Titles in each pill */
  #resultsDetail .pill .muted.small {
    display: block;
    margin: 0 0 6px 0;
    font-weight: 600;
    color: #334155;
  }

  /* Values a bit larger for readability */
  #resultsDetail .pill strong { font-size: 1.06rem; }

  /* If a line has multiple values, allow wrap neatly */
  #resultsDetail .pill div { word-wrap: break-word; }
}
