* { box-sizing: border-box; }

body {
  font-family: system-ui, sans-serif;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  background: #f4f4f4;
  color: #222;
}

body.modal-open { overflow: hidden; }

h1 { font-size: 1.25rem; margin: 0 0 1rem; }

h2 {
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.grid-3,
.grid-bottom {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

@media (min-width: 540px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-bottom { grid-template-columns: 1fr 1.6fr; }
}

@media (min-width: 900px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

fieldset.facades { margin-bottom: 0.75rem; }

.facades-inner {
  display: grid;
  gap: 0.75rem;
  align-items: start;
}

@media (min-width: 720px) {
  .facades-inner { grid-template-columns: 1fr minmax(220px, 300px); }
}

.facades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}

.facades-table th,
.facades-table td {
  border: 1px solid #ddd;
  padding: 0.35rem 0.5rem;
  text-align: left;
}

.facades-table th { background: #eee; }
.facades-table td.area { text-align: right; color: #555; }
.facades-table input[type="number"] { width: 100%; }

.facades-table input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.facades-table tr.inactive { opacity: 0.45; }

.facades-tau {
  display: grid;
  gap: 0.75rem;
}

.facades-tau label { margin-bottom: 0; }

.otros-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

@media (min-width: 720px) {
  .otros-fields { grid-template-columns: 1fr 1fr; }
  .otros-fields label:last-child { grid-column: 1 / -1; }
  .facades-table { margin-bottom: 0; }
}

fieldset {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0.75rem;
  margin: 0;
  background: #fff;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

label:last-child { margin-bottom: 0; }

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  padding: 0;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  border: none;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  cursor: pointer;
  flex-shrink: 0;
}

.info-btn:hover { background: #cbd5e1; }

.formula {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.formula p { margin: 0; }

.formula .eq {
  font-family: 'Times New Roman', Times, serif;
  font-size: 1.2rem;
  text-align: center;
  margin: 0.6rem 0;
}

.formula .eq-note {
  font-size: 0.78rem;
  color: #666;
  text-align: center;
  line-height: 1.5;
}

input {
  padding: 0.35rem 0.5rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  font-size: 0.9rem;
}

button[type="submit"] {
  padding: 0.5rem 1.25rem;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  background: #2563eb;
  color: #fff;
}

button[type="submit"]:hover { background: #1d4ed8; }

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.summary span {
  background: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.summary strong { color: #2563eb; }

.summary-key {
  border-color: #93c5fd;
  background: #eff6ff;
}

.summary-key strong { color: #1d4ed8; }

canvas {
  width: 100%;
  height: 220px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  display: block;
}

#table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  background: #fff;
  margin-top: 1rem;
}

#table th,
#table td {
  border: 1px solid #ddd;
  padding: 0.35rem 0.5rem;
  text-align: right;
}

#table th { background: #eee; text-align: center; }
#table td:first-child,
#table th:first-child { text-align: left; }

/* Modal ayuda */
.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: min(80vh, 520px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.5rem;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: #222;
}

.modal-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: #666;
  cursor: pointer;
}

.modal-close:hover { background: #f1f5f9; color: #222; }

.modal-body {
  padding: 0.75rem 1rem 1rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #333;
}

sub {
  margin-left: -3px; 
  margin-bottom: -6px
}