* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: #1f2933; background: #f3f5f7; }
body { display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: #1f4e78; color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.topbar .brand strong { font-size: 16px; margin-right: 10px; }
.topbar .muted { color: #c9dff5; font-size: 13px; }
.topbar nav a { color: #fff; margin-left: 14px; text-decoration: none; padding: 4px 8px; border-radius: 3px; }
.topbar nav a:hover, .topbar nav a.active { background: rgba(255, 255, 255, 0.15); }

.search { padding: 10px 18px; background: #fff; border-bottom: 1px solid #e5e7eb; }
.search form { display: flex; gap: 8px; align-items: center; }
.search input { flex: 1 1 auto; padding: 8px 10px; border: 1px solid #cbd2d9; border-radius: 4px; font-size: 14px; }
.search button { padding: 8px 14px; border: 0; background: #1f4e78; color: #fff; border-radius: 4px; cursor: pointer; font-size: 14px; }
.search button:hover { background: #163a59; }
.muted { color: #6b7280; }

.layout { flex: 1 1 auto; display: flex; min-height: 0; }
#map { flex: 1 1 auto; }
.sidebar {
  width: 420px; background: #fff; padding: 14px 16px; overflow-y: auto;
  border-right: 1px solid #e5e7eb;
}
.sidebar h3 { font-size: 13px; text-transform: uppercase; color: #1f4e78; margin: 8px 0 6px; }
.sidebar hr { border: 0; border-top: 1px solid #e5e7eb; margin: 14px 0; }

.layer-row { display: flex; align-items: flex-start; padding: 5px 0; gap: 8px; }
.layer-row label { font-size: 12px; line-height: 1.3; cursor: pointer; }
.layer-row input[disabled] + label { opacity: 0.6; }
.tier { display: inline-block; min-width: 18px; padding: 1px 4px; border-radius: 3px; background: #e5edf5; color: #1f4e78; font-size: 11px; text-align: center; margin-right: 4px; }
.cat { color: #6b7280; font-size: 10px; margin-top: 1px; }

#point-info { font-size: 13px; line-height: 1.4; }
table.kv { width: 100%; border-collapse: collapse; margin: 4px 0; font-size: 12px; }
table.kv td { padding: 3px 6px; border-bottom: 1px solid #f1f3f5; vertical-align: top; }
table.kv td:first-child { color: #6b7280; width: 35%; font-weight: 600; }

.section-title { font-weight: 600; color: #1f4e78; margin-top: 12px; font-size: 12px; text-transform: uppercase; }

.interpretation {
  background: #fffbe6; border-left: 3px solid #d4ad1f;
  padding: 8px 10px; margin: 10px 0; font-size: 12px; border-radius: 3px;
}
.interpretation .section-title { color: #835c00; margin-top: 0; }
.interpretation ul.notes { margin: 6px 0 4px 18px; padding: 0; }
.interpretation .small { font-size: 10px; margin-top: 4px; font-style: italic; }

.tag { display: inline-block; padding: 2px 6px; background: #e5edf5; border-radius: 3px; font-size: 11px; margin-right: 4px; }
.tag.error { background: #fde2e2; color: #b53d3d; }
.tag.ok { background: #e2f5e7; color: #2f7a3a; }

/* admin */
.admin-page { display: block; }
.admin-main { padding: 20px; max-width: 1100px; margin: 0 auto; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 16px 18px; margin-bottom: 16px; }
.card h2 { font-size: 15px; text-transform: uppercase; color: #1f4e78; margin: 0 0 10px; }
.card form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card input, .card button { padding: 7px 10px; border: 1px solid #cbd2d9; border-radius: 4px; font-size: 13px; }
.card button { background: #1f4e78; color: #fff; border-color: #1f4e78; cursor: pointer; }
.card button.secondary { background: #6b7280; border-color: #6b7280; }
.card button:hover { opacity: 0.9; }
.card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.card table th { text-align: left; padding: 6px 8px; background: #f3f5f7; }
.card table td { padding: 6px 8px; border-bottom: 1px solid #f1f3f5; }
.kpi { display: flex; gap: 18px; margin: 12px 0; flex-wrap: wrap; }
.kpi > div { background: #f3f5f7; padding: 10px 14px; border-radius: 4px; }
.kpi .label { color: #6b7280; font-size: 11px; text-transform: uppercase; }
.kpi .value { font-size: 22px; color: #1f4e78; font-weight: 600; }


/* responsive */
@media (max-width: 900px) {
  .calculo-grid { grid-template-columns: 1fr; }
  .calculo-grid .col-2 { grid-column: span 1; }
  #calculo-form fieldset.suggested .row { grid-template-columns: 1fr; }
}

/* === Brand link === */
.topbar .brand a {
  color: inherit; text-decoration: none;
}
.topbar .brand a:hover { opacity: 0.85; }

/* === Cálculo preliminar standalone page === */
.calculo-page { display: block; }
.calculo-main {
  padding: 20px 28px 50px; max-width: 1400px; margin: 0 auto;
  color: #111827;
}
.calculo-header h1 {
  font-size: 26px; margin: 14px 0 6px; color: #14365a;
  font-weight: 700; letter-spacing: -0.3px;
}
.calculo-header .muted { font-size: 14px; color: #4b5563; }
.calculo-header .muted.loaded { color: #1f6c2f; font-weight: 600; }
.calculo-header .muted a { color: #1f4e78; font-weight: 600; }

.calculo-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 20px;
}
.calculo-grid .col-2 { grid-column: span 2; }

#calculo-form fieldset {
  margin: 0; padding: 16px 20px;
  border: 1px solid #c8d0d8; border-radius: 6px; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
#calculo-form legend {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px;
  color: #14365a; padding: 0 8px; font-weight: 700;
}
#calculo-form fieldset.suggested {
  background: #fffae0; border-color: #d9b62b;
}
#calculo-form fieldset.suggested legend { color: #6e5300; }

#calculo-form label {
  display: block; font-size: 13px; color: #1f2933;
  margin: 10px 0 4px; font-weight: 600;
}
#calculo-form input,
#calculo-form select,
#calculo-form textarea {
  display: block; width: 100%;
  padding: 9px 11px; font-size: 14px;
  border: 1px solid #99a4b3; border-radius: 4px;
  background: #fff; color: #111827;
  font-family: inherit; font-weight: 500;
}
#calculo-form input:focus,
#calculo-form select:focus,
#calculo-form textarea:focus {
  border-color: #1f4e78; outline: 2px solid #c4daf0; outline-offset: -1px;
}
#calculo-form input::placeholder,
#calculo-form textarea::placeholder { color: #8893a3; }

#calculo-form textarea { resize: vertical; min-height: 60px; line-height: 1.45; }
#calculo-form fieldset.suggested .row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px;
}
#calculo-form fieldset.suggested .row label { margin-top: 0; }

#calculo-form .actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px solid #e5e7eb; margin-top: 6px;
}
#calculo-form button {
  padding: 10px 18px; font-size: 14px; border: 0;
  background: #1f4e78; color: #fff; border-radius: 4px; cursor: pointer;
  font-weight: 600;
}
#calculo-form button.secondary { background: #5a6573; }
#calculo-form button:hover { opacity: 0.9; }

@media (max-width: 900px) {
  .calculo-grid { grid-template-columns: 1fr; }
  .calculo-grid .col-2 { grid-column: span 1; }
  #calculo-form fieldset.suggested .row { grid-template-columns: 1fr; }
}
