:root {
  --brand: #0b6ea8;
  --brand-dark: #084f79;
  --ink: #1b2733;
  --ink-soft: #55636f;
  --line: #d8dee5;
  --bg: #f4f6f8;
  --danger: #b3261e;
  --ok: #1e7a46;
  --bar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---------- Barra superior ---------- */
#appbar {
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--brand-dark);
  color: #fff;
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark { font-weight: 700; letter-spacing: .5px; }
.brand-sep { opacity: .5; }
.brand-title { font-size: 14px; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Mapa ---------- */
#viewDiv {
  position: absolute;
  top: var(--bar-h);
  right: 0;
  bottom: 0;
  left: 0;
}

/* ---------- Botones ---------- */
.btn {
  font: inherit;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  display: inline-block;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:not(:disabled):hover { background: #0a80c4; }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.panel .btn-ghost { color: var(--brand); }
.panel .btn-ghost:hover { background: rgba(11, 110, 168, .08); }
.btn-mini { font-size: 12px; padding: 4px 10px; background: #fff; border-color: var(--line); color: var(--ink); }

.btn-icon {
  background: none;
  border: 0;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 0 4px;
}

/* ---------- Aviso inicial ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 30, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: 8px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.modal-header {
  padding: 20px 24px 0;
}
.modal-header h1 { margin: 0; font-size: 20px; }
.modal-body {
  padding: 12px 24px;
  overflow: auto;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.modal-body p { margin: 0 0 12px; }
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-footer .btn { align-self: flex-end; }

/* Contenido de los popups del mapa */
.popup-contenido { font-size: 14px; }
.popup-row { display: flex; gap: 6px; padding: 3px 0; }
.popup-label { font-weight: 600; color: var(--ink-soft); flex: 0 0 auto; }
.popup-label::after { content: ":"; }
.popup-btn { margin-top: 12px; width: 100%; }

.modal-wide { max-width: 720px; }
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
}

/* Pasos del modal de descarga */
.paso { display: flex; flex-direction: column; }
.paso.hidden { display: none; }
.paso-titulo {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--brand-dark);
  font-weight: 700;
  margin: 18px 0 4px;
}
.paso-texto { font-size: 14px; margin: 0 0 12px; }
.paso label { font-size: 13px; font-weight: 600; margin: 10px 0 4px; color: var(--ink); }
.paso input[type="text"],
.paso input[type="email"],
.paso textarea {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  width: 100%;
  resize: vertical;
}
.paso input:focus, .paso textarea:focus {
  outline: 2px solid rgba(11, 110, 168, .35);
  border-color: var(--brand);
}
.paso input.invalid, .paso textarea.invalid { border-color: var(--danger); }

.modal-wide .modal-body { max-height: min(72vh, 640px); }

.enlace-descarga {
  display: block;
  word-break: break-all;
  font-size: 13.5px;
  background: #f1f6fa;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
}
.enlace-descarga.hidden { display: none; }
#dl-descargar.hidden, #dl-sin-url.hidden, #dl-texto-enlace.hidden { display: none; }

.check { display: flex; gap: 9px; font-size: 13.5px; line-height: 1.45; color: var(--ink); }
.check input { margin-top: 3px; flex: 0 0 auto; }
.check-inline { margin: 6px 0 4px; }
a { color: var(--brand); }

/* ---------- Panel de solicitud ---------- */
.panel {
  position: absolute;
  top: calc(var(--bar-h) + 12px);
  right: 12px;
  width: 350px;
  max-height: calc(100% - var(--bar-h) - 24px);
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.panel.hidden { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 12px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-header h2 { margin: 0; font-size: 16px; }

.panel-body {
  padding: 14px 16px 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.panel-body label { font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.panel-body input[type="text"],
.panel-body input[type="email"],
.panel-body textarea {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  width: 100%;
  resize: vertical;
}
.panel-body input:focus, .panel-body textarea:focus {
  outline: 2px solid rgba(11, 110, 168, .35);
  border-color: var(--brand);
}
.panel-body input.invalid, .panel-body textarea.invalid { border-color: var(--danger); }

.panel-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: #eef4f8;
  border-left: 3px solid var(--brand);
  padding: 8px 10px;
  border-radius: 3px;
}
.req { color: var(--danger); }

.panel-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}

.form-msg { font-size: 13px; margin: 12px 0 0; min-height: 1em; }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: var(--ok); }

/* ---------- Contadores flotantes ---------- */
.contadores {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
}
.contador { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.contador-num { font-weight: 700; font-size: 15px; min-width: 1.4em; text-align: right; }
.contador-lbl { color: var(--ink-soft); }
.contador-punto {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, .45);
  flex: 0 0 auto;
  align-self: center;
}
.punto-disponible { background: #a8dcb0; }
.punto-solicitada { background: #e8e0a0; }

/* ---------- Sugerencia de dibujo ---------- */
.hint {
  position: absolute;
  top: calc(var(--bar-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(27, 39, 51, .92);
  color: #fff;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 30;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.hint.hidden { display: none; }
.hint-error {
  background: rgba(179, 38, 30, .94);
  max-width: min(560px, 90vw);
  border-radius: 6px;
  line-height: 1.45;
  display: block;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .brand-title { display: none; }
  .panel {
    left: 12px;
    right: 12px;
    width: auto;
  }
  .hint { width: calc(100% - 24px); justify-content: space-between; }
}
