*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #f4f6f8, #eaf0f4, #f0f4f2);
  min-height: 100vh;
  color: #2b3a4a;
}
.header {
  background: #2b3a4a;
  border-bottom: 1px solid #1f2d3a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 1.25rem 2rem;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.header-icon {
  background: #2563eb;
  color: #fff;
  border-radius: 0.75rem;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.header h1 { font-size: 1.5rem; font-weight: 700; color: #ffffff; }
.header p  { font-size: 0.875rem; color: #5ab963; }

.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
}
@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; }
}

.card {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border: 1px solid #e2e8f0;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-blue { border: 2px solid #5ab963; }
.card h2, .card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #2b3a4a;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card h2 .icon, .card h3 .icon { color: #5ab963; font-size: 1.1rem; }

.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.375rem;
}
.field select, .field input[type="number"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0.5rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}
.field select:focus, .field input[type="number"]:focus {
  border-color: #5ab963;
  box-shadow: 0 0 0 3px rgba(90,185,99,0.15);
}
.field .hint { font-size: 0.75rem; color: #94a3b8; margin-top: 0.25rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* También aplica a inputs dentro de .field-row sin wrapper .field */
.field-row input[type="number"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0.5rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  outline: none;
}

.toggle-group { display: flex; gap: 0.5rem; }
.toggle-btn {
  flex: 1;
  border-radius: 0.5rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}
.toggle-btn:hover { border-color: #94a3b8; }
.toggle-btn.active {
  border-color: #5ab963;
  background: #edf7ee;
  color: #3a8a42;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ── Resultado total (Barrio) ── */
.result-total {
  background: #2b3a4a;
  border: 2px solid #5ab963;
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.result-total .title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #5ab963;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.result-total .grid5 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 700px) {
  .result-total .grid5 { grid-template-columns: repeat(2, 1fr); }
}
.result-total .metric-label { font-size: 0.75rem; font-weight: 600; color: #5ab963; }
.result-total .metric-value { font-size: 1.1rem; font-weight: 700; color: #ffffff; margin-top: 0.125rem; }
.result-total .metric-value.green-text { color: #5ab963; }
.result-total .metric-value.orange-text { color: #fde68a; }
.result-total .metric-hint { font-size: 0.75rem; color: #94a3b8; }

/* ── Resultado por edificio ── */
.result-building {
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid;
}
.result-building.green  { background: #edf7ee; border-color: #5ab963; }
.result-building.orange { background: #fffbeb; border-color: #fde68a; }
.result-building .tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.result-building .flex-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.result-building .big-value { font-size: 2rem; font-weight: 700; margin-top: 0.25rem; }
.result-building .big-value.green-text  { color: #3a8a42; }
.result-building .big-value.orange-text { color: #b45309; }
.result-building .autofinancia { font-size: 0.875rem; color: #3a8a42; font-weight: 500; margin-top: 0.25rem; }
.result-building .stats { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.result-building .stat { text-align: center; }
.result-building .stat-label { font-size: 0.75rem; font-weight: 600; color: #64748b; text-transform: uppercase; }
.result-building .stat-value { font-size: 1.25rem; font-weight: 700; color: #1e293b; margin-top: 0.25rem; }
.result-building .stat-value.green-text  { color: #3a8a42; }
.result-building .stat-value.orange-text { color: #b45309; }
.result-building .stat-unit { font-size: 0.75rem; font-weight: 400; color: #64748b; }

/* ── Desglose ── */
.breakdown {
  background: #fff;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.breakdown .bk-header {
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 700;
  font-size: 1rem;
  color: #1e293b;
}
.breakdown .bk-header span { font-weight: 400; font-size: 0.875rem; color: #64748b; }
.breakdown .section-label {
  padding: 0.75rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.breakdown .section-label.costes   { background: #fef2f2; color: #b91c1c; }
.breakdown .section-label.ingresos { background: #edf7ee; color: #3a8a42; }
.breakdown .bk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid #f1f5f9;
}
.breakdown .bk-row .bk-label    { font-size: 0.875rem; color: #1e293b; }
.breakdown .bk-row .bk-sublabel { font-size: 0.75rem; color: #64748b; }
.breakdown .bk-row .bk-value {
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.breakdown .bk-row .bk-value.deduction { color: #3a8a42; }
.breakdown .bk-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}
.breakdown .bk-total .bk-label { font-weight: 700; font-size: 0.875rem; }
.breakdown .bk-total .bk-value { font-size: 1.1rem; font-weight: 700; }
.bk-value.green-text  { color: #3a8a42; }
.bk-value.orange-text { color: #b45309; }

/* ── Parámetros ── */
.params-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  font-size: 0.875rem;
}
@media (max-width: 600px) {
  .params-grid { grid-template-columns: repeat(2, 1fr); }
}
.params-grid .p-label { font-size: 0.75rem; color: #64748b; }
.params-grid .p-value { font-weight: 600; color: #1e293b; }

/* ── Nota ── */
.note {
  background: #edf7ee;
  border: 1px solid #b8debb;
  border-radius: 1rem;
  padding: 1rem;
  font-size: 0.75rem;
  color: #2b3a4a;
}
.note strong { font-weight: 700; }
