/* =========================
   RESET GENERAL
   ========================= */
* {
  box-sizing: border-box;
}

/* =========================
   VARIABLES DE COLOR Y DISEÑO
   ========================= */
:root {
  --dark: #102638;
  --text: #17364d;
  --muted: #587188;
  --blue: #12a7d4;
  --blue2: #0a7ba8;
  --soft: #f4f9fc;
  --line: #d7e9f1;
  --card: #fff;
  --green: #22a06b;
  --red: #d94b4b;
  --yellow: #f2b744;
  --shadow: 0 18px 44px rgba(16,38,56,.13);
  --radius: 24px;
}

/* =========================
   BASE DEL DOCUMENTO
   ========================= */
body {
  margin: 0;
  font-family: "Segoe UI",Arial,sans-serif;
  background: linear-gradient(180deg,#f3fbff,#e7f3f8);
  color: var(--text);
  font-weight: 400;
}

/* =========================
   TIPOGRAFÍA GENERAL
   ========================= */
h1,h2,h3,h4,p {
  margin-top: 0;
}

h1,h2,h3 {
  color: #082236;
}

h1 {
  font-weight: 650;
}

h2 {
  font-weight: 700;
}

h3 {
  font-weight: 650;
}

h4 {
  font-weight: 600;
}

/* =========================
   ENCABEZADO PRINCIPAL
   ========================= */
.hero {
  background: linear-gradient(135deg,#123149,#13a5cf);
  color: #fff;
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
  padding: 18px 20px 22px;
}

/* =========================
   NAVEGACIÓN Y CONTENEDORES BASE
   ========================= */
.nav,.hero-content,.main-shell,.footer {
  width: min(1180px,calc(100% - 40px));
  margin-inline: auto;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.logo-img {
  width: 62px;
  height: 46px;
  object-fit: contain;
  display: block;
}

/* =========================
   IDENTIDAD VISUAL Y LOGO
   ========================= */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 62px;
  height: 46px;
  border-radius: 15px;
  background: linear-gradient(135deg,#ffd257,#ff9b1b);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
}

.brand h1 {
  font-size: 30px;
  margin: 0;
  color: #fff;
}

.brand p {
  margin: 2px 0 0;
  color: rgba(255,255,255,.86);
  font-size: 14px;
}

/* =========================
   BOTONES DE NAVEGACIÓN
   ========================= */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tab {
  border: 1px solid rgba(255,255,255,.23);
  background: rgba(255,255,255,.14);
  color: #fff;
  border-radius: 14px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: #082236;
}

/* =========================
   CONTENIDO DEL ENCABEZADO
   ========================= */
.hero-content {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 16px;
  margin-top: 18px;
}

.hero-text,.formula-card {
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.21);
  border-radius: 24px;
  padding: 20px;
}

.chip {
  display: inline-block;
  border-radius: 999px;
  background: rgba(255,185,71,.24);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
}

.hero h2 {
  font-size: clamp(27px,4vw,42px);
  line-height: 1.12;
  color: #fff;
  margin: 14px 0 10px;
}

.hero p {
  line-height: 1.45;
  color: #fff;
  margin: 0;
}

.formula-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.formula-card span,.formula-card small {
  opacity: .9;
}

.formula-card strong {
  font-size: 42px;
  color: #fff;
  margin: 8px 0;
}

/* =========================
   ESTRUCTURA GENERAL DE SECCIONES
   ========================= */
.main-shell {
  padding: 22px 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout {
  width: 100%;
}

.single-layout {
  max-width: 100%;
  margin: 0;
}

.simulator-layout {
  display: grid;
  grid-template-columns: 300px minmax(460px,1fr) 300px;
  gap: 18px;
}

/* =========================
   TARJETAS Y PANELES PRINCIPALES
   ========================= */
.panel {
  background: var(--card);
  border: 1px solid rgba(16,38,56,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* =========================
   FORMULARIOS Y CAMPOS
   ========================= */
.field {
  display: grid;
  gap: 9px;
  margin-bottom: 18px;
  font-weight: 500;
  color: #09253a;
}

select,input {
  font: inherit;
}

select,input[type=number] {
  width: 100%;
  border: 1px solid #cde2ec;
  border-radius: 15px;
  background: #fff;
  color: #082236;
  padding: 12px 14px;
  outline: none;
  font-weight: 500;
}

/* =========================
   CONTROLES DESLIZANTES
   ========================= */
.slider-block {
  margin: 20px 0;
}

.slider-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.slider-title span:first-child {
  font-weight: 500;
  color: #09253a;
}

.value-input {
  width: 128px;
  display: flex;
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.value-input input {
  border: 0;
  background: transparent;
  text-align: right;
  color: #027aa8;
  font-weight: 500;
  padding: 10px 4px;
}

.value-input span {
  padding-right: 11px;
  color: #027aa8;
  font-weight: 500;
}

/* =========================
   ESTILO DE RANGOS
   ========================= */
input[type=range] {
  width: 100%;
  accent-color: var(--blue);
}

/* =========================
   BOTONES DEL SISTEMA
   ========================= */
.btn {
  border: 0;
  border-radius: 15px;
  padding: 13px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.primary {
  background: linear-gradient(135deg,var(--blue),var(--blue2));
  color: #fff;
}

.soft {
  background: #edf5f8;
  color: #082236;
  border: 1px solid var(--line);
}

.danger {
  background: #fff1f1;
  color: #9b2727;
  border: 1px solid #ffd0d0;
}

.danger-active {
  background: linear-gradient(135deg,#f05252,#c93131)!important;
  color: #fff!important;
}

.button-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.full {
  width: 100%;
  margin-top: 12px;
}

/* =========================
   CABECERAS INTERNAS DE PANELES
   ========================= */
.panel-head,.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.panel-head p,.section-head p {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0;
}

/* =========================
   INDICADORES Y ESCALA DE DENSIDAD
   ========================= */
.badge {
  border-radius: 999px;
  background: var(--yellow);
  padding: 11px 16px;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.scale-line {
  display: grid;
  grid-template-columns: 60px 1fr 80px;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
  color: #506a7d;
  font-size: 13px;
  font-weight: 600;
}

.scale-bar {
  height: 12px;
  border-radius: 99px;
  background: linear-gradient(90deg,var(--green),var(--yellow),var(--red));
  position: relative;
}

.scale-bar i {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 18px;
  height: 30px;
  border-radius: 10px;
  background: #fff;
  border: 4px solid var(--dark);
}

/* =========================
   TANQUE INTERACTIVO
   ========================= */
.tank {
  height: 380px;
  position: relative;
  border: 9px solid #7a5d48;
  border-top: 0;
  border-radius: 0 0 23px 23px;
  overflow: hidden;
  background: linear-gradient(180deg,#cdf5ff 0 32%,#3099cf 32% 100%);
  box-shadow: inset 0 -35px 60px rgba(0,54,100,.30);
}

.liquid-layer {
  position: absolute;
  inset: 32% 0 0;
  background: rgba(18,126,192,.56);
  border-top: 4px solid rgba(255,255,255,.55);
}

.liquid-label {
  position: absolute;
  z-index: 5;
  left: 18px;
  top: 16px;
  background: rgba(255,255,255,.9);
  border-radius: 999px;
  padding: 8px 14px;
  color: #09253a;
  font-weight: 600;
}

.object-block {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 135px;
  transform: translateX(-50%);
  width: 108px;
  height: 108px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg,#b87943,#6a3b1f);
  box-shadow: 14px 14px 0 rgba(0,0,0,.18),inset -12px -12px 22px rgba(0,0,0,.12);
  transition: .55s ease;
}

.object-block span {
  background: rgba(0,0,0,.25);
  border-radius: 10px;
  padding: 6px 9px;
  font-weight: 600;
}

.tank-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28px;
  background: rgba(48,37,30,.34);
}

/* =========================
   MÉTRICAS Y EXPLICACIÓN
   ========================= */
.metrics {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 12px;
  margin-top: 16px;
}

.metrics div,.info-box,.object-card,.visual-compare,.question-card,.score-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px;
}

.metrics span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.metrics strong {
  font-size: 17px;
  color: #082236;
}

.explain-panel p {
  line-height: 1.55;
}

.info-box {
  margin-top: 14px;
}

.info-box p {
  margin: 6px 0 0;
}

.info-box code {
  display: block;
  margin-top: 8px;
  color: #027aa8;
  font-weight: 500;
}

/* =========================
   SECCIÓN EXPLORAR / COMPARACIÓN INTERACTIVA
   ========================= */
.explore-grid {
  display: grid;
  grid-template-columns: 270px minmax(420px,1fr) 270px;
  gap: 16px;
  margin-top: 20px;
}

.slider-block.compact {
  margin: 16px 0;
}

.slider-title output {
  color: #027aa8;
}

.mini-result {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px;
  margin-top: 12px;
  color: #082236;
}

.compare-tank {
  height: 340px;
  border: 8px solid #7a5d48;
  border-top: 0;
  border-radius: 0 0 22px 22px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg,#d5f7ff 0 34%,#3aa1d4 34% 100%);
  margin: 14px 0;
}

.explore-liquid {
  position: absolute;
  inset: 34% 0 0;
  background: rgba(18,126,192,.55);
}

.small-object {
  position: absolute;
  width: 76px;
  height: 76px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  box-shadow: 10px 10px 0 rgba(0,0,0,.17);
  transition: .45s ease;
}

.compare-summary {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  line-height: 1.5;
}

/* =========================
   MODO RETO
   ========================= */
.game-layout {
  display: grid;
  grid-template-columns: minmax(500px,1fr) 310px;
  gap: 18px;
  margin-top: 18px;
}

.start-btn {
  min-width: 150px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  color: #28475d;
}

.progress-bar {
  height: 12px;
  border-radius: 999px;
  background: #d8eaf1;
  overflow: hidden;
  margin: 10px 0 18px;
}

.progress-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg,var(--blue),#ff9b1b);
  transition: .3s;
}

.question-card h4 {
  font-size: 18px;
  font-weight: 500;
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.answer {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.answer.correct {
  border-color: var(--green);
  background: #edf9f4;
}

.answer.wrong {
  border-color: var(--red);
  background: #fff1f1;
}

.feedback {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  min-height: 56px;
  margin-bottom: 14px;
}

.score-mini {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 10px;
  margin: 14px 0;
}

.score-mini div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px;
}

.score-mini span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.score-mini strong {
  font-size: 24px;
  font-weight: 500;
}

/* =========================
   BITÁCORA, TABLAS Y EXPORTACIÓN
   ========================= */
.bitacora-actions {
  margin: 20px 0 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.small {
  max-height: 245px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 880px;
  background: #fff;
}

th,td {
  padding: 13px 16px;
  border-bottom: 1px solid #e2edf2;
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--dark);
  color: #fff;
  font-weight: 600;
}

td {
  font-weight: 400;
}

tr:nth-child(even) td {
  background: #f8fbfd;
}

.score-card table {
  min-width: 300px;
}

.export-box {
  position: relative;
}

.export-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: var(--shadow);
  padding: 8px;
  min-width: 140px;
}

.export-menu.open {
  display: grid;
  gap: 7px;
}

.export-menu button {
  border: 0;
  background: #edf5f8;
  border-radius: 12px;
  padding: 11px 14px;
  text-align: left;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

/* =========================
   PIE DE PÁGINA
   ========================= */
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,.75);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 30px;
  color: #496578;
}

.footer strong {
  font-weight: 600;
}

/* =========================
   MODALES DEL SISTEMA
   ========================= */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  place-items: center;
  background: rgba(16,38,56,.54);
  backdrop-filter: blur(6px);
  z-index: 999;
  padding: 18px;
}

.modal.show {
  display: grid;
}

.modal-card {
  width: min(440px,100%);
  background: #fff;
  border-radius: 26px;
  padding: 32px 26px 22px;
  text-align: center;
  box-shadow: 0 28px 80px rgba(0,0,0,.28);
}

.modal-icon {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: -72px auto 12px;
  background: linear-gradient(135deg,#79d832,#22a06b);
  color: #fff;
  font-size: 42px;
  font-weight: 700;
}

.modal-icon.warn {
  background: linear-gradient(135deg,#ffbd48,#ff9415);
}

.modal-icon.err {
  background: linear-gradient(135deg,#ff6d6d,#d94b4b);
}

.modal-card h3 {
  font-weight: 600;
}

.modal-card p {
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* =========================
   RESPONSIVE: PANTALLAS MEDIANAS
   ========================= */
@media(max-width:1120px) {
  .simulator-layout {
    grid-template-columns: 300px 1fr;
  }

  .explain-panel {
    grid-column: 1/-1;
  }

  .explore-grid,.game-layout {
    grid-template-columns: 1fr;
  }

  .hero-content {
    grid-template-columns: 1fr;
  }
}

/* =========================
   RESPONSIVE: TABLETS Y CELULARES
   ========================= */
@media(max-width:780px) {
  .nav {
    flex-direction: column;
    align-items: stretch;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .simulator-layout {
    grid-template-columns: 1fr;
  }

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

  .panel-head,.section-head {
    flex-direction: column;
  }

  .button-pair,.answers {
    grid-template-columns: 1fr;
  }

  .main-shell,.nav,.hero-content,.footer {
    width: min(100% - 24px,1180px);
  }

  .hero {
    padding: 14px 0 18px;
  }

  .export-box,.export-box .btn {
    width: 100%;
  }

  .export-menu {
    left: 0;
    right: 0;
  }

  .tank {
    height: 335px;
  }
}

/* =========================
   RESPONSIVE: CELULARES PEQUEÑOS
   ========================= */
@media(max-width:520px) {
  .tabs,.metrics,.score-mini {
    grid-template-columns: 1fr;
  }

  .slider-title {
    align-items: stretch;
    flex-direction: column;
  }

  .value-input {
    width: 100%;
  }

  .hero h2 {
    font-size: 28px;
  }

  .formula-card strong {
    font-size: 34px;
  }

  .tank {
    height: 315px;
  }

  .object-block {
    width: 92px;
    height: 92px;
  }

  .panel {
    padding: 16px;
  }

  .scale-line {
    grid-template-columns: 50px 1fr 66px;
    font-size: 12px;
  }
}
